diff --git a/.Rbuildignore b/.Rbuildignore index e476be9b..99a86496 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -15,3 +15,5 @@ index.md logo.png ^pkgdown$ LICENSE.md +CLAUDE.md +.claude diff --git a/.gitignore b/.gitignore index 7b732e72..fb57b49b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .RData .Ruserdata .DS_Store +CLAUDE.md diff --git a/DESCRIPTION b/DESCRIPTION index f0621364..de4bd59c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mapgl Title: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' -Version: 0.1.4.9000 -Date: 2025-01-02 +Version: 0.2.2.9000 +Date: 2025-06-11 Authors@R: person(given = "Kyle", family = "Walker", email = "kyle@walker-data.com", role = c("aut", "cre")) Description: Provides an interface to the 'Mapbox GL JS' () @@ -10,10 +10,13 @@ Description: Provides an interface to the 'Mapbox GL JS' (= 4.1.0) Imports: htmlwidgets, geojsonsf, @@ -23,8 +26,10 @@ Imports: grDevices, base64enc, terra, - classInt -Suggests: + classInt, shiny, + viridisLite +Suggests: mapboxapi, - usethis + usethis, + leaflet diff --git a/NAMESPACE b/NAMESPACE index cb6ceef2..a369b6e0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,13 +3,17 @@ export(add_categorical_legend) export(add_circle_layer) export(add_continuous_legend) +export(add_control) export(add_draw_control) +export(add_features_to_draw) export(add_fill_extrusion_layer) export(add_fill_layer) export(add_fullscreen_control) export(add_geocoder_control) export(add_geolocate_control) +export(add_globe_control) export(add_globe_minimap) +export(add_h3j_source) export(add_heatmap_layer) export(add_image) export(add_image_source) @@ -35,6 +39,7 @@ export(clear_legend) export(clear_markers) export(cluster_options) export(compare) +export(concat) export(ease_to) export(fit_bounds) export(fly_to) @@ -44,27 +49,45 @@ export(interpolate) export(jump_to) export(mapbox_style) export(mapboxgl) +export(mapboxglCompareOutput) export(mapboxglOutput) +export(mapboxgl_compare_proxy) export(mapboxgl_proxy) +export(mapboxgl_view) export(maplibre) +export(maplibreCompareOutput) export(maplibreOutput) +export(maplibre_compare_proxy) export(maplibre_proxy) +export(maplibre_view) export(maptiler_style) export(match_expr) export(move_layer) +export(number_format) +export(on_section) export(renderMapboxgl) +export(renderMapboxglCompare) export(renderMaplibre) +export(renderMaplibreCompare) export(set_config_property) export(set_filter) export(set_fog) export(set_layout_property) export(set_paint_property) +export(set_popup) +export(set_projection) +export(set_rain) +export(set_snow) export(set_source) export(set_style) export(set_terrain) export(set_tooltip) export(set_view) export(step_expr) +export(story_leaflet) +export(story_map) +export(story_maplibre) +export(story_section) import(base64enc) import(geojsonsf) import(grDevices) diff --git a/NEWS.md b/NEWS.md index 333d43ad..3af83413 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,47 @@ +# mapgl (development version) + +* Enhanced draw control functionality with improved feature editing capabilities: + - Added ability to load existing features from map sources into the draw control for editing either when initializing the draw control or via `add_features_to_draw()` + - Fixed vertex styling to properly highlight selected vertices during editing + - Extended draw control support to compare views, enabling feature editing in side-by-side map comparisons + - Improved compatibility with both Mapbox GL JS and MapLibre GL JS + +* Fixed `hover_options` for vector tile sources in MapLibre (#67): + - Added proper source layer handling for vector tiles when using hover effects + - Now works correctly with PMTiles and other vector tile sources that include feature IDs + - Note: Vector tiles must include feature IDs for hover effects to work. GeoJSON sources automatically generate IDs. + +* Enhanced tooltip functionality with expression support: + - Tooltips can now use expressions for dynamic content generation + - Use `get_column()` to reference feature properties in tooltips + - Added `concat()` helper function for combining strings and expressions + - Example: `tooltip = concat("Name: ", get_column("name"), "
Value: ", get_column("value"))` + - Works with both regular tooltips and `set_tooltip()` in Shiny applications + +# mapgl 0.2.2 + +* Added `mapboxgl_view()` and `maplibre_view()` functions for quick visualization of sf objects with automatic geometry detection and column-based styling (#102). +* Added support for rain and snow effects on Mapbox GL maps with `set_rain()` and `set_snow()` functions. +* Added `add_globe_control()` for MapLibre maps, allowing users to toggle between "mercator" and "globe" projections. +* Fixed issue with `set_style()` in Shiny applications for both Mapbox and MapLibre maps (#99). +* Fixed namespacing issue in `get_drawn_features()` for Shiny modules (#95). +* Improved compare functionality with better control support and swiper color customization. + +# mapgl 0.2.1 + +* Improved styling and positioning behavior of the layers control. Users can now customize the appearance of the layers control, and the layers control is collapsed by default with cleaner appearance. +Added ability to link legends to specific layers with the new `layer_id` parameter in `add_legend()`. When a layer is toggled in the layers control, its associated legend will automatically show or hide. +* Added support for custom legend positioning with new margin parameters (`margin_top`, `margin_right`, `margin_bottom`, `margin_left`) that allow fine-grained control over legend placement. +* Fixed layers control toggle button state to correctly reflect the initial visibility of layers, resolving the issue with layers set to `visibility = "none"` showing as active in the control. +* Support for the `compare()` plugin in Shiny applications, with new rendering and proxy functions for comparison apps in Mapbox and MapLibre. +* New `mode` parameter in `compare()` allowing users to choose between `"swipe"` mode with a comparison slider, and `"sync"` mode which displays synchronized maps side-by-side. +* Updates throughout the codebase to allow features to be used in comparison maps via Shiny proxy sessions. + +# mapgl 0.2.0 + +* A new "story map" feature allows users to build interactive story maps. [View the story mapping vignette](https://walker-data.com/mapgl/articles/story-maps.html) for more information. +* Various bug fixes and performance improvements; [visit the package GitHub page for more details](https://github.com/walkerke/mapgl). + # mapgl 0.1.4 * `add_image()` allows you to add your own image to the map's sprite for use as an icon / symbol layer diff --git a/R/controls.R b/R/controls.R index c3bdacb6..95d3cbbb 100644 --- a/R/controls.R +++ b/R/controls.R @@ -19,24 +19,48 @@ #' add_fullscreen_control(position = "top-right") #' } add_fullscreen_control <- function(map, position = "top-right") { - map$x$fullscreen_control <- list( - enabled = TRUE, - position = position - ) - - if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + map$x$fullscreen_control <- list( + enabled = TRUE, + position = position + ) - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list( - type = "add_fullscreen_control", - position = position - ) - )) + if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_fullscreen_control", + position = position, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_fullscreen_control", + position = position + ) + ) + ) } + } - map + map } #' Add a navigation control to a map @@ -57,47 +81,77 @@ add_fullscreen_control <- function(map, position = "top-right") { #' mapboxgl() |> #' add_navigation_control(visualize_pitch = TRUE) #' } -add_navigation_control <- function(map, - show_compass = TRUE, - show_zoom = TRUE, - visualize_pitch = FALSE, - position = "top-right", - orientation = "vertical") { - nav_control <- list( - show_compass = show_compass, - show_zoom = show_zoom, - visualize_pitch = visualize_pitch, - position = position, - orientation = orientation - ) +add_navigation_control <- function( + map, + show_compass = TRUE, + show_zoom = TRUE, + visualize_pitch = FALSE, + position = "top-right", + orientation = "vertical" +) { + nav_control <- list( + show_compass = show_compass, + show_zoom = show_zoom, + visualize_pitch = visualize_pitch, + position = position, + orientation = orientation + ) - if (any( - inherits(map, "mapboxgl_proxy"), - inherits(map, "maplibre_proxy") - )) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) { - "mapboxgl-proxy" - } else { - "maplibre-proxy" - } - - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list( - type = "add_navigation_control", - options = nav_control, - position = position, - orientation = orientation - ) - )) + if ( + any( + inherits(map, "mapboxgl_proxy"), + inherits(map, "maplibre_proxy") + ) + ) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_navigation_control", + options = nav_control, + position = position, + orientation = orientation, + map = map$map_side + ) + ) + ) } else { - if (is.null(map$x$navigation_control)) { - map$x$navigation_control <- list() - } - map$x$navigation_control <- nav_control + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_navigation_control", + options = nav_control, + position = position, + orientation = orientation + ) + ) + ) } + } else { + if (is.null(map$x$navigation_control)) { + map$x$navigation_control <- list() + } + map$x$navigation_control <- nav_control + } - return(map) + return(map) } @@ -107,6 +161,13 @@ add_navigation_control <- function(map, #' @param position The position of the control on the map (one of "top-left", "top-right", "bottom-left", "bottom-right"). #' @param layers A vector of layer IDs to be included in the control. If NULL, all layers will be included. #' @param collapsible Whether the control should be collapsible. +#' @param use_icon Whether to use a stacked layers icon instead of the "Layers" text when collapsed. Only applies when collapsible = TRUE. +#' @param background_color The background color for the layers control; this will be the +#' color used for inactive layer items. +#' @param active_color The background color for active layer items. +#' @param hover_color The background color for layer items when hovered. +#' @param active_text_color The text color for active layer items. +#' @param inactive_text_color The text color for inactive layer items. #' #' @return The modified map object with the layers control added. #' @export @@ -130,61 +191,114 @@ add_navigation_control <- function(map, #' source = rds, #' line_color = "pink" #' ) |> -#' add_layers_control(collapsible = TRUE) +#' add_layers_control( +#' position = "top-left", +#' background_color = "#ffffff", +#' active_color = "#4a90e2" +#' ) #' } -add_layers_control <- function(map, - position = "top-left", - layers = NULL, - collapsible = FALSE) { - control_id <- paste0("layers-control-", as.hexmode(sample(1:1000000, 1))) - - # Create the control container - control_html <- paste0( - '' - ) +add_layers_control <- function( + map, + position = "top-left", + layers = NULL, + collapsible = TRUE, + use_icon = TRUE, + background_color = NULL, + active_color = NULL, + hover_color = NULL, + active_text_color = NULL, + inactive_text_color = NULL +) { + control_id <- paste0("layers-control-", as.hexmode(sample(1:1000000, 1))) - # If layers is NULL, get the layers added by the user - if (is.null(layers)) { - layers <- unlist(lapply(map$x$layers, function(y) { - y$id - })) - } + # If layers is NULL, get the layers added by the user + if (is.null(layers)) { + layers <- unlist(lapply(map$x$layers, function(y) { + y$id + })) + } - # Add control to map - if (inherits(map, "mapboxgl_proxy") || - inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) { - "mapboxgl-proxy" - } else { - "maplibre-proxy" - } - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list( - type = "add_layers_control", - control_id = control_id, - position = position, - layers = layers, - collapsible = collapsible - ) - )) + # Create custom colors object if any color options were specified + custom_colors <- NULL + if ( + !is.null(background_color) || + !is.null(active_color) || + !is.null(hover_color) || + !is.null(inactive_text_color) || + !is.null(active_text_color) + ) { + custom_colors <- list() + if (!is.null(background_color)) custom_colors$background <- background_color + if (!is.null(active_color)) custom_colors$active <- active_color + if (!is.null(hover_color)) custom_colors$hover <- hover_color + if (!is.null(inactive_text_color)) custom_colors$text <- inactive_text_color + if (!is.null(active_text_color)) + custom_colors$activeText <- active_text_color + } + + # Add control to map + if ( + inherits(map, "mapboxgl_proxy") || + inherits(map, "maplibre_proxy") + ) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_layers_control", + control_id = control_id, + position = position, + layers = layers, + collapsible = collapsible, + use_icon = use_icon, + custom_colors = custom_colors, + map = map$map_side + ) + ) + ) } else { - map$x$layers_control <- list( + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_layers_control", control_id = control_id, position = position, layers = layers, - collapsible = collapsible + collapsible = collapsible, + use_icon = use_icon, + custom_colors = custom_colors + ) ) - map$x$control_html <- control_html + ) } + } else { + map$x$layers_control <- list( + control_id = control_id, + position = position, + layers = layers, + collapsible = collapsible, + use_icon = use_icon, + custom_colors = custom_colors + ) + } - return(map) + return(map) } #' Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app @@ -194,19 +308,44 @@ add_layers_control <- function(map, #' @return The modified map object with all controls removed. #' @export clear_controls <- function(map) { - if (inherits(map, "mapboxgl_proxy") || - inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) { - "mapboxgl-proxy" - } else { - "maplibre-proxy" - } - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "clear_controls") - )) + if ( + inherits(map, "mapboxgl_proxy") || + inherits(map, "maplibre_proxy") + ) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "clear_controls", + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list(type = "clear_controls") + ) + ) } - return(map) + } + return(map) } #' Add a scale control to a map @@ -228,35 +367,63 @@ clear_controls <- function(map) { #' mapboxgl() |> #' add_scale_control(position = "bottom-right", unit = "imperial") #' } -add_scale_control <- function(map, - position = "bottom-left", - unit = "metric", - max_width = 100) { - scale_control <- list( - position = position, - unit = unit, - maxWidth = max_width - ) +add_scale_control <- function( + map, + position = "bottom-left", + unit = "metric", + max_width = 100 +) { + scale_control <- list( + position = position, + unit = unit, + maxWidth = max_width + ) - if (inherits(map, "mapboxgl_proxy") || - inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) { - "mapboxgl-proxy" - } else { - "maplibre-proxy" - } - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "add_scale_control", options = scale_control) - )) + if ( + inherits(map, "mapboxgl_proxy") || + inherits(map, "maplibre_proxy") + ) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_scale_control", + options = scale_control, + map = map$map_side + ) + ) + ) } else { - if (is.null(map$x$scale_control)) { - map$x$scale_control <- list() - } - map$x$scale_control <- scale_control + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list(type = "add_scale_control", options = scale_control) + ) + ) } + } else { + if (is.null(map$x$scale_control)) { + map$x$scale_control <- list() + } + map$x$scale_control <- scale_control + } - return(map) + return(map) } #' Add a draw control to a map @@ -268,6 +435,15 @@ add_scale_control <- function(map, #' @param simplify_freehand Logical, whether to apply simplification to freehand drawings. Default is FALSE. #' @param orientation A string specifying the orientation of the draw control. #' Either "vertical" (default) or "horizontal". +#' @param source A character string specifying a source ID to add to the draw control. +#' Default is NULL. +#' @param point_color Color for point features. Default is "#3bb2d0" (light blue). +#' @param line_color Color for line features. Default is "#3bb2d0" (light blue). +#' @param fill_color Fill color for polygon features. Default is "#3bb2d0" (light blue). +#' @param fill_opacity Fill opacity for polygon features. Default is 0.1. +#' @param active_color Color for active (selected) features. Default is "#fbb03b" (orange). +#' @param vertex_radius Radius of vertex points in pixels. Default is 5. +#' @param line_width Width of lines in pixels. Default is 2. #' @param ... Additional named arguments. See \url{https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md#options} for a list of options. #' #' @return The modified map object with the draw control added. @@ -283,49 +459,149 @@ add_scale_control <- function(map, #' zoom = 9 #' ) |> #' add_draw_control() +#' +#' # With initial features from a source +#' library(tigris) +#' tx <- counties(state = "TX", cb = TRUE) +#' mapboxgl(bounds = tx) |> +#' add_source(id = "tx", data = tx) |> +#' add_draw_control(source = "tx") +#' +#' # With custom styling +#' mapboxgl() |> +#' add_draw_control( +#' point_color = "#ff0000", +#' line_color = "#00ff00", +#' fill_color = "#0000ff", +#' fill_opacity = 0.3, +#' active_color = "#ff00ff", +#' vertex_radius = 7, +#' line_width = 3 +#' ) #' } -add_draw_control <- function(map, - position = "top-left", - freehand = FALSE, - simplify_freehand = FALSE, - orientation = "vertical", - ...) { - # if (inherits(map, "maplibregl") || inherits(map, "maplibre_proxy")) { - # rlang::abort("The draw control is not yet supported for MapLibre maps.") - # } - - options <- list(...) - - map$x$draw_control <- list( - enabled = TRUE, - position = position, - freehand = freehand, - simplify_freehand = simplify_freehand, - orientation = orientation, - options = options +add_draw_control <- function( + map, + position = "top-left", + freehand = FALSE, + simplify_freehand = FALSE, + orientation = "vertical", + source = NULL, + point_color = "#3bb2d0", + line_color = "#3bb2d0", + fill_color = "#3bb2d0", + fill_opacity = 0.1, + active_color = "#fbb03b", + vertex_radius = 5, + line_width = 2, + ... +) { + # if (inherits(map, "maplibregl") || inherits(map, "maplibre_proxy")) { + # rlang::abort("The draw control is not yet supported for MapLibre maps.") + # } + + options <- list(...) + + # Handle source if provided + draw_source <- NULL + if (!is.null(source)) { + if (is.character(source) && length(source) == 1) { + # It's a source ID to reference + draw_source <- source + } else { + rlang::abort("source must be a character string referencing a source ID") + } + } + + map$x$draw_control <- list( + enabled = TRUE, + position = position, + freehand = freehand, + simplify_freehand = simplify_freehand, + orientation = orientation, + options = options, + source = draw_source, + styling = list( + point_color = point_color, + line_color = line_color, + fill_color = fill_color, + fill_opacity = fill_opacity, + active_color = active_color, + vertex_radius = vertex_radius, + line_width = line_width ) + ) - if (inherits(map, "mapboxgl_proxy") || - inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) { - "mapboxgl-proxy" - } else { - "maplibre-proxy" - } - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list( - type = "add_draw_control", - position = position, - options = options, - freehand = freehand, - simplify_freehand = simplify_freehand, - orientation = orientation + if ( + inherits(map, "mapboxgl_proxy") || + inherits(map, "maplibre_proxy") + ) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_draw_control", + position = position, + options = options, + freehand = freehand, + simplify_freehand = simplify_freehand, + orientation = orientation, + source = draw_source, + styling = list( + point_color = point_color, + line_color = line_color, + fill_color = fill_color, + fill_opacity = fill_opacity, + active_color = active_color, + vertex_radius = vertex_radius, + line_width = line_width + ), + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_draw_control", + position = position, + options = options, + freehand = freehand, + simplify_freehand = simplify_freehand, + orientation = orientation, + source = draw_source, + styling = list( + point_color = point_color, + line_color = line_color, + fill_color = fill_color, + fill_opacity = fill_opacity, + active_color = active_color, + vertex_radius = vertex_radius, + line_width = line_width ) - )) + ) + ) + ) } + } - map + map } #' Get drawn features from the map @@ -368,64 +644,200 @@ add_draw_control <- function(map, #' shinyApp(ui, server) #' } get_drawn_features <- function(map) { - if (!shiny::is.reactive(map) && - !inherits(map, c("mapboxgl", "mapboxgl_proxy"))) { - stop( - "Invalid map object. Expected mapboxgl or mapboxgl_proxy object within a Shiny context." - ) - } + if ( + !shiny::is.reactive(map) && + !inherits( + map, + c("mapboxgl", "mapboxgl_proxy", "maplibregl", "maplibre_proxy") + ) + ) { + stop( + "Invalid map object. Expected mapboxgl, mapboxgl_proxy, maplibre or maplibre_proxy object within a Shiny context." + ) + } - # If map is reactive (e.g., output$map in Shiny), evaluate it - if (shiny::is.reactive(map)) { - map <- map() - } + # If map is reactive (e.g., output$map in Shiny), evaluate it + if (shiny::is.reactive(map)) { + map <- map() + } - # Determine if we're in a Shiny session - in_shiny <- shiny::isRunning() + # Determine if we're in a Shiny session + in_shiny <- shiny::isRunning() - if (!in_shiny) { - warning( - "Getting drawn features outside of a Shiny context is not supported. Please use this function within a Shiny application." - ) - return(sf::st_sf(geometry = sf::st_sfc())) # Return an empty sf object - } + if (!in_shiny) { + warning( + "Getting drawn features outside of a Shiny context is not supported. Please use this function within a Shiny application." + ) + return(sf::st_sf(geometry = sf::st_sfc())) # Return an empty sf object + } - # Get the session object - session <- shiny::getDefaultReactiveDomain() + # Get the session object + session <- shiny::getDefaultReactiveDomain() - if (inherits(map, "mapboxgl")) { - # Initial map object in Shiny - map_id <- map$elementId - } else if (inherits(map, "mapboxgl_proxy")) { - # Proxy object - map_id <- map$id - } else { - stop("Unexpected map object type.") - } + if (inherits(map, "mapboxgl") || inherits(map, "maplibregl")) { + # Initial map object in Shiny + map_id <- map$elementId + } else if ( + inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy") + ) { + # Proxy object + map_id <- map$id + } else { + stop("Unexpected map object type.") + } - # Send message to get drawn features - session$sendCustomMessage("mapboxgl-proxy", list( + # Send message to get drawn features + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + session$sendCustomMessage( + proxy_class, + list( + id = map_id, + message = list( + type = "get_drawn_features", + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + session$sendCustomMessage( + proxy_class, + list( id = map_id, message = list(type = "get_drawn_features") - )) - - # Wait for response - features_json <- NULL - wait_time <- 0 - while (is.null(features_json) && - wait_time < 3) { - # Wait up to 3 seconds - features_json <- session$input[[paste0(map_id, "_drawn_features")]] - Sys.sleep(0.1) - wait_time <- wait_time + 0.1 - } + ) + ) + } + + # Trim any module namespacing off to index the session proxy inputs + map_drawn_id <- sub( + pattern = session$ns(""), + replacement = "", + x = paste0(map_id, "_drawn_features") + ) + # Wait for response + features_json <- NULL + wait_time <- 0 + while ( + is.null(features_json) && + wait_time < 3 + ) { + # Wait up to 3 seconds + features_json <- session$input[[map_drawn_id]] + Sys.sleep(0.1) + wait_time <- wait_time + 0.1 + } + + if ( + !is.null(features_json) && + features_json != "null" && + nchar(features_json) > 0 + ) { + sf::st_make_valid(sf::st_read(features_json, quiet = TRUE)) + } else { + sf::st_sf(geometry = sf::st_sfc()) # Return an empty sf object if no features + } +} + +#' Add features to an existing draw control +#' +#' This function adds features from an existing source to a draw control on a map. +#' +#' @param map A map object with a draw control already added +#' @param source Character string specifying a source ID to get features from +#' @param clear_existing Logical, whether to clear existing drawn features before adding new ones. Default is FALSE. +#' +#' @return The modified map object +#' @export +#' +#' @examples +#' \dontrun{ +#' library(mapgl) +#' library(tigris) +#' +#' # Add features from an existing source +#' tx <- counties(state = "TX", cb = TRUE) +#' mapboxgl(bounds = tx) |> +#' add_source(id = "tx", data = tx) |> +#' add_draw_control() |> +#' add_features_to_draw(source = "tx") +#' +#' # In a Shiny app +#' observeEvent(input$load_data, { +#' mapboxgl_proxy("map") |> +#' add_features_to_draw( +#' source = "dynamic_data", +#' clear_existing = TRUE +#' ) +#' }) +#' } +add_features_to_draw <- function(map, source, clear_existing = FALSE) { + # Validate source + if (!is.character(source) || length(source) != 1) { + rlang::abort("source must be a character string referencing a source ID") + } - if (!is.null(features_json) && - features_json != "null" && nchar(features_json) > 0) { - sf::st_make_valid(sf::st_read(features_json, quiet = TRUE)) + # Prepare the data + draw_data <- list( + source = source, + clear_existing = clear_existing + ) + + # Handle proxy vs initial map + if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_features_to_draw", + data = draw_data, + map = map$map_side + ) + ) + ) } else { - sf::st_sf(geometry = sf::st_sfc()) # Return an empty sf object if no features + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_features_to_draw", + data = draw_data + ) + ) + ) } + } else { + # For initial map, store in a queue + if (is.null(map$x$draw_features_queue)) { + map$x$draw_features_queue <- list() + } + map$x$draw_features_queue <- append( + map$x$draw_features_queue, + list(draw_data) + ) + } + + return(map) } #' Add a geocoder control to a map @@ -454,37 +866,68 @@ get_drawn_features <- function(map) { #' maplibre() |> #' add_geocoder_control(position = "top-right", placeholder = "Search location") #' } -add_geocoder_control <- function(map, - position = "top-right", - placeholder = "Search", - collapsed = FALSE, - ...) { - geocoder_options <- list( - position = position, - placeholder = placeholder, - collapsed = collapsed, - ... - ) +add_geocoder_control <- function( + map, + position = "top-right", + placeholder = "Search", + collapsed = FALSE, + ... +) { + geocoder_options <- list( + position = position, + placeholder = placeholder, + collapsed = collapsed, + ... + ) - if (inherits(map, "mapboxgl_proxy") || - inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) { - "mapboxgl-proxy" - } else { - "maplibre-proxy" - } - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "add_geocoder_control", options = geocoder_options) - )) + if ( + inherits(map, "mapboxgl_proxy") || + inherits(map, "maplibre_proxy") + ) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_geocoder_control", + options = geocoder_options, + map = map$map_side + ) + ) + ) } else { - if (is.null(map$x$geocoder_control)) { - map$x$geocoder_control <- list() - } - map$x$geocoder_control <- geocoder_options + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_geocoder_control", + options = geocoder_options + ) + ) + ) + } + } else { + if (is.null(map$x$geocoder_control)) { + map$x$geocoder_control <- list() } + map$x$geocoder_control <- geocoder_options + } - return(map) + return(map) } #' Add a reset control to a map @@ -507,35 +950,63 @@ add_geocoder_control <- function(map, #' mapboxgl() |> #' add_reset_control(position = "top-left") #' } -add_reset_control <- function(map, - position = "top-right", - animate = TRUE, - duration = NULL) { - reset_control <- list(position = position, animate = animate) - - if (!is.null(duration)) { - if (!animate) { - rlang::warn("duration is ignored when `animate` is `FALSE`.") - } - reset_control$duration <- duration +add_reset_control <- function( + map, + position = "top-right", + animate = TRUE, + duration = NULL +) { + reset_control <- list(position = position, animate = animate) + + if (!is.null(duration)) { + if (!animate) { + rlang::warn("duration is ignored when `animate` is `FALSE`.") } + reset_control$duration <- duration + } - if (inherits(map, "mapboxgl_proxy") || - inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) { - "mapboxgl-proxy" - } else { - "maplibre-proxy" - } - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "add_reset_control", options = reset_control) - )) + if ( + inherits(map, "mapboxgl_proxy") || + inherits(map, "maplibre_proxy") + ) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_reset_control", + options = reset_control, + map = map$map_side + ) + ) + ) } else { - map$x$reset_control <- reset_control + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list(type = "add_reset_control", options = reset_control) + ) + ) } + } else { + map$x$reset_control <- reset_control + } - return(map) + return(map) } #' Add a geolocate control to a map @@ -572,44 +1043,245 @@ add_reset_control <- function(map, #' show_user_heading = TRUE #' ) #' } -add_geolocate_control <- function(map, - position = "top-right", - track_user = FALSE, - show_accuracy_circle = TRUE, - show_user_location = TRUE, - show_user_heading = FALSE, - fit_bounds_options = list(maxZoom = 15), - position_options = list( - enableHighAccuracy = FALSE, - timeout = 6000 - )) { - geolocate_control <- list( - position = position, - trackUserLocation = track_user, - showAccuracyCircle = show_accuracy_circle, - showUserLocation = show_user_location, - showUserHeading = show_user_heading, - fitBoundsOptions = fit_bounds_options, - positionOptions = position_options - ) +add_geolocate_control <- function( + map, + position = "top-right", + track_user = FALSE, + show_accuracy_circle = TRUE, + show_user_location = TRUE, + show_user_heading = FALSE, + fit_bounds_options = list(maxZoom = 15), + position_options = list( + enableHighAccuracy = FALSE, + timeout = 6000 + ) +) { + geolocate_control <- list( + position = position, + trackUserLocation = track_user, + showAccuracyCircle = show_accuracy_circle, + showUserLocation = show_user_location, + showUserHeading = show_user_heading, + fitBoundsOptions = fit_bounds_options, + positionOptions = position_options + ) - if (inherits(map, "mapboxgl_proxy") || - inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) { - "mapboxgl-proxy" - } else { - "maplibre-proxy" - } - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "add_geolocate_control", options = geolocate_control) - )) + if ( + inherits(map, "mapboxgl_proxy") || + inherits(map, "maplibre_proxy") + ) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_geolocate_control", + options = geolocate_control, + map = map$map_side + ) + ) + ) } else { - if (is.null(map$x$geolocate_control)) { - map$x$geolocate_control <- list() - } - map$x$geolocate_control <- geolocate_control + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_geolocate_control", + options = geolocate_control + ) + ) + ) } + } else { + if (is.null(map$x$geolocate_control)) { + map$x$geolocate_control <- list() + } + map$x$geolocate_control <- geolocate_control + } + + return(map) +} + +#' Add a globe control to a map +#' +#' This function adds a globe control to a MapLibre GL map that allows toggling +#' between "mercator" and "globe" projections with a single click. +#' +#' @param map A map object created by the `maplibre` function. +#' @param position The position of the control. Can be one of "top-left", "top-right", +#' "bottom-left", or "bottom-right". Default is "top-right". +#' +#' @return The modified map object with the globe control added. +#' @export +#' +#' @examples +#' \dontrun{ +#' library(mapgl) +#' +#' maplibre() |> +#' add_globe_control(position = "top-right") +#' } +add_globe_control <- function(map, position = "top-right") { + globe_control <- list( + position = position + ) + if (inherits(map, "mapboxgl") || inherits(map, "mapboxgl_proxy")) { + warning( + "The globe control is only available for MapLibre maps, not Mapbox GL maps." + ) return(map) + } + + if (inherits(map, "maplibre_proxy")) { + if (inherits(map, "maplibre_compare_proxy")) { + # For compare proxies + map$session$sendCustomMessage( + "maplibre-compare-proxy", + list( + id = map$id, + message = list( + type = "add_globe_control", + position = position, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + map$session$sendCustomMessage( + "maplibre-proxy", + list( + id = map$id, + message = list( + type = "add_globe_control", + position = position + ) + ) + ) + } + } else { + if (is.null(map$x$globe_control)) { + map$x$globe_control <- list() + } + map$x$globe_control <- globe_control + } + + return(map) +} + +#' Add a custom control to a map +#' +#' This function adds a custom control to a Mapbox GL or MapLibre GL map. +#' It allows you to create custom HTML element controls and add them to the map. +#' +#' @param map A map object created by the `mapboxgl` or `maplibre` functions. +#' @param html Character string containing the HTML content for the control. +#' @param position The position of the control. Can be one of "top-left", "top-right", +#' "bottom-left", or "bottom-right". Default is "top-right". +#' @param className Optional CSS class name for the control container. +#' @param ... Additional arguments passed to the JavaScript side. +#' +#' @return The modified map object with the custom control added. +#' @export +#' +#' @examples +#' \dontrun{ +#' library(mapgl) +#' +#' maplibre() |> +#' add_control( +#' html = "
+#'

Custom HTML

+#' image +#'
", +#' position = "top-left" +#' ) +#' } +add_control <- function( + map, + html, + position = "top-right", + className = NULL, + ... +) { + control_id <- paste0("custom-control-", as.hexmode(sample(1:1000000, 1))) + + # Create options list + control_options <- list( + html = html, + position = position + ) + + # Add className if provided + if (!is.null(className)) { + control_options$className <- className + } + + # Add any additional parameters + control_options <- c(control_options, list(...)) + + if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_custom_control", + control_id = control_id, + options = control_options, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) { + "mapboxgl-proxy" + } else { + "maplibre-proxy" + } + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_custom_control", + control_id = control_id, + options = control_options + ) + ) + ) + } + } else { + # For initial map creation + if (is.null(map$x$custom_controls)) { + map$x$custom_controls <- list() + } + + map$x$custom_controls[[control_id]] <- control_options + } + + return(map) } diff --git a/R/h3j-h3t.R b/R/h3j-h3t.R new file mode 100644 index 00000000..e680d5cd --- /dev/null +++ b/R/h3j-h3t.R @@ -0,0 +1,49 @@ + +# addH3JSource +#' Add a hexagon source from the H3 geospatial indexing system. +#' @references https://h3geo.org, https://github.com/INSPIDE/h3j-h3t +#' @inheritParams add_vector_source +#' @export +#' @examplesIf interactive() +#' url = "https://inspide.github.io/h3j-h3t/examples/h3j/sample.h3j" +#' maplibre(center=c(-3.704, 40.417), zoom=15, pitch=30) |> +#' add_h3j_source("h3j_testsource", +#' url = url +#' ) |> +#' add_fill_extrusion_layer( +#' id = "h3j_testlayer", +#' source = "h3j_testsource", +#' fill_extrusion_color = interpolate( +#' column = "value", +#' values = c(0, 21.864), +#' stops = c("#430254", "#f83c70") +#' ), +#' fill_extrusion_height = list( +#' "interpolate", +#' list("linear"), +#' list("zoom"), +#' 14, +#' 0, +#' 15.05, +#' list("*", 10, list("get", "value")) +#' ), +#' fill_extrusion_opacity = 0.7 +#' ) +#' +add_h3j_source <- function(map, id, url) { + h3j_sources <- list( + id = id, + url = url + ) + + if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_h3j_sources", h3j_sources = h3j_sources))) + } else { + map$x$h3j_sources <-c(map$x$h3j_sources, list(h3j_sources)) + } + + return(map) +} + + diff --git a/R/layers.R b/R/layers.R index 771c7cc3..1e1075d0 100644 --- a/R/layers.R +++ b/R/layers.R @@ -53,21 +53,23 @@ #' ) #' ) #' } -add_layer <- function(map, - id, - type = "fill", - source, - source_layer = NULL, - paint = list(), - layout = list(), - slot = NULL, - min_zoom = NULL, - max_zoom = NULL, - popup = NULL, - tooltip = NULL, - hover_options = NULL, - before_id = NULL, - filter = NULL) { +add_layer <- function( + map, + id, + type = "fill", + source, + source_layer = NULL, + paint = list(), + layout = list(), + slot = NULL, + min_zoom = NULL, + max_zoom = NULL, + popup = NULL, + tooltip = NULL, + hover_options = NULL, + before_id = NULL, + filter = NULL +) { if (length(paint) == 0) { paint <- NULL } @@ -86,22 +88,25 @@ add_layer <- function(map, ) } - map$x$layers <- c(map$x$layers, list(list( - id = id, - type = type, - source = source, - source_layer = source_layer, - paint = paint, - layout = layout, - slot = slot, - minzoom = min_zoom, - maxzoom = max_zoom, - popup = popup, - tooltip = tooltip, - hover_options = hover_options, - before_id = before_id, - filter = filter - ))) + map$x$layers <- c( + map$x$layers, + list(list( + id = id, + type = type, + source = source, + source_layer = source_layer, + paint = paint, + layout = layout, + slot = slot, + minzoom = min_zoom, + maxzoom = max_zoom, + popup = popup, + tooltip = tooltip, + hover_options = hover_options, + before_id = before_id, + filter = filter + )) + ) if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { layer <- list( @@ -136,13 +141,36 @@ add_layer <- function(map, layer$maxzoom <- max_zoom } - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - - - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "add_layer", layer = layer) - )) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_layer", + layer = layer, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list(type = "add_layer", layer = layer) + ) + ) + } map } else { @@ -205,42 +233,45 @@ add_layer <- function(map, #' fill_opacity = 0.5 #' ) #' } -add_fill_layer <- function(map, - id, - source, - source_layer = NULL, - fill_antialias = TRUE, - fill_color = NULL, - fill_emissive_strength = NULL, - fill_opacity = NULL, - fill_outline_color = NULL, - fill_pattern = NULL, - fill_sort_key = NULL, - fill_translate = NULL, - fill_translate_anchor = "map", - fill_z_offset = NULL, - visibility = "visible", - slot = NULL, - min_zoom = NULL, - max_zoom = NULL, - popup = NULL, - tooltip = NULL, - hover_options = NULL, - before_id = NULL, - filter = NULL) { +add_fill_layer <- function( + map, + id, + source, + source_layer = NULL, + fill_antialias = TRUE, + fill_color = NULL, + fill_emissive_strength = NULL, + fill_opacity = NULL, + fill_outline_color = NULL, + fill_pattern = NULL, + fill_sort_key = NULL, + fill_translate = NULL, + fill_translate_anchor = "map", + fill_z_offset = NULL, + visibility = "visible", + slot = NULL, + min_zoom = NULL, + max_zoom = NULL, + popup = NULL, + tooltip = NULL, + hover_options = NULL, + before_id = NULL, + filter = NULL +) { paint <- list() layout <- list() - - if (!is.null(fill_antialias)) paint[["fill-antialias"]] <- fill_antialias if (!is.null(fill_color)) paint[["fill-color"]] <- fill_color - if (!is.null(fill_emissive_strength)) paint[["fill-emissive-strength"]] <- fill_emissive_strength + if (!is.null(fill_emissive_strength)) + paint[["fill-emissive-strength"]] <- fill_emissive_strength if (!is.null(fill_opacity)) paint[["fill-opacity"]] <- fill_opacity - if (!is.null(fill_outline_color)) paint[["fill-outline-color"]] <- fill_outline_color + if (!is.null(fill_outline_color)) + paint[["fill-outline-color"]] <- fill_outline_color if (!is.null(fill_pattern)) paint[["fill-pattern"]] <- fill_pattern if (!is.null(fill_translate)) paint[["fill-translate"]] <- fill_translate - if (!is.null(fill_translate_anchor)) paint[["fill-translate-anchor"]] <- fill_translate_anchor + if (!is.null(fill_translate_anchor)) + paint[["fill-translate-anchor"]] <- fill_translate_anchor if (!is.null(fill_z_offset)) paint[["fill-z-offset"]] <- fill_z_offset if (!is.null(fill_sort_key)) layout[["fill-sort-key"]] <- fill_sort_key @@ -339,65 +370,74 @@ add_fill_layer <- function(map, #' line_opacity = 0.7 #' ) #' } -add_line_layer <- function(map, - id, - source, - source_layer = NULL, - line_blur = NULL, - line_cap = NULL, - line_color = NULL, - line_dasharray = NULL, - line_emissive_strength = NULL, - line_gap_width = NULL, - line_gradient = NULL, - line_join = NULL, - line_miter_limit = NULL, - line_occlusion_opacity = NULL, - line_offset = NULL, - line_opacity = NULL, - line_pattern = NULL, - line_round_limit = NULL, - line_sort_key = NULL, - line_translate = NULL, - line_translate_anchor = "map", - line_trim_color = NULL, - line_trim_fade_range = NULL, - line_trim_offset = NULL, - line_width = NULL, - line_z_offset = NULL, - visibility = "visible", - slot = NULL, - min_zoom = NULL, - max_zoom = NULL, - popup = NULL, - tooltip = NULL, - hover_options = NULL, - before_id = NULL, - filter = NULL) { +add_line_layer <- function( + map, + id, + source, + source_layer = NULL, + line_blur = NULL, + line_cap = NULL, + line_color = NULL, + line_dasharray = NULL, + line_emissive_strength = NULL, + line_gap_width = NULL, + line_gradient = NULL, + line_join = NULL, + line_miter_limit = NULL, + line_occlusion_opacity = NULL, + line_offset = NULL, + line_opacity = NULL, + line_pattern = NULL, + line_round_limit = NULL, + line_sort_key = NULL, + line_translate = NULL, + line_translate_anchor = "map", + line_trim_color = NULL, + line_trim_fade_range = NULL, + line_trim_offset = NULL, + line_width = NULL, + line_z_offset = NULL, + visibility = "visible", + slot = NULL, + min_zoom = NULL, + max_zoom = NULL, + popup = NULL, + tooltip = NULL, + hover_options = NULL, + before_id = NULL, + filter = NULL +) { paint <- list() layout <- list() if (!is.null(line_blur)) paint[["line-blur"]] <- line_blur if (!is.null(line_color)) paint[["line-color"]] <- line_color if (!is.null(line_dasharray)) paint[["line-dasharray"]] <- line_dasharray - if (!is.null(line_emissive_strength)) paint[["line-emissive-strength"]] <- line_emissive_strength + if (!is.null(line_emissive_strength)) + paint[["line-emissive-strength"]] <- line_emissive_strength if (!is.null(line_gap_width)) paint[["line-gap-width"]] <- line_gap_width if (!is.null(line_gradient)) paint[["line-gradient"]] <- line_gradient - if (!is.null(line_occlusion_opacity)) paint[["line-occlusion-opacity"]] <- line_occlusion_opacity + if (!is.null(line_occlusion_opacity)) + paint[["line-occlusion-opacity"]] <- line_occlusion_opacity if (!is.null(line_offset)) paint[["line-offset"]] <- line_offset if (!is.null(line_opacity)) paint[["line-opacity"]] <- line_opacity if (!is.null(line_pattern)) paint[["line-pattern"]] <- line_pattern if (!is.null(line_translate)) paint[["line-translate"]] <- line_translate - if (!is.null(line_translate_anchor)) paint[["line-translate-anchor"]] <- line_translate_anchor + if (!is.null(line_translate_anchor)) + paint[["line-translate-anchor"]] <- line_translate_anchor if (!is.null(line_trim_color)) paint[["line-trim-color"]] <- line_trim_color - if (!is.null(line_trim_fade_range)) paint[["line-trim-fade-range"]] <- line_trim_fade_range - if (!is.null(line_trim_offset)) paint[["line-trim-offset"]] <- line_trim_offset + if (!is.null(line_trim_fade_range)) + paint[["line-trim-fade-range"]] <- line_trim_fade_range + if (!is.null(line_trim_offset)) + paint[["line-trim-offset"]] <- line_trim_offset if (!is.null(line_width)) paint[["line-width"]] <- line_width if (!is.null(line_cap)) layout[["line-cap"]] <- line_cap if (!is.null(line_join)) layout[["line-join"]] <- line_join - if (!is.null(line_miter_limit)) layout[["line-miter-limit"]] <- line_miter_limit - if (!is.null(line_round_limit)) layout[["line-round-limit"]] <- line_round_limit + if (!is.null(line_miter_limit)) + layout[["line-miter-limit"]] <- line_miter_limit + if (!is.null(line_round_limit)) + layout[["line-round-limit"]] <- line_round_limit if (!is.null(line_sort_key)) layout[["line-sort-key"]] <- line_sort_key if (!is.null(line_z_offset)) layout[["line-z-offset"]] <- line_z_offset if (!is.null(visibility)) layout[["visibility"]] <- visibility @@ -481,33 +521,49 @@ add_line_layer <- function(map, #' heatmap_opacity = 0.7 #' ) #' } -add_heatmap_layer <- function(map, - id, - source, - source_layer = NULL, - heatmap_color = NULL, - heatmap_intensity = NULL, - heatmap_opacity = NULL, - heatmap_radius = NULL, - heatmap_weight = NULL, - visibility = "visible", - slot = NULL, - min_zoom = NULL, - max_zoom = NULL, - before_id = NULL, - filter = NULL) { +add_heatmap_layer <- function( + map, + id, + source, + source_layer = NULL, + heatmap_color = NULL, + heatmap_intensity = NULL, + heatmap_opacity = NULL, + heatmap_radius = NULL, + heatmap_weight = NULL, + visibility = "visible", + slot = NULL, + min_zoom = NULL, + max_zoom = NULL, + before_id = NULL, + filter = NULL +) { paint <- list() layout <- list() if (!is.null(heatmap_color)) paint[["heatmap-color"]] <- heatmap_color - if (!is.null(heatmap_intensity)) paint[["heatmap-intensity"]] <- heatmap_intensity + if (!is.null(heatmap_intensity)) + paint[["heatmap-intensity"]] <- heatmap_intensity if (!is.null(heatmap_opacity)) paint[["heatmap-opacity"]] <- heatmap_opacity if (!is.null(heatmap_radius)) paint[["heatmap-radius"]] <- heatmap_radius if (!is.null(heatmap_weight)) paint[["heatmap-weight"]] <- heatmap_weight if (!is.null(visibility)) layout[["visibility"]] <- visibility - map <- add_layer(map, id, "heatmap", source, source_layer, paint, layout, slot, min_zoom, max_zoom, before_id, filter) + map <- add_layer( + map, + id, + "heatmap", + source, + source_layer, + paint, + layout, + slot, + min_zoom, + max_zoom, + before_id, + filter + ) return(map) } @@ -576,40 +632,67 @@ add_heatmap_layer <- function(map, #' ) #' ) #' } -add_fill_extrusion_layer <- function(map, - id, - source, - source_layer = NULL, - fill_extrusion_base = NULL, - fill_extrusion_color = NULL, - fill_extrusion_height = NULL, - fill_extrusion_opacity = NULL, - fill_extrusion_pattern = NULL, - fill_extrusion_translate = NULL, - fill_extrusion_translate_anchor = "map", - visibility = "visible", - slot = NULL, - min_zoom = NULL, - max_zoom = NULL, - popup = NULL, - tooltip = NULL, - hover_options = NULL, - before_id = NULL, - filter = NULL) { +add_fill_extrusion_layer <- function( + map, + id, + source, + source_layer = NULL, + fill_extrusion_base = NULL, + fill_extrusion_color = NULL, + fill_extrusion_height = NULL, + fill_extrusion_opacity = NULL, + fill_extrusion_pattern = NULL, + fill_extrusion_translate = NULL, + fill_extrusion_translate_anchor = "map", + visibility = "visible", + slot = NULL, + min_zoom = NULL, + max_zoom = NULL, + popup = NULL, + tooltip = NULL, + hover_options = NULL, + before_id = NULL, + filter = NULL +) { paint <- list() layout <- list() - if (!is.null(fill_extrusion_base)) paint[["fill-extrusion-base"]] <- fill_extrusion_base - if (!is.null(fill_extrusion_color)) paint[["fill-extrusion-color"]] <- fill_extrusion_color - if (!is.null(fill_extrusion_height)) paint[["fill-extrusion-height"]] <- fill_extrusion_height - if (!is.null(fill_extrusion_opacity)) paint[["fill-extrusion-opacity"]] <- fill_extrusion_opacity - if (!is.null(fill_extrusion_pattern)) paint[["fill-extrusion-pattern"]] <- fill_extrusion_pattern - if (!is.null(fill_extrusion_translate)) paint[["fill-extrusion-translate"]] <- fill_extrusion_translate - if (!is.null(fill_extrusion_translate_anchor)) paint[["fill-extrusion-translate-anchor"]] <- fill_extrusion_translate_anchor + if (!is.null(fill_extrusion_base)) + paint[["fill-extrusion-base"]] <- fill_extrusion_base + if (!is.null(fill_extrusion_color)) + paint[["fill-extrusion-color"]] <- fill_extrusion_color + if (!is.null(fill_extrusion_height)) + paint[["fill-extrusion-height"]] <- fill_extrusion_height + if (!is.null(fill_extrusion_opacity)) + paint[["fill-extrusion-opacity"]] <- fill_extrusion_opacity + if (!is.null(fill_extrusion_pattern)) + paint[["fill-extrusion-pattern"]] <- fill_extrusion_pattern + if (!is.null(fill_extrusion_translate)) + paint[["fill-extrusion-translate"]] <- fill_extrusion_translate + if (!is.null(fill_extrusion_translate_anchor)) + paint[[ + "fill-extrusion-translate-anchor" + ]] <- fill_extrusion_translate_anchor if (!is.null(visibility)) layout[["visibility"]] <- visibility - map <- add_layer(map, id, "fill-extrusion", source, source_layer, paint, layout, slot, min_zoom, max_zoom, popup, tooltip, hover_options, before_id, filter) + map <- add_layer( + map, + id, + "fill-extrusion", + source, + source_layer, + paint, + layout, + slot, + min_zoom, + max_zoom, + popup, + tooltip, + hover_options, + before_id, + filter + ) return(map) } @@ -645,17 +728,19 @@ add_fill_extrusion_layer <- function(map, #' circle_stroke_color = "#ffffff", #' circle_stroke_width = 2 #' ) -cluster_options <- function(max_zoom = 14, - cluster_radius = 50, - color_stops = c("#51bbd6", "#f1f075", "#f28cb1"), - radius_stops = c(20, 30, 40), - count_stops = c(0, 100, 750), - circle_blur = NULL, - circle_opacity = NULL, - circle_stroke_color = NULL, - circle_stroke_opacity = NULL, - circle_stroke_width = NULL, - text_color = "black") { +cluster_options <- function( + max_zoom = 14, + cluster_radius = 50, + color_stops = c("#51bbd6", "#f1f075", "#f28cb1"), + radius_stops = c(20, 30, 40), + count_stops = c(0, 100, 750), + circle_blur = NULL, + circle_opacity = NULL, + circle_stroke_color = NULL, + circle_stroke_opacity = NULL, + circle_stroke_width = NULL, + text_color = "black" +) { list( max_zoom = max_zoom, cluster_radius = cluster_radius, @@ -771,30 +856,32 @@ cluster_options <- function(max_zoom = 14, #' circular_patches = TRUE #' ) #' } -add_circle_layer <- function(map, - id, - source, - source_layer = NULL, - circle_blur = NULL, - circle_color = NULL, - circle_opacity = NULL, - circle_radius = NULL, - circle_sort_key = NULL, - circle_stroke_color = NULL, - circle_stroke_opacity = NULL, - circle_stroke_width = NULL, - circle_translate = NULL, - circle_translate_anchor = "map", - visibility = "visible", - slot = NULL, - min_zoom = NULL, - max_zoom = NULL, - popup = NULL, - tooltip = NULL, - hover_options = NULL, - before_id = NULL, - filter = NULL, - cluster_options = NULL) { +add_circle_layer <- function( + map, + id, + source, + source_layer = NULL, + circle_blur = NULL, + circle_color = NULL, + circle_opacity = NULL, + circle_radius = NULL, + circle_sort_key = NULL, + circle_stroke_color = NULL, + circle_stroke_opacity = NULL, + circle_stroke_width = NULL, + circle_translate = NULL, + circle_translate_anchor = "map", + visibility = "visible", + slot = NULL, + min_zoom = NULL, + max_zoom = NULL, + popup = NULL, + tooltip = NULL, + hover_options = NULL, + before_id = NULL, + filter = NULL, + cluster_options = NULL +) { paint <- list() layout <- list() @@ -802,13 +889,19 @@ add_circle_layer <- function(map, if (!is.null(circle_color)) paint[["circle-color"]] <- circle_color if (!is.null(circle_opacity)) paint[["circle-opacity"]] <- circle_opacity if (!is.null(circle_radius)) paint[["circle-radius"]] <- circle_radius - if (!is.null(circle_stroke_color)) paint[["circle-stroke-color"]] <- circle_stroke_color - if (!is.null(circle_stroke_opacity)) paint[["circle-stroke-opacity"]] <- circle_stroke_opacity - if (!is.null(circle_stroke_width)) paint[["circle-stroke-width"]] <- circle_stroke_width - if (!is.null(circle_translate)) paint[["circle-translate"]] <- circle_translate - if (!is.null(circle_translate_anchor)) paint[["circle-translate-anchor"]] <- circle_translate_anchor - - if (!is.null(circle_sort_key)) layout[["circle-sort-key"]] <- circle_sort_key + if (!is.null(circle_stroke_color)) + paint[["circle-stroke-color"]] <- circle_stroke_color + if (!is.null(circle_stroke_opacity)) + paint[["circle-stroke-opacity"]] <- circle_stroke_opacity + if (!is.null(circle_stroke_width)) + paint[["circle-stroke-width"]] <- circle_stroke_width + if (!is.null(circle_translate)) + paint[["circle-translate"]] <- circle_translate + if (!is.null(circle_translate_anchor)) + paint[["circle-translate-anchor"]] <- circle_translate_anchor + + if (!is.null(circle_sort_key)) + layout[["circle-sort-key"]] <- circle_sort_key if (!is.null(visibility)) layout[["visibility"]] <- visibility if (!is.null(cluster_options)) { @@ -856,7 +949,9 @@ add_circle_layer <- function(map, for (prop in names(optional_paint)) { if (!is.null(optional_paint[[prop]])) { - map$x$layers[[length(map$x$layers)]]$paint[[prop]] <- optional_paint[[prop]] + map$x$layers[[length(map$x$layers)]]$paint[[ + prop + ]] <- optional_paint[[prop]] } } @@ -957,38 +1052,58 @@ add_circle_layer <- function(map, #' raster_fade_duration = 0 #' ) #' } -add_raster_layer <- function(map, - id, - source, - source_layer = NULL, - raster_brightness_max = NULL, - raster_brightness_min = NULL, - raster_contrast = NULL, - raster_fade_duration = NULL, - raster_hue_rotate = NULL, - raster_opacity = NULL, - raster_resampling = NULL, - raster_saturation = NULL, - visibility = "visible", - slot = NULL, - min_zoom = NULL, - max_zoom = NULL, - before_id = NULL) { +add_raster_layer <- function( + map, + id, + source, + source_layer = NULL, + raster_brightness_max = NULL, + raster_brightness_min = NULL, + raster_contrast = NULL, + raster_fade_duration = NULL, + raster_hue_rotate = NULL, + raster_opacity = NULL, + raster_resampling = NULL, + raster_saturation = NULL, + visibility = "visible", + slot = NULL, + min_zoom = NULL, + max_zoom = NULL, + before_id = NULL +) { paint <- list() layout <- list() - if (!is.null(raster_brightness_max)) paint[["raster-brightness-max"]] <- raster_brightness_max - if (!is.null(raster_brightness_min)) paint[["raster-brightness-min"]] <- raster_brightness_min + if (!is.null(raster_brightness_max)) + paint[["raster-brightness-max"]] <- raster_brightness_max + if (!is.null(raster_brightness_min)) + paint[["raster-brightness-min"]] <- raster_brightness_min if (!is.null(raster_contrast)) paint[["raster-contrast"]] <- raster_contrast - if (!is.null(raster_fade_duration)) paint[["raster-fade-duration"]] <- raster_fade_duration - if (!is.null(raster_hue_rotate)) paint[["raster-hue-rotate"]] <- raster_hue_rotate + if (!is.null(raster_fade_duration)) + paint[["raster-fade-duration"]] <- raster_fade_duration + if (!is.null(raster_hue_rotate)) + paint[["raster-hue-rotate"]] <- raster_hue_rotate if (!is.null(raster_opacity)) paint[["raster-opacity"]] <- raster_opacity - if (!is.null(raster_resampling)) paint[["raster-resampling"]] <- raster_resampling - if (!is.null(raster_saturation)) paint[["raster-saturation"]] <- raster_saturation + if (!is.null(raster_resampling)) + paint[["raster-resampling"]] <- raster_resampling + if (!is.null(raster_saturation)) + paint[["raster-saturation"]] <- raster_saturation if (!is.null(visibility)) layout[["visibility"]] <- visibility - map <- add_layer(map, id, "raster", source, source_layer, paint, layout, slot, min_zoom, max_zoom, before_id) + map <- add_layer( + map, + id, + "raster", + source, + source_layer, + paint, + layout, + slot, + min_zoom, + max_zoom, + before_id + ) return(map) } @@ -1131,153 +1246,184 @@ add_raster_layer <- function(map, #' tooltip = "icon" #' ) #' } -add_symbol_layer <- function(map, - id, - source, - source_layer = NULL, - icon_allow_overlap = NULL, - icon_anchor = NULL, - icon_color = NULL, - icon_color_brightness_max = NULL, - icon_color_brightness_min = NULL, - icon_color_contrast = NULL, - icon_color_saturation = NULL, - icon_emissive_strength = NULL, - icon_halo_blur = NULL, - icon_halo_color = NULL, - icon_halo_width = NULL, - icon_ignore_placement = NULL, - icon_image = NULL, - icon_image_cross_fade = NULL, - icon_keep_upright = NULL, - icon_offset = NULL, - icon_opacity = NULL, - icon_optional = NULL, - icon_padding = NULL, - icon_pitch_alignment = NULL, - icon_rotate = NULL, - icon_rotation_alignment = NULL, - icon_size = NULL, - icon_text_fit = NULL, - icon_text_fit_padding = NULL, - icon_translate = NULL, - icon_translate_anchor = NULL, - symbol_avoid_edges = NULL, - symbol_placement = NULL, - symbol_sort_key = NULL, - symbol_spacing = NULL, - symbol_z_elevate = NULL, - symbol_z_offset = NULL, - symbol_z_order = NULL, - text_allow_overlap = NULL, - text_anchor = NULL, - text_color = "black", - text_emissive_strength = NULL, - text_field = NULL, - text_font = NULL, - text_halo_blur = NULL, - text_halo_color = NULL, - text_halo_width = NULL, - text_ignore_placement = NULL, - text_justify = NULL, - text_keep_upright = NULL, - text_letter_spacing = NULL, - text_line_height = NULL, - text_max_angle = NULL, - text_max_width = NULL, - text_offset = NULL, - text_opacity = NULL, - text_optional = NULL, - text_padding = NULL, - text_pitch_alignment = NULL, - text_radial_offset = NULL, - text_rotate = NULL, - text_rotation_alignment = NULL, - text_size = NULL, - text_transform = NULL, - text_translate = NULL, - text_translate_anchor = NULL, - text_variable_anchor = NULL, - text_writing_mode = NULL, - visibility = "visible", - slot = NULL, - min_zoom = NULL, - max_zoom = NULL, - popup = NULL, - tooltip = NULL, - hover_options = NULL, - before_id = NULL, - filter = NULL, - cluster_options = NULL) { +add_symbol_layer <- function( + map, + id, + source, + source_layer = NULL, + icon_allow_overlap = NULL, + icon_anchor = NULL, + icon_color = NULL, + icon_color_brightness_max = NULL, + icon_color_brightness_min = NULL, + icon_color_contrast = NULL, + icon_color_saturation = NULL, + icon_emissive_strength = NULL, + icon_halo_blur = NULL, + icon_halo_color = NULL, + icon_halo_width = NULL, + icon_ignore_placement = NULL, + icon_image = NULL, + icon_image_cross_fade = NULL, + icon_keep_upright = NULL, + icon_offset = NULL, + icon_opacity = NULL, + icon_optional = NULL, + icon_padding = NULL, + icon_pitch_alignment = NULL, + icon_rotate = NULL, + icon_rotation_alignment = NULL, + icon_size = NULL, + icon_text_fit = NULL, + icon_text_fit_padding = NULL, + icon_translate = NULL, + icon_translate_anchor = NULL, + symbol_avoid_edges = NULL, + symbol_placement = NULL, + symbol_sort_key = NULL, + symbol_spacing = NULL, + symbol_z_elevate = NULL, + symbol_z_offset = NULL, + symbol_z_order = NULL, + text_allow_overlap = NULL, + text_anchor = NULL, + text_color = "black", + text_emissive_strength = NULL, + text_field = NULL, + text_font = NULL, + text_halo_blur = NULL, + text_halo_color = NULL, + text_halo_width = NULL, + text_ignore_placement = NULL, + text_justify = NULL, + text_keep_upright = NULL, + text_letter_spacing = NULL, + text_line_height = NULL, + text_max_angle = NULL, + text_max_width = NULL, + text_offset = NULL, + text_opacity = NULL, + text_optional = NULL, + text_padding = NULL, + text_pitch_alignment = NULL, + text_radial_offset = NULL, + text_rotate = NULL, + text_rotation_alignment = NULL, + text_size = NULL, + text_transform = NULL, + text_translate = NULL, + text_translate_anchor = NULL, + text_variable_anchor = NULL, + text_writing_mode = NULL, + visibility = "visible", + slot = NULL, + min_zoom = NULL, + max_zoom = NULL, + popup = NULL, + tooltip = NULL, + hover_options = NULL, + before_id = NULL, + filter = NULL, + cluster_options = NULL +) { paint <- list() layout <- list() - if (!is.null(icon_allow_overlap)) layout[["icon-allow-overlap"]] <- icon_allow_overlap + if (!is.null(icon_allow_overlap)) + layout[["icon-allow-overlap"]] <- icon_allow_overlap if (!is.null(icon_anchor)) layout[["icon-anchor"]] <- icon_anchor if (!is.null(icon_color)) paint[["icon-color"]] <- icon_color - if (!is.null(icon_color_brightness_max)) paint[["icon-color-brightness-max"]] <- icon_color_brightness_max - if (!is.null(icon_color_brightness_min)) paint[["icon-color-brightness-min"]] <- icon_color_brightness_min - if (!is.null(icon_color_contrast)) paint[["icon-color-contrast"]] <- icon_color_contrast - if (!is.null(icon_color_saturation)) paint[["icon-color-saturation"]] <- icon_color_saturation - if (!is.null(icon_emissive_strength)) paint[["icon-emissive-strength"]] <- icon_emissive_strength + if (!is.null(icon_color_brightness_max)) + paint[["icon-color-brightness-max"]] <- icon_color_brightness_max + if (!is.null(icon_color_brightness_min)) + paint[["icon-color-brightness-min"]] <- icon_color_brightness_min + if (!is.null(icon_color_contrast)) + paint[["icon-color-contrast"]] <- icon_color_contrast + if (!is.null(icon_color_saturation)) + paint[["icon-color-saturation"]] <- icon_color_saturation + if (!is.null(icon_emissive_strength)) + paint[["icon-emissive-strength"]] <- icon_emissive_strength if (!is.null(icon_halo_blur)) paint[["icon-halo-blur"]] <- icon_halo_blur if (!is.null(icon_halo_color)) paint[["icon-halo-color"]] <- icon_halo_color if (!is.null(icon_halo_width)) paint[["icon-halo-width"]] <- icon_halo_width - if (!is.null(icon_ignore_placement)) layout[["icon-ignore-placement"]] <- icon_ignore_placement + if (!is.null(icon_ignore_placement)) + layout[["icon-ignore-placement"]] <- icon_ignore_placement if (!is.null(icon_image)) layout[["icon-image"]] <- icon_image - if (!is.null(icon_image_cross_fade)) layout[["icon-image-cross-fade"]] <- icon_image_cross_fade - if (!is.null(icon_keep_upright)) layout[["icon-keep-upright"]] <- icon_keep_upright + if (!is.null(icon_image_cross_fade)) + layout[["icon-image-cross-fade"]] <- icon_image_cross_fade + if (!is.null(icon_keep_upright)) + layout[["icon-keep-upright"]] <- icon_keep_upright if (!is.null(icon_offset)) layout[["icon-offset"]] <- icon_offset if (!is.null(icon_opacity)) paint[["icon-opacity"]] <- icon_opacity if (!is.null(icon_optional)) layout[["icon-optional"]] <- icon_optional if (!is.null(icon_padding)) layout[["icon-padding"]] <- icon_padding - if (!is.null(icon_pitch_alignment)) layout[["icon-pitch-alignment"]] <- icon_pitch_alignment + if (!is.null(icon_pitch_alignment)) + layout[["icon-pitch-alignment"]] <- icon_pitch_alignment if (!is.null(icon_rotate)) layout[["icon-rotate"]] <- icon_rotate - if (!is.null(icon_rotation_alignment)) layout[["icon-rotation-alignment"]] <- icon_rotation_alignment + if (!is.null(icon_rotation_alignment)) + layout[["icon-rotation-alignment"]] <- icon_rotation_alignment if (!is.null(icon_size)) layout[["icon-size"]] <- icon_size if (!is.null(icon_text_fit)) layout[["icon-text-fit"]] <- icon_text_fit - if (!is.null(icon_text_fit_padding)) layout[["icon-text-fit-padding"]] <- icon_text_fit_padding + if (!is.null(icon_text_fit_padding)) + layout[["icon-text-fit-padding"]] <- icon_text_fit_padding if (!is.null(icon_translate)) paint[["icon-translate"]] <- icon_translate - if (!is.null(icon_translate_anchor)) paint[["icon-translate-anchor"]] <- icon_translate_anchor - - if (!is.null(symbol_avoid_edges)) layout[["symbol-avoid-edges"]] <- symbol_avoid_edges - if (!is.null(symbol_placement)) layout[["symbol-placement"]] <- symbol_placement - if (!is.null(symbol_sort_key)) layout[["symbol-sort-key"]] <- symbol_sort_key + if (!is.null(icon_translate_anchor)) + paint[["icon-translate-anchor"]] <- icon_translate_anchor + + if (!is.null(symbol_avoid_edges)) + layout[["symbol-avoid-edges"]] <- symbol_avoid_edges + if (!is.null(symbol_placement)) + layout[["symbol-placement"]] <- symbol_placement + if (!is.null(symbol_sort_key)) + layout[["symbol-sort-key"]] <- symbol_sort_key if (!is.null(symbol_spacing)) layout[["symbol-spacing"]] <- symbol_spacing - if (!is.null(symbol_z_elevate)) layout[["symbol-z-elevate"]] <- symbol_z_elevate + if (!is.null(symbol_z_elevate)) + layout[["symbol-z-elevate"]] <- symbol_z_elevate if (!is.null(symbol_z_order)) layout[["symbol-z-order"]] <- symbol_z_order if (!is.null(symbol_z_offset)) paint[["symbol-z-offset"]] <- symbol_z_offset - if (!is.null(text_allow_overlap)) layout[["text-allow-overlap"]] <- text_allow_overlap + if (!is.null(text_allow_overlap)) + layout[["text-allow-overlap"]] <- text_allow_overlap if (!is.null(text_anchor)) layout[["text-anchor"]] <- text_anchor if (!is.null(text_color)) paint[["text-color"]] <- text_color - if (!is.null(text_emissive_strength)) paint[["text-emissive-strength"]] <- text_emissive_strength + if (!is.null(text_emissive_strength)) + paint[["text-emissive-strength"]] <- text_emissive_strength if (!is.null(text_field)) layout[["text-field"]] <- text_field if (!is.null(text_font)) layout[["text-font"]] <- text_font if (!is.null(text_halo_blur)) paint[["text-halo-blur"]] <- text_halo_blur if (!is.null(text_halo_color)) paint[["text-halo-color"]] <- text_halo_color if (!is.null(text_halo_width)) paint[["text-halo-width"]] <- text_halo_width - if (!is.null(text_ignore_placement)) layout[["text-ignore-placement"]] <- text_ignore_placement + if (!is.null(text_ignore_placement)) + layout[["text-ignore-placement"]] <- text_ignore_placement if (!is.null(text_justify)) layout[["text-justify"]] <- text_justify - if (!is.null(text_keep_upright)) layout[["text-keep-upright"]] <- text_keep_upright - if (!is.null(text_letter_spacing)) layout[["text-letter-spacing"]] <- text_letter_spacing - if (!is.null(text_line_height)) layout[["text-line-height"]] <- text_line_height + if (!is.null(text_keep_upright)) + layout[["text-keep-upright"]] <- text_keep_upright + if (!is.null(text_letter_spacing)) + layout[["text-letter-spacing"]] <- text_letter_spacing + if (!is.null(text_line_height)) + layout[["text-line-height"]] <- text_line_height if (!is.null(text_max_angle)) layout[["text-max-angle"]] <- text_max_angle if (!is.null(text_max_width)) layout[["text-max-width"]] <- text_max_width if (!is.null(text_offset)) layout[["text-offset"]] <- text_offset if (!is.null(text_opacity)) paint[["text-opacity"]] <- text_opacity if (!is.null(text_optional)) layout[["text-optional"]] <- text_optional if (!is.null(text_padding)) layout[["text-padding"]] <- text_padding - if (!is.null(text_pitch_alignment)) layout[["text-pitch-alignment"]] <- text_pitch_alignment - if (!is.null(text_radial_offset)) layout[["text-radial-offset"]] <- text_radial_offset + if (!is.null(text_pitch_alignment)) + layout[["text-pitch-alignment"]] <- text_pitch_alignment + if (!is.null(text_radial_offset)) + layout[["text-radial-offset"]] <- text_radial_offset if (!is.null(text_rotate)) layout[["text-rotate"]] <- text_rotate - if (!is.null(text_rotation_alignment)) layout[["text-rotation-alignment"]] <- text_rotation_alignment + if (!is.null(text_rotation_alignment)) + layout[["text-rotation-alignment"]] <- text_rotation_alignment if (!is.null(text_size)) layout[["text-size"]] <- text_size if (!is.null(text_transform)) layout[["text-transform"]] <- text_transform if (!is.null(text_translate)) paint[["text-translate"]] <- text_translate - if (!is.null(text_translate_anchor)) paint[["text-translate-anchor"]] <- text_translate_anchor - if (!is.null(text_variable_anchor)) layout[["text-variable-anchor"]] <- text_variable_anchor - if (!is.null(text_writing_mode)) layout[["text-writing-mode"]] <- text_writing_mode + if (!is.null(text_translate_anchor)) + paint[["text-translate-anchor"]] <- text_translate_anchor + if (!is.null(text_variable_anchor)) + layout[["text-variable-anchor"]] <- text_variable_anchor + if (!is.null(text_writing_mode)) + layout[["text-writing-mode"]] <- text_writing_mode if (!is.null(visibility)) layout[["visibility"]] <- visibility @@ -1326,7 +1472,9 @@ add_symbol_layer <- function(map, for (prop in names(optional_paint)) { if (!is.null(optional_paint[[prop]])) { - map$x$layers[[length(map$x$layers)]]$paint[[prop]] <- optional_paint[[prop]] + map$x$layers[[length(map$x$layers)]]$paint[[ + prop + ]] <- optional_paint[[prop]] } } @@ -1359,7 +1507,23 @@ add_symbol_layer <- function(map, before_id = before_id ) } else { - map <- add_layer(map, id, "symbol", source, source_layer, paint, layout, slot, min_zoom, max_zoom, popup, tooltip, hover_options, before_id, filter) + map <- add_layer( + map, + id, + "symbol", + source, + source_layer, + paint, + layout, + slot, + min_zoom, + max_zoom, + popup, + tooltip, + hover_options, + before_id, + filter + ) } return(map) diff --git a/R/legends.R b/R/legends.R index d8456bf1..70aaf99d 100644 --- a/R/legends.R +++ b/R/legends.R @@ -9,21 +9,73 @@ #' @param position The position of the legend on the map (one of "top-left", "bottom-left", "top-right", "bottom-right"). #' @param sizes An optional numeric vector of sizes for the legend patches, or a single numeric value (only for categorical legends). #' @param add Logical, whether to add this legend to existing legends (TRUE) or replace existing legends (FALSE). Default is FALSE. +#' @param unique_id Optional. A unique identifier for the legend. If not provided, a random ID will be generated. #' @param width The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default. +#' @param layer_id The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled. +#' @param margin_top Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning). +#' @param margin_left Custom left margin in pixels. Default is NULL. +#' @param margin_bottom Custom bottom margin in pixels. Default is NULL. +#' @param margin_right Custom right margin in pixels. Default is NULL. #' #' @return The updated map object with the legend added. #' @export -add_legend <- function(map, legend_title, values, colors, - type = c("continuous", "categorical"), - circular_patches = FALSE, position = "top-left", - sizes = NULL, add = FALSE, width = NULL) { +add_legend <- function( + map, + legend_title, + values, + colors, + type = c("continuous", "categorical"), + circular_patches = FALSE, + position = "top-left", + sizes = NULL, + add = FALSE, + unique_id = NULL, + width = NULL, + layer_id = NULL, + margin_top = NULL, + margin_right = NULL, + margin_bottom = NULL, + margin_left = NULL +) { type <- match.arg(type) - unique_id <- paste0("legend-", as.hexmode(sample(1:1000000, 1))) + if (is.null(unique_id)) { + unique_id <- paste0("legend-", as.hexmode(sample(1:1000000, 1))) + } if (type == "continuous") { - add_continuous_legend(map, legend_title, values, colors, position, unique_id, add, width) + add_continuous_legend( + map, + legend_title, + values, + colors, + position, + unique_id, + add, + width, + layer_id, + margin_top, + margin_right, + margin_bottom, + margin_left + ) } else { - add_categorical_legend(map, legend_title, values, colors, circular_patches, position, unique_id, sizes, add, width) + add_categorical_legend( + map, + legend_title, + values, + colors, + circular_patches, + position, + unique_id, + sizes, + add, + width, + layer_id, + margin_top, + margin_right, + margin_bottom, + margin_left + ) } } @@ -42,6 +94,11 @@ add_legend <- function(map, legend_title, values, colors, #' @param sizes An optional numeric vector of sizes for the legend patches, or a single numeric value. If provided as a vector, it should have the same length as `values`. If `circular_patches` is `FALSE` (for square patches), sizes represent the width and height of the patch in pixels. If `circular_patches` is `TRUE`, sizes represent the radius of the circle. #' @param add Logical, whether to add this legend to existing legends (TRUE) or replace existing legends (FALSE). Default is FALSE. #' @param width The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default. +#' @param layer_id The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled. +#' @param margin_top Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning). +#' @param margin_left Custom left margin in pixels. Default is NULL. +#' @param margin_bottom Custom bottom margin in pixels. Default is NULL. +#' @param margin_right Custom right margin in pixels. Default is NULL. #' #' @return The updated map object with the legend added. #' @export @@ -62,12 +119,30 @@ add_legend <- function(map, legend_title, values, colors, #' width = "300px" #' ) #' } -add_categorical_legend <- function(map, legend_title, values, colors, circular_patches = FALSE, position = "top-left", unique_id = NULL, sizes = NULL, add = FALSE, width = NULL) { +add_categorical_legend <- function( + map, + legend_title, + values, + colors, + circular_patches = FALSE, + position = "top-left", + unique_id = NULL, + sizes = NULL, + add = FALSE, + width = NULL, + layer_id = NULL, + margin_top = NULL, + margin_right = NULL, + margin_bottom = NULL, + margin_left = NULL +) { # Validate and prepare inputs if (length(colors) == 1) { colors <- rep(colors, length(values)) } else if (length(colors) != length(values)) { - stop("'colors' must be a single value or have the same length as 'values'.") + stop( + "'colors' must be a single value or have the same length as 'values'." + ) } # Give a default size of 20 if no size supplied @@ -87,19 +162,33 @@ add_categorical_legend <- function(map, legend_title, values, colors, circular_p if (length(sizes) == 1) { sizes <- rep(sizes, length(values)) } else if (length(sizes) != length(values)) { - stop("'sizes' must be a single value or have the same length as 'values'.") + stop( + "'sizes' must be a single value or have the same length as 'values'." + ) } max_size <- max(sizes) legend_items <- lapply(seq_along(values), function(i) { shape_style <- if (circular_patches) "border-radius: 50%;" else "" - size_style <- if (!is.null(sizes)) sprintf("width: %dpx; height: %dpx;", sizes[i], sizes[i]) else "" + size_style <- if (!is.null(sizes)) + sprintf("width: %dpx; height: %dpx;", sizes[i], sizes[i]) else "" paste0( '
', - '
', - '
', - '', values[i], "", + '
', + '
', + '', + values[i], + "", "
" ) }) @@ -108,18 +197,37 @@ add_categorical_legend <- function(map, legend_title, values, colors, circular_p unique_id <- paste0("legend-", as.hexmode(sample(1:1000000, 1))) } + # Add data-layer-id attribute if layer_id is provided + layer_attr <- if (!is.null(layer_id)) { + paste0(' data-layer-id="', layer_id, '"') + } else { + "" + } + legend_html <- paste0( - '
', - "

", legend_title, "

", + '
", + "

", + legend_title, + "

", paste0(legend_items, collapse = ""), "
" ) - width_style <- if (!is.null(width)) paste0("width: ", width, ";") else "max-width: 250px;" + width_style <- if (!is.null(width)) paste0("width: ", width, ";") else + "max-width: 250px;" - legend_css <- paste0(" + legend_css <- paste0( + " @import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap'); - #", unique_id, " h2 { + #", + unique_id, + " h2 { font-size: 14px; font-family: 'Open Sans'; line-height: 20px; @@ -130,32 +238,62 @@ add_categorical_legend <- function(map, legend_title, values, colors, circular_p overflow: hidden; text-overflow: ellipsis; } - #", unique_id, " { + #", + unique_id, + " { position: absolute; border-radius: 10px; margin: 10px; - ", width_style, " + ", + width_style, + " background-color: #ffffff80; padding: 10px 20px; z-index: 1002; } - #", unique_id, ".top-left { - top: 10px; - left: 10px; + #", + unique_id, + ".top-left { + top: ", + ifelse(is.null(margin_top), "10px", paste0(margin_top, "px")), + "; + left: ", + ifelse(is.null(margin_left), "10px", paste0(margin_left, "px")), + "; } - #", unique_id, ".bottom-left { - bottom: 10px; - left: 10px; + #", + unique_id, + ".bottom-left { + bottom: ", + ifelse(is.null(margin_bottom), "10px", paste0(margin_bottom, "px")), + "; + left: ", + ifelse(is.null(margin_left), "10px", paste0(margin_left, "px")), + "; } - #", unique_id, ".top-right { - top: 10px; - right: 10px; + #", + unique_id, + ".top-right { + top: ", + ifelse(is.null(margin_top), "10px", paste0(margin_top, "px")), + "; + right: ", + ifelse(is.null(margin_right), "10px", paste0(margin_right, "px")), + "; } - #", unique_id, ".bottom-right { - bottom: 10px; - right: 10px; + #", + unique_id, + ".bottom-right { + bottom: ", + ifelse(is.null(margin_bottom), "10px", paste0(margin_bottom, "px")), + "; + right: ", + ifelse(is.null(margin_right), "10px", paste0(margin_right, "px")), + "; } - #", unique_id, " .legend-item { + #", + unique_id, + " .legend-item { display: flex; align-items: center; margin-bottom: 5px; @@ -164,26 +302,48 @@ add_categorical_legend <- function(map, legend_title, values, colors, circular_p max-width: 100%; overflow: hidden; } - #", unique_id, " .legend-patch-container { + #", + unique_id, + " .legend-patch-container { display: flex; justify-content: center; align-items: center; margin-right: 5px; } - #", unique_id, " .legend-color { + #", + unique_id, + " .legend-color { display: inline-block; flex-shrink: 0; } - #", unique_id, " .legend-text { + #", + unique_id, + " .legend-text { flex-grow: 1; text-overflow: ellipsis; overflow: hidden; } - ") + " + ) if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- ifelse(inherits(map, "mapboxgl_proxy"), "mapboxgl-proxy", "maplibre-proxy") - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_legend", html = legend_html, legend_css = legend_css, add = add))) + proxy_class <- ifelse( + inherits(map, "mapboxgl_proxy"), + "mapboxgl-proxy", + "maplibre-proxy" + ) + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_legend", + html = legend_html, + legend_css = legend_css, + add = add + ) + ) + ) map } else { if (!add) { @@ -207,44 +367,91 @@ add_categorical_legend <- function(map, legend_title, values, colors, circular_p #' @param unique_id A unique ID for the legend container. Defaults to NULL. #' @param add Logical, whether to add this legend to existing legends (TRUE) or replace existing legends (FALSE). Default is FALSE. #' @param width The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default. +#' @param layer_id The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled. +#' @param margin_top Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning). +#' @param margin_left Custom left margin in pixels. Default is NULL. +#' @param margin_bottom Custom bottom margin in pixels. Default is NULL. +#' @param margin_right Custom right margin in pixels. Default is NULL. #' #' @return The updated map object with the legend added. #' @export -add_continuous_legend <- function(map, legend_title, values, colors, position = "top-left", unique_id = NULL, add = FALSE, width = NULL) { +add_continuous_legend <- function( + map, + legend_title, + values, + colors, + position = "top-left", + unique_id = NULL, + add = FALSE, + width = NULL, + layer_id = NULL, + margin_top = NULL, + margin_right = NULL, + margin_bottom = NULL, + margin_left = NULL +) { if (is.null(unique_id)) { unique_id <- paste0("legend-", as.hexmode(sample(1:1000000, 1))) } - color_gradient <- paste0("linear-gradient(to right, ", paste(colors, collapse = ", "), ")") + color_gradient <- paste0( + "linear-gradient(to right, ", + paste(colors, collapse = ", "), + ")" + ) num_values <- length(values) value_labels <- paste0( '
', paste0( - '', values, "", + '', + values, + "", collapse = "" ), "
" ) + # Add data-layer-id attribute if layer_id is provided + layer_attr <- if (!is.null(layer_id)) { + paste0(' data-layer-id="', layer_id, '"') + } else { + "" + } + legend_html <- paste0( - '
', - "

", legend_title, "

", - '
', + '
", + "

", + legend_title, + "

", + '
', '
', value_labels, "
", "
" ) - width_style <- if (!is.null(width)) paste0("width: ", width, ";") else "width: 200px;" + width_style <- if (!is.null(width)) paste0("width: ", width, ";") else + "width: 200px;" - legend_css <- paste0(" + legend_css <- paste0( + " @import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap'); - #", unique_id, " h2 { + #", + unique_id, + " h2 { font-size: 14px; font-family: 'Open Sans'; line-height: 20px; @@ -252,60 +459,110 @@ add_continuous_legend <- function(map, legend_title, values, colors, position = margin-top: 0px; } - #", unique_id, " { + #", + unique_id, + " { position: absolute; border-radius: 10px; margin: 10px; - ", width_style, " + ", + width_style, + " background-color: #ffffff80; padding: 10px 20px; z-index: 1002; } - #", unique_id, ".top-left { - top: 10px; - left: 10px; + #", + unique_id, + ".top-left { + top: ", + ifelse(is.null(margin_top), "10px", paste0(margin_top, "px")), + "; + left: ", + ifelse(is.null(margin_left), "10px", paste0(margin_left, "px")), + "; } - #", unique_id, ".bottom-left { - bottom: 10px; - left: 10px; + #", + unique_id, + ".bottom-left { + bottom: ", + ifelse(is.null(margin_bottom), "10px", paste0(margin_bottom, "px")), + "; + left: ", + ifelse(is.null(margin_left), "10px", paste0(margin_left, "px")), + "; } - #", unique_id, ".top-right { - top: 10px; - right: 10px; + #", + unique_id, + ".top-right { + top: ", + ifelse(is.null(margin_top), "10px", paste0(margin_top, "px")), + "; + right: ", + ifelse(is.null(margin_right), "10px", paste0(margin_right, "px")), + "; } - #", unique_id, ".bottom-right { - bottom: 10px; - right: 10px; + #", + unique_id, + ".bottom-right { + bottom: ", + ifelse(is.null(margin_bottom), "10px", paste0(margin_bottom, "px")), + "; + right: ", + ifelse(is.null(margin_right), "10px", paste0(margin_right, "px")), + "; } - #", unique_id, " .legend-gradient { + #", + unique_id, + " .legend-gradient { height: 20px; margin: 5px 10px 5px 10px; } - #", unique_id, " .legend-labels { + #", + unique_id, + " .legend-labels { position: relative; height: 20px; margin: 0 10px; } - #", unique_id, " .legend-labels span { + #", + unique_id, + " .legend-labels span { font-size: 12px; position: absolute; transform: translateX(-50%); /* Center all labels by default */ white-space: nowrap; } -") +" + ) if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- ifelse(inherits(map, "mapboxgl_proxy"), "mapboxgl-proxy", "maplibre-proxy") + proxy_class <- ifelse( + inherits(map, "mapboxgl_proxy"), + "mapboxgl-proxy", + "maplibre-proxy" + ) - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_legend", html = legend_html, legend_css = legend_css, add = add))) + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_legend", + html = legend_html, + legend_css = legend_css, + add = add + ) + ) + ) map } else { @@ -321,18 +578,33 @@ add_continuous_legend <- function(map, legend_title, values, colors, position = } -#' Clear legend from a map in a proxy session +#' Clear legend(s) from a map in a proxy session #' #' @param map A map object created by the `mapboxgl_proxy` or `maplibre_proxy` function. +#' @param legend_ids Optional. A character vector of legend IDs to clear. If not provided, all legends will be cleared. #' -#' @return The updated map object with the legend cleared. +#' @return The updated map object with the specified legend(s) cleared. #' @export -clear_legend <- function(map) { +clear_legend <- function(map, legend_ids = NULL) { if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- ifelse(inherits(map, "mapboxgl_proxy"), "mapboxgl-proxy", "maplibre-proxy") - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "clear_legend"))) + proxy_class <- ifelse( + inherits(map, "mapboxgl_proxy"), + "mapboxgl-proxy", + "maplibre-proxy" + ) + message <- if (is.null(legend_ids)) { + list(type = "clear_legend") + } else { + list(type = "clear_legend", ids = legend_ids) + } + map$session$sendCustomMessage( + proxy_class, + list(id = map$id, message = message) + ) } else { - stop("clear_legend can only be used with mapboxgl_proxy or maplibre_proxy objects.") + stop( + "clear_legend can only be used with mapboxgl_proxy or maplibre_proxy objects." + ) } return(map) } diff --git a/R/mapboxgl.R b/R/mapboxgl.R index 327d61de..dda66cca 100644 --- a/R/mapboxgl.R +++ b/R/mapboxgl.R @@ -6,7 +6,7 @@ #' @param bearing The initial bearing (rotation) of the map, in degrees. #' @param pitch The initial pitch (tilt) of the map, in degrees. #' @param projection The map projection to use (e.g., "mercator", "globe"). -#' @param parallels A vector of two numbers representing the standard parellels of the projection. Only available when the projection is "albers" or "lambertConformalConic". +#' @param parallels A vector of two numbers representing the standard parallels of the projection. Only available when the projection is "albers" or "lambertConformalConic". #' @param access_token Your Mapbox access token. #' @param bounds An sf object or bounding box to fit the map to. #' @param width The width of the output htmlwidget. @@ -20,74 +20,77 @@ #' \dontrun{ #' mapboxgl(projection = "globe") #' } -mapboxgl <- function(style = NULL, - center = c(0, 0), - zoom = 0, - bearing = 0, - pitch = 0, - projection = "globe", - parallels = NULL, - access_token = NULL, - bounds = NULL, - width = "100%", - height = NULL, - ...) { - - if (is.null(access_token)) { - if (Sys.getenv("MAPBOX_PUBLIC_TOKEN") == "") { - rlang::abort(c("A Mapbox access token is required. Get one from your account at https://www.mapbox.com, and do one of the following:", - i = "Run `usethis::edit_r_environ()` and add the line MAPBOX_PUBLIC_TOKEN='your_token_goes_here';", - i = "Install the mapboxapi R package and run `mb_access_token('your_token_goes_here', install = TRUE)`", - i = "Alternatively, supply your token to the `access_token` parameter in this function or run `Sys.setenv(MAPBOX_PUBLIC_TOKEN='your_token_goes_here') for this session.")) - } else { - access_token <- Sys.getenv("MAPBOX_PUBLIC_TOKEN") +mapboxgl <- function( + style = NULL, + center = c(0, 0), + zoom = 0, + bearing = 0, + pitch = 0, + projection = "globe", + parallels = NULL, + access_token = NULL, + bounds = NULL, + width = "100%", + height = NULL, + ... +) { + if (is.null(access_token)) { + if (Sys.getenv("MAPBOX_PUBLIC_TOKEN") == "") { + rlang::abort(c( + "A Mapbox access token is required. Get one from your account at https://www.mapbox.com, and do one of the following:", + i = "Run `usethis::edit_r_environ()` and add the line MAPBOX_PUBLIC_TOKEN='your_token_goes_here';", + i = "Install the mapboxapi R package and run `mb_access_token('your_token_goes_here', install = TRUE)`", + i = "Alternatively, supply your token to the `access_token` parameter in this function or run `Sys.setenv(MAPBOX_PUBLIC_TOKEN='your_token_goes_here') for this session." + )) + } else { + access_token <- Sys.getenv("MAPBOX_PUBLIC_TOKEN") + } } - } - additional_params <- list(...) + additional_params <- list(...) - if (!is.null(bounds)) { - if (inherits(bounds, "sf")) { - bounds <- as.vector(sf::st_bbox(sf::st_transform(bounds, 4326))) + if (!is.null(bounds)) { + if (inherits(bounds, "sf")) { + bounds <- as.vector(sf::st_bbox(sf::st_transform(bounds, 4326))) + } + additional_params$bounds <- bounds } - additional_params$bounds <- bounds - } - control_css <- htmltools::htmlDependency( - name = "layers-control", - version = "1.0.0", - src = c(file = system.file("htmlwidgets/styles", package = "mapgl")), - stylesheet = "layers-control.css" - ) + control_css <- htmltools::htmlDependency( + name = "layers-control", + version = "1.0.0", + src = c(file = system.file("htmlwidgets/styles", package = "mapgl")), + stylesheet = "layers-control.css" + ) - htmlwidgets::createWidget( - name = "mapboxgl", - x = list( - style = style, - center = center, - zoom = zoom, - bearing = bearing, - pitch = pitch, - projection = projection, - parallels = parallels, - access_token = access_token, - additional_params = additional_params - ), - width = width, - height = height, - package = "mapgl", - dependencies = list(control_css), - sizingPolicy = htmlwidgets::sizingPolicy( - viewer.suppress = FALSE, - browser.fill = TRUE, - viewer.fill = TRUE, - knitr.figure = TRUE, - padding = 0, - knitr.defaultHeight = "500px", - viewer.defaultHeight = "100vh", - browser.defaultHeight = "100vh" + htmlwidgets::createWidget( + name = "mapboxgl", + x = list( + style = style, + center = center, + zoom = zoom, + bearing = bearing, + pitch = pitch, + projection = projection, + parallels = parallels, + access_token = access_token, + additional_params = additional_params + ), + width = width, + height = height, + package = "mapgl", + dependencies = list(control_css), + sizingPolicy = htmlwidgets::sizingPolicy( + viewer.suppress = FALSE, + browser.fill = TRUE, + viewer.fill = TRUE, + knitr.figure = TRUE, + padding = 0, + knitr.defaultHeight = "500px", + viewer.defaultHeight = "100vh", + browser.defaultHeight = "100vh" + ) ) - ) } #' Create a Mapbox GL output element for Shiny @@ -99,7 +102,13 @@ mapboxgl <- function(style = NULL, #' @return A Mapbox GL output element for use in a Shiny UI #' @export mapboxglOutput <- function(outputId, width = "100%", height = "400px") { - htmlwidgets::shinyWidgetOutput(outputId, "mapboxgl", width, height, package = "mapgl") + htmlwidgets::shinyWidgetOutput( + outputId, + "mapboxgl", + width, + height, + package = "mapgl" + ) } #' Render a Mapbox GL output element in Shiny @@ -111,6 +120,8 @@ mapboxglOutput <- function(outputId, width = "100%", height = "400px") { #' @return A rendered Mapbox GL map for use in a Shiny server #' @export renderMapboxgl <- function(expr, env = parent.frame(), quoted = FALSE) { - if (!quoted) { expr <- substitute(expr) } # force quoted - htmlwidgets::shinyRenderWidget(expr, mapboxglOutput, env, quoted = TRUE) + if (!quoted) { + expr <- substitute(expr) + } # force quoted + htmlwidgets::shinyRenderWidget(expr, mapboxglOutput, env, quoted = TRUE) } diff --git a/R/maplibre.R b/R/maplibre.R index c2750b31..d8a31836 100644 --- a/R/maplibre.R +++ b/R/maplibre.R @@ -17,57 +17,58 @@ #' \dontrun{ #' maplibre() #' } -maplibre <- function(style = carto_style("voyager"), - center = c(0, 0), - zoom = 0, - bearing = 0, - pitch = 0, - bounds = NULL, - width = "100%", - height = NULL, - ...) { +maplibre <- function( + style = carto_style("voyager"), + center = c(0, 0), + zoom = 0, + bearing = 0, + pitch = 0, + bounds = NULL, + width = "100%", + height = NULL, + ... +) { + additional_params <- list(...) - additional_params <- list(...) - - if (!is.null(bounds)) { - if (inherits(bounds, "sf")) { - bounds <- as.vector(sf::st_bbox(sf::st_transform(bounds, 4326))) + if (!is.null(bounds)) { + if (inherits(bounds, "sf")) { + bounds <- as.vector(sf::st_bbox(sf::st_transform(bounds, 4326))) + } + additional_params$bounds <- bounds } - additional_params$bounds <- bounds - } - control_css <- htmltools::htmlDependency( - name = "layers-control", - version = "1.0.0", - src = c(file = system.file("htmlwidgets/styles", package = "mapgl")), - stylesheet = "layers-control.css" - ) + control_css <- htmltools::htmlDependency( + name = "layers-control", + version = "1.0.0", + src = c(file = system.file("htmlwidgets/styles", package = "mapgl")), + stylesheet = "layers-control.css" + ) - htmlwidgets::createWidget( - name = "maplibregl", - x = list( - style = style, - center = center, - zoom = zoom, - bearing = bearing, - pitch = pitch, - additional_params = additional_params - ), - width = width, - height = height, - package = "mapgl", - dependencies = list(control_css), - sizingPolicy = htmlwidgets::sizingPolicy( - viewer.suppress = FALSE, - browser.fill = TRUE, - viewer.fill = TRUE, - knitr.figure = TRUE, - padding = 0, - knitr.defaultHeight = "500px", - viewer.defaultHeight = "100vh", - browser.defaultHeight = "100vh" + htmlwidgets::createWidget( + name = "maplibregl", + x = list( + style = style, + center = center, + zoom = zoom, + bearing = bearing, + pitch = pitch, + additional_params = additional_params + ), + width = width, + height = height, + package = "mapgl", + dependencies = list(control_css), + sizingPolicy = htmlwidgets::sizingPolicy( + viewer.suppress = FALSE, + browser.fill = TRUE, + viewer.fill = TRUE, + knitr.figure = TRUE, + padding = 0, + knitr.defaultHeight = "500px", + viewer.defaultHeight = "100vh", + browser.defaultHeight = "100vh" + ) ) - ) } #' Create a Maplibre GL output element for Shiny @@ -79,7 +80,13 @@ maplibre <- function(style = carto_style("voyager"), #' @return A Maplibre GL output element for use in a Shiny UI #' @export maplibreOutput <- function(outputId, width = "100%", height = "400px") { - htmlwidgets::shinyWidgetOutput(outputId, "maplibregl", width, height, package = "mapgl") + htmlwidgets::shinyWidgetOutput( + outputId, + "maplibregl", + width, + height, + package = "mapgl" + ) } #' Render a Maplibre GL output element in Shiny @@ -91,6 +98,8 @@ maplibreOutput <- function(outputId, width = "100%", height = "400px") { #' @return A rendered Maplibre GL map for use in a Shiny server #' @export renderMaplibre <- function(expr, env = parent.frame(), quoted = FALSE) { - if (!quoted) { expr <- substitute(expr) } # force quoted - htmlwidgets::shinyRenderWidget(expr, maplibreOutput, env, quoted = TRUE) + if (!quoted) { + expr <- substitute(expr) + } # force quoted + htmlwidgets::shinyRenderWidget(expr, maplibreOutput, env, quoted = TRUE) } diff --git a/R/plugins.R b/R/plugins.R index 91f0190f..9add095e 100644 --- a/R/plugins.R +++ b/R/plugins.R @@ -1,50 +1,168 @@ -#' Create a Compare slider widget +#' Create a Compare widget #' -#' This function creates a comparison view between two Mapbox GL or Maplibre GL maps, allowing users to swipe between the two maps to compare different styles or data layers. +#' This function creates a comparison view between two Mapbox GL or Maplibre GL maps, allowing users to either swipe between the two maps or view them side-by-side with synchronized navigation. #' #' @param map1 A `mapboxgl` or `maplibre` object representing the first map. #' @param map2 A `mapboxgl` or `maplibre` object representing the second map. #' @param width Width of the map container. #' @param height Height of the map container. #' @param elementId An optional string specifying the ID of the container for the comparison. If NULL, a unique ID will be generated. -#' @param mousemove A logical value indicating whether to enable swiping during cursor movement (rather than only when clicked). -#' @param orientation A string specifying the orientation of the swiper, either "horizontal" or "vertical". +#' @param mousemove A logical value indicating whether to enable swiping during cursor movement (rather than only when clicked). Only applicable when `mode="swipe"`. +#' @param orientation A string specifying the orientation of the swiper or the side-by-side layout, either "horizontal" or "vertical". +#' @param mode A string specifying the comparison mode: "swipe" (default) for a swipeable comparison with a slider, or "sync" for synchronized maps displayed next to each other. +#' @param swiper_color An optional CSS color value (e.g., "#000000", "rgb(0,0,0)", "black") to customize the color of the swiper handle. Only applicable when `mode="swipe"`. #' #' @return A comparison widget. #' @export #' +#' @details +#' ## Comparison modes +#' +#' The `compare()` function supports two modes: +#' +#' * `mode="swipe"` (default) - Creates a swipeable interface with a slider to reveal portions of each map +#' * `mode="sync"` - Places the maps next to each other with synchronized navigation +#' +#' In both modes, navigation (panning, zooming, rotating, tilting) is synchronized between the maps. +#' +#' ## Using the compare widget in Shiny +#' +#' The compare widget can be used in Shiny applications with the following functions: +#' +#' * `mapboxglCompareOutput()` / `renderMapboxglCompare()` - For Mapbox GL comparisons +#' * `maplibreCompareOutput()` / `renderMaplibreCompare()` - For Maplibre GL comparisons +#' * `mapboxgl_compare_proxy()` / `maplibre_compare_proxy()` - For updating maps in a compare widget +#' +#' After creating a compare widget in a Shiny app, you can use the proxy functions to update either the "before" +#' (left/top) or "after" (right/bottom) map. The proxy objects work with all the regular map update functions like `set_style()`, +#' `set_paint_property()`, etc. +#' +#' To get a proxy that targets a specific map in the comparison: +#' +#' ```r +#' # Access the left/top map +#' left_proxy <- maplibre_compare_proxy("compare_id", map_side = "before") +#' +#' # Access the right/bottom map +#' right_proxy <- maplibre_compare_proxy("compare_id", map_side = "after") +#' ``` +#' +#' The compare widget also provides Shiny input values for view state and clicks. For a compare widget with ID "mycompare", you'll have: +#' +#' * `input$mycompare_before_view` - View state (center, zoom, bearing, pitch) of the left/top map +#' * `input$mycompare_after_view` - View state of the right/bottom map +#' * `input$mycompare_before_click` - Click events on the left/top map +#' * `input$mycompare_after_click` - Click events on the right/bottom map +#' #' @examples #' \dontrun{ #' library(mapgl) #' -#' library(mapgl) -#' #' m1 <- mapboxgl(style = mapbox_style("light")) -#' #' m2 <- mapboxgl(style = mapbox_style("dark")) #' +#' # Default swipe mode #' compare(m1, m2) +#' +#' # Synchronized side-by-side mode +#' compare(m1, m2, mode = "sync") +#' +#' # Custom swiper color +#' compare(m1, m2, swiper_color = "#FF0000") # Red swiper +#' +#' # Shiny example +#' library(shiny) +#' +#' ui <- fluidPage( +#' maplibreCompareOutput("comparison") +#' ) +#' +#' server <- function(input, output, session) { +#' output$comparison <- renderMaplibreCompare({ +#' compare( +#' maplibre(style = carto_style("positron")), +#' maplibre(style = carto_style("dark-matter")), +#' mode = "sync" +#' ) +#' }) +#' +#' # Update the right map +#' observe({ +#' right_proxy <- maplibre_compare_proxy("comparison", map_side = "after") +#' set_style(right_proxy, carto_style("voyager")) +#' }) +#' +#' # Example with custom swiper color +#' output$comparison2 <- renderMaplibreCompare({ +#' compare( +#' maplibre(style = carto_style("positron")), +#' maplibre(style = carto_style("dark-matter")), +#' swiper_color = "#3498db" # Blue swiper +#' ) +#' }) #' } -compare <- function(map1, - map2, - width = "100%", - height = NULL, - elementId = NULL, - mousemove = FALSE, - orientation = "vertical") { +#' } +compare <- function( + map1, + map2, + width = "100%", + height = NULL, + elementId = NULL, + mousemove = FALSE, + orientation = "vertical", + mode = "swipe", + swiper_color = NULL +) { + if (!mode %in% c("swipe", "sync")) { + stop("Mode must be either 'swipe' or 'sync'.") + } + if (inherits(map1, "mapboxgl") && inherits(map2, "mapboxgl")) { - compare.mapboxgl(map1, map2, width, height, elementId, mousemove, orientation) + compare.mapboxgl( + map1, + map2, + width, + height, + elementId, + mousemove, + orientation, + mode, + swiper_color + ) } else if (inherits(map1, "maplibregl") && inherits(map2, "maplibregl")) { - compare.maplibre(map1, map2, width, height, elementId, mousemove, orientation) + compare.maplibre( + map1, + map2, + width, + height, + elementId, + mousemove, + orientation, + mode, + swiper_color + ) } else { stop("Both maps must be either mapboxgl or maplibregl objects.") } } # Mapbox GL comparison widget -compare.mapboxgl <- function(map1, map2, width, height, elementId, mousemove, orientation) { +compare.mapboxgl <- function( + map1, + map2, + width, + height, + elementId, + mousemove, + orientation, + mode, + swiper_color = NULL +) { if (is.null(elementId)) { - elementId <- paste0("compare-container-", as.hexmode(sample(1:1000000, 1))) + elementId <- paste0( + "compare-container-", + as.hexmode(sample(1:1000000, 1)) + ) } x <- list( @@ -52,7 +170,16 @@ compare.mapboxgl <- function(map1, map2, width, height, elementId, mousemove, or map2 = map2$x, elementId = elementId, mousemove = mousemove, - orientation = orientation + orientation = orientation, + mode = mode, + swiper_color = swiper_color + ) + + control_css <- htmltools::htmlDependency( + name = "layers-control", + version = "1.0.0", + src = c(file = system.file("htmlwidgets/styles", package = "mapgl")), + stylesheet = "layers-control.css" ) htmlwidgets::createWidget( @@ -61,7 +188,9 @@ compare.mapboxgl <- function(map1, map2, width, height, elementId, mousemove, or width = width, height = height, package = "mapgl", - elementId = elementId, + dependencies = list(control_css), + elementId = if (is.null(shiny::getDefaultReactiveDomain())) + elementId else NULL, sizingPolicy = htmlwidgets::sizingPolicy( viewer.suppress = FALSE, browser.fill = TRUE, @@ -76,32 +205,58 @@ compare.mapboxgl <- function(map1, map2, width, height, elementId, mousemove, or } # Maplibre comparison widget -compare.maplibre <- function(map1, map2, width, height, elementId, mousemove, orientation) { +compare.maplibre <- function( + map1, + map2, + width, + height, + elementId, + mousemove, + orientation, + mode, + swiper_color = NULL +) { if (is.null(elementId)) { - elementId <- paste0("compare-container-", as.hexmode(sample(1:1000000, 1))) - } - - check_for_popups_or_tooltips <- function(map) { - if (!is.null(map$x$layers)) { - for (layer in map$x$layers) { - if (!is.null(layer$popup) || !is.null(layer$tooltip)) { - return(TRUE) - } - } - } - return(FALSE) + elementId <- paste0( + "compare-container-", + as.hexmode(sample(1:1000000, 1)) + ) } - if (check_for_popups_or_tooltips(map1) || check_for_popups_or_tooltips(map2)) { - rlang::warn("Popups and tooltips are not currently supported for `compare()` with maplibre maps.") - } + # check_for_popups_or_tooltips <- function(map) { + # if (!is.null(map$x$layers)) { + # for (layer in map$x$layers) { + # if (!is.null(layer$popup) || !is.null(layer$tooltip)) { + # return(TRUE) + # } + # } + # } + # return(FALSE) + # } + # + # if ( + # check_for_popups_or_tooltips(map1) || check_for_popups_or_tooltips(map2) + # ) { + # rlang::warn( + # "Popups and tooltips are not currently supported for `compare()` with maplibre maps." + # ) + # } x <- list( map1 = map1$x, map2 = map2$x, elementId = elementId, mousemove = mousemove, - orientation = orientation + orientation = orientation, + mode = mode, + swiper_color = swiper_color + ) + + control_css <- htmltools::htmlDependency( + name = "layers-control", + version = "1.0.0", + src = c(file = system.file("htmlwidgets/styles", package = "mapgl")), + stylesheet = "layers-control.css" ) htmlwidgets::createWidget( @@ -110,7 +265,9 @@ compare.maplibre <- function(map1, map2, width, height, elementId, mousemove, or width = width, height = height, package = "mapgl", - elementId = elementId, + dependencies = list(control_css), + elementId = if (is.null(shiny::getDefaultReactiveDomain())) + elementId else NULL, sizingPolicy = htmlwidgets::sizingPolicy( viewer.suppress = FALSE, browser.fill = TRUE, @@ -124,6 +281,150 @@ compare.maplibre <- function(map1, map2, width, height, elementId, mousemove, or ) } +#' Create a Mapbox GL Compare output element for Shiny +#' +#' @param outputId The output variable to read from +#' @param width The width of the element +#' @param height The height of the element +#' +#' @return A Mapbox GL Compare output element for use in a Shiny UI +#' @export +mapboxglCompareOutput <- function(outputId, width = "100%", height = "400px") { + htmlwidgets::shinyWidgetOutput( + outputId, + "mapboxgl_compare", + width, + height, + package = "mapgl" + ) +} + +#' Render a Mapbox GL Compare output element in Shiny +#' +#' @param expr An expression that generates a Mapbox GL Compare map +#' @param env The environment in which to evaluate `expr` +#' @param quoted Is `expr` a quoted expression +#' +#' @return A rendered Mapbox GL Compare map for use in a Shiny server +#' @export +renderMapboxglCompare <- function(expr, env = parent.frame(), quoted = FALSE) { + if (!quoted) { + expr <- substitute(expr) + } # force quoted + htmlwidgets::shinyRenderWidget( + expr, + mapboxglCompareOutput, + env, + quoted = TRUE + ) +} + +#' Create a Maplibre GL Compare output element for Shiny +#' +#' @param outputId The output variable to read from +#' @param width The width of the element +#' @param height The height of the element +#' +#' @return A Maplibre GL Compare output element for use in a Shiny UI +#' @export +maplibreCompareOutput <- function(outputId, width = "100%", height = "400px") { + htmlwidgets::shinyWidgetOutput( + outputId, + "maplibregl_compare", + width, + height, + package = "mapgl" + ) +} + +#' Render a Maplibre GL Compare output element in Shiny +#' +#' @param expr An expression that generates a Maplibre GL Compare map +#' @param env The environment in which to evaluate `expr` +#' @param quoted Is `expr` a quoted expression +#' +#' @return A rendered Maplibre GL Compare map for use in a Shiny server +#' @export +renderMaplibreCompare <- function(expr, env = parent.frame(), quoted = FALSE) { + if (!quoted) { + expr <- substitute(expr) + } # force quoted + htmlwidgets::shinyRenderWidget( + expr, + maplibreCompareOutput, + env, + quoted = TRUE + ) +} + +#' Create a proxy object for a Mapbox GL Compare widget in Shiny +#' +#' This function allows updates to be sent to an existing Mapbox GL Compare widget in a Shiny application. +#' +#' @param compareId The ID of the compare output element. +#' @param session The Shiny session object. +#' @param map_side Which map side to target in the compare widget, either "before" or "after". +#' +#' @return A proxy object for the Mapbox GL Compare widget. +#' @export +mapboxgl_compare_proxy <- function( + compareId, + session = shiny::getDefaultReactiveDomain(), + map_side = "before" +) { + if (is.null(session)) { + stop( + "mapboxgl_compare_proxy must be called from within a Shiny session" + ) + } + + if ( + !is.null(session$ns) && + nzchar(session$ns(NULL)) && + substring(compareId, 1, nchar(session$ns(""))) != session$ns("") + ) { + compareId <- session$ns(compareId) + } + + proxy <- list(id = compareId, session = session, map_side = map_side) + class(proxy) <- c("mapboxgl_compare_proxy", "mapboxgl_proxy") + proxy +} + +#' Create a proxy object for a Maplibre GL Compare widget in Shiny +#' +#' This function allows updates to be sent to an existing Maplibre GL Compare widget in a Shiny application. +#' +#' @param compareId The ID of the compare output element. +#' @param session The Shiny session object. +#' @param map_side Which map side to target in the compare widget, either "before" or "after". +#' +#' @return A proxy object for the Maplibre GL Compare widget. +#' @export +maplibre_compare_proxy <- function( + compareId, + session = shiny::getDefaultReactiveDomain(), + map_side = "before" +) { + if (is.null(session)) { + stop( + "maplibre_compare_proxy must be called from within a Shiny session" + ) + } + + if ( + !is.null(session$ns) && + nzchar(session$ns(NULL)) && + substring(compareId, 1, nchar(session$ns(""))) != session$ns("") + ) { + compareId <- session$ns(compareId) + } + + proxy <- list(id = compareId, session = session, map_side = map_side) + class(proxy) <- c("maplibre_compare_proxy", "maplibre_proxy") + proxy +} + #' Add a Globe Minimap to a map #' #' This function adds a globe minimap control to a Mapbox GL or Maplibre map. @@ -149,13 +450,15 @@ compare.maplibre <- function(map1, map2, width, height, elementId, mousemove, or #' m <- maplibre() %>% #' add_globe_minimap() #' } -add_globe_minimap <- function(map, position = "bottom-right", globe_size = 82, - land_color = "white", water_color = "rgba(30 40 70/60%)", - marker_color = "#ff2233", marker_size = 1) { - if (!inherits(map, c("mapboxgl", "maplibregl"))) { - stop("Globe minimap is only supported for mapboxgl or maplibre maps.") - } - +add_globe_minimap <- function( + map, + position = "bottom-right", + globe_size = 82, + land_color = "white", + water_color = "rgba(30 40 70/60%)", + marker_color = "#ff2233", + marker_size = 1 +) { map$x$globe_minimap <- list( enabled = TRUE, position = position, @@ -166,32 +469,50 @@ add_globe_minimap <- function(map, position = "bottom-right", globe_size = 82, marker_size = marker_size ) - if (inherits(map, "mapboxgl_proxy")) { - map$session$sendCustomMessage("mapboxgl-proxy", list( - id = map$id, - message = list( - type = "add_globe_minimap", - position = position, - globe_size = globe_size, - land_color = land_color, - water_color = water_color, - marker_color = marker_color, - marker_size = marker_size + if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_globe_minimap", + position = position, + globe_size = globe_size, + land_color = land_color, + water_color = water_color, + marker_color = marker_color, + marker_size = marker_size, + map = map$map_side + ) + ) ) - )) - } else if (inherits(map, "maplibre_proxy")) { - map$session$sendCustomMessage("maplibre-proxy", list( - id = map$id, - message = list( - type = "add_globe_minimap", - position = position, - globe_size = globe_size, - land_color = land_color, - water_color = water_color, - marker_color = marker_color, - marker_size = marker_size + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_globe_minimap", + position = position, + globe_size = globe_size, + land_color = land_color, + water_color = water_color, + marker_color = marker_color, + marker_size = marker_size + ) + ) ) - )) + } } map diff --git a/R/quickview.R b/R/quickview.R new file mode 100644 index 00000000..6b118198 --- /dev/null +++ b/R/quickview.R @@ -0,0 +1,835 @@ +#' Quick visualization of geometries with Mapbox GL +#' +#' This function provides a quick way to visualize sf geometries using Mapbox GL JS. +#' It automatically detects the geometry type and applies appropriate styling. +#' +#' @param data An sf object to visualize +#' @param column The name of the column to visualize. If NULL (default), geometries are shown with default styling. +#' @param n Number of quantile breaks for numeric columns. If specified, uses step_expr() instead of interpolate(). +#' @param style The Mapbox style to use. Defaults to mapbox_style("light"). +#' @param ... Additional arguments passed to mapboxgl() +#' +#' @return A Mapbox GL map object +#' @export +#' +#' @examples +#' \dontrun{ +#' library(sf) +#' nc <- st_read(system.file("shape/nc.shp", package = "sf")) +#' +#' # Basic view +#' mapboxgl_view(nc) +#' +#' # View with column visualization +#' mapboxgl_view(nc, column = "AREA") +#' +#' # View with quantile breaks +#' mapboxgl_view(nc, column = "AREA", n = 5) +#' } +mapboxgl_view <- function(data, column = NULL, n = NULL, style = mapbox_style("light"), ...) { + if (!inherits(data, "sf")) { + stop("data must be an sf object") + } + + # Get geometry type + geom_type <- sf::st_geometry_type(data, by_geometry = FALSE) + + # Initialize map with bounds + map <- mapboxgl(style = style, bounds = data, ...) + + # Default navy color + default_color <- "navy" + + # Create popup column with all data + data_cols <- names(data)[!names(data) %in% c("geometry", attr(data, "sf_column"))] + if (length(data_cols) > 0) { + popup_html <- apply(data, 1, function(row) { + paste0( + sapply(data_cols, function(col) { + paste0("", col, ": ", row[[col]]) + }), + collapse = "
" + ) + }) + data$popup_content <- popup_html + } + + # Determine layer type and add appropriate layer + if (grepl("POINT|MULTIPOINT", geom_type)) { + # Point/MultiPoint -> circle layer + if (is.null(column)) { + map <- map |> + add_circle_layer( + id = "quickview", + source = data, + circle_color = default_color, + circle_radius = 5, + circle_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) + } else { + # Check if column exists + if (!column %in% names(data)) { + stop(paste0("Column '", column, "' not found in data")) + } + + col_data <- data[[column]] + + if (is.numeric(col_data)) { + # Numeric column + min_val <- min(col_data, na.rm = TRUE) + max_val <- max(col_data, na.rm = TRUE) + + if (!is.null(n)) { + # Use quantile breaks + breaks <- quantile(col_data, probs = seq(0, 1, length.out = n + 1), na.rm = TRUE) + breaks <- unique(breaks) # Remove duplicates + n_breaks <- length(breaks) - 1 + + # Generate n_breaks colors for n bins + colors <- viridisLite::viridis(n_breaks) + + # For step expressions, base is first color, stops are remaining colors + # values are the thresholds (excluding min) + map <- map |> + add_circle_layer( + id = "quickview", + source = data, + circle_color = step_expr( + column = column, + base = colors[1], + values = breaks[2:n_breaks], + stops = colors[2:n_breaks], + na_color = "lightgrey" + ), + circle_radius = 5, + circle_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c( + paste0("< ", round(breaks[2], 2)), + if (n_breaks > 1) { + sapply(2:n_breaks, function(i) { + paste0(round(breaks[i], 2), " - ", round(breaks[i + 1], 2)) + }) + } else NULL + ), + colors = colors, + type = "categorical", + circular_patches = TRUE + ) + } else { + # Use continuous interpolation with 5 equal-interval breaks + breaks <- seq(min_val, max_val, length.out = 5) + colors <- viridisLite::viridis(5) + + map <- map |> + add_circle_layer( + id = "quickview", + source = data, + circle_color = interpolate( + column = column, + values = breaks, + stops = colors, + na_color = "lightgrey" + ), + circle_radius = 5, + circle_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c(round(min_val, 2), round(max_val, 2)), + colors = colors, + type = "continuous" + ) + } + } else { + # Categorical column + unique_vals <- unique(col_data[!is.na(col_data)]) + n_cats <- length(unique_vals) + colors <- viridisLite::viridis(n_cats) + + map <- map |> + add_circle_layer( + id = "quickview", + source = data, + circle_color = match_expr( + column = column, + values = unique_vals, + stops = colors, + default = "lightgrey" + ), + circle_radius = 5, + circle_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = as.character(unique_vals), + colors = colors, + type = "categorical", + circular_patches = TRUE + ) + } + } + } else if (grepl("LINESTRING|MULTILINESTRING", geom_type)) { + # LineString/MultiLineString -> line layer + if (is.null(column)) { + map <- map |> + add_line_layer( + id = "quickview", + source = data, + line_color = default_color, + line_width = 2, + line_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) + } else { + # Check if column exists + if (!column %in% names(data)) { + stop(paste0("Column '", column, "' not found in data")) + } + + col_data <- data[[column]] + + if (is.numeric(col_data)) { + # Numeric column + min_val <- min(col_data, na.rm = TRUE) + max_val <- max(col_data, na.rm = TRUE) + + if (!is.null(n)) { + # Use quantile breaks + breaks <- quantile(col_data, probs = seq(0, 1, length.out = n + 1), na.rm = TRUE) + breaks <- unique(breaks) # Remove duplicates + n_breaks <- length(breaks) - 1 + + # Generate n_breaks colors for n bins + colors <- viridisLite::viridis(n_breaks) + + # For step expressions, base is first color, stops are remaining colors + # values are the thresholds (excluding min) + map <- map |> + add_line_layer( + id = "quickview", + source = data, + line_color = step_expr( + column = column, + base = colors[1], + values = breaks[2:n_breaks], + stops = colors[2:n_breaks], + na_color = "lightgrey" + ), + line_width = 2, + line_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c( + paste0("< ", round(breaks[2], 2)), + if (n_breaks > 1) { + sapply(2:n_breaks, function(i) { + paste0(round(breaks[i], 2), " - ", round(breaks[i + 1], 2)) + }) + } else NULL + ), + colors = colors, + type = "categorical" + ) + } else { + # Use continuous interpolation with 5 equal-interval breaks + breaks <- seq(min_val, max_val, length.out = 5) + colors <- viridisLite::viridis(5) + + map <- map |> + add_line_layer( + id = "quickview", + source = data, + line_color = interpolate( + column = column, + values = breaks, + stops = colors, + na_color = "lightgrey" + ), + line_width = 2, + line_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c(round(min_val, 2), round(max_val, 2)), + colors = colors, + type = "continuous" + ) + } + } else { + # Categorical column + unique_vals <- unique(col_data[!is.na(col_data)]) + n_cats <- length(unique_vals) + colors <- viridisLite::viridis(n_cats) + + map <- map |> + add_line_layer( + id = "quickview", + source = data, + line_color = match_expr( + column = column, + values = unique_vals, + stops = colors, + default = "lightgrey" + ), + line_width = 2, + line_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = as.character(unique_vals), + colors = colors, + type = "categorical" + ) + } + } + } else { + # Polygon/MultiPolygon -> fill layer + if (is.null(column)) { + map <- map |> + add_fill_layer( + id = "quickview", + source = data, + fill_color = default_color, + fill_opacity = 0.6, + fill_outline_color = "white", + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) + } else { + # Check if column exists + if (!column %in% names(data)) { + stop(paste0("Column '", column, "' not found in data")) + } + + col_data <- data[[column]] + + if (is.numeric(col_data)) { + # Numeric column + min_val <- min(col_data, na.rm = TRUE) + max_val <- max(col_data, na.rm = TRUE) + + if (!is.null(n)) { + # Use quantile breaks + breaks <- quantile(col_data, probs = seq(0, 1, length.out = n + 1), na.rm = TRUE) + breaks <- unique(breaks) # Remove duplicates + n_breaks <- length(breaks) - 1 + + # Generate n+1 colors for n bins (base + n stops) + colors <- viridisLite::viridis(n_breaks) + + # For step expressions, base is first color, stops are remaining colors + # values are the thresholds (excluding min) + map <- map |> + add_fill_layer( + id = "quickview", + source = data, + fill_color = step_expr( + column = column, + base = colors[1], + values = breaks[2:n_breaks], + stops = colors[2:n_breaks], + na_color = "lightgrey" + ), + fill_opacity = 0.6, + fill_outline_color = "white", + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c( + paste0("< ", round(breaks[2], 2)), + if (n_breaks > 1) { + sapply(2:n_breaks, function(i) { + paste0(round(breaks[i], 2), " - ", round(breaks[i + 1], 2)) + }) + } else NULL + ), + colors = colors, + type = "categorical" + ) + } else { + # Use continuous interpolation with 5 equal-interval breaks + breaks <- seq(min_val, max_val, length.out = 5) + colors <- viridisLite::viridis(5) + + map <- map |> + add_fill_layer( + id = "quickview", + source = data, + fill_color = interpolate( + column = column, + values = breaks, + stops = colors, + na_color = "lightgrey" + ), + fill_opacity = 0.6, + fill_outline_color = "white", + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c(round(min_val, 2), round(max_val, 2)), + colors = colors, + type = "continuous" + ) + } + } else { + # Categorical column + unique_vals <- unique(col_data[!is.na(col_data)]) + n_cats <- length(unique_vals) + colors <- viridisLite::viridis(n_cats) + + map <- map |> + add_fill_layer( + id = "quickview", + source = data, + fill_color = match_expr( + column = column, + values = unique_vals, + stops = colors, + default = "lightgrey" + ), + fill_opacity = 0.6, + fill_outline_color = "white", + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = as.character(unique_vals), + colors = colors, + type = "categorical" + ) + } + } + } + + return(map) +} + +#' Quick visualization of geometries with MapLibre GL +#' +#' This function provides a quick way to visualize sf geometries using MapLibre GL JS. +#' It automatically detects the geometry type and applies appropriate styling. +#' +#' @param data An sf object to visualize +#' @param column The name of the column to visualize. If NULL (default), geometries are shown with default styling. +#' @param n Number of quantile breaks for numeric columns. If specified, uses step_expr() instead of interpolate(). +#' @param style The MapLibre style to use. Defaults to carto_style("positron"). +#' @param ... Additional arguments passed to maplibre() +#' +#' @return A MapLibre GL map object +#' @export +#' +#' @examples +#' \dontrun{ +#' library(sf) +#' nc <- st_read(system.file("shape/nc.shp", package = "sf")) +#' +#' # Basic view +#' maplibre_view(nc) +#' +#' # View with column visualization +#' maplibre_view(nc, column = "AREA") +#' +#' # View with quantile breaks +#' maplibre_view(nc, column = "AREA", n = 5) +#' } +maplibre_view <- function(data, column = NULL, n = NULL, style = carto_style("positron"), ...) { + if (!inherits(data, "sf")) { + stop("data must be an sf object") + } + + # Get geometry type + geom_type <- sf::st_geometry_type(data, by_geometry = FALSE) + + # Initialize map with bounds + map <- maplibre(style = style, bounds = data, ...) + + # Default navy color + default_color <- "navy" + + # Create popup column with all data + data_cols <- names(data)[!names(data) %in% c("geometry", attr(data, "sf_column"))] + if (length(data_cols) > 0) { + popup_html <- apply(data, 1, function(row) { + paste0( + sapply(data_cols, function(col) { + paste0("", col, ": ", row[[col]]) + }), + collapse = "
" + ) + }) + data$popup_content <- popup_html + } + + # Determine layer type and add appropriate layer + if (grepl("POINT|MULTIPOINT", geom_type)) { + # Point/MultiPoint -> circle layer + if (is.null(column)) { + map <- map |> + add_circle_layer( + id = "quickview", + source = data, + circle_color = default_color, + circle_radius = 5, + circle_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) + } else { + # Check if column exists + if (!column %in% names(data)) { + stop(paste0("Column '", column, "' not found in data")) + } + + col_data <- data[[column]] + + if (is.numeric(col_data)) { + # Numeric column + min_val <- min(col_data, na.rm = TRUE) + max_val <- max(col_data, na.rm = TRUE) + + if (!is.null(n)) { + # Use quantile breaks + breaks <- quantile(col_data, probs = seq(0, 1, length.out = n + 1), na.rm = TRUE) + breaks <- unique(breaks) # Remove duplicates + n_breaks <- length(breaks) - 1 + + # Generate n_breaks colors for n bins + colors <- viridisLite::viridis(n_breaks) + + # For step expressions, base is first color, stops are remaining colors + # values are the thresholds (excluding min) + map <- map |> + add_circle_layer( + id = "quickview", + source = data, + circle_color = step_expr( + column = column, + base = colors[1], + values = breaks[2:n_breaks], + stops = colors[2:n_breaks], + na_color = "lightgrey" + ), + circle_radius = 5, + circle_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c( + paste0("< ", round(breaks[2], 2)), + if (n_breaks > 1) { + sapply(2:n_breaks, function(i) { + paste0(round(breaks[i], 2), " - ", round(breaks[i + 1], 2)) + }) + } else NULL + ), + colors = colors, + type = "categorical", + circular_patches = TRUE + ) + } else { + # Use continuous interpolation with 5 equal-interval breaks + breaks <- seq(min_val, max_val, length.out = 5) + colors <- viridisLite::viridis(5) + + map <- map |> + add_circle_layer( + id = "quickview", + source = data, + circle_color = interpolate( + column = column, + values = breaks, + stops = colors, + na_color = "lightgrey" + ), + circle_radius = 5, + circle_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c(round(min_val, 2), round(max_val, 2)), + colors = colors, + type = "continuous" + ) + } + } else { + # Categorical column + unique_vals <- unique(col_data[!is.na(col_data)]) + n_cats <- length(unique_vals) + colors <- viridisLite::viridis(n_cats) + + map <- map |> + add_circle_layer( + id = "quickview", + source = data, + circle_color = match_expr( + column = column, + values = unique_vals, + stops = colors, + default = "lightgrey" + ), + circle_radius = 5, + circle_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = as.character(unique_vals), + colors = colors, + type = "categorical", + circular_patches = TRUE + ) + } + } + } else if (grepl("LINESTRING|MULTILINESTRING", geom_type)) { + # LineString/MultiLineString -> line layer + if (is.null(column)) { + map <- map |> + add_line_layer( + id = "quickview", + source = data, + line_color = default_color, + line_width = 2, + line_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) + } else { + # Check if column exists + if (!column %in% names(data)) { + stop(paste0("Column '", column, "' not found in data")) + } + + col_data <- data[[column]] + + if (is.numeric(col_data)) { + # Numeric column + min_val <- min(col_data, na.rm = TRUE) + max_val <- max(col_data, na.rm = TRUE) + + if (!is.null(n)) { + # Use quantile breaks + breaks <- quantile(col_data, probs = seq(0, 1, length.out = n + 1), na.rm = TRUE) + breaks <- unique(breaks) # Remove duplicates + n_breaks <- length(breaks) - 1 + + # Generate n_breaks colors for n bins + colors <- viridisLite::viridis(n_breaks) + + # For step expressions, base is first color, stops are remaining colors + # values are the thresholds (excluding min) + map <- map |> + add_line_layer( + id = "quickview", + source = data, + line_color = step_expr( + column = column, + base = colors[1], + values = breaks[2:n_breaks], + stops = colors[2:n_breaks], + na_color = "lightgrey" + ), + line_width = 2, + line_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c( + paste0("< ", round(breaks[2], 2)), + if (n_breaks > 1) { + sapply(2:n_breaks, function(i) { + paste0(round(breaks[i], 2), " - ", round(breaks[i + 1], 2)) + }) + } else NULL + ), + colors = colors, + type = "categorical" + ) + } else { + # Use continuous interpolation with 5 equal-interval breaks + breaks <- seq(min_val, max_val, length.out = 5) + colors <- viridisLite::viridis(5) + + map <- map |> + add_line_layer( + id = "quickview", + source = data, + line_color = interpolate( + column = column, + values = breaks, + stops = colors, + na_color = "lightgrey" + ), + line_width = 2, + line_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c(round(min_val, 2), round(max_val, 2)), + colors = colors, + type = "continuous" + ) + } + } else { + # Categorical column + unique_vals <- unique(col_data[!is.na(col_data)]) + n_cats <- length(unique_vals) + colors <- viridisLite::viridis(n_cats) + + map <- map |> + add_line_layer( + id = "quickview", + source = data, + line_color = match_expr( + column = column, + values = unique_vals, + stops = colors, + default = "lightgrey" + ), + line_width = 2, + line_opacity = 0.8, + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = as.character(unique_vals), + colors = colors, + type = "categorical" + ) + } + } + } else { + # Polygon/MultiPolygon -> fill layer + if (is.null(column)) { + map <- map |> + add_fill_layer( + id = "quickview", + source = data, + fill_color = default_color, + fill_opacity = 0.6, + fill_outline_color = "white", + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) + } else { + # Check if column exists + if (!column %in% names(data)) { + stop(paste0("Column '", column, "' not found in data")) + } + + col_data <- data[[column]] + + if (is.numeric(col_data)) { + # Numeric column + min_val <- min(col_data, na.rm = TRUE) + max_val <- max(col_data, na.rm = TRUE) + + if (!is.null(n)) { + # Use quantile breaks + breaks <- quantile(col_data, probs = seq(0, 1, length.out = n + 1), na.rm = TRUE) + breaks <- unique(breaks) # Remove duplicates + n_breaks <- length(breaks) - 1 + + # Generate n_breaks colors for n bins + colors <- viridisLite::viridis(n_breaks) + + # For step expressions, base is first color, stops are remaining colors + # values are the thresholds (excluding min) + map <- map |> + add_fill_layer( + id = "quickview", + source = data, + fill_color = step_expr( + column = column, + base = colors[1], + values = breaks[2:n_breaks], + stops = colors[2:n_breaks], + na_color = "lightgrey" + ), + fill_opacity = 0.6, + fill_outline_color = "white", + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c( + paste0("< ", round(breaks[2], 2)), + if (n_breaks > 1) { + sapply(2:n_breaks, function(i) { + paste0(round(breaks[i], 2), " - ", round(breaks[i + 1], 2)) + }) + } else NULL + ), + colors = colors, + type = "categorical" + ) + } else { + # Use continuous interpolation with 5 equal-interval breaks + breaks <- seq(min_val, max_val, length.out = 5) + colors <- viridisLite::viridis(5) + + map <- map |> + add_fill_layer( + id = "quickview", + source = data, + fill_color = interpolate( + column = column, + values = breaks, + stops = colors, + na_color = "lightgrey" + ), + fill_opacity = 0.6, + fill_outline_color = "white", + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = c(round(min_val, 2), round(max_val, 2)), + colors = colors, + type = "continuous" + ) + } + } else { + # Categorical column + unique_vals <- unique(col_data[!is.na(col_data)]) + n_cats <- length(unique_vals) + colors <- viridisLite::viridis(n_cats) + + map <- map |> + add_fill_layer( + id = "quickview", + source = data, + fill_color = match_expr( + column = column, + values = unique_vals, + stops = colors, + default = "lightgrey" + ), + fill_opacity = 0.6, + fill_outline_color = "white", + popup = if (exists("popup_content", data)) "popup_content" else NULL + ) |> + add_legend( + legend_title = column, + values = as.character(unique_vals), + colors = colors, + type = "categorical" + ) + } + } + } + + return(map) +} diff --git a/R/shiny.R b/R/shiny.R index 4cad553b..0c299c26 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -12,9 +12,11 @@ mapboxgl_proxy <- function(mapId, session = shiny::getDefaultReactiveDomain()) { stop("mapboxgl_proxy must be called from within a Shiny session") } - if (!is.null(session$ns) && - nzchar(session$ns(NULL)) && - substring(mapId, 1, nchar(session$ns(""))) != session$ns("")) { + if ( + !is.null(session$ns) && + nzchar(session$ns(NULL)) && + substring(mapId, 1, nchar(session$ns(""))) != session$ns("") + ) { mapId <- session$ns(mapId) } @@ -37,9 +39,11 @@ maplibre_proxy <- function(mapId, session = shiny::getDefaultReactiveDomain()) { stop("maplibre_proxy must be called from within a Shiny session") } - if (!is.null(session$ns) && - nzchar(session$ns(NULL)) && - substring(mapId, 1, nchar(session$ns(""))) != session$ns("")) { + if ( + !is.null(session$ns) && + nzchar(session$ns(NULL)) && + substring(mapId, 1, nchar(session$ns(""))) != session$ns("") + ) { mapId <- session$ns(mapId) } @@ -60,14 +64,47 @@ maplibre_proxy <- function(mapId, session = shiny::getDefaultReactiveDomain()) { #' @export set_filter <- function(map, layer_id, filter) { if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "set_filter", layer = layer_id, filter = filter) - )) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies, use the appropriate message handler + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_filter", + layer = layer_id, + filter = filter, + map = map$map_side # Add which map to target + ) + ) + ) + } else { + # For regular proxies, use existing message handler + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_filter", + layer = layer_id, + filter = filter + ) + ) + ) + } } else { if (is.null(map$x$setFilter)) map$x$setFilter <- list() - map$x$setFilter[[length(map$x$setFilter) + 1]] <- list(layer = layer_id, filter = filter) + map$x$setFilter[[length(map$x$setFilter) + 1]] <- list( + layer = layer_id, + filter = filter + ) } return(map) } @@ -82,14 +119,38 @@ set_filter <- function(map, layer_id, filter) { #' @return The updated proxy object. #' @export clear_layer <- function(proxy, layer_id) { - if (!any(inherits(proxy, "mapboxgl_proxy"), inherits(proxy, "maplibre_proxy"))) { + if ( + !any( + inherits(proxy, "mapboxgl_proxy"), + inherits(proxy, "maplibre_proxy") + ) + ) { stop("Invalid proxy object") } - proxy_class <- if (inherits(proxy, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + if ( + inherits(proxy, "mapboxgl_compare_proxy") || + inherits(proxy, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(proxy, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + message <- list( + type = "remove_layer", + layer = layer_id, + map = proxy$map_side + ) + } else { + # For regular proxies + proxy_class <- if (inherits(proxy, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + message <- list(type = "remove_layer", layer = layer_id) + } - message <- list(type = "remove_layer", layer = layer_id) - proxy$session$sendCustomMessage(proxy_class, list(id = proxy$id, message = message)) + proxy$session$sendCustomMessage( + proxy_class, + list(id = proxy$id, message = message) + ) proxy } @@ -104,14 +165,50 @@ clear_layer <- function(proxy, layer_id) { #' @export set_layout_property <- function(map, layer, name, value) { if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "set_layout_property", layer = layer, name = name, value = value) - )) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_layout_property", + layer = layer, + name = name, + value = value, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_layout_property", + layer = layer, + name = name, + value = value + ) + ) + ) + } } else { if (is.null(map$x$setLayoutProperty)) map$x$setLayoutProperty <- list() - map$x$setLayoutProperty[[length(map$x$setLayoutProperty) + 1]] <- list(layer = layer, name = name, value = value) + map$x$setLayoutProperty[[length(map$x$setLayoutProperty) + 1]] <- list( + layer = layer, + name = name, + value = value + ) } return(map) } @@ -127,14 +224,50 @@ set_layout_property <- function(map, layer, name, value) { #' @export set_paint_property <- function(map, layer, name, value) { if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "set_paint_property", layer = layer, name = name, value = value) - )) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_paint_property", + layer = layer, + name = name, + value = value, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_paint_property", + layer = layer, + name = name, + value = value + ) + ) + ) + } } else { if (is.null(map$x$setPaintProperty)) map$x$setPaintProperty <- list() - map$x$setPaintProperty[[length(map$x$setPaintProperty) + 1]] <- list(layer = layer, name = name, value = value) + map$x$setPaintProperty[[length(map$x$setPaintProperty) + 1]] <- list( + layer = layer, + name = name, + value = value + ) } return(map) } @@ -147,10 +280,36 @@ set_paint_property <- function(map, layer, name, value) { #' @export clear_markers <- function(map) { if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "clear_markers"))) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "clear_markers", + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list(id = map$id, message = list(type = "clear_markers")) + ) + } } else { - stop("clear_markers() can only be used with mapboxgl_proxy() or maplibre_proxy()") + stop( + "clear_markers() can only be used with mapboxgl_proxy(), maplibre_proxy(), mapboxgl_compare_proxy(), or maplibre_compare_proxy()" + ) } return(map) } @@ -161,6 +320,7 @@ clear_markers <- function(map) { #' @param style The new style URL to be applied to the map. #' @param config A named list of options to be passed to the style config. #' @param diff A boolean that attempts a diff-based update rather than re-drawing the full style. Not available for all styles. +#' @param preserve_layers A boolean that indicates whether to preserve user-added sources and layers when changing styles. Defaults to TRUE. #' #' @return The modified map object. #' @export @@ -180,20 +340,51 @@ clear_markers <- function(map) { #' set_style(mapbox_style("dark"), config = list(showLabels = FALSE), diff = TRUE) #' }) #' } -set_style <- function(map, style, config = NULL, diff = TRUE) { +set_style <- function(map, style, config = NULL, diff = TRUE, preserve_layers = TRUE) { if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list( - type = "set_style", - style = style, - config = config, - diff = diff + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_style", + style = style, + config = config, + diff = diff, + preserve_layers = preserve_layers, + map = map$map_side + ) + ) ) - )) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_style", + style = style, + config = config, + diff = diff, + preserve_layers = preserve_layers + ) + ) + ) + } } else { - stop("set_style can only be used with mapboxgl_proxy or maplibre_proxy.") + stop( + "set_style can only be used with mapboxgl_proxy, maplibre_proxy, mapboxgl_compare_proxy, or maplibre_compare_proxy." + ) } return(map) } @@ -209,19 +400,43 @@ set_style <- function(map, style, config = NULL, diff = TRUE) { #' @return The updated proxy object. #' @export move_layer <- function(proxy, layer_id, before_id = NULL) { - if (!any(inherits(proxy, "mapboxgl_proxy"), inherits(proxy, "maplibre_proxy"))) { + if ( + !any( + inherits(proxy, "mapboxgl_proxy"), + inherits(proxy, "maplibre_proxy") + ) + ) { stop("Invalid proxy object") } - proxy_class <- if (inherits(proxy, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + if ( + inherits(proxy, "mapboxgl_compare_proxy") || + inherits(proxy, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(proxy, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + message <- list( + type = "move_layer", + layer = layer_id, + before = before_id, + map = proxy$map_side + ) + } else { + # For regular proxies + proxy_class <- if (inherits(proxy, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + message <- list( + type = "move_layer", + layer = layer_id, + before = before_id + ) + } - message <- list( - type = "move_layer", - layer = layer_id, - before = before_id + proxy$session$sendCustomMessage( + proxy_class, + list(id = proxy$id, message = message) ) - - proxy$session$sendCustomMessage(proxy_class, list(id = proxy$id, message = message)) proxy } @@ -233,17 +448,102 @@ move_layer <- function(proxy, layer_id, before_id = NULL) { #' #' @return The updated map object. #' @export -set_tooltip <- function(map, layer, tooltip) { - if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "set_tooltip", layer = layer, tooltip = tooltip) - )) - } else { - stop("set_tooltip can only be used with mapboxgl_proxy or maplibre_proxy.") - } - return(map) +set_tooltip <- function(map, layer, tooltip) { + if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_tooltip", + layer = layer, + tooltip = tooltip, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_tooltip", + layer = layer, + tooltip = tooltip + ) + ) + ) + } + } else { + stop( + "set_tooltip can only be used with mapboxgl_proxy, maplibre_proxy, mapboxgl_compare_proxy, or maplibre_compare_proxy." + ) + } + return(map) +} + +#' Set popup on a map layer +#' +#' @param map A map object created by the `mapboxgl` or `maplibre` function, or a proxy object. +#' @param layer The ID of the layer to update. +#' @param popup The name of the popup property or an expression to set. +#' +#' @return The updated map object. +#' @export +set_popup <- function(map, layer, popup) { + if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_popup", + layer = layer, + popup = popup, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_popup", + layer = layer, + popup = popup + ) + ) + ) + } + } else { + stop( + "set_popup can only be used with mapboxgl_proxy, maplibre_proxy, mapboxgl_compare_proxy, or maplibre_compare_proxy." + ) + } + return(map) } #' Set source of a map layer @@ -254,22 +554,55 @@ set_tooltip <- function(map, layer, tooltip) { #' #' @return The updated map object. #' @export -set_source <- function(map, layer, source) { - if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { +set_source <- function(map, layer, source) { + if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { + # Convert sf objects to GeoJSON source + if (inherits(source, "sf")) { + source <- geojsonsf::sf_geojson(sf::st_transform( + source, + crs = 4326 + )) + } - # Convert sf objects to GeoJSON source - if (inherits(source, "sf")) { - source <- geojsonsf::sf_geojson(sf::st_transform(source, crs = 4326)) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_source", + layer = layer, + source = source, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) + "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "set_source", + layer = layer, + source = source + ) + ) + ) + } + } else { + stop( + "set_source can only be used with mapboxgl_proxy, maplibre_proxy, mapboxgl_compare_proxy, or maplibre_compare_proxy." + ) } - - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "set_source", layer = layer, source = source) - )) - } else { - stop("set_source can only be used with mapboxgl_proxy or maplibre_proxy.") - } - return(map) + return(map) } diff --git a/R/sources.R b/R/sources.R index b95f1565..354689bc 100644 --- a/R/sources.R +++ b/R/sources.R @@ -28,8 +28,39 @@ add_source <- function(map, id, data, ...) { source <- c(source, extra_args) if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_source", source = source))) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_source", + source = source, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_source", + source = source + ) + ) + ) + } } else { map$x$sources <- c(map$x$sources, list(source)) } @@ -41,19 +72,60 @@ add_source <- function(map, id, data, ...) { #' @param map A map object created by the `mapboxgl` or `maplibre` function. #' @param id A unique ID for the source. #' @param url A URL pointing to the vector tile source. +#' @param promote_id An optional property name to use as the feature ID. This is required for hover effects on vector tiles. +#' @param ... Additional arguments to be passed to the JavaScript addSource method. #' #' @return The modified map object with the new source added. #' @export -add_vector_source <- function(map, id, url) { +add_vector_source <- function(map, id, url, promote_id = NULL, ...) { source <- list( id = id, type = "vector", url = url ) + if (!is.null(promote_id)) { + source$promoteId <- promote_id + } + + # Add any additional arguments + extra_args <- list(...) + source <- c(source, extra_args) + if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_source", source = source))) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_source", + source = source, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_source", + source = source + ) + ) + ) + } } else { map$x$sources <- c(map$x$sources, list(source)) } @@ -69,16 +141,27 @@ add_vector_source <- function(map, id, url) { #' @param tiles A vector of tile URLs for the raster source. (optional) #' @param tileSize The size of the raster tiles. #' @param maxzoom The maximum zoom level for the raster tiles. +#' @param ... Additional arguments to be passed to the JavaScript addSource method. #' #' @return The modified map object with the new source added. #' @export -add_raster_source <- function(map, id, url = NULL, tiles = NULL, tileSize = 256, maxzoom = 22) { +add_raster_source <- function( + map, + id, + url = NULL, + tiles = NULL, + tileSize = 256, + maxzoom = 22, + ... +) { if (is.null(url) && is.null(tiles)) { stop("Either 'url' or 'tiles' must be provided.") } if (!is.null(url) && !is.null(tiles)) { - stop("Both 'url' and 'tiles' cannot be provided simultaneously. Please provide only one.") + stop( + "Both 'url' and 'tiles' cannot be provided simultaneously. Please provide only one." + ) } source <- list( @@ -90,7 +173,6 @@ add_raster_source <- function(map, id, url = NULL, tiles = NULL, tileSize = 256, if (!is.null(url)) { source$url <- url } else if (!is.null(tiles)) { - if (!is.list(tiles)) { source$tiles <- list(tiles) } else { @@ -102,9 +184,38 @@ add_raster_source <- function(map, id, url = NULL, tiles = NULL, tileSize = 256, source$maxzoom <- maxzoom } + # Add any additional arguments + extra_args <- list(...) + source <- c(source, extra_args) + if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_source", source = source))) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_source", + source = source, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list(id = map$id, message = list(type = "add_source", source = source)) + ) + } } else { map$x$sources <- c(map$x$sources, list(source)) } @@ -119,10 +230,18 @@ add_raster_source <- function(map, id, url = NULL, tiles = NULL, tileSize = 256, #' @param url A URL pointing to the raster DEM source. #' @param tileSize The size of the raster tiles. #' @param maxzoom The maximum zoom level for the raster tiles. +#' @param ... Additional arguments to be passed to the JavaScript addSource method. #' #' @return The modified map object with the new source added. #' @export -add_raster_dem_source <- function(map, id, url, tileSize = 512, maxzoom = NULL) { +add_raster_dem_source <- function( + map, + id, + url, + tileSize = 512, + maxzoom = NULL, + ... +) { source <- list( id = id, type = "raster-dem", @@ -134,9 +253,38 @@ add_raster_dem_source <- function(map, id, url, tileSize = 512, maxzoom = NULL) source$maxzoom <- maxzoom } + # Add any additional arguments + extra_args <- list(...) + source <- c(source, extra_args) + if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_source", source = source))) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_source", + source = source, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list(id = map$id, message = list(type = "add_source", source = source)) + ) + } } else { map$x$sources <- c(map$x$sources, list(source)) } @@ -155,8 +303,14 @@ add_raster_dem_source <- function(map, id, url, tileSize = 512, maxzoom = NULL) #' #' @return The modified map object with the new source added. #' @export -add_image_source <- function(map, id, url = NULL, data = NULL, coordinates = NULL, colors = NULL) { - +add_image_source <- function( + map, + id, + url = NULL, + data = NULL, + coordinates = NULL, + colors = NULL +) { if (!is.null(data)) { if (inherits(data, "RasterLayer")) { data <- terra::rast(data) @@ -164,46 +318,111 @@ add_image_source <- function(map, id, url = NULL, data = NULL, coordinates = NUL if (terra::has.colors(data)) { # If the raster already has a color table - rlang::warn("This function does not support existing color tables, but this feature is in progress.") + rlang::warn( + "This function does not support existing color tables, but this feature is in progress." + ) } - data <- terra::project(data, "EPSG:4326") + # Project to Web Mercator + data_mercator <- terra::project(data, "EPSG:3857") + + # Get extent in WGS84 for coordinates + data_wgs84 <- terra::project(data_mercator, "EPSG:4326") if (terra::nlyr(data) == 3) { - # For RGB raster + # For RGB raster - write the mercator version to PNG png_path <- tempfile(fileext = ".png") - terra::writeRaster(data, png_path, overwrite = TRUE) + terra::writeRaster(data_mercator, png_path, overwrite = TRUE) url <- base64enc::dataURI(file = png_path, mime = "image/png") } else { - + # For single band data if (is.null(colors)) { - colors <- grDevices::colorRampPalette(c("#440154", "#3B528B", "#21908C", "#5DC863", "#FDE725"))(256) - } else if (length(colors) < 256) { - colors <- grDevices::colorRampPalette(colors)(256) + # Get 255 colors for data (0-254), reserving index 255 for NA + colors <- grDevices::colorRampPalette(c( + "#440154", + "#3B528B", + "#21908C", + "#5DC863", + "#FDE725" + ))(255) + } else if (length(colors) >= 255) { + # Use first 255 colors if more provided + colors <- colors[1:255] + } else { + # Interpolate to 255 colors + colors <- grDevices::colorRampPalette(colors)(255) + } + + # Extract values + values <- terra::values(data_mercator) + + # Handle NA values + na_mask <- is.na(values) + + # Rescale to 0-254 range + if (all(is.na(values))) { + # Handle the case where all values are NA + scaled_values <- values # Keep all as NA + } else { + # Get min/max excluding NAs + min_val <- min(values, na.rm = TRUE) + max_val <- max(values, na.rm = TRUE) + + if (min_val == max_val) { + # Handle case where all non-NA values are the same + scaled_values <- values + scaled_values[!na_mask] <- 127 # Middle value + } else { + # Normal rescaling + scaled_values <- (values - min_val) / (max_val - min_val) * 254 + } } - data <- data / max(terra::values(data), na.rm = TRUE) * 254 - data <- round(data) - data[is.na(terra::values(data))] <- 255 - coltb <- data.frame(value = 0:255, col = colors) + # Round to integers + scaled_values <- round(scaled_values) + + # Ensure values are in 0-254 range + scaled_values[scaled_values < 0] <- 0 + scaled_values[scaled_values > 254] <- 254 + + # Set NA values to 255 (which we'll make transparent) + scaled_values[na_mask] <- 255 + + # Update the raster + terra::values(data_mercator) <- scaled_values + + # Create color table (255 colors + transparent for NA) + transparent_color <- "#00000000" # Fully transparent + coltb <- data.frame(value = 0:255, col = c(colors, transparent_color)) - # Create color table - terra::coltab(data) <- coltb + # Apply color table + terra::coltab(data_mercator) <- coltb + # Write to PNG with appropriate datatype png_path <- tempfile(fileext = ".png") - terra::writeRaster(data, png_path, overwrite = TRUE, NAflag = 255, datatype = "INT1U") + terra::writeRaster( + data_mercator, + png_path, + overwrite = TRUE, + datatype = "INT1U" + ) url <- base64enc::dataURI(file = png_path, mime = "image/png") - } - # Compute coordinates if not provided + + # Compute coordinates from the WGS84 version if (is.null(coordinates)) { - ext <- terra::ext(data) + ext <- terra::ext(data_wgs84) + coordinates <- list( - unname(c(ext[1], ext[4])), # top-left - unname(c(ext[2], ext[4])), # top-right - unname(c(ext[2], ext[3])), # bottom-right - unname(c(ext[1], ext[3])) # bottom-left + c(ext[1], ext[4]), # top-left + c(ext[2], ext[4]), # top-right + c(ext[2], ext[3]), # bottom-right + c(ext[1], ext[3]) # bottom-left ) + + # Ensure coordinates are numeric vectors + coordinates <- lapply(coordinates, as.numeric) + names(coordinates) <- NULL } } @@ -219,8 +438,33 @@ add_image_source <- function(map, id, url = NULL, data = NULL, coordinates = NUL ) if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_source", source = source))) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_source", + source = source, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list(id = map$id, message = list(type = "add_source", source = source)) + ) + } } else { map$x$sources <- c(map$x$sources, list(source)) } @@ -246,8 +490,33 @@ add_video_source <- function(map, id, urls, coordinates) { ) if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list(id = map$id, message = list(type = "add_source", source = source))) + if ( + inherits(map, "mapboxgl_compare_proxy") || + inherits(map, "maplibre_compare_proxy") + ) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) + "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage( + proxy_class, + list( + id = map$id, + message = list( + type = "add_source", + source = source, + map = map$map_side + ) + ) + ) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else + "maplibre-proxy" + map$session$sendCustomMessage( + proxy_class, + list(id = map$id, message = list(type = "add_source", source = source)) + ) + } } else { map$x$sources <- c(map$x$sources, list(source)) } diff --git a/R/storymaps.R b/R/storymaps.R new file mode 100644 index 00000000..3f1d9401 --- /dev/null +++ b/R/storymaps.R @@ -0,0 +1,294 @@ +#' Create a story section for story maps +#' @param title Section title +#' @param content Section content - can be text, HTML, or Shiny outputs +#' @param position Position of text block ("left", "center", "right") +#' @param width Width of text block in pixels (default: 400) +#' @param bg_color Background color (with alpha) for text block +#' @param text_color Text color +#' @param font_family Font family for the section +#' @export +story_section <- function( + title, + content, + position = c("left", "center", "right"), + width = 400, + bg_color = NULL, + text_color = NULL, + font_family = NULL) { + position <- match.arg(position) + + # Calculate margin based on position + margin_style <- switch(position, + "left" = "margin-left: 50px;", + "center" = if (is.numeric(width)) { + sprintf("margin-left: calc(50%% - %dpx);", width / 2) + } else { + sprintf("margin-left: calc(50%% - (%s/2));", width) + }, + "right" = sprintf("margin-right: 50px; margin-left: auto;") + ) + + # Create style + panel_style <- sprintf( + "width: %s; %s%s%s%s", + if (is.numeric(width)) paste0(width, "px") else width, + margin_style, + if (!is.null(bg_color)) sprintf(" background: %s;", bg_color) else "", + if (!is.null(text_color)) sprintf(" color: %s;", text_color) else "", + if (!is.null(font_family)) sprintf(" font-family: %s;", font_family) else "" + ) + + div( + class = "section-panel", + style = panel_style, + h2(title), + # If content is a list or multiple elements, wrap them + if (is.list(content) || length(content) > 1) { + div(class = "section-content", content) + } else { + # Single string or element + div(class = "section-content", p(content)) + } + ) +} + +#' Create a scrollytelling story map +#' @param map_id The ID of your mapboxgl, maplibre, or leaflet output +#' defined in the server, e.g. `"map"` +#' @param sections A named list of story_section objects. +#' Names will correspond to map events defined within +#' the server using `on_section()`. +#' @param map_type One of `"mapboxgl"`, `"maplibre"`, or `"leaflet"`. +#' This will use either `mapboxglOutput()`, `maplibreOutput()`, +#' or `leafletOutput()` respectively, and must +#' correspond to the appropriate `render*()` function used in the server. +#' @param root_margin The margin around the viewport for triggering sections by +#' the intersection observer. Should be specified as a string, +#' e.g. `"-20% 0px -20% 0px"`. +#' @param threshold A number that indicates the visibility ratio for a story +#'' panel to be used to trigger a section; should be a number between +#' 0 and 1. Defaults to 0, meaning that the section is triggered as soon +#' as the first pixel is visible. +#' @param styles Optional custom CSS styles. Should be specified as a +#' character string within `shiny::tags$style()`. +#' @param bg_color Default background color for all sections +#' @param text_color Default text color for all sections +#' @param font_family Default font family for all sections +#' @export +story_map <- function( + map_id, + sections, + map_type = c("mapboxgl", "maplibre", "leaflet"), + root_margin = "-20% 0px -20% 0px", + threshold = 0, + styles = NULL, + bg_color = "rgba(255,255,255,0.9)", + text_color = "#34495e", + font_family = NULL) { + # Apply global styles to sections that don't override them + sections <- lapply(sections, function(section) { + # Only update attributes if they weren't explicitly set + if (is.null(section$attribs$style)) { + section$attribs$style <- "" + } + + # Parse existing style string to get current values + current_style <- section$attribs$style + current_bg <- if (grepl("background:", current_style)) NULL else bg_color + current_color <- if (grepl("(?:^|;)\\s*color:", current_style)) NULL else text_color + current_font <- if (grepl("font-family:", current_style)) NULL else font_family + + # Update section with global styles if not already set + if (!is.null(current_bg)) { + section$attribs$style <- paste(section$attribs$style, sprintf("background: %s;", current_bg)) + } + if (!is.null(current_color)) { + section$attribs$style <- paste(section$attribs$style, sprintf("color: %s;", current_color)) + } + if (!is.null(current_font)) { + section$attribs$style <- paste(section$attribs$style, sprintf("font-family: %s;", current_font)) + } + + section + }) + + default_styles <- tags$style(sprintf( + " + .section-panel { + padding: 20px; + margin-top: 20vh; + margin-bottom: 20vh; + box-shadow: 0 0 10px rgba(0,0,0,0.1); + border-radius: 8px; + pointer-events: auto; + background: %s; + color: %s; + %s + } + .section-panel h2 { + margin-bottom: 15px; + } + .section-panel p { + line-height: 1.6; + } + .spacer { + height: 60vh; + pointer-events: none; + } + .scroll-container { + position: relative; + z-index: 2; + pointer-events: none; + } + ", + bg_color, + text_color, + if (!is.null(font_family)) sprintf("font-family: %s;", font_family) else "" + )) + + # Intersection Observer setup (same as before) + observer_js <- sprintf(" + var observer; + + $(document).ready(function() { + var options = { + root: null, + rootMargin: '%s', + threshold: %s + }; + + var callback = function(entries) { + entries.forEach(function(entry) { + if (entry.isIntersecting) { + Shiny.setInputValue('%s_active_section', entry.target.id, {priority: 'event'}); + } + }); + }; + + observer = new IntersectionObserver(callback, options); + + $('.section').each(function() { + observer.observe(this); + }); + }); + ", root_margin, threshold, map_id) + + map_output_fn <- switch(match.arg(map_type), + mapboxgl = mapboxglOutput, + maplibre = maplibreOutput, + leaflet = leaflet::leafletOutput + ) + + # Create container structure + tagList( + div( + style = "position: fixed; top: 0; left: 0; width: 100%; height: 100vh; z-index: 1;", + map_output_fn(map_id, height = "100%") + ), + div( + class = "scroll-container", + tags$head( + default_styles, + if (!is.null(styles)) styles, + tags$script(observer_js) + ), + Map(function(id, section) { + # Modify the section's class and id to include the list name + section$attribs$class <- paste(section$attribs$class, id) + section$attribs$id <- paste0("section-", id) + + tagList( + div( + class = "section", + id = id, + section # story_section object + ), + div(class = "spacer") + ) + }, names(sections), sections) + ) + ) +} + +#' Observe events on story map section transitions +#' +#' For a given `story_section()`, you may want to trigger an event when the section becomes visible. +#' This function wraps `shiny::observeEvent()` to allow you to modify the state of your map or +#' invoke other Shiny actions on user scroll. +#' +#' @param map_id The ID of your map output +#' @param section_id The ID of the section to trigger on, defined in `story_section()` +#' @param handler Expression to execute when section becomes visible. +#' @export +on_section <- function(map_id, section_id, handler) { + # Get the current reactive domain + domain <- shiny::getDefaultReactiveDomain() + if (is.null(domain)) { + stop("on_section() must be called from within a Shiny reactive context") + } + + # Capture the handler expression + handler_expr <- substitute(handler) + + # Create a reactive environment for evaluation + parent_env <- parent.frame() + + shiny::observeEvent(domain$input[[paste0(map_id, "_active_section")]], { + active_section <- domain$input[[paste0(map_id, "_active_section")]] + if (active_section == section_id) { + local({ + eval(handler_expr, envir = parent_env) + }) + } + }) +} + +#' Create a scrollytelling story map with MapLibre +#' @inheritParams story_map +#' @export +story_maplibre <- function( + map_id, + sections, + root_margin = "-20% 0px -20% 0px", + threshold = 0, + styles = NULL, + bg_color = "rgba(255,255,255,0.9)", + text_color = "#34495e", + font_family = NULL) { + story_map( + map_id = map_id, + sections = sections, + map_type = "maplibre", + root_margin = root_margin, + threshold = threshold, + styles = styles, + bg_color = bg_color, + text_color = text_color, + font_family = font_family + ) +} + +#' Create a scrollytelling story map with Leaflet +#' @inheritParams story_map +#' @export +story_leaflet <- function( + map_id, + sections, + root_margin = "-20% 0px -20% 0px", + threshold = 0, + styles = NULL, + bg_color = "rgba(255,255,255,0.9)", + text_color = "#34495e", + font_family = NULL) { + story_map( + map_id = map_id, + sections = sections, + map_type = "leaflet", + root_margin = root_margin, + threshold = threshold, + styles = styles, + bg_color = bg_color, + text_color = text_color, + font_family = font_family + ) +} diff --git a/R/style_helpers.R b/R/style_helpers.R index 5a3d034a..5e15b007 100644 --- a/R/style_helpers.R +++ b/R/style_helpers.R @@ -296,6 +296,113 @@ get_column <- function(column) { list("get", column) } +#' Create a concatenation expression +#' +#' This function creates a concatenation expression that combines multiple values or expressions into a single string. +#' Useful for creating dynamic tooltips or labels. +#' +#' @param ... Values or expressions to concatenate. Can be strings, numbers, or other expressions like `get_column()`. +#' +#' @return A list representing the concatenation expression. +#' @export +#' @examples +#' # Create a dynamic tooltip +#' concat("Name: ", get_column("name"), "
Value: ", get_column("value")) +concat <- function(...) { + c(list("concat"), list(...)) +} + +#' Create a number formatting expression +#' +#' This function creates a number formatting expression that formats numeric values +#' according to locale-specific conventions. It can be used in tooltips, popups, +#' and text fields for symbol layers. +#' +#' @param column The name of the column containing the numeric value to format. +#' Can also be an expression that evaluates to a number. +#' @param locale A string specifying the locale to use for formatting (e.g., "en-US", +#' "de-DE", "fr-FR"). Defaults to "en-US". +#' @param style The formatting style to use. Options include: +#' - "decimal" (default): Plain number formatting +#' - "currency": Currency formatting (requires `currency` parameter) +#' - "percent": Percentage formatting (multiplies by 100 and adds %) +#' - "unit": Unit formatting (requires `unit` parameter) +#' @param currency For style = "currency", the ISO 4217 currency code (e.g., "USD", "EUR", "GBP"). +#' @param unit For style = "unit", the unit to use (e.g., "kilometer", "mile", "liter"). +#' @param minimum_fraction_digits The minimum number of fraction digits to display. +#' @param maximum_fraction_digits The maximum number of fraction digits to display. +#' @param minimum_integer_digits The minimum number of integer digits to display. +#' @param use_grouping Whether to use grouping separators (e.g., thousands separators). +#' Defaults to TRUE. +#' @param notation The formatting notation. Options include: +#' - "standard" (default): Regular notation +#' - "scientific": Scientific notation +#' - "engineering": Engineering notation +#' - "compact": Compact notation (e.g., "1.2K", "3.4M") +#' @param compact_display For notation = "compact", whether to use "short" (default) +#' or "long" form. +#' +#' @return A list representing the number-format expression. +#' @export +#' @examples +#' # Basic number formatting with thousands separators +#' number_format("population") +#' +#' # Currency formatting +#' number_format("income", style = "currency", currency = "USD") +#' +#' # Percentage with 1 decimal place +#' number_format("rate", style = "percent", maximum_fraction_digits = 1) +#' +#' # Compact notation for large numbers +#' number_format("population", notation = "compact") +#' +#' # Using within a tooltip +#' concat("Population: ", number_format("population", notation = "compact")) +#' +#' # Using with get_column() +#' number_format(get_column("value"), style = "currency", currency = "EUR") +number_format <- function(column, + locale = "en-US", + style = "decimal", + currency = NULL, + unit = NULL, + minimum_fraction_digits = NULL, + maximum_fraction_digits = NULL, + minimum_integer_digits = NULL, + use_grouping = NULL, + notation = NULL, + compact_display = NULL) { + + # Handle column input - can be a string or an expression + if (is.character(column) && length(column) == 1) { + column_expr <- get_column(column) + } else { + column_expr <- column + } + + # Build options list + options <- list(locale = locale) + + # Add style options + if (!is.null(style)) options$style <- style + if (!is.null(currency)) options$currency <- currency + if (!is.null(unit)) options$unit <- unit + + # Add digit options (using hyphenated names for JS compatibility) + if (!is.null(minimum_fraction_digits)) options$`min-fraction-digits` <- minimum_fraction_digits + if (!is.null(maximum_fraction_digits)) options$`max-fraction-digits` <- maximum_fraction_digits + if (!is.null(minimum_integer_digits)) options$`min-integer-digits` <- minimum_integer_digits + + # Add other options + if (!is.null(use_grouping)) options$useGrouping <- use_grouping + if (!is.null(notation)) options$notation <- notation + if (!is.null(compact_display)) options$compactDisplay <- compact_display + + # Return the expression + list("number-format", column_expr, options) +} + # Trim hex colors (so packages like viridisLite can be used) trim_hex_colors <- function(colors) { ifelse(substr(colors, 1, 1) == "#" & nchar(colors) == 9, @@ -303,3 +410,25 @@ trim_hex_colors <- function(colors) { colors ) } + +#' Set Projection for a Mapbox/Maplibre Map +#' +#' This function sets the projection dynamically after map initialization. +#' +#' @param map A map object created by mapboxgl() or maplibre() functions, or their respective proxy objects +#' @param projection A string representing the projection name (e.g., "mercator", "globe", "albers", "equalEarth", etc.) +#' @return The modified map object +#' @export +set_projection <- function(map, projection) { + if (any(inherits(map, "mapboxgl_proxy"), inherits(map, "maplibre_proxy"))) { + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list(type = "set_projection", projection = projection) + )) + } else { + if (is.null(map$x$setProjection)) map$x$setProjection <- list() + map$x$setProjection[[length(map$x$setProjection) + 1]] <- list(projection = projection) + } + return(map) +} diff --git a/R/terrain.R b/R/terrain.R index 1d90fa4d..aa4b0002 100644 --- a/R/terrain.R +++ b/R/terrain.R @@ -65,3 +65,140 @@ set_fog <- function(map, range = NULL, color = NULL, horizon_blend = NULL, map } + +#' Set rain effect on a Mapbox GL map +#' +#' @param map A map object created by the `mapboxgl` function or a proxy object. +#' @param density A number between 0 and 1 controlling the rain particles density. Default is 0.5. +#' @param intensity A number between 0 and 1 controlling the rain particles movement speed. Default is 1. +#' @param color A string specifying the color of the rain droplets. Default is "#a8adbc". +#' @param opacity A number between 0 and 1 controlling the rain particles opacity. Default is 0.7. +#' @param center_thinning A number between 0 and 1 controlling the thinning factor of rain particles from center. Default is 0.57. +#' @param direction A numeric vector of length 2 defining the azimuth and polar angles of the rain direction. Default is c(0, 80). +#' @param droplet_size A numeric vector of length 2 controlling the rain droplet size (x - normal to direction, y - along direction). Default is c(2.6, 18.2). +#' @param distortion_strength A number between 0 and 1 controlling the rain particles screen-space distortion strength. Default is 0.7. +#' @param vignette A number between 0 and 1 controlling the screen-space vignette rain tinting effect intensity. Default is 1.0. +#' @param vignette_color A string specifying the rain vignette screen-space corners tint color. Default is "#464646". +#' @param remove A logical value indicating whether to remove the rain effect. Default is FALSE. +#' +#' @return The updated map object. +#' @export +#' +#' @examples +#' \dontrun{ +#' # Add rain effect with default values +#' mapboxgl(...) |> set_rain() +#' +#' # Add rain effect with custom values +#' mapboxgl( +#' style = mapbox_style("standard"), +#' center = c(24.951528, 60.169573), +#' zoom = 16.8, +#' pitch = 74, +#' bearing = 12.8 +#' ) |> +#' set_rain( +#' density = 0.5, +#' opacity = 0.7, +#' color = "#a8adbc" +#' ) +#' +#' # Remove rain effect (useful in Shiny) +#' map_proxy |> set_rain(remove = TRUE) +#' } +set_rain <- function(map, density = 0.5, intensity = 1.0, color = "#a8adbc", + opacity = 0.7, center_thinning = 0.57, direction = c(0, 80), + droplet_size = c(2.6, 18.2), distortion_strength = 0.7, + vignette = 1.0, vignette_color = "#464646", + remove = FALSE) { + + # If remove is TRUE, set rain to NULL to remove the effect + if (remove) { + map$x$rain <- NULL + return(map) + } + + rain <- list( + density = density, + intensity = intensity, + color = color, + opacity = opacity, + "center-thinning" = center_thinning, + direction = direction, + "droplet-size" = droplet_size, + "distortion-strength" = distortion_strength, + vignette = vignette, + "vignette-color" = vignette_color + ) + + map$x$rain <- rain + + map +} + +#' Set snow effect on a Mapbox GL map +#' +#' @param map A map object created by the `mapboxgl` function or a proxy object. +#' @param density A number between 0 and 1 controlling the snow particles density. Default is 0.85. +#' @param intensity A number between 0 and 1 controlling the snow particles movement speed. Default is 1.0. +#' @param color A string specifying the color of the snow particles. Default is "#ffffff". +#' @param opacity A number between 0 and 1 controlling the snow particles opacity. Default is 1.0. +#' @param center_thinning A number between 0 and 1 controlling the thinning factor of snow particles from center. Default is 0.4. +#' @param direction A numeric vector of length 2 defining the azimuth and polar angles of the snow direction. Default is c(0, 50). +#' @param flake_size A number between 0 and 5 controlling the snow flake particle size. Default is 0.71. +#' @param vignette A number between 0 and 1 controlling the snow vignette screen-space effect. Default is 0.3. +#' @param vignette_color A string specifying the snow vignette screen-space corners tint color. Default is "#ffffff". +#' @param remove A logical value indicating whether to remove the snow effect. Default is FALSE. +#' +#' @return The updated map object. +#' @export +#' +#' @examples +#' \dontrun{ +#' # Add snow effect with default values +#' mapboxgl(...) |> set_snow() +#' +#' # Add snow effect with custom values +#' mapboxgl( +#' style = mapbox_style("standard"), +#' center = c(24.951528, 60.169573), +#' zoom = 16.8, +#' pitch = 74, +#' bearing = 12.8 +#' ) |> +#' set_snow( +#' density = 0.85, +#' flake_size = 0.71, +#' color = "#ffffff" +#' ) +#' +#' # Remove snow effect (useful in Shiny) +#' map_proxy |> set_snow(remove = TRUE) +#' } +set_snow <- function(map, density = 0.85, intensity = 1.0, color = "#ffffff", + opacity = 1.0, center_thinning = 0.4, direction = c(0, 50), + flake_size = 0.71, vignette = 0.3, vignette_color = "#ffffff", + remove = FALSE) { + + # If remove is TRUE, set snow to NULL to remove the effect + if (remove) { + map$x$snow <- NULL + return(map) + } + + snow <- list( + density = density, + intensity = intensity, + color = color, + opacity = opacity, + "center-thinning" = center_thinning, + direction = direction, + "flake-size" = flake_size, + vignette = vignette, + "vignette-color" = vignette_color + ) + + map$x$snow <- snow + + map +} \ No newline at end of file diff --git a/R/views.R b/R/views.R index 8160b272..8c87575a 100644 --- a/R/views.R +++ b/R/views.R @@ -17,11 +17,26 @@ fit_bounds <- function(map, bbox, animate = FALSE, ...) { } if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "fit_bounds", bounds = bbox, options = options) - )) + if (inherits(map, "mapboxgl_compare_proxy") || inherits(map, "maplibre_compare_proxy")) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list( + type = "fit_bounds", + bounds = bbox, + options = options, + map = map$map_side + ) + )) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list(type = "fit_bounds", bounds = bbox, options = options) + )) + } } else { map$x$fitBounds <- list(bounds = bbox, options = options) } @@ -46,11 +61,25 @@ fly_to <- function(map, center, zoom = NULL, ...) { if (!is.null(zoom)) options$zoom <- zoom if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "fly_to", options = options) - )) + if (inherits(map, "mapboxgl_compare_proxy") || inherits(map, "maplibre_compare_proxy")) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list( + type = "fly_to", + options = options, + map = map$map_side + ) + )) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list(type = "fly_to", options = options) + )) + } } else { map$x$flyTo <- options } @@ -74,11 +103,25 @@ ease_to <- function(map, center, zoom = NULL, ...) { if (!is.null(zoom)) options$zoom <- zoom if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "ease_to", options = options) - )) + if (inherits(map, "mapboxgl_compare_proxy") || inherits(map, "maplibre_compare_proxy")) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list( + type = "ease_to", + options = options, + map = map$map_side + ) + )) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list(type = "ease_to", options = options) + )) + } } else { map$x$easeTo <- options } @@ -95,15 +138,37 @@ ease_to <- function(map, center, zoom = NULL, ...) { #' @export set_view <- function(map, center, zoom) { if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "set_center", center = center) - )) - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "set_zoom", zoom = zoom) - )) + if (inherits(map, "mapboxgl_compare_proxy") || inherits(map, "maplibre_compare_proxy")) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list( + type = "set_center", + center = center, + map = map$map_side + ) + )) + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list( + type = "set_zoom", + zoom = zoom, + map = map$map_side + ) + )) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list(type = "set_center", center = center) + )) + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list(type = "set_zoom", zoom = zoom) + )) + } } else { map$x$setCenter <- center map$x$setZoom <- zoom @@ -128,11 +193,25 @@ jump_to <- function(map, center, zoom = NULL, ...) { if (!is.null(zoom)) options$zoom <- zoom if (inherits(map, "mapboxgl_proxy") || inherits(map, "maplibre_proxy")) { - proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" - map$session$sendCustomMessage(proxy_class, list( - id = map$id, - message = list(type = "jump_to", options = options) - )) + if (inherits(map, "mapboxgl_compare_proxy") || inherits(map, "maplibre_compare_proxy")) { + # For compare proxies + proxy_class <- if (inherits(map, "mapboxgl_compare_proxy")) "mapboxgl-compare-proxy" else "maplibre-compare-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list( + type = "jump_to", + options = options, + map = map$map_side + ) + )) + } else { + # For regular proxies + proxy_class <- if (inherits(map, "mapboxgl_proxy")) "mapboxgl-proxy" else "maplibre-proxy" + map$session$sendCustomMessage(proxy_class, list( + id = map$id, + message = list(type = "jump_to", options = options) + )) + } } else { map$x$jumpTo <- options } diff --git a/README.md b/README.md index 7507d0da..55a75bec 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ Read through these vignettes to learn how to use the package: - [Using __mapgl__ with Shiny](https://walker-data.com/mapgl/articles/shiny.html) +- [Building story maps with __mapgl__](https://walker-data.com/mapgl/articles/story-maps.html) + ## Recommended training and how to learn more If you find this project useful in your work and would like to ensure continued development of the package, you can provide support in the following ways: diff --git a/_pkgdown.yml b/_pkgdown.yml index 22014a29..cec2c2ca 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -18,7 +18,6 @@ navbar: - reference - articles - news - right: github components: home: icon: fa-home fa-lg @@ -36,8 +35,147 @@ navbar: - text: Fundamentals of map design with mapgl href: articles/map-design.html - text: Using mapgl with Shiny - href: articles/margins-of-error.html + href: articles/shiny.html + - text: Building story maps with mapgl + href: articles/story-maps.html - github: - icon: fa-github fa-lg - href: https://github.com/walkerke/mapgl +reference: +- title: "Creating Maps" + desc: "Functions to initialize Mapbox GL and MapLibre GL maps" + contents: + - mapboxgl + - maplibre + - mapboxgl_view + - maplibre_view + +- title: "Adding Layers" + desc: "Functions to add various types of visualization layers to your map" + contents: + - add_layer + - add_fill_layer + - add_line_layer + - add_circle_layer + - add_heatmap_layer + - add_fill_extrusion_layer + - add_raster_layer + - add_symbol_layer + +- title: "Data Sources" + desc: "Functions to add different types of data sources" + contents: + - add_source + - add_vector_source + - add_raster_source + - add_raster_dem_source + - add_image_source + - add_video_source + - add_h3j_source + +- title: "Map Controls" + desc: "Functions to add interactive controls to your map" + contents: + - add_navigation_control + - add_fullscreen_control + - add_scale_control + - add_layers_control + - add_draw_control + - add_geocoder_control + - add_reset_control + - add_geolocate_control + - add_globe_control + - add_control + - clear_controls + +- title: "Legends" + desc: "Functions for adding and managing map legends" + contents: + - add_legend + - add_categorical_legend + - add_continuous_legend + - clear_legend + +- title: "Markers" + desc: "Functions for adding and managing markers" + contents: + - add_markers + - clear_markers + +- title: "Styling Helpers" + desc: "Functions to help with map styling and expressions" + contents: + - mapbox_style + - maptiler_style + - carto_style + - interpolate + - match_expr + - step_expr + - get_column + - concat + - number_format + - cluster_options + +- title: "Camera and View" + desc: "Functions to control map camera and viewport" + contents: + - fit_bounds + - fly_to + - ease_to + - jump_to + - set_view + +- title: "Map Configuration" + desc: "Functions to configure map appearance and behavior" + contents: + - set_style + - set_projection + - set_terrain + - set_fog + - set_rain + - set_snow + - set_config_property + +- title: "Layer Management" + desc: "Functions to modify and manage existing layers" + contents: + - set_filter + - set_paint_property + - set_layout_property + - set_tooltip + - set_popup + - set_source + - clear_layer + - move_layer + +- title: "Shiny Integration" + desc: "Functions for using mapgl in Shiny applications" + contents: + - mapboxglOutput + - maplibreOutput + - renderMapboxgl + - renderMaplibre + - mapboxgl_proxy + - maplibre_proxy + - mapboxglCompareOutput + - maplibreCompareOutput + - renderMapboxglCompare + - renderMaplibreCompare + - mapboxgl_compare_proxy + - maplibre_compare_proxy + +- title: "Advanced Features" + desc: "Functions for advanced mapping features" + contents: + - compare + - add_globe_minimap + - add_image + - get_drawn_features + - add_features_to_draw + +- title: "Story Maps" + desc: "Functions for creating scrollytelling story maps" + contents: + - story_map + - story_maplibre + - story_leaflet + - story_section + - on_section diff --git a/data-raw/get-maplibre.R b/data-raw/get-maplibre.R index 6f42cb70..f9c5d383 100644 --- a/data-raw/get-maplibre.R +++ b/data-raw/get-maplibre.R @@ -2,18 +2,32 @@ # Set the WD, then: # Main assets: -download.file("https://unpkg.com/maplibre-gl/dist/maplibre-gl.js", destfile = "inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.js") -download.file("https://unpkg.com/maplibre-gl/dist/maplibre-gl.css", destfile = "inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.css") +download.file( + "https://unpkg.com/maplibre-gl/dist/maplibre-gl.js", + destfile = "inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.js" +) +download.file( + "https://unpkg.com/maplibre-gl/dist/maplibre-gl.css", + destfile = "inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.css" +) # Draw control: -download.file("https://www.unpkg.com/@mapbox/mapbox-gl-draw@1.4.3/dist/mapbox-gl-draw.js", - destfile = "inst/htmlwidgets/lib/mapbox-gl-draw/mapbox-gl-draw.js") -download.file("https://www.unpkg.com/@mapbox/mapbox-gl-draw@1.4.3/dist/mapbox-gl-draw.css", - destfile = "inst/htmlwidgets/lib/mapbox-gl-draw/mapbox-gl-draw.css") +download.file( + "https://www.unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.js", + destfile = "inst/htmlwidgets/lib/mapbox-gl-draw/mapbox-gl-draw.js" +) +download.file( + "https://www.unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css", + destfile = "inst/htmlwidgets/lib/mapbox-gl-draw/mapbox-gl-draw.css" +) # Geocoder: -download.file("https://unpkg.com/@maplibre/maplibre-gl-geocoder@1.5.0/dist/maplibre-gl-geocoder.min.js", - destfile = "inst/htmlwidgets/lib/maplibre-gl-geocoder/maplibre-gl-geocoder.min.js") -download.file("https://unpkg.com/@maplibre/maplibre-gl-geocoder@1.5.0/dist/maplibre-gl-geocoder.css", - destfile = "inst/htmlwidgets/lib/maplibre-gl-geocoder/maplibre-gl-geocoder.css") +download.file( + "https://unpkg.com/@maplibre/maplibre-gl-geocoder@1.5.0/dist/maplibre-gl-geocoder.min.js", + destfile = "inst/htmlwidgets/lib/maplibre-gl-geocoder/maplibre-gl-geocoder.min.js" +) +download.file( + "https://unpkg.com/@maplibre/maplibre-gl-geocoder@1.5.0/dist/maplibre-gl-geocoder.css", + destfile = "inst/htmlwidgets/lib/maplibre-gl-geocoder/maplibre-gl-geocoder.css" +) diff --git a/docs/404.html b/docs/404.html index f25273b1..afc7d1c2 100644 --- a/docs/404.html +++ b/docs/404.html @@ -6,16 +6,15 @@ Page not found (404) • mapgl - - - - - - + + + + + - - + + @@ -27,7 +26,7 @@ mapgl - 0.1.4 + 0.2.2.9000
@@ -74,7 +77,7 @@
diff --git a/docs/CLAUDE.html b/docs/CLAUDE.html new file mode 100644 index 00000000..e25df846 --- /dev/null +++ b/docs/CLAUDE.html @@ -0,0 +1,214 @@ + +CLAUDE.md • mapgl + Skip to contents + + +
+
+
+ +
+ +

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

+
+

Overview

+

The mapgl R package provides an interface to Mapbox GL JS and MapLibre GL JS for creating interactive maps in R. It is designed to feel familiar to R users while making the powerful capabilities of both mapping libraries available.

+
+
+

Common Development Commands

+
+

Package Building and Installation

+
+# Build and install the package locally
+devtools::install()
+
+# Check the package for issues
+devtools::check()
+
+# Generate documentation from roxygen2 comments
+devtools::document()
+
+# Run tests
+devtools::test()
+
+# Build the package
+devtools::build()
+
+
+

Vignette and Documentation

+
+# Build all vignettes
+devtools::build_vignettes()
+
+# Build a specific vignette
+knitr::knit("vignettes/getting-started.Rmd")
+
+# Build pkgdown site
+pkgdown::build_site()
+
+
+

Shiny Development

+
+# When developing Shiny apps with mapgl, use:
+shiny::runApp("app.R", reload = TRUE)
+
+
+

Testing Individual Functions

+
+# Load the development version
+devtools::load_all()
+
+# Test individual functions
+library(mapgl)
+map <- maplibre() |>
+  add_circle_layer(data = sf_object, ...)
+
+
+
+

Architecture and Code Structure

+
+

HTMLWidgets Architecture

+

The package uses the htmlwidgets framework to bridge R and JavaScript:

+
  1. +R Functions (R/ directory): +
    • +mapboxgl.R / maplibre.R: Main widget creation functions
    • +
    • +layers.R: Functions for adding map layers (circles, fills, lines, etc.)
    • +
    • +sources.R: Functions for adding data sources
    • +
    • +controls.R: Functions for adding UI controls
    • +
    • +shiny.R: Shiny integration with proxy functions
    • +
    • +plugins.R: Integration with JS plugins (globe minimap, geocoder, etc.)
    • +
  2. +
  3. +JavaScript Bindings (inst/htmlwidgets/ directory): +
    • +mapboxgl.js / maplibregl.js: Main JS widget bindings
    • +
    • +mapboxgl_compare.js / maplibregl_compare.js: Compare view implementations
    • +
    • YAML files define dependencies for each widget
    • +
  4. +
  5. +External Libraries (inst/htmlwidgets/lib/ directory): +
    • MapLibre GL JS (vendored)
    • +
    • Mapbox GL JS (loaded from CDN)
    • +
    • Various plugins (globe-minimap, draw, geocoder, etc.)
    • +
  6. +
+
+

Widget Communication Pattern

+
  1. R functions create list structures with map instructions
  2. +
  3. These are serialized to JSON and sent to JavaScript
  4. +
  5. JavaScript interprets instructions and updates the map
  6. +
  7. Shiny proxy functions send messages to existing maps
  8. +
+
+

Key Design Patterns

+

Layer Management: Each layer requires a source. The package automatically creates sources when needed:

+
+# This creates both a source and a layer
+add_circle_layer(map, id = "circles", source = "data", data = sf_object)
+

Proxy Pattern: For Shiny apps, proxy functions allow updating existing maps:

+
+maplibre_proxy("map_id") |>
+  set_filter("layer_id", list("==", "property", "value"))
+

Expression System: The package supports Mapbox GL expressions:

+
+interpolate(
+  column = "value",
+  values = c(0, 100),
+  colors = c("blue", "red")
+)
+

Control Positioning: Controls can be positioned at 8 locations: - “top-left”, “top-center”, “top-right” - “bottom-left”, “bottom-center”, “bottom-right” - “middle-left”, “middle-right”

+
+
+

Dependencies and Versions

+
  • MapLibre GL JS: v5.3.0 (vendored)
  • +
  • Mapbox GL JS: v3.12.0 (CDN)
  • +
  • R dependencies: htmlwidgets, sf, geojsonsf, shiny, etc.
  • +
+
+

Working with Styles

+

The package supports multiple style sources: - mapbox_style(): Official Mapbox styles (requires token) - maptiler_style(): MapTiler styles (requires API key) - carto_style(): CARTO styles (free) - Custom style URLs or JSON objects

+
+
+

Testing Changes

+
  1. Test JavaScript changes by modifying files in inst/htmlwidgets/ +
  2. +
  3. Test R changes by running devtools::load_all() and testing interactively
  4. +
  5. Use the examples in vignettes/ as test cases
  6. +
  7. Test Shiny functionality with apps in vignettes/ or create minimal examples
  8. +
+
+

Current Issues and Edge Cases

+
  • Globe minimap positioning in MapLibre with “bottom-right” position has CSS issues
  • +
  • Compare views require special handling for synchronized map updates
  • +
  • Some Mapbox-specific features may not work in MapLibre and vice versa
  • +
+
+

Specific instructions

+
  • DO NOT create an examples folder
  • +
  • DO NOT create R script files or any other files within the folder before getting explicit approval
  • +
  • Code style should follow Posit’s Air formatter
  • +
  • Code style prefers snake case (with words separated by underscores) rather than camel case.
  • +
+
+
+ +
+ + +
+ + + + + + + diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 48b37252..2a9d5659 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -1,5 +1,5 @@ -License • mapgl +License • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -49,7 +52,7 @@ diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 1ab47fc8..10cd3798 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -1,5 +1,5 @@ -MIT License • mapgl +MIT License • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
@@ -53,7 +56,7 @@
diff --git a/docs/articles/getting-started.html b/docs/articles/getting-started.html index 9a591304..622ffc7b 100644 --- a/docs/articles/getting-started.html +++ b/docs/articles/getting-started.html @@ -6,16 +6,15 @@ Getting started with mapgl • mapgl - - - - - - + + + + + - - + + @@ -26,7 +25,7 @@ mapgl - 0.1.4 + 0.2.2.9000 @@ -59,18 +62,18 @@ - - - - - - -
+ + + + + + +
@@ -166,9 +169,7 @@

Comparing map viewscompare() that allows users to create synced swipe maps that can compare two -styles. This function works for either Mapbox or MapLibre maps. I don’t -have this working correctly in rendered R Markdown / Quarto docs or -Shiny apps yet, but I’m working on it!

+styles. This function works for either Mapbox or MapLibre maps.

 m1 <- mapboxgl()
 m2 <- mapboxgl(mapbox_style("satellite-streets"))
@@ -187,7 +188,7 @@ 

Comparing map views -

Site built with pkgdown 2.0.9.9000.

+

Site built with pkgdown 2.1.3.9000.

diff --git a/docs/articles/getting-started_files/h3j-h3t-0.9.2/h3j_h3t.js b/docs/articles/getting-started_files/h3j-h3t-0.9.2/h3j_h3t.js new file mode 100644 index 00000000..16631aa5 --- /dev/null +++ b/docs/articles/getting-started_files/h3j-h3t-0.9.2/h3j_h3t.js @@ -0,0 +1,3 @@ +!function(A){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=A();else if("function"==typeof define&&define.amd)define([],A);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).h3j_h3t=A()}}((function(){return function A(e,r,t){function i(o,a){if(!r[o]){if(!e[o]){var f="function"==typeof require&&require;if(!a&&f)return f(o,!0);if(n)return n(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var u=r[o]={exports:{}};e[o][0].call(u.exports,(function(A){return i(e[o][1][A]||A)}),u,u.exports,A,e,r,t)}return r[o].exports}for(var n="function"==typeof require&&require,o=0;o>3}if(n--,1===i||2===i)o+=A.readSVarint(),a+=A.readSVarint(),1===i&&(e&&f.push(e),e=[]),e.push(new t(o,a));else{if(7!==i)throw new Error("unknown command "+i);e&&e.push(e[0].clone())}}return e&&f.push(e),f},i.prototype.bbox=function(){var A=this._pbf;A.pos=this._geometry;for(var e=A.readVarint()+A.pos,r=1,t=0,i=0,n=0,o=1/0,a=-1/0,f=1/0,s=-1/0;A.pos>3}if(t--,1===r||2===r)(i+=A.readSVarint())a&&(a=i),(n+=A.readSVarint())s&&(s=n);else if(7!==r)throw new Error("unknown command "+r)}return[o,f,a,s]},i.prototype.toGeoJSON=function(A,e,r){var t,n,a=this.extent*Math.pow(2,r),f=this.extent*A,s=this.extent*e,u=this.loadGeometry(),l=i.types[this.type];function h(A){for(var e=0;e>3;e=1===t?A.readString():2===t?A.readFloat():3===t?A.readDouble():4===t?A.readVarint64():5===t?A.readVarint():6===t?A.readSVarint():7===t?A.readBoolean():null}return e}(r))}e.exports=i,i.prototype.feature=function(A){if(A<0||A>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[A];var e=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,e,this.extent,this._keys,this._values)}},{"./vectortilefeature.js":4}],6:[function(A,e,r){!function(A,t){"object"==typeof r&&void 0!==e?e.exports=t():A.geojsonvt=t()}(this,(function(){"use strict";function A(r,t,i,n){for(var o,a=n,f=i-t>>1,s=i-t,u=r[t],l=r[t+1],h=r[i],c=r[i+1],d=t+3;da)o=d,a=g;else if(g===a){var w=Math.abs(d-f);wn&&(o-t>3&&A(r,t,o,n),r[o+2]=a,i-o>3&&A(r,o,i,n))}function e(A,e,r,t,i,n){var o=i-r,a=n-t;if(0!==o||0!==a){var f=((A-r)*o+(e-t)*a)/(o*o+a*a);f>1?(r=i,t=n):f>0&&(r+=o*f,t+=a*f)}return(o=A-r)*o+(a=e-t)*a}function r(A,e,r,i){var n={id:void 0===A?null:A,type:e,geometry:r,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(A){var e=A.geometry,r=A.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)t(A,e);else if("Polygon"===r||"MultiLineString"===r)for(var i=0;i0&&(a+=i?(n*h-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(h-o,2))),n=l,o=h}var c=r.length-3;r[2]=1,A(r,0,c,t),r[c+2]=1,r.size=Math.abs(a),r.start=0,r.end=r.size}function a(A,e,r,t){for(var i=0;i1?1:r}function u(A,e,t,i,n,o,a,f){if(i/=e,o>=(t/=e)&&a=i)return null;for(var s=[],u=0;u=t&&B=i)){var b=[];if("Point"===w||"MultiPoint"===w)l(g,b,t,i,n);else if("LineString"===w)h(g,b,t,i,n,!1,f.lineMetrics);else if("MultiLineString"===w)d(g,b,t,i,n,!1);else if("Polygon"===w)d(g,b,t,i,n,!0);else if("MultiPolygon"===w)for(var v=0;v=r&&o<=t&&(e.push(A[n]),e.push(A[n+1]),e.push(A[n+2]))}}function h(A,e,r,t,i,n,o){for(var a,f,s=c(A),u=0===i?w:p,l=A.start,h=0;hr&&(f=u(s,d,B,v,m,r),o&&(s.start=l+a*f)):k>t?M=r&&(f=u(s,d,B,v,m,r),Q=!0),M>t&&k<=t&&(f=u(s,d,B,v,m,t),Q=!0),!n&&Q&&(o&&(s.end=l+a*f),e.push(s),s=c(A)),o&&(l+=a)}var y=A.length-3;d=A[y],B=A[y+1],b=A[y+2],(k=0===i?d:B)>=r&&k<=t&&g(s,d,B,b),y=s.length-3,n&&y>=3&&(s[y]!==s[0]||s[y+1]!==s[1])&&g(s,s[0],s[1],s[2]),s.length&&e.push(s)}function c(A){var e=[];return e.size=A.size,e.start=A.start,e.end=A.end,e}function d(A,e,r,t,i,n){for(var o=0;oo.maxX&&(o.maxX=u),l>o.maxY&&(o.maxY=l)}return o}function M(A,e,r,t){var i=e.geometry,n=e.type,o=[];if("Point"===n||"MultiPoint"===n)for(var a=0;a0&&e.size<(i?o:t))r.numPoints+=e.length/3;else{for(var a=[],f=0;fo)&&(r.numSimplified++,a.push(e[f]),a.push(e[f+1])),r.numPoints++;i&&function(A,e){for(var r=0,t=0,i=A.length,n=i-2;t0===e)for(t=0,i=A.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var t=function(A,e){var r=[];if("FeatureCollection"===A.type)for(var t=0;t1&&console.time("creation"),c=this.tiles[h]=k(A,e,r,t,f),this.tileCoords.push({z:e,x:r,y:t}),s)){s>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,t,c.numFeatures,c.numPoints,c.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(c.source=A,i){if(e===f.maxZoom||e===i)continue;var g=1<1&&console.time("clipping");var w,p,B,b,v,m,M=.5*f.buffer/f.extent,Q=.5-M,y=.5+M,x=1+M;w=p=B=b=null,v=u(A,l,r-M,r+y,0,c.minX,c.maxX,f),m=u(A,l,r+Q,r+x,0,c.minX,c.maxX,f),A=null,v&&(w=u(v,l,t-M,t+y,1,c.minY,c.maxY,f),p=u(v,l,t+Q,t+x,1,c.minY,c.maxY,f),v=null),m&&(B=u(m,l,t-M,t+y,1,c.minY,c.maxY,f),b=u(m,l,t+Q,t+x,1,c.minY,c.maxY,f),m=null),s>1&&console.timeEnd("clipping"),a.push(w||[],e+1,2*r,2*t),a.push(p||[],e+1,2*r,2*t+1),a.push(B||[],e+1,2*r+1,2*t),a.push(b||[],e+1,2*r+1,2*t+1)}}},y.prototype.getTile=function(A,e,r){var t=this.options,i=t.extent,n=t.debug;if(A<0||A>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",A,e,r);for(var f,s=A,u=e,l=r;!f&&s>0;)s--,u=Math.floor(u/2),l=Math.floor(l/2),f=this.tiles[E(s,u,l)];return f&&f.source?(n>1&&console.log("found parent tile z%d-%d-%d",s,u,l),n>1&&console.time("drilling down"),this.splitTile(f.source,s,u,l,A,e,r),n>1&&console.timeEnd("drilling down"),this.tiles[a]?v(this.tiles[a],i):null):null},function(A,e){return new y(A,e)}}))},{}],7:[function(A,e,r){var t=function(A){var e,r=void 0!==(A=A||{})?A:{},t={};for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);var i,n=[],o="";document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",i=function(A,e,r){var t=new XMLHttpRequest;t.open("GET",A,!0),t.responseType="arraybuffer",t.onload=function(){if(200==t.status||0==t.status&&t.response)e(t.response);else{var i=J(A);i?e(i.buffer):r()}},t.onerror=r,t.send(null)};var a=r.print||console.log.bind(console),f=r.printErr||console.warn.bind(console);for(e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);t=null,r.arguments&&(n=r.arguments);var s=0,u=function(){return s};var l=!1;function h(A){var e,t=r["_"+A];return e="Cannot call unknown function "+A+", make sure it is exported",t||fA("Assertion failed: "+e),t}function c(A,e,r,t,i){var n={string:function(A){var e=0;if(null!=A&&0!==A){var r=1+(A.length<<2);(function(A,e,r){(function(A,e,r,t){if(!(t>0))return 0;for(var i=r,n=r+t-1,o=0;o=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&A.charCodeAt(++o);if(a<=127){if(r>=n)break;e[r++]=a}else if(a<=2047){if(r+1>=n)break;e[r++]=192|a>>6,e[r++]=128|63&a}else if(a<=65535){if(r+2>=n)break;e[r++]=224|a>>12,e[r++]=128|a>>6&63,e[r++]=128|63&a}else{if(r+3>=n)break;e[r++]=240|a>>18,e[r++]=128|a>>12&63,e[r++]=128|a>>6&63,e[r++]=128|63&a}}e[r]=0})(A,B,e,r)})(A,e=AA(r),r)}return e},array:function(A){var e=AA(A.length);return function(A,e){p.set(A,e)}(A,e),e}};var o=h(A),a=[],f=0;if(t)for(var s=0;s=t);)++i;if(i-e>16&&A.subarray&&d)return d.decode(A.subarray(e,i));for(var n="";e>10,56320|1023&s)}}else n+=String.fromCharCode((31&o)<<6|a)}else n+=String.fromCharCode(o)}return n}(B,A,e):""}var w,p,B,b,v,m,k;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");function M(A,e){return A%e>0&&(A+=e-A%e),A}function Q(A){w=A,r.HEAP8=p=new Int8Array(A),r.HEAP16=b=new Int16Array(A),r.HEAP32=v=new Int32Array(A),r.HEAPU8=B=new Uint8Array(A),r.HEAPU16=new Uint16Array(A),r.HEAPU32=new Uint32Array(A),r.HEAPF32=m=new Float32Array(A),r.HEAPF64=k=new Float64Array(A)}var y=r.TOTAL_MEMORY||33554432;function E(A){for(;A.length>0;){var e=A.shift();if("function"!=typeof e){var t=e.func;"number"==typeof t?void 0===e.arg?r.dynCall_v(t):r.dynCall_vi(t,e.arg):t(void 0===e.arg?null:e.arg)}else e()}}y=(w=r.buffer?r.buffer:new ArrayBuffer(y)).byteLength,Q(w),v[6004]=5266928;var x=[],D=[],_=[],I=[];var F=Math.abs,C=Math.ceil,P=Math.floor,U=Math.min,G=0,S=null,T=null;r.preloadedImages={},r.preloadedAudios={};var V,H,R=null,L="data:application/octet-stream;base64,";function z(A){return String.prototype.startsWith?A.startsWith(L):0===A.indexOf(L)}R="data:application/octet-stream;base64,AAAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAABAAAAAMAAAAGAAAABQAAAAIAAAAAAAAAAgAAAAMAAAABAAAABAAAAAYAAAAAAAAABQAAAAMAAAAGAAAABAAAAAUAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAABAAAABQAAAAIAAAAAAAAAAQAAAAMAAAAGAAAABAAAAAYAAAAAAAAABQAAAAIAAAABAAAABAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAgAAAAMAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAABgAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAABgAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAAAAAACAAAAAwAAAAQAAAAFAAAABgAAAAAAAAABAAAAAwAAAAQAAAAFAAAABgAAAAAAAAABAAAAAgAAAAQAAAAFAAAABgAAAAAAAAABAAAAAgAAAAMAAAAFAAAABgAAAAAAAAABAAAAAgAAAAMAAAAEAAAABgAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAAAAAAABgAAAAAAAAADAAAAAgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAUAAAAEAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAEAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAUAAAACAAAABAAAAAMAAAAIAAAAAQAAAAcAAAAGAAAACQAAAAAAAAADAAAAAgAAAAIAAAAGAAAACgAAAAsAAAAAAAAAAQAAAAUAAAADAAAADQAAAAEAAAAHAAAABAAAAAwAAAAAAAAABAAAAH8AAAAPAAAACAAAAAMAAAAAAAAADAAAAAUAAAACAAAAEgAAAAoAAAAIAAAAAAAAABAAAAAGAAAADgAAAAsAAAARAAAAAQAAAAkAAAACAAAABwAAABUAAAAJAAAAEwAAAAMAAAANAAAAAQAAAAgAAAAFAAAAFgAAABAAAAAEAAAAAAAAAA8AAAAJAAAAEwAAAA4AAAAUAAAAAQAAAAcAAAAGAAAACgAAAAsAAAAYAAAAFwAAAAUAAAACAAAAEgAAAAsAAAARAAAAFwAAABkAAAACAAAABgAAAAoAAAAMAAAAHAAAAA0AAAAaAAAABAAAAA8AAAADAAAADQAAABoAAAAVAAAAHQAAAAMAAAAMAAAABwAAAA4AAAB/AAAAEQAAABsAAAAJAAAAFAAAAAYAAAAPAAAAFgAAABwAAAAfAAAABAAAAAgAAAAMAAAAEAAAABIAAAAhAAAAHgAAAAgAAAAFAAAAFgAAABEAAAALAAAADgAAAAYAAAAjAAAAGQAAABsAAAASAAAAGAAAAB4AAAAgAAAABQAAAAoAAAAQAAAAEwAAACIAAAAUAAAAJAAAAAcAAAAVAAAACQAAABQAAAAOAAAAEwAAAAkAAAAoAAAAGwAAACQAAAAVAAAAJgAAABMAAAAiAAAADQAAAB0AAAAHAAAAFgAAABAAAAApAAAAIQAAAA8AAAAIAAAAHwAAABcAAAAYAAAACwAAAAoAAAAnAAAAJQAAABkAAAAYAAAAfwAAACAAAAAlAAAACgAAABcAAAASAAAAGQAAABcAAAARAAAACwAAAC0AAAAnAAAAIwAAABoAAAAqAAAAHQAAACsAAAAMAAAAHAAAAA0AAAAbAAAAKAAAACMAAAAuAAAADgAAABQAAAARAAAAHAAAAB8AAAAqAAAALAAAAAwAAAAPAAAAGgAAAB0AAAArAAAAJgAAAC8AAAANAAAAGgAAABUAAAAeAAAAIAAAADAAAAAyAAAAEAAAABIAAAAhAAAAHwAAACkAAAAsAAAANQAAAA8AAAAWAAAAHAAAACAAAAAeAAAAGAAAABIAAAA0AAAAMgAAACUAAAAhAAAAHgAAADEAAAAwAAAAFgAAABAAAAApAAAAIgAAABMAAAAmAAAAFQAAADYAAAAkAAAAMwAAACMAAAAuAAAALQAAADgAAAARAAAAGwAAABkAAAAkAAAAFAAAACIAAAATAAAANwAAACgAAAA2AAAAJQAAACcAAAA0AAAAOQAAABgAAAAXAAAAIAAAACYAAAB/AAAAIgAAADMAAAAdAAAALwAAABUAAAAnAAAAJQAAABkAAAAXAAAAOwAAADkAAAAtAAAAKAAAABsAAAAkAAAAFAAAADwAAAAuAAAANwAAACkAAAAxAAAANQAAAD0AAAAWAAAAIQAAAB8AAAAqAAAAOgAAACsAAAA+AAAAHAAAACwAAAAaAAAAKwAAAD4AAAAvAAAAQAAAABoAAAAqAAAAHQAAACwAAAA1AAAAOgAAAEEAAAAcAAAAHwAAACoAAAAtAAAAJwAAACMAAAAZAAAAPwAAADsAAAA4AAAALgAAADwAAAA4AAAARAAAABsAAAAoAAAAIwAAAC8AAAAmAAAAKwAAAB0AAABFAAAAMwAAAEAAAAAwAAAAMQAAAB4AAAAhAAAAQwAAAEIAAAAyAAAAMQAAAH8AAAA9AAAAQgAAACEAAAAwAAAAKQAAADIAAAAwAAAAIAAAAB4AAABGAAAAQwAAADQAAAAzAAAARQAAADYAAABHAAAAJgAAAC8AAAAiAAAANAAAADkAAABGAAAASgAAACAAAAAlAAAAMgAAADUAAAA9AAAAQQAAAEsAAAAfAAAAKQAAACwAAAA2AAAARwAAADcAAABJAAAAIgAAADMAAAAkAAAANwAAACgAAAA2AAAAJAAAAEgAAAA8AAAASQAAADgAAABEAAAAPwAAAE0AAAAjAAAALgAAAC0AAAA5AAAAOwAAAEoAAABOAAAAJQAAACcAAAA0AAAAOgAAAH8AAAA+AAAATAAAACwAAABBAAAAKgAAADsAAAA/AAAATgAAAE8AAAAnAAAALQAAADkAAAA8AAAASAAAAEQAAABQAAAAKAAAADcAAAAuAAAAPQAAADUAAAAxAAAAKQAAAFEAAABLAAAAQgAAAD4AAAArAAAAOgAAACoAAABSAAAAQAAAAEwAAAA/AAAAfwAAADgAAAAtAAAATwAAADsAAABNAAAAQAAAAC8AAAA+AAAAKwAAAFQAAABFAAAAUgAAAEEAAAA6AAAANQAAACwAAABWAAAATAAAAEsAAABCAAAAQwAAAFEAAABVAAAAMQAAADAAAAA9AAAAQwAAAEIAAAAyAAAAMAAAAFcAAABVAAAARgAAAEQAAAA4AAAAPAAAAC4AAABaAAAATQAAAFAAAABFAAAAMwAAAEAAAAAvAAAAWQAAAEcAAABUAAAARgAAAEMAAAA0AAAAMgAAAFMAAABXAAAASgAAAEcAAABZAAAASQAAAFsAAAAzAAAARQAAADYAAABIAAAAfwAAAEkAAAA3AAAAUAAAADwAAABYAAAASQAAAFsAAABIAAAAWAAAADYAAABHAAAANwAAAEoAAABOAAAAUwAAAFwAAAA0AAAAOQAAAEYAAABLAAAAQQAAAD0AAAA1AAAAXgAAAFYAAABRAAAATAAAAFYAAABSAAAAYAAAADoAAABBAAAAPgAAAE0AAAA/AAAARAAAADgAAABdAAAATwAAAFoAAABOAAAASgAAADsAAAA5AAAAXwAAAFwAAABPAAAATwAAAE4AAAA/AAAAOwAAAF0AAABfAAAATQAAAFAAAABEAAAASAAAADwAAABjAAAAWgAAAFgAAABRAAAAVQAAAF4AAABlAAAAPQAAAEIAAABLAAAAUgAAAGAAAABUAAAAYgAAAD4AAABMAAAAQAAAAFMAAAB/AAAASgAAAEYAAABkAAAAVwAAAFwAAABUAAAARQAAAFIAAABAAAAAYQAAAFkAAABiAAAAVQAAAFcAAABlAAAAZgAAAEIAAABDAAAAUQAAAFYAAABMAAAASwAAAEEAAABoAAAAYAAAAF4AAABXAAAAUwAAAGYAAABkAAAAQwAAAEYAAABVAAAAWAAAAEgAAABbAAAASQAAAGMAAABQAAAAaQAAAFkAAABhAAAAWwAAAGcAAABFAAAAVAAAAEcAAABaAAAATQAAAFAAAABEAAAAagAAAF0AAABjAAAAWwAAAEkAAABZAAAARwAAAGkAAABYAAAAZwAAAFwAAABTAAAATgAAAEoAAABsAAAAZAAAAF8AAABdAAAATwAAAFoAAABNAAAAbQAAAF8AAABqAAAAXgAAAFYAAABRAAAASwAAAGsAAABoAAAAZQAAAF8AAABcAAAATwAAAE4AAABtAAAAbAAAAF0AAABgAAAAaAAAAGIAAABuAAAATAAAAFYAAABSAAAAYQAAAH8AAABiAAAAVAAAAGcAAABZAAAAbwAAAGIAAABuAAAAYQAAAG8AAABSAAAAYAAAAFQAAABjAAAAUAAAAGkAAABYAAAAagAAAFoAAABxAAAAZAAAAGYAAABTAAAAVwAAAGwAAAByAAAAXAAAAGUAAABmAAAAawAAAHAAAABRAAAAVQAAAF4AAABmAAAAZQAAAFcAAABVAAAAcgAAAHAAAABkAAAAZwAAAFsAAABhAAAAWQAAAHQAAABpAAAAbwAAAGgAAABrAAAAbgAAAHMAAABWAAAAXgAAAGAAAABpAAAAWAAAAGcAAABbAAAAcQAAAGMAAAB0AAAAagAAAF0AAABjAAAAWgAAAHUAAABtAAAAcQAAAGsAAAB/AAAAZQAAAF4AAABzAAAAaAAAAHAAAABsAAAAZAAAAF8AAABcAAAAdgAAAHIAAABtAAAAbQAAAGwAAABdAAAAXwAAAHUAAAB2AAAAagAAAG4AAABiAAAAaAAAAGAAAAB3AAAAbwAAAHMAAABvAAAAYQAAAG4AAABiAAAAdAAAAGcAAAB3AAAAcAAAAGsAAABmAAAAZQAAAHgAAABzAAAAcgAAAHEAAABjAAAAdAAAAGkAAAB1AAAAagAAAHkAAAByAAAAcAAAAGQAAABmAAAAdgAAAHgAAABsAAAAcwAAAG4AAABrAAAAaAAAAHgAAAB3AAAAcAAAAHQAAABnAAAAdwAAAG8AAABxAAAAaQAAAHkAAAB1AAAAfwAAAG0AAAB2AAAAcQAAAHkAAABqAAAAdgAAAHgAAABsAAAAcgAAAHUAAAB5AAAAbQAAAHcAAABvAAAAcwAAAG4AAAB5AAAAdAAAAHgAAAB4AAAAcwAAAHIAAABwAAAAeQAAAHcAAAB2AAAAeQAAAHQAAAB4AAAAdwAAAHUAAABxAAAAdgAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAEAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAQAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAADAAAABQAAAAEAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAgAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAABQAAAAUAAAAAAAAAAAAAAP////8BAAAAAAAAAAMAAAAEAAAAAgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAQAAAP//////////AQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAIAAAAAAAAAAAAAAAEAAAACAAAABgAAAAQAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAoAAAACAAAAAAAAAAAAAAABAAAAAQAAAAUAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAAAAAAAAAAAAAEAAAADAAAABwAAAAYAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAHAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAAAAAAAAAAAAQAAAAAAAAAJAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAAAAAAAAAAAAQAAAAQAAAAIAAAACgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAAAAAAAAAAABAAAACwAAAA8AAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA4AAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAgAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAAAAAAAAAAABAAAADAAAABAAAAAMAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAEAAAAKAAAAEwAAAAgAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAJAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAgAAAAAAAAAAAAAAAQAAAA0AAAARAAAADQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABMAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAAAAAAAAAAAAAEAAAAOAAAAEgAAAA8AAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAAAAAABAAAA//////////8TAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABIAAAAAAAAAGAAAAAAAAAAhAAAAAAAAAB4AAAAAAAAAIAAAAAMAAAAxAAAAAQAAADAAAAADAAAAMgAAAAMAAAAIAAAAAAAAAAUAAAAFAAAACgAAAAUAAAAWAAAAAAAAABAAAAAAAAAAEgAAAAAAAAApAAAAAQAAACEAAAAAAAAAHgAAAAAAAAAEAAAAAAAAAAAAAAAFAAAAAgAAAAUAAAAPAAAAAQAAAAgAAAAAAAAABQAAAAUAAAAfAAAAAQAAABYAAAAAAAAAEAAAAAAAAAACAAAAAAAAAAYAAAAAAAAADgAAAAAAAAAKAAAAAAAAAAsAAAAAAAAAEQAAAAMAAAAYAAAAAQAAABcAAAADAAAAGQAAAAMAAAAAAAAAAAAAAAEAAAAFAAAACQAAAAUAAAAFAAAAAAAAAAIAAAAAAAAABgAAAAAAAAASAAAAAQAAAAoAAAAAAAAACwAAAAAAAAAEAAAAAQAAAAMAAAAFAAAABwAAAAUAAAAIAAAAAQAAAAAAAAAAAAAAAQAAAAUAAAAQAAAAAQAAAAUAAAAAAAAAAgAAAAAAAAAHAAAAAAAAABUAAAAAAAAAJgAAAAAAAAAJAAAAAAAAABMAAAAAAAAAIgAAAAMAAAAOAAAAAQAAABQAAAADAAAAJAAAAAMAAAADAAAAAAAAAA0AAAAFAAAAHQAAAAUAAAABAAAAAAAAAAcAAAAAAAAAFQAAAAAAAAAGAAAAAQAAAAkAAAAAAAAAEwAAAAAAAAAEAAAAAgAAAAwAAAAFAAAAGgAAAAUAAAAAAAAAAQAAAAMAAAAAAAAADQAAAAUAAAACAAAAAQAAAAEAAAAAAAAABwAAAAAAAAAaAAAAAAAAACoAAAAAAAAAOgAAAAAAAAAdAAAAAAAAACsAAAAAAAAAPgAAAAMAAAAmAAAAAQAAAC8AAAADAAAAQAAAAAMAAAAMAAAAAAAAABwAAAAFAAAALAAAAAUAAAANAAAAAAAAABoAAAAAAAAAKgAAAAAAAAAVAAAAAQAAAB0AAAAAAAAAKwAAAAAAAAAEAAAAAwAAAA8AAAAFAAAAHwAAAAUAAAADAAAAAQAAAAwAAAAAAAAAHAAAAAUAAAAHAAAAAQAAAA0AAAAAAAAAGgAAAAAAAAAfAAAAAAAAACkAAAAAAAAAMQAAAAAAAAAsAAAAAAAAADUAAAAAAAAAPQAAAAMAAAA6AAAAAQAAAEEAAAADAAAASwAAAAMAAAAPAAAAAAAAABYAAAAFAAAAIQAAAAUAAAAcAAAAAAAAAB8AAAAAAAAAKQAAAAAAAAAqAAAAAQAAACwAAAAAAAAANQAAAAAAAAAEAAAABAAAAAgAAAAFAAAAEAAAAAUAAAAMAAAAAQAAAA8AAAAAAAAAFgAAAAUAAAAaAAAAAQAAABwAAAAAAAAAHwAAAAAAAAAyAAAAAAAAADAAAAAAAAAAMQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAIQAAAAMAAAAYAAAAAwAAABIAAAADAAAAEAAAAAMAAABGAAAAAAAAAEMAAAAAAAAAQgAAAAMAAAA0AAAAAwAAADIAAAAAAAAAMAAAAAAAAAAlAAAAAwAAACAAAAAAAAAAHgAAAAMAAABTAAAAAAAAAFcAAAADAAAAVQAAAAMAAABKAAAAAwAAAEYAAAAAAAAAQwAAAAAAAAA5AAAAAQAAADQAAAADAAAAMgAAAAAAAAAZAAAAAAAAABcAAAAAAAAAGAAAAAMAAAARAAAAAAAAAAsAAAADAAAACgAAAAMAAAAOAAAAAwAAAAYAAAADAAAAAgAAAAMAAAAtAAAAAAAAACcAAAAAAAAAJQAAAAMAAAAjAAAAAwAAABkAAAAAAAAAFwAAAAAAAAAbAAAAAwAAABEAAAAAAAAACwAAAAMAAAA/AAAAAAAAADsAAAADAAAAOQAAAAMAAAA4AAAAAwAAAC0AAAAAAAAAJwAAAAAAAAAuAAAAAwAAACMAAAADAAAAGQAAAAAAAAAkAAAAAAAAABQAAAAAAAAADgAAAAMAAAAiAAAAAAAAABMAAAADAAAACQAAAAMAAAAmAAAAAwAAABUAAAADAAAABwAAAAMAAAA3AAAAAAAAACgAAAAAAAAAGwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAFAAAAAAAAAAzAAAAAwAAACIAAAAAAAAAEwAAAAMAAABIAAAAAAAAADwAAAADAAAALgAAAAMAAABJAAAAAwAAADcAAAAAAAAAKAAAAAAAAABHAAAAAwAAADYAAAADAAAAJAAAAAAAAABAAAAAAAAAAC8AAAAAAAAAJgAAAAMAAAA+AAAAAAAAACsAAAADAAAAHQAAAAMAAAA6AAAAAwAAACoAAAADAAAAGgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAMwAAAAMAAABSAAAAAwAAAEAAAAAAAAAALwAAAAAAAABMAAAAAwAAAD4AAAAAAAAAKwAAAAMAAABhAAAAAAAAAFkAAAADAAAARwAAAAMAAABiAAAAAwAAAFQAAAAAAAAARQAAAAAAAABgAAAAAwAAAFIAAAADAAAAQAAAAAAAAABLAAAAAAAAAEEAAAAAAAAAOgAAAAMAAAA9AAAAAAAAADUAAAADAAAALAAAAAMAAAAxAAAAAwAAACkAAAADAAAAHwAAAAMAAABeAAAAAAAAAFYAAAAAAAAATAAAAAMAAABRAAAAAwAAAEsAAAAAAAAAQQAAAAAAAABCAAAAAwAAAD0AAAAAAAAANQAAAAMAAABrAAAAAAAAAGgAAAADAAAAYAAAAAMAAABlAAAAAwAAAF4AAAAAAAAAVgAAAAAAAABVAAAAAwAAAFEAAAADAAAASwAAAAAAAAA5AAAAAAAAADsAAAAAAAAAPwAAAAMAAABKAAAAAAAAAE4AAAADAAAATwAAAAMAAABTAAAAAwAAAFwAAAADAAAAXwAAAAMAAAAlAAAAAAAAACcAAAADAAAALQAAAAMAAAA0AAAAAAAAADkAAAAAAAAAOwAAAAAAAABGAAAAAwAAAEoAAAAAAAAATgAAAAMAAAAYAAAAAAAAABcAAAADAAAAGQAAAAMAAAAgAAAAAwAAACUAAAAAAAAAJwAAAAMAAAAyAAAAAwAAADQAAAAAAAAAOQAAAAAAAAAuAAAAAAAAADwAAAAAAAAASAAAAAMAAAA4AAAAAAAAAEQAAAADAAAAUAAAAAMAAAA/AAAAAwAAAE0AAAADAAAAWgAAAAMAAAAbAAAAAAAAACgAAAADAAAANwAAAAMAAAAjAAAAAAAAAC4AAAAAAAAAPAAAAAAAAAAtAAAAAwAAADgAAAAAAAAARAAAAAMAAAAOAAAAAAAAABQAAAADAAAAJAAAAAMAAAARAAAAAwAAABsAAAAAAAAAKAAAAAMAAAAZAAAAAwAAACMAAAAAAAAALgAAAAAAAABHAAAAAAAAAFkAAAAAAAAAYQAAAAMAAABJAAAAAAAAAFsAAAADAAAAZwAAAAMAAABIAAAAAwAAAFgAAAADAAAAaQAAAAMAAAAzAAAAAAAAAEUAAAADAAAAVAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAWQAAAAAAAAA3AAAAAwAAAEkAAAAAAAAAWwAAAAMAAAAmAAAAAAAAAC8AAAADAAAAQAAAAAMAAAAiAAAAAwAAADMAAAAAAAAARQAAAAMAAAAkAAAAAwAAADYAAAAAAAAARwAAAAAAAABgAAAAAAAAAGgAAAAAAAAAawAAAAMAAABiAAAAAAAAAG4AAAADAAAAcwAAAAMAAABhAAAAAwAAAG8AAAADAAAAdwAAAAMAAABMAAAAAAAAAFYAAAADAAAAXgAAAAMAAABSAAAAAAAAAGAAAAAAAAAAaAAAAAAAAABUAAAAAwAAAGIAAAAAAAAAbgAAAAMAAAA6AAAAAAAAAEEAAAADAAAASwAAAAMAAAA+AAAAAwAAAEwAAAAAAAAAVgAAAAMAAABAAAAAAwAAAFIAAAAAAAAAYAAAAAAAAABVAAAAAAAAAFcAAAAAAAAAUwAAAAMAAABlAAAAAAAAAGYAAAADAAAAZAAAAAMAAABrAAAAAwAAAHAAAAADAAAAcgAAAAMAAABCAAAAAAAAAEMAAAADAAAARgAAAAMAAABRAAAAAAAAAFUAAAAAAAAAVwAAAAAAAABeAAAAAwAAAGUAAAAAAAAAZgAAAAMAAAAxAAAAAAAAADAAAAADAAAAMgAAAAMAAAA9AAAAAwAAAEIAAAAAAAAAQwAAAAMAAABLAAAAAwAAAFEAAAAAAAAAVQAAAAAAAABfAAAAAAAAAFwAAAAAAAAAUwAAAAAAAABPAAAAAAAAAE4AAAAAAAAASgAAAAMAAAA/AAAAAQAAADsAAAADAAAAOQAAAAMAAABtAAAAAAAAAGwAAAAAAAAAZAAAAAUAAABdAAAAAQAAAF8AAAAAAAAAXAAAAAAAAABNAAAAAQAAAE8AAAAAAAAATgAAAAAAAAB1AAAABAAAAHYAAAAFAAAAcgAAAAUAAABqAAAAAQAAAG0AAAAAAAAAbAAAAAAAAABaAAAAAQAAAF0AAAABAAAAXwAAAAAAAABaAAAAAAAAAE0AAAAAAAAAPwAAAAAAAABQAAAAAAAAAEQAAAAAAAAAOAAAAAMAAABIAAAAAQAAADwAAAADAAAALgAAAAMAAABqAAAAAAAAAF0AAAAAAAAATwAAAAUAAABjAAAAAQAAAFoAAAAAAAAATQAAAAAAAABYAAAAAQAAAFAAAAAAAAAARAAAAAAAAAB1AAAAAwAAAG0AAAAFAAAAXwAAAAUAAABxAAAAAQAAAGoAAAAAAAAAXQAAAAAAAABpAAAAAQAAAGMAAAABAAAAWgAAAAAAAABpAAAAAAAAAFgAAAAAAAAASAAAAAAAAABnAAAAAAAAAFsAAAAAAAAASQAAAAMAAABhAAAAAQAAAFkAAAADAAAARwAAAAMAAABxAAAAAAAAAGMAAAAAAAAAUAAAAAUAAAB0AAAAAQAAAGkAAAAAAAAAWAAAAAAAAABvAAAAAQAAAGcAAAAAAAAAWwAAAAAAAAB1AAAAAgAAAGoAAAAFAAAAWgAAAAUAAAB5AAAAAQAAAHEAAAAAAAAAYwAAAAAAAAB3AAAAAQAAAHQAAAABAAAAaQAAAAAAAAB3AAAAAAAAAG8AAAAAAAAAYQAAAAAAAABzAAAAAAAAAG4AAAAAAAAAYgAAAAMAAABrAAAAAQAAAGgAAAADAAAAYAAAAAMAAAB5AAAAAAAAAHQAAAAAAAAAZwAAAAUAAAB4AAAAAQAAAHcAAAAAAAAAbwAAAAAAAABwAAAAAQAAAHMAAAAAAAAAbgAAAAAAAAB1AAAAAQAAAHEAAAAFAAAAaQAAAAUAAAB2AAAAAQAAAHkAAAAAAAAAdAAAAAAAAAByAAAAAQAAAHgAAAABAAAAdwAAAAAAAAByAAAAAAAAAHAAAAAAAAAAawAAAAAAAABkAAAAAAAAAGYAAAAAAAAAZQAAAAMAAABTAAAAAQAAAFcAAAADAAAAVQAAAAMAAAB2AAAAAAAAAHgAAAAAAAAAcwAAAAUAAABsAAAAAQAAAHIAAAAAAAAAcAAAAAAAAABcAAAAAQAAAGQAAAAAAAAAZgAAAAAAAAB1AAAAAAAAAHkAAAAFAAAAdwAAAAUAAABtAAAAAQAAAHYAAAAAAAAAeAAAAAAAAABfAAAAAQAAAGwAAAABAAAAcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAB+ogX28rbpPxqumpJv+fM/165tC4ns9D+XaEnTqUsEQFrOtNlC4PA/3U+0XG6P9b9TdUUBxTTjP4PUp8ex1ty/B1rD/EN43z+lcDi6LLrZP/a45NWEHMY/oJ5ijLDZ+j/xw3rjxWPjP2B8A46ioQdAotff3wla2z+FMSpA1jj+v6b5Y1mtPbS/cIu8K0F457/2esiyJpDNv98k5Ts2NeA/pvljWa09tD88ClUJ60MDQPZ6yLImkM0/4ONKxa0UBcD2uOTVhBzGv5G7JRxGave/8cN648Vj47+HCwtkjAXIv6LX398JWtu/qyheaCAL9D9TdUUBxTTjv4gyTxslhwVAB1rD/EN4378EH/28teoFwH6iBfbytum/F6ztFYdK/r/Xrm0Liez0vwcS6wNGWeO/Ws602ULg8L9TCtRLiLT8P8pi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAMuhRbbsNlBBYqHW9OmHIkF9XBuqnS31QAK37uYhNMhAOSo3UUupm0DC+6pc6JxvQHV9eseEEEJAzURsCyqlFEB8BQ4NMJjnPyy3tBoS97o/xawXQznRjj89J2K2CZxhP6vX43RIIDQ/S8isgygEBz+LvFHQkmzaPjFFFO7wMq4+AADMLkTtjkIAAOgkJqxhQgAAU7B0MjRCAADwpBcVB0IAAACYP2HaQQAAAIn/Ja5BzczM4Eg6gUHNzMxMU7BTQTMzMzNfgCZBAAAAAEi3+UAAAAAAwGPNQDMzMzMzy6BAmpmZmZkxc0AzMzMzM/NFQDMzMzMzMxlAzczMzMzM7D+ygXSx2U6RQKimJOvQKnpA23hmONTHY0A/AGcxyudNQNb3K647mzZA+S56rrwWIUAm4kUQ+9UJQKre9hGzh/M/BLvoy9WG3T+LmqMf8VHGP2m3nYNV37A/gbFHcyeCmT+cBPWBckiDP61tZACjKW0/q2RbYVUYVj8uDypVyLNAP6jGS5cA5zBBwcqhBdCNGUEGEhQ/JVEDQT6WPnRbNO1AB/AWSJgT1kDfUWNCNLDAQNk+5C33OqlAchWL34QSk0DKvtDIrNV8QNF0G3kFzGVASSeWhBl6UED+/0mNGuk4QGjA/dm/1CJALPLPMql6DEDSHoDrwpP1P2jouzWST+A/egAAAAAAAABKAwAAAAAAAPoWAAAAAAAAyqAAAAAAAAB6ZQQAAAAAAErGHgAAAAAA+mvXAAAAAADK8+MFAAAAAHqqOykAAAAASqmhIAEAAAD6oGvkBwAAAMpm8T43AAAAes+ZuIIBAABKrDQMkwoAAPq1cFUFSgAAyvkUViUGAgAAAAAAAwAAAAYAAAACAAAABQAAAAEAAAAEAAAAAAAAAAAAAAAFAAAAAwAAAAEAAAAGAAAABAAAAAIAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAA/////wAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAP////8AAAAAAAAAAAEAAAABAAAAAAAAAAAAAAD/////AAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAAAAAAABAAEAAAEBAAAAAAABAAAAAQAAAAEAAQAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAAYWxnb3MuYwBfcG9seWZpbGxJbnRlcm5hbABhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0dlb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9HZW9Cb3VuZGFyeQBwb2x5Z29uLT5uZXh0ID09IE5VTEwAbGlua2VkR2VvLmMAYWRkTmV3TGlua2VkUG9seWdvbgBuZXh0ICE9IE5VTEwAbG9vcCAhPSBOVUxMAGFkZE5ld0xpbmtlZExvb3AAcG9seWdvbi0+Zmlyc3QgPT0gTlVMTABhZGRMaW5rZWRMb29wAGNvb3JkICE9IE5VTEwAYWRkTGlua2VkQ29vcmQAbG9vcC0+Zmlyc3QgPT0gTlVMTABpbm5lckxvb3BzICE9IE5VTEwAbm9ybWFsaXplTXVsdGlQb2x5Z29uAGJib3hlcyAhPSBOVUxMAGNhbmRpZGF0ZXMgIT0gTlVMTABmaW5kUG9seWdvbkZvckhvbGUAY2FuZGlkYXRlQkJveGVzICE9IE5VTEwAcmV2RGlyICE9IElOVkFMSURfRElHSVQAbG9jYWxpai5jAGgzVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAcGVudGFnb25Sb3RhdGlvbnMgPj0gMABkaXJlY3Rpb25Sb3RhdGlvbnMgPj0gMABiYXNlQ2VsbCA9PSBvcmlnaW5CYXNlQ2VsbABiYXNlQ2VsbCAhPSBJTlZBTElEX0JBU0VfQ0VMTABsb2NhbElqa1RvSDMAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAd2l0aGluUGVudGFnb25Sb3RhdGlvbnMgPj0gMABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";function Y(A){return A}function O(A){return A.replace(/\b__Z[\w\d_]+/g,(function(A){return A===A?A:A+" ["+A+"]"}))}function j(){var A=new Error;if(!A.stack){try{throw new Error(0)}catch(e){A=e}if(!A.stack)return"(no stack trace available)"}return A.stack.toString()}function N(){return p.length}function Z(A){try{var e=new ArrayBuffer(A);if(e.byteLength!=A)return;return new Int8Array(e).set(p),$(e),Q(e),1}catch(A){}}var W="function"==typeof atob?atob:function(A){var e,r,t,i,n,o,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="",s=0;A=A.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{e=a.indexOf(A.charAt(s++))<<2|(i=a.indexOf(A.charAt(s++)))>>4,r=(15&i)<<4|(n=a.indexOf(A.charAt(s++)))>>2,t=(3&n)<<6|(o=a.indexOf(A.charAt(s++))),f+=String.fromCharCode(e),64!==n&&(f+=String.fromCharCode(r)),64!==o&&(f+=String.fromCharCode(t))}while(s>2]=A,i[a+4>>2]=e,(a=0!=(0|n))&&(i[n>>2]=0),0|UA(A,e))return I=o,0|(d=1);i[d>>2]=0;A:do{if((0|r)>=1)if(a)for(l=0,h=1,c=1,f=0,a=A;;){if(!(f|l)){if(0==(0|(a=0|U(a,e,4,d)))&0==(0|(e=0|M()))){a=2;break A}if(0|UA(a,e)){a=1;break A}}if(0==(0|(a=0|U(a,e,0|i[16+(l<<2)>>2],d)))&0==(0|(e=0|M()))){a=2;break A}if(i[(A=t+(c<<3)|0)>>2]=a,i[A+4>>2]=e,i[n+(c<<2)>>2]=h,A=(0|(f=f+1|0))==(0|h),u=6==(0|(s=l+1|0)),0|UA(a,e)){a=1;break A}if((0|(h=h+(u&A&1)|0))>(0|r)){a=0;break}l=A?u?0:s:l,c=c+1|0,f=A?0:f}else for(l=0,h=1,c=1,f=0,a=A;;){if(!(f|l)){if(0==(0|(a=0|U(a,e,4,d)))&0==(0|(e=0|M()))){a=2;break A}if(0|UA(a,e)){a=1;break A}}if(0==(0|(a=0|U(a,e,0|i[16+(l<<2)>>2],d)))&0==(0|(e=0|M()))){a=2;break A}if(i[(A=t+(c<<3)|0)>>2]=a,i[A+4>>2]=e,A=(0|(f=f+1|0))==(0|h),u=6==(0|(s=l+1|0)),0|UA(a,e)){a=1;break A}if((0|(h=h+(u&A&1)|0))>(0|r)){a=0;break}l=A?u?0:s:l,c=c+1|0,f=A?0:f}else a=0}while(0);return I=o,0|(d=a)}function P(A,e,r,t,n,o,a){r|=0,t|=0,n|=0,o|=0,a|=0;var f,s,u=0,l=0,h=0,c=0,d=0;if(s=I,I=I+16|0,f=s,0==(0|(A|=0))&0==(0|(e|=0)))I=s;else{if(u=0|Me(0|A,0|e,0|o,((0|o)<0)<<31>>31|0),M(),!(0==(0|(d=0|i[(c=l=t+(u<<3)|0)>>2]))&0==(0|(c=0|i[c+4>>2]))|(h=(0|d)==(0|A)&(0|c)==(0|e))))do{h=(0|(c=0|i[(d=l=t+((u=(u+1|0)%(0|o)|0)<<3)|0)>>2]))==(0|A)&(0|(d=0|i[d+4>>2]))==(0|e)}while(!(0==(0|c)&0==(0|d)|h));u=n+(u<<2)|0,h&&(0|i[u>>2])<=(0|a)||(i[(d=l)>>2]=A,i[d+4>>2]=e,i[u>>2]=a,(0|a)>=(0|r)||(d=a+1|0,i[f>>2]=0,P(c=0|U(A,e,2,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,3,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,1,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,5,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,4,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,6,f),0|M(),r,t,n,o,d))),I=s}}function U(A,e,r,t){A|=0,e|=0,r|=0;var n,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0;if((0|i[(t|=0)>>2])>0){a=0;do{r=0|fA(r),a=a+1|0}while((0|a)<(0|i[t>>2]))}n=0|Qe(0|A,0|e,45),M(),o=127&n,f=0|GA(A,e),a=0|Qe(0|A,0|e,52),M(),a&=15;A:do{if(a)for(;;){if(h=0|Qe(0|A,0|e,0|(l=3*(15-a|0)|0)),M(),h&=7,c=0==(0|RA(a)),a=a+-1|0,u=0|ye(7,0,0|l),e&=~(0|M()),A=(l=0|ye(0|i[(c?464:48)+(28*h|0)+(r<<2)>>2],0,0|l))|A&~u,e|=0|M(),!(r=0|i[(c?672:256)+(28*h|0)+(r<<2)>>2])){r=0;break A}if(!a){s=6;break}}else s=6}while(0);6==(0|s)&&(A|=h=0|ye(0|(c=0|i[880+(28*o|0)+(r<<2)>>2]),0,45),e=0|M()|-1040385&e,r=0|i[4304+(28*o|0)+(r<<2)>>2],127==(127&c|0)&&(c=0|ye(0|i[880+(28*o|0)+20>>2],0,45),e=0|M()|-1040385&e,r=0|i[4304+(28*o|0)+20>>2],A=0|TA(c|A,e),e=0|M(),i[t>>2]=1+(0|i[t>>2]))),s=0|Qe(0|A,0|e,45),M(),s&=127;A:do{if(0|S(s)){e:do{if(1==(0|GA(A,e))){if((0|o)!=(0|s)){if(0|R(s,0|i[7728+(28*o|0)>>2])){A=0|HA(A,e),f=1,e=0|M();break}A=0|TA(A,e),f=1,e=0|M();break}switch(0|f){case 5:A=0|HA(A,e),e=0|M(),i[t>>2]=5+(0|i[t>>2]),f=0;break e;case 3:A=0|TA(A,e),e=0|M(),i[t>>2]=1+(0|i[t>>2]),f=0;break e;default:return c=0,k(0|(h=0)),0|c}}else f=0}while(0);if((0|r)>0){a=0;do{A=0|SA(A,e),e=0|M(),a=a+1|0}while((0|a)!=(0|r))}if((0|o)!=(0|s)){if(!(0|T(s))){if(0!=(0|f)|5!=(0|GA(A,e)))break;i[t>>2]=1+(0|i[t>>2]);break}switch(127&n){case 8:case 118:break A}3!=(0|GA(A,e))&&(i[t>>2]=1+(0|i[t>>2]))}}else if((0|r)>0){a=0;do{A=0|TA(A,e),e=0|M(),a=a+1|0}while((0|a)!=(0|r))}}while(0);return i[t>>2]=((0|i[t>>2])+r|0)%6|0,c=A,k(0|(h=e)),0|c}function G(A,e,r,t,o,a){e|=0,r|=0,t|=0,o|=0,a|=0;var f,s,u,l,h,c,d,g,w,p=0,B=0,b=0,v=0,m=0,k=0,Q=0,y=0,E=0,x=0,D=0,_=0,F=0,C=0;if(w=I,I=I+48|0,c=w+32|0,d=w+16|0,g=w,(0|(p=0|i[(A|=0)>>2]))<=0)return I=w,0|(_=0);f=A+4|0,s=c+8|0,u=d+8|0,l=g+8|0,h=((0|e)<0)<<31>>31,D=0;A:for(;;){E=(B=0|i[f>>2])+(D<<4)|0,i[c>>2]=i[E>>2],i[c+4>>2]=i[E+4>>2],i[c+8>>2]=i[E+8>>2],i[c+12>>2]=i[E+12>>2],(0|D)==(p+-1|0)?(i[d>>2]=i[B>>2],i[d+4>>2]=i[B+4>>2],i[d+8>>2]=i[B+8>>2],i[d+12>>2]=i[B+12>>2]):(E=B+(D+1<<4)|0,i[d>>2]=i[E>>2],i[d+4>>2]=i[E+4>>2],i[d+8>>2]=i[E+8>>2],i[d+12>>2]=i[E+12>>2]),E=0|N(c,d,r);e:do{if((0|E)>0){x=+(0|E),y=0;r:for(;;){C=+(E-y|0),F=+(0|y),n[g>>3]=+n[c>>3]*C/x+ +n[d>>3]*F/x,n[l>>3]=+n[s>>3]*C/x+ +n[u>>3]*F/x,B=0|Me(0|(k=0|LA(g,r)),0|(Q=0|M()),0|e,0|h),M(),v=0|i[(b=p=a+(B<<3)|0)>>2],b=0|i[b+4>>2];t:do{if(0==(0|v)&0==(0|b))_=14;else for(m=0;;){if((0|m)>(0|e)){p=1;break t}if((0|v)==(0|k)&(0|b)==(0|Q)){p=7;break t}if(0==(0|(v=0|i[(b=p=a+((B=(B+1|0)%(0|e)|0)<<3)|0)>>2]))&0==(0|(b=0|i[b+4>>2]))){_=14;break}m=m+1|0}}while(0);switch(14==(0|_)&&(_=0,0==(0|k)&0==(0|Q)?p=7:(i[p>>2]=k,i[p+4>>2]=Q,p=0|i[t>>2],i[(m=o+(p<<3)|0)>>2]=k,i[m+4>>2]=Q,i[t>>2]=p+1,p=0)),7&p){case 7:case 0:break;default:break r}if((0|E)<=(0|(y=y+1|0))){_=8;break e}}if(0|p){p=-1,_=20;break A}}else _=8}while(0);if(8==(0|_)&&(_=0),(0|(D=D+1|0))>=(0|(p=0|i[A>>2]))){p=0,_=20;break}}return 20==(0|_)?(I=w,0|p):0}function S(A){return 0|i[7728+(28*(A|=0)|0)+16>>2]}function T(A){return 4==(0|(A|=0))|117==(0|A)|0}function V(A){return 0|i[11152+(216*(0|i[(A|=0)>>2])|0)+(72*(0|i[A+4>>2])|0)+(24*(0|i[A+8>>2])|0)+(i[A+12>>2]<<3)>>2]}function H(A){return 0|i[11152+(216*(0|i[(A|=0)>>2])|0)+(72*(0|i[A+4>>2])|0)+(24*(0|i[A+8>>2])|0)+(i[A+12>>2]<<3)+4>>2]}function R(A,e){return e|=0,(0|i[7728+(28*(A|=0)|0)+20>>2])==(0|e)?0|(e=1):0|(e=(0|i[7728+(28*A|0)+24>>2])==(0|e))}function L(A,e){return 0|i[880+(28*(A|=0)|0)+((e|=0)<<2)>>2]}function z(A,e){return e|=0,(0|i[880+(28*(A|=0)|0)>>2])==(0|e)?0|(e=0):(0|i[880+(28*A|0)+4>>2])==(0|e)?0|(e=1):(0|i[880+(28*A|0)+8>>2])==(0|e)?0|(e=2):(0|i[880+(28*A|0)+12>>2])==(0|e)?0|(e=3):(0|i[880+(28*A|0)+16>>2])==(0|e)?0|(e=4):(0|i[880+(28*A|0)+20>>2])==(0|e)?0|(e=5):0|((0|i[880+(28*A|0)+24>>2])==(0|e)?6:7)}function Y(A){return+n[(A|=0)+16>>3]<+n[A+24>>3]|0}function O(A,e){A|=0;var r,t,i=0;return(i=+n[(e|=0)>>3])>=+n[A+8>>3]&&i<=+n[A>>3]?(r=+n[A+16>>3],i=+n[A+24>>3],e=(t=+n[e+8>>3])>=i,A=t<=r&1,r>2]=0,l=l+4|0}while((0|l)<(0|h));return NA(e,o),OA(h=0|i[(l=o)>>2],l=0|i[l+4>>2],r),jA(h,l,t),s=+DA(r,t+8|0),n[r>>3]=+n[A>>3],n[(l=r+8|0)>>3]=+n[A+16>>3],n[t>>3]=+n[A+8>>3],n[(h=t+8|0)>>3]=+n[A+24>>3],u=+DA(r,t),h=~~+B(+u*u/+Ee(+ +f(+(+n[l>>3]-+n[h>>3])/(+n[r>>3]-+n[t>>3])),3)/(s*(2.59807621135*s)*.8)),I=a,0|(0==(0|h)?1:h)}function N(A,e,r){A|=0,e|=0,r|=0;var t,n,o,a,f,s=0,u=0;a=I,I=I+288|0,t=a+264|0,n=a+96|0,u=(s=o=a)+96|0;do{i[s>>2]=0,s=s+4|0}while((0|s)<(0|u));return NA(r,o),OA(s=0|i[(u=o)>>2],u=0|i[u+4>>2],t),jA(s,u,n),f=+DA(t,n+8|0),u=~~+B(+ +DA(A,e)/(2*f)),I=a,0|(0==(0|u)?1:u)}function Z(A,e,r,t){e|=0,r|=0,t|=0,i[(A|=0)>>2]=e,i[A+4>>2]=r,i[A+8>>2]=t}function W(A,e){A|=0;var r,t,o,a,s=0,u=0,l=0,h=0,c=0,d=0,g=0;i[(a=(e|=0)+8|0)>>2]=0,t=+n[A>>3],h=+f(+t),o=+n[A+8>>3],h+=.5*(c=+f(+o)/.8660254037844386),h-=+(0|(s=~~h)),c-=+(0|(A=~~c));do{if(h<.5){if(h<.3333333333333333){if(i[e>>2]=s,c<.5*(h+1)){i[e+4>>2]=A;break}A=A+1|0,i[e+4>>2]=A;break}if(A=(1&!(c<(g=1-h)))+A|0,i[e+4>>2]=A,g<=c&c<2*h){s=s+1|0,i[e>>2]=s;break}i[e>>2]=s;break}if(!(h<.6666666666666666)){if(s=s+1|0,i[e>>2]=s,c<.5*h){i[e+4>>2]=A;break}A=A+1|0,i[e+4>>2]=A;break}if(c<1-h){if(i[e+4>>2]=A,2*h-1>2]=s;break}}else A=A+1|0,i[e+4>>2]=A;s=s+1|0,i[e>>2]=s}while(0);do{if(t<0){if(1&A){s=~~(+(0|s)-(2*(+((d=0|ve(0|s,((0|s)<0)<<31>>31|0,0|(d=(A+1|0)/2|0),((0|d)<0)<<31>>31|0))>>>0)+4294967296*+(0|M()))+1)),i[e>>2]=s;break}s=~~(+(0|s)-2*(+((d=0|ve(0|s,((0|s)<0)<<31>>31|0,0|(d=(0|A)/2|0),((0|d)<0)<<31>>31|0))>>>0)+4294967296*+(0|M()))),i[e>>2]=s;break}}while(0);d=e+4|0,o<0&&(s=s-((1|A<<1)/2|0)|0,i[e>>2]=s,A=0-A|0,i[d>>2]=A),u=A-s|0,(0|s)<0?(l=0-s|0,i[d>>2]=u,i[a>>2]=l,i[e>>2]=0,A=u,s=0):l=0,(0|A)<0&&(s=s-A|0,i[e>>2]=s,l=l-A|0,i[a>>2]=l,i[d>>2]=0,A=0),r=s-l|0,u=A-l|0,(0|l)<0&&(i[e>>2]=r,i[d>>2]=u,i[a>>2]=0,A=u,s=r,l=0),(0|(u=(0|l)<(0|(u=(0|A)<(0|s)?A:s))?l:u))<=0||(i[e>>2]=s-u,i[d>>2]=A-u,i[a>>2]=l-u)}function J(A){var e,r=0,t=0,n=0,o=0,a=0;r=0|i[(A|=0)>>2],t=0|i[(e=A+4|0)>>2],(0|r)<0&&(t=t-r|0,i[e>>2]=t,i[(a=A+8|0)>>2]=(0|i[a>>2])-r,i[A>>2]=0,r=0),(0|t)<0?(r=r-t|0,i[A>>2]=r,o=(0|i[(a=A+8|0)>>2])-t|0,i[a>>2]=o,i[e>>2]=0,t=0):(a=o=A+8|0,o=0|i[o>>2]),(0|o)<0&&(r=r-o|0,i[A>>2]=r,t=t-o|0,i[e>>2]=t,i[a>>2]=0,o=0),(0|(n=(0|o)<(0|(n=(0|t)<(0|r)?t:r))?o:n))<=0||(i[A>>2]=r-n,i[e>>2]=t-n,i[a>>2]=o-n)}function K(A,e){e|=0;var r,t;t=0|i[(A|=0)+8>>2],r=+((0|i[A+4>>2])-t|0),n[e>>3]=+((0|i[A>>2])-t|0)-.5*r,n[e+8>>3]=.8660254037844386*r}function X(A,e,r){A|=0,e|=0,i[(r|=0)>>2]=(0|i[e>>2])+(0|i[A>>2]),i[r+4>>2]=(0|i[e+4>>2])+(0|i[A+4>>2]),i[r+8>>2]=(0|i[e+8>>2])+(0|i[A+8>>2])}function q(A,e,r){A|=0,e|=0,i[(r|=0)>>2]=(0|i[A>>2])-(0|i[e>>2]),i[r+4>>2]=(0|i[A+4>>2])-(0|i[e+4>>2]),i[r+8>>2]=(0|i[A+8>>2])-(0|i[e+8>>2])}function $(A,e){e|=0;var r,t=0;t=0|b(0|i[(A|=0)>>2],e),i[A>>2]=t,r=0|b(0|i[(t=A+4|0)>>2],e),i[t>>2]=r,e=0|b(0|i[(A=A+8|0)>>2],e),i[A>>2]=e}function AA(A){var e,r,t=0,n=0,o=0,a=0,f=0;f=(0|(r=0|i[(A|=0)>>2]))<0,A=(A=(n=(0|(a=((e=(0|(o=(0|i[A+4>>2])-(f?r:0)|0))<0)?0-o|0:0)+((0|i[A+8>>2])-(f?r:0))|0))<0)?0:a)-((o=(0|(n=(0|A)<(0|(n=(0|(t=(e?0:o)-(n?a:0)|0))<(0|(a=(f?0:r)-(e?o:0)-(n?a:0)|0))?t:a))?A:n))>0)?n:0)|0,t=t-(o?n:0)|0;A:do{switch(a-(o?n:0)|0){case 0:switch(0|t){case 0:return 0|(f=0==(0|A)?0:1==(0|A)?1:7);case 1:return 0|(f=0==(0|A)?2:1==(0|A)?3:7);default:break A}case 1:switch(0|t){case 0:return 0|(f=0==(0|A)?4:1==(0|A)?5:7);case 1:if(A)break A;return 0|(A=6);default:break A}}}while(0);return 0|(f=7)}function eA(A){var e,r,t=0,n=0,o=0,a=0,f=0;n=0|i[(e=(A|=0)+8|0)>>2],o=0|we(+((3*(t=(0|i[A>>2])-n|0)|0)-(n=(0|i[(r=A+4|0)>>2])-n|0)|0)/7),i[A>>2]=o,t=0|we(+((n<<1)+t|0)/7),i[r>>2]=t,i[e>>2]=0,n=t-o|0,(0|o)<0?(f=0-o|0,i[r>>2]=n,i[e>>2]=f,i[A>>2]=0,t=n,o=0,n=f):n=0,(0|t)<0&&(o=o-t|0,i[A>>2]=o,n=n-t|0,i[e>>2]=n,i[r>>2]=0,t=0),f=o-n|0,a=t-n|0,(0|n)<0?(i[A>>2]=f,i[r>>2]=a,i[e>>2]=0,t=a,a=f,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|t)<(0|a)?t:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=t-o,i[e>>2]=n-o)}function rA(A){var e,r,t=0,n=0,o=0,a=0,f=0;n=0|i[(e=(A|=0)+8|0)>>2],o=0|we(+(((t=(0|i[A>>2])-n|0)<<1)+(n=(0|i[(r=A+4|0)>>2])-n|0)|0)/7),i[A>>2]=o,t=0|we(+((3*n|0)-t|0)/7),i[r>>2]=t,i[e>>2]=0,n=t-o|0,(0|o)<0?(f=0-o|0,i[r>>2]=n,i[e>>2]=f,i[A>>2]=0,t=n,o=0,n=f):n=0,(0|t)<0&&(o=o-t|0,i[A>>2]=o,n=n-t|0,i[e>>2]=n,i[r>>2]=0,t=0),f=o-n|0,a=t-n|0,(0|n)<0?(i[A>>2]=f,i[r>>2]=a,i[e>>2]=0,t=a,a=f,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|t)<(0|a)?t:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=t-o,i[e>>2]=n-o)}function tA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],o=0|i[(r=A+4|0)>>2],a=0|i[(t=A+8|0)>>2],f=o+(3*n|0)|0,i[A>>2]=f,o=a+(3*o|0)|0,i[r>>2]=o,n=(3*a|0)+n|0,i[t>>2]=n,a=o-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=a,i[t>>2]=n,i[A>>2]=0,o=a,a=0):a=f,(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function iA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=(3*(n=0|i[(r=A+4|0)>>2])|0)+f|0,f=(o=0|i[(t=A+8|0)>>2])+(3*f|0)|0,i[A>>2]=f,i[r>>2]=a,n=(3*o|0)+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,f=0):o=a,(0|o)<0&&(f=f-o|0,i[A>>2]=f,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=f-n|0,a=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=a,i[t>>2]=0,f=e,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|a)<(0|f)?a:f))?n:o))<=0||(i[A>>2]=f-o,i[r>>2]=a-o,i[t>>2]=n-o)}function nA(A,e){A|=0;var r,t,n,o=0,a=0,f=0;((e|=0)+-1|0)>>>0>=6||(f=(0|i[15472+(12*e|0)>>2])+(0|i[A>>2])|0,i[A>>2]=f,n=A+4|0,a=(0|i[15472+(12*e|0)+4>>2])+(0|i[n>>2])|0,i[n>>2]=a,t=A+8|0,e=(0|i[15472+(12*e|0)+8>>2])+(0|i[t>>2])|0,i[t>>2]=e,o=a-f|0,(0|f)<0?(e=e-f|0,i[n>>2]=o,i[t>>2]=e,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,e=e-o|0,i[t>>2]=e,i[n>>2]=0,o=0),r=a-e|0,f=o-e|0,(0|e)<0?(i[A>>2]=r,i[n>>2]=f,i[t>>2]=0,a=r,e=0):f=o,(0|(o=(0|e)<(0|(o=(0|f)<(0|a)?f:a))?e:o))<=0||(i[A>>2]=a-o,i[n>>2]=f-o,i[t>>2]=e-o))}function oA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=(n=0|i[(r=A+4|0)>>2])+f|0,f=(o=0|i[(t=A+8|0)>>2])+f|0,i[A>>2]=f,i[r>>2]=a,n=o+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function aA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],a=0|i[(r=A+4|0)>>2],o=0|i[(t=A+8|0)>>2],f=a+n|0,i[A>>2]=f,a=o+a|0,i[r>>2]=a,n=o+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function fA(A){switch(0|(A|=0)){case 1:A=5;break;case 5:A=4;break;case 4:A=6;break;case 6:A=2;break;case 2:A=3;break;case 3:A=1}return 0|A}function sA(A){switch(0|(A|=0)){case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5;break;case 5:A=1}return 0|A}function uA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],o=0|i[(r=A+4|0)>>2],a=0|i[(t=A+8|0)>>2],f=o+(n<<1)|0,i[A>>2]=f,o=a+(o<<1)|0,i[r>>2]=o,n=(a<<1)+n|0,i[t>>2]=n,a=o-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=a,i[t>>2]=n,i[A>>2]=0,o=a,a=0):a=f,(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function lA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=((n=0|i[(r=A+4|0)>>2])<<1)+f|0,f=(o=0|i[(t=A+8|0)>>2])+(f<<1)|0,i[A>>2]=f,i[r>>2]=a,n=(o<<1)+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,f=0):o=a,(0|o)<0&&(f=f-o|0,i[A>>2]=f,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=f-n|0,a=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=a,i[t>>2]=0,f=e,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|a)<(0|f)?a:f))?n:o))<=0||(i[A>>2]=f-o,i[r>>2]=a-o,i[t>>2]=n-o)}function hA(A,e){e|=0;var r,t,n,o=0,a=0,f=0;return n=(0|(t=(0|i[(A|=0)>>2])-(0|i[e>>2])|0))<0,r=(0|(a=(0|i[A+4>>2])-(0|i[e+4>>2])-(n?t:0)|0))<0,e=(e=(A=(0|(f=(n?0-t|0:0)+(0|i[A+8>>2])-(0|i[e+8>>2])+(r?0-a|0:0)|0))<0)?0:f)-((a=(0|(A=(0|e)<(0|(A=(0|(o=(r?0:a)-(A?f:0)|0))<(0|(f=(n?0:t)-(r?a:0)-(A?f:0)|0))?o:f))?e:A))>0)?A:0)|0,o=o-(a?A:0)|0,0|((0|(A=(0|(A=f-(a?A:0)|0))>-1?A:0-A|0))>(0|(e=(0|(o=(0|o)>-1?o:0-o|0))>(0|(e=(0|e)>-1?e:0-e|0))?o:e))?A:e)}function cA(A,e){e|=0;var r;r=0|i[(A|=0)+8>>2],i[e>>2]=(0|i[A>>2])-r,i[e+4>>2]=(0|i[A+4>>2])-r}function dA(A,e){e|=0;var r,t,n,o=0,a=0,f=0;a=0|i[(A|=0)>>2],i[e>>2]=a,A=0|i[A+4>>2],i[(t=e+4|0)>>2]=A,i[(n=e+8|0)>>2]=0,o=A-a|0,(0|a)<0?(A=0-a|0,i[t>>2]=o,i[n>>2]=A,i[e>>2]=0,a=0):(o=A,A=0),(0|o)<0&&(a=a-o|0,i[e>>2]=a,A=A-o|0,i[n>>2]=A,i[t>>2]=0,o=0),r=a-A|0,f=o-A|0,(0|A)<0?(i[e>>2]=r,i[t>>2]=f,i[n>>2]=0,o=f,f=r,A=0):f=a,(0|(a=(0|A)<(0|(a=(0|o)<(0|f)?o:f))?A:a))<=0||(i[e>>2]=f-a,i[t>>2]=o-a,i[n>>2]=A-a)}function gA(A){var e,r,t,n;r=(n=0|i[(e=(A|=0)+8|0)>>2])-(0|i[A>>2])|0,i[A>>2]=r,A=(0|i[(t=A+4|0)>>2])-n|0,i[t>>2]=A,i[e>>2]=0-(A+r)}function wA(A){var e,r,t=0,n=0,o=0,a=0,f=0;t=0-(n=0|i[(A|=0)>>2])|0,i[A>>2]=t,i[(e=A+8|0)>>2]=0,a=(o=0|i[(r=A+4|0)>>2])+n|0,(0|n)>0?(i[r>>2]=a,i[e>>2]=n,i[A>>2]=0,t=0,o=a):n=0,(0|o)<0?(f=t-o|0,i[A>>2]=f,n=n-o|0,i[e>>2]=n,i[r>>2]=0,a=f-n|0,t=0-n|0,(0|n)<0?(i[A>>2]=a,i[r>>2]=t,i[e>>2]=0,o=t,n=0):(o=0,a=f)):a=t,(0|(t=(0|n)<(0|(t=(0|o)<(0|a)?o:a))?n:t))<=0||(i[A>>2]=a-t,i[r>>2]=o-t,i[e>>2]=n-t)}function pA(A,e,r,t){e|=0,r|=0,t|=0;var o,a=0,f=0,s=0,u=0;if(o=I,I=I+32|0,function(A,e){e|=0;var r=0,t=0,i=0;r=+n[(A=A|0)>>3],t=+l(+r),r=+h(+r),n[e+16>>3]=r,r=+n[A+8>>3],i=t*+l(+r),n[e>>3]=i,r=t*+h(+r),n[e+8>>3]=r}(A|=0,f=o),i[r>>2]=0,a=+fe(15888,f),(s=+fe(15912,f))>2]=1,a=s),(s=+fe(15936,f))>2]=2,a=s),(s=+fe(15960,f))>2]=3,a=s),(s=+fe(15984,f))>2]=4,a=s),(s=+fe(16008,f))>2]=5,a=s),(s=+fe(16032,f))>2]=6,a=s),(s=+fe(16056,f))>2]=7,a=s),(s=+fe(16080,f))>2]=8,a=s),(s=+fe(16104,f))>2]=9,a=s),(s=+fe(16128,f))>2]=10,a=s),(s=+fe(16152,f))>2]=11,a=s),(s=+fe(16176,f))>2]=12,a=s),(s=+fe(16200,f))>2]=13,a=s),(s=+fe(16224,f))>2]=14,a=s),(s=+fe(16248,f))>2]=15,a=s),(s=+fe(16272,f))>2]=16,a=s),(s=+fe(16296,f))>2]=17,a=s),(s=+fe(16320,f))>2]=18,a=s),(s=+fe(16344,f))>2]=19,a=s),(s=+d(+(1-.5*a)))<1e-16)return i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,void(I=o);if(r=0|i[r>>2],a=+EA((a=+n[16368+(24*r|0)>>3])-+EA(+function(A,e){A|=0;var r=0,t=0,i=0,o=0,a=0;return o=+n[(e=e|0)>>3],t=+l(+o),i=+n[e+8>>3]-+n[A+8>>3],a=t*+h(+i),r=+n[A>>3],+ +p(+a,+(+h(+o)*+l(+r)-+l(+i)*(t*+h(+r))))}(15568+(r<<4)|0,A))),u=0|RA(e)?+EA(a+-.3334731722518321):a,a=+c(+s)/.381966011250105,(0|e)>0){f=0;do{a*=2.6457513110645907,f=f+1|0}while((0|f)!=(0|e))}s=+l(+u)*a,n[t>>3]=s,u=+h(+u)*a,n[t+8>>3]=u,I=o}function BA(A,e,r,t,o){e|=0,r|=0,t|=0,o|=0;var a=0,u=0;if((a=+function(A){var e=0,r=0;return r=+n[(A=A|0)>>3],e=+n[A+8>>3],+ +s(+(r*r+e*e))}(A|=0))<1e-16)return e=15568+(e<<4)|0,i[o>>2]=i[e>>2],i[o+4>>2]=i[e+4>>2],i[o+8>>2]=i[e+8>>2],void(i[o+12>>2]=i[e+12>>2]);if(u=+p(+ +n[A+8>>3],+ +n[A>>3]),(0|r)>0){A=0;do{a/=2.6457513110645907,A=A+1|0}while((0|A)!=(0|r))}t?(a/=3,r=0==(0|RA(r)),a=+w(.381966011250105*(r?a:a/2.6457513110645907))):(a=+w(.381966011250105*a),0|RA(r)&&(u=+EA(u+.3334731722518321))),function(A,e,r,t){A|=0,e=+e,t|=0;var o=0,a=0,s=0,u=0;if((r=+r)<1e-16)return i[t>>2]=i[A>>2],i[t+4>>2]=i[A+4>>2],i[t+8>>2]=i[A+8>>2],void(i[t+12>>2]=i[A+12>>2]);a=e<0?e+6.283185307179586:e,a=e>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(o=+f(+(a+-3.141592653589793))<1e-16,e=+n[A>>3],o){e-=r,n[t>>3]=e,o=t;break}if(s=+l(+r),r=+h(+r),e=s*+h(+e)+ +l(+a)*(r*+l(+e)),e=+g(+((e=e>1?1:e)<-1?-1:e)),n[t>>3]=e,+f(+(e+-1.5707963267948966))<1e-16)return n[t>>3]=1.5707963267948966,void(n[t+8>>3]=0);if(+f(+(e+1.5707963267948966))<1e-16)return n[t>>3]=-1.5707963267948966,void(n[t+8>>3]=0);if(u=+l(+e),a=r*+h(+a)/u,r=+n[A>>3],e=(s-+h(+e)*+h(+r))/+l(+r)/u,s=a>1?1:a,e=e>1?1:e,(e=+n[A+8>>3]+ +p(+(s<-1?-1:s),+(e<-1?-1:e)))>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);return void(n[t+8>>3]=e)}e=+n[A>>3]+r,n[t>>3]=e,o=t}while(0);if(+f(+(e+-1.5707963267948966))<1e-16)return n[o>>3]=1.5707963267948966,void(n[t+8>>3]=0);if(+f(+(e+1.5707963267948966))<1e-16)return n[o>>3]=-1.5707963267948966,void(n[t+8>>3]=0);if((e=+n[A+8>>3])>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);n[t+8>>3]=e}(15568+(e<<4)|0,+EA(+n[16368+(24*e|0)>>3]-u),a,o)}function bA(A,e,r){e|=0,r|=0;var t,n;t=I,I=I+16|0,K((A|=0)+4|0,n=t),BA(n,0|i[A>>2],e,0,r),I=t}function vA(A,e,r,t,o){A|=0,e|=0,r|=0,t|=0,o|=0;var a,f,s,u,l,h,c,d,g,w,p,B,b,v,m,k,M,y,E,x,D,_,F=0,C=0,P=0,U=0,G=0,S=0;if(_=I,I=I+272|0,U=_+240|0,E=_,x=_+224|0,D=_+208|0,p=_+176|0,B=_+160|0,b=_+192|0,v=_+144|0,m=_+128|0,k=_+112|0,M=_+96|0,y=_+80|0,i[(F=_+256|0)>>2]=e,i[U>>2]=i[A>>2],i[U+4>>2]=i[A+4>>2],i[U+8>>2]=i[A+8>>2],i[U+12>>2]=i[A+12>>2],mA(U,F,E),i[o>>2]=0,(0|(U=t+r+(5==(0|t)&1)|0))<=(0|r))I=_;else{f=x+4|0,s=p+4|0,u=r+5|0,l=16848+((a=0|i[F>>2])<<2)|0,h=16928+(a<<2)|0,c=m+8|0,d=k+8|0,g=M+8|0,w=D+4|0,P=r;A:for(;;){C=E+(((0|P)%5|0)<<4)|0,i[D>>2]=i[C>>2],i[D+4>>2]=i[C+4>>2],i[D+8>>2]=i[C+8>>2],i[D+12>>2]=i[C+12>>2];do{}while(2==(0|kA(D,a,0,1)));if((0|P)>(0|r)&0!=(0|RA(e))){if(i[p>>2]=i[D>>2],i[p+4>>2]=i[D+4>>2],i[p+8>>2]=i[D+8>>2],i[p+12>>2]=i[D+12>>2],K(f,B),t=0|i[p>>2],F=0|i[17008+(80*t|0)+(i[x>>2]<<2)>>2],i[p>>2]=i[18608+(80*t|0)+(20*F|0)>>2],(0|(C=0|i[18608+(80*t|0)+(20*F|0)+16>>2]))>0){A=0;do{oA(s),A=A+1|0}while((0|A)<(0|C))}switch(C=18608+(80*t|0)+(20*F|0)+4|0,i[b>>2]=i[C>>2],i[b+4>>2]=i[C+4>>2],i[b+8>>2]=i[C+8>>2],$(b,3*(0|i[l>>2])|0),X(s,b,s),J(s),K(s,v),G=+(0|i[h>>2]),n[m>>3]=3*G,n[c>>3]=0,S=-1.5*G,n[k>>3]=S,n[d>>3]=2.598076211353316*G,n[M>>3]=S,n[g>>3]=-2.598076211353316*G,0|i[17008+(80*(0|i[p>>2])|0)+(i[D>>2]<<2)>>2]){case 1:A=k,t=m;break;case 3:A=M,t=k;break;case 2:A=m,t=M;break;default:A=12;break A}oe(B,v,t,A,y),BA(y,0|i[p>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])}if((0|P)<(0|u)&&(K(w,p),BA(p,0|i[D>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])),i[x>>2]=i[D>>2],i[x+4>>2]=i[D+4>>2],i[x+8>>2]=i[D+8>>2],i[x+12>>2]=i[D+12>>2],(0|(P=P+1|0))>=(0|U)){A=3;break}}3!=(0|A)?12==(0|A)&&Q(22474,22521,581,22531):I=_}}function mA(A,e,r){A|=0,e|=0,r|=0;var t,n=0,o=0,a=0,f=0,s=0;t=I,I=I+128|0,o=t,f=20208,s=(a=n=t+64|0)+60|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));f=20272,s=(a=o)+60|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));n=(s=0==(0|RA(0|i[e>>2])))?n:o,uA(o=A+4|0),lA(o),0|RA(0|i[e>>2])&&(iA(o),i[e>>2]=1+(0|i[e>>2])),i[r>>2]=i[A>>2],X(o,n,e=r+4|0),J(e),i[r+16>>2]=i[A>>2],X(o,n+12|0,e=r+20|0),J(e),i[r+32>>2]=i[A>>2],X(o,n+24|0,e=r+36|0),J(e),i[r+48>>2]=i[A>>2],X(o,n+36|0,e=r+52|0),J(e),i[r+64>>2]=i[A>>2],X(o,n+48|0,r=r+68|0),J(r),I=t}function kA(A,e,r,t){r|=0,t|=0;var n,o,a,f,s,u,l=0,h=0,c=0,d=0,g=0;if(u=I,I=I+32|0,s=u+12|0,o=u,g=(A|=0)+4|0,d=0|i[16928+((e|=0)<<2)>>2],d=(f=0!=(0|t))?3*d|0:d,l=0|i[g>>2],n=0|i[(a=A+8|0)>>2],f){if((0|(l=n+l+(t=0|i[(h=A+12|0)>>2])|0))==(0|d))return I=u,0|(g=1);c=h}else l=n+l+(t=0|i[(c=A+12|0)>>2])|0;if((0|l)<=(0|d))return I=u,0|(g=0);do{if((0|t)>0){if(t=0|i[A>>2],(0|n)>0){h=18608+(80*t|0)+60|0,t=A;break}t=18608+(80*t|0)+40|0,r?(Z(s,d,0,0),q(g,s,o),aA(o),X(o,s,g),h=t,t=A):(h=t,t=A)}else h=18608+(80*(0|i[A>>2])|0)+20|0,t=A}while(0);if(i[t>>2]=i[h>>2],(0|i[(l=h+16|0)>>2])>0){t=0;do{oA(g),t=t+1|0}while((0|t)<(0|i[l>>2]))}return A=h+4|0,i[s>>2]=i[A>>2],i[s+4>>2]=i[A+4>>2],i[s+8>>2]=i[A+8>>2],e=0|i[16848+(e<<2)>>2],$(s,f?3*e|0:e),X(g,s,g),J(g),t=f&&((0|i[a>>2])+(0|i[g>>2])+(0|i[c>>2])|0)==(0|d)?1:2,I=u,0|(g=t)}function MA(A,e){A|=0,e|=0;var r=0;do{r=0|kA(A,e,0,1)}while(2==(0|r));return 0|r}function QA(A,e,r,t,o){A|=0,e|=0,r|=0,t|=0,o|=0;var a,f,s,u,l,h,c,d,g,w,p,B,b,v,m,k,M,y,E=0,x=0,D=0,_=0,F=0;if(y=I,I=I+240|0,v=y+208|0,m=y,k=y+192|0,M=y+176|0,g=y+160|0,w=y+144|0,p=y+128|0,B=y+112|0,b=y+96|0,i[(E=y+224|0)>>2]=e,i[v>>2]=i[A>>2],i[v+4>>2]=i[A+4>>2],i[v+8>>2]=i[A+8>>2],i[v+12>>2]=i[A+12>>2],yA(v,E,m),i[o>>2]=0,(0|(d=t+r+(6==(0|t)&1)|0))<=(0|r))I=y;else{f=r+6|0,s=16928+((a=0|i[E>>2])<<2)|0,u=w+8|0,l=p+8|0,h=B+8|0,c=k+4|0,x=0,D=r,t=-1;A:for(;;){if(A=m+((E=(0|D)%6|0)<<4)|0,i[k>>2]=i[A>>2],i[k+4>>2]=i[A+4>>2],i[k+8>>2]=i[A+8>>2],i[k+12>>2]=i[A+12>>2],A=x,x=0|kA(k,a,0,1),(0|D)>(0|r)&0!=(0|RA(e))&&(1!=(0|A)&&(0|i[k>>2])!=(0|t))){switch(K(m+(((E+5|0)%6|0)<<4)+4|0,M),K(m+(E<<4)+4|0,g),_=+(0|i[s>>2]),n[w>>3]=3*_,n[u>>3]=0,F=-1.5*_,n[p>>3]=F,n[l>>3]=2.598076211353316*_,n[B>>3]=F,n[h>>3]=-2.598076211353316*_,E=0|i[v>>2],0|i[17008+(80*E|0)+(((0|t)==(0|E)?0|i[k>>2]:t)<<2)>>2]){case 1:A=p,t=w;break;case 3:A=B,t=p;break;case 2:A=w,t=B;break;default:A=8;break A}oe(M,g,t,A,b),0|ae(M,b)||0|ae(g,b)||(BA(b,0|i[v>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2]))}if((0|D)<(0|f)&&(K(c,M),BA(M,0|i[k>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])),(0|(D=D+1|0))>=(0|d)){A=3;break}t=0|i[k>>2]}3!=(0|A)?8==(0|A)&&Q(22557,22521,746,22602):I=y}}function yA(A,e,r){A|=0,e|=0,r|=0;var t,n=0,o=0,a=0,f=0,s=0;t=I,I=I+160|0,o=t,f=20336,s=(a=n=t+80|0)+72|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));f=20416,s=(a=o)+72|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));n=(s=0==(0|RA(0|i[e>>2])))?n:o,uA(o=A+4|0),lA(o),0|RA(0|i[e>>2])&&(iA(o),i[e>>2]=1+(0|i[e>>2])),i[r>>2]=i[A>>2],X(o,n,e=r+4|0),J(e),i[r+16>>2]=i[A>>2],X(o,n+12|0,e=r+20|0),J(e),i[r+32>>2]=i[A>>2],X(o,n+24|0,e=r+36|0),J(e),i[r+48>>2]=i[A>>2],X(o,n+36|0,e=r+52|0),J(e),i[r+64>>2]=i[A>>2],X(o,n+48|0,e=r+68|0),J(e),i[r+80>>2]=i[A>>2],X(o,n+60|0,r=r+84|0),J(r),I=t}function EA(A){var e;return e=(A=+A)<0?A+6.283185307179586:A,+(A>=6.283185307179586?e+-6.283185307179586:e)}function xA(A,e){return e|=0,+f(+(+n[(A|=0)>>3]-+n[e>>3]))<17453292519943298e-27?0|(e=+f(+(+n[A+8>>3]-+n[e+8>>3]))<17453292519943298e-27):0|(e=0)}function DA(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))*6371.007180918475}function _A(A,e,r){A|=0,r|=0;var t,i,o,a,f=0,u=0,d=0,g=0,B=0,b=0;return b=+n[(e|=0)>>3],o=+n[A>>3],B=+h(.5*(b-o)),d=+n[e+8>>3],i=+n[A+8>>3],g=+h(.5*(d-i)),t=+l(+o),a=+l(+b),g=2*+p(+ +s(+(g=B*B+g*(a*t*g))),+ +s(+(1-g))),B=+n[r>>3],b=+h(.5*(B-b)),f=+n[r+8>>3],d=+h(.5*(f-d)),u=+l(+B),d=2*+p(+ +s(+(d=b*b+d*(a*u*d))),+ +s(+(1-d))),B=+h(.5*(o-B)),f=+h(.5*(i-f)),f=2*+p(+ +s(+(f=B*B+f*(t*u*f))),+ +s(+(1-f))),4*+w(+ +s(+ +c(.5*(u=.5*(g+d+f)))*+c(.5*(u-g))*+c(.5*(u-d))*+c(.5*(u-f))))}function IA(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),45),M(),127&e|0}function FA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0;if(!(!0&134217728==(-16777216&(e|=0)|0)))return 0|(e=0);if(o=0|Qe(0|(A|=0),0|e,45),M(),(o&=127)>>>0>121)return 0|(e=0);r=0|Qe(0|A,0|e,52),M(),r&=15;do{if(0|r){for(i=1,t=0;;){if(n=0|Qe(0|A,0|e,3*(15-i|0)|0),M(),0!=(0|(n&=7))&(1^t)){if(1==(0|n)&0!=(0|S(o))){a=0,t=13;break}t=1}if(7==(0|n)){a=0,t=13;break}if(!(i>>>0>>0)){t=9;break}i=i+1|0}if(9==(0|t)){if(15!=(0|r))break;return 0|(a=1)}if(13==(0|t))return 0|a}}while(0);for(;;){if(a=0|Qe(0|A,0|e,3*(14-r|0)|0),M(),!(7==(7&a|0)&!0)){a=0,t=13;break}if(!(r>>>0<14)){a=1,t=13;break}r=r+1|0}return 13==(0|t)?0|a:0}function CA(A,e,r){r|=0;var t=0,i=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|(t&=15))>=(0|r)){if((0|t)!=(0|r))if(r>>>0<=15){if(A|=i=0|ye(0|r,0,52),e=0|M()|-15728641&e,(0|t)>(0|r))do{i=0|ye(7,0,3*(14-r|0)|0),r=r+1|0,A|=i,e=0|M()|e}while((0|r)<(0|t))}else e=0,A=0}else e=0,A=0;return k(0|e),0|A}function PA(A,e,r,t){r|=0,t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(f&=15))<=(0|r)){if((0|f)==(0|r))return i[(r=t)>>2]=A,void(i[r+4>>2]=e);if(n=(0|(u=0|ee(7,r-f|0)))/7|0,s=0|Qe(0|A,0|e,45),M(),0|S(127&s)){A:do{if(f)for(a=1;;){if(o=0|Qe(0|A,0|e,3*(15-a|0)|0),M(),0|(o&=7))break A;if(!(a>>>0>>0)){o=0;break}a=a+1|0}else o=0}while(0);a=0==(0|o)}else a=0;if(l=0|ye(f+1|0,0,52),o=0|M()|-15728641&e,PA(e=(l|A)&~(e=0|ye(7,0,0|(s=3*(14-f|0)|0))),f=o&~(0|M()),r,t),o=t+(n<<3)|0,!a)return PA((l=0|ye(1,0,0|s))|e,0|M()|f,r,o),l=o+(n<<3)|0,PA((u=0|ye(2,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(3,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(4,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(5,0,0|s))|e,0|M()|f,r,l),void PA((u=0|ye(6,0,0|s))|e,0|M()|f,r,l+(n<<3)|0);a=o+(n<<3)|0,(0|u)>6&&(_e(0|o,0,(l=(a>>>0>(u=o+8|0)>>>0?a:u)+-1+(0-o)|0)+8&-8|0),o=u+(l>>>3<<3)|0),PA((l=0|ye(2,0,0|s))|e,0|M()|f,r,o),l=o+(n<<3)|0,PA((u=0|ye(3,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(4,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(5,0,0|s))|e,0|M()|f,r,l),PA((u=0|ye(6,0,0|s))|e,0|M()|f,r,l+(n<<3)|0)}}function UA(A,e){var r=0,t=0,i=0;if(i=0|Qe(0|(A|=0),0|(e|=0),45),M(),!(0|S(127&i)))return 0|(i=0);i=0|Qe(0|A,0|e,52),M(),i&=15;A:do{if(i)for(t=1;;){if(r=0|Qe(0|A,0|e,3*(15-t|0)|0),M(),0|(r&=7))break A;if(!(t>>>0>>0)){r=0;break}t=t+1|0}else r=0}while(0);return 0|(i=0==(0|r)&1)}function GA(A,e){var r=0,t=0,i=0;if(i=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(i&=15))return 0|(i=0);for(t=1;;){if(r=0|Qe(0|A,0|e,3*(15-t|0)|0),M(),0|(r&=7)){t=5;break}if(!(t>>>0>>0)){r=0,t=5;break}t=t+1|0}return 5==(0|t)?0|r:0}function SA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0,f=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(f&=15))return f=A,k(0|(a=e)),0|f;for(a=1,r=0;;){t=0|ye(7,0,0|(n=3*(15-a|0)|0)),i=0|M(),o=0|Qe(0|A,0|e,0|n),M(),A=(n=0|ye(0|fA(7&o),0,0|n))|A&~t,e=(o=0|M())|e&~i;A:do{if(!r)if(0==(n&t|0)&0==(o&i|0))r=0;else if(t=0|Qe(0|A,0|e,52),M(),t&=15){r=1;e:for(;;){switch(o=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),7&o){case 1:break e;case 0:break;default:r=1;break A}if(!(r>>>0>>0)){r=1;break A}r=r+1|0}for(r=1;;){if(i=0|Qe(0|A,0|e,0|(o=3*(15-r|0)|0)),M(),n=0|ye(7,0,0|o),e&=~(0|M()),A=A&~n|(o=0|ye(0|fA(7&i),0,0|o)),e=0|e|M(),!(r>>>0>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return k(0|e),0|A}function TA(A,e){var r=0,t=0,i=0,n=0,o=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(t&=15))return t=A,k(0|(r=e)),0|t;for(r=1;o=0|Qe(0|A,0|e,0|(n=3*(15-r|0)|0)),M(),i=0|ye(7,0,0|n),e&=~(0|M()),A=(n=0|ye(0|fA(7&o),0,0|n))|A&~i,e=0|M()|e,r>>>0>>0;)r=r+1|0;return k(0|e),0|A}function VA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0,f=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(f&=15))return f=A,k(0|(a=e)),0|f;for(a=1,r=0;;){t=0|ye(7,0,0|(n=3*(15-a|0)|0)),i=0|M(),o=0|Qe(0|A,0|e,0|n),M(),A=(n=0|ye(0|sA(7&o),0,0|n))|A&~t,e=(o=0|M())|e&~i;A:do{if(!r)if(0==(n&t|0)&0==(o&i|0))r=0;else if(t=0|Qe(0|A,0|e,52),M(),t&=15){r=1;e:for(;;){switch(o=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),7&o){case 1:break e;case 0:break;default:r=1;break A}if(!(r>>>0>>0)){r=1;break A}r=r+1|0}for(r=1;;){if(n=0|ye(7,0,0|(i=3*(15-r|0)|0)),o=e&~(0|M()),e=0|Qe(0|A,0|e,0|i),M(),A=A&~n|(e=0|ye(0|sA(7&e),0,0|i)),e=0|o|M(),!(r>>>0>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return k(0|e),0|A}function HA(A,e){var r=0,t=0,i=0,n=0,o=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(t&=15))return t=A,k(0|(r=e)),0|t;for(r=1;n=0|ye(7,0,0|(o=3*(15-r|0)|0)),i=e&~(0|M()),e=0|Qe(0|A,0|e,0|o),M(),A=(e=0|ye(0|sA(7&e),0,0|o))|A&~n,e=0|M()|i,r>>>0>>0;)r=r+1|0;return k(0|e),0|A}function RA(A){return 0|(0|(A|=0))%2}function LA(A,e){A|=0;var r,t;return t=I,I=I+16|0,r=t,(e|=0)>>>0<=15&&2146435072!=(2146435072&i[A+4>>2]|0)&&2146435072!=(2146435072&i[A+8+4>>2]|0)?(!function(A,e,r){var t,i;t=I,I=I+16|0,pA(A|=0,e|=0,r|=0,i=t),W(i,r+4|0),I=t}(A,e,r),e=0|function(A,e){A|=0;var r,t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0;if(r=I,I=I+64|0,s=r+40|0,n=r+24|0,o=r+12|0,a=r,ye(0|(e|=0),0,52),t=134225919|M(),!e)return(0|i[A+4>>2])>2||(0|i[A+8>>2])>2||(0|i[A+12>>2])>2?(s=0,k(0|(f=0)),I=r,0|s):(ye(0|V(A),0,45),f=0|M()|t,s=-1,k(0|f),I=r,0|s);if(i[s>>2]=i[A>>2],i[s+4>>2]=i[A+4>>2],i[s+8>>2]=i[A+8>>2],i[s+12>>2]=i[A+12>>2],f=s+4|0,(0|e)>0)for(A=-1;i[n>>2]=i[f>>2],i[n+4>>2]=i[f+4>>2],i[n+8>>2]=i[f+8>>2],1&e?(eA(f),i[o>>2]=i[f>>2],i[o+4>>2]=i[f+4>>2],i[o+8>>2]=i[f+8>>2],tA(o)):(rA(f),i[o>>2]=i[f>>2],i[o+4>>2]=i[f+4>>2],i[o+8>>2]=i[f+8>>2],iA(o)),q(n,o,a),J(a),u=0|ye(7,0,0|(l=3*(15-e|0)|0)),t&=~(0|M()),A=(l=0|ye(0|AA(a),0,0|l))|A&~u,t=0|M()|t,(0|e)>1;)e=e+-1|0;else A=-1;A:do{if((0|i[f>>2])<=2&&(0|i[s+8>>2])<=2&&(0|i[s+12>>2])<=2){if(e=0|ye(0|(n=0|V(s)),0,45),e|=A,A=0|M()|-1040385&t,a=0|H(s),!(0|S(n))){if((0|a)<=0)break;for(o=0;;){if(n=0|Qe(0|e,0|A,52),M(),n&=15)for(t=1;s=0|Qe(0|e,0|A,0|(l=3*(15-t|0)|0)),M(),u=0|ye(7,0,0|l),A&=~(0|M()),e=e&~u|(l=0|ye(0|fA(7&s),0,0|l)),A=0|A|M(),t>>>0>>0;)t=t+1|0;if((0|(o=o+1|0))==(0|a))break A}}o=0|Qe(0|e,0|A,52),M(),o&=15;e:do{if(o){t=1;r:for(;;){switch(l=0|Qe(0|e,0|A,3*(15-t|0)|0),M(),7&l){case 1:break r;case 0:break;default:break e}if(!(t>>>0>>0))break e;t=t+1|0}if(0|R(n,0|i[s>>2]))for(t=1;u=0|ye(7,0,0|(s=3*(15-t|0)|0)),l=A&~(0|M()),A=0|Qe(0|e,0|A,0|s),M(),e=e&~u|(A=0|ye(0|sA(7&A),0,0|s)),A=0|l|M(),t>>>0>>0;)t=t+1|0;else for(t=1;s=0|Qe(0|e,0|A,0|(l=3*(15-t|0)|0)),M(),u=0|ye(7,0,0|l),A&=~(0|M()),e=e&~u|(l=0|ye(0|fA(7&s),0,0|l)),A=0|A|M(),t>>>0>>0;)t=t+1|0}}while(0);if((0|a)>0){t=0;do{e=0|SA(e,A),A=0|M(),t=t+1|0}while((0|t)!=(0|a))}}else e=0,A=0}while(0);return l=e,k(0|(u=A)),I=r,0|l}(r,e),A=0|M()):(A=0,e=0),k(0|A),I=t,0|e}function zA(A,e,r){var t,n=0,o=0,a=0;if(t=(r|=0)+4|0,o=0|Qe(0|(A|=0),0|(e|=0),52),M(),o&=15,a=0|Qe(0|A,0|e,45),M(),n=0==(0|o),0|S(127&a)){if(n)return 0|(a=1);n=1}else{if(n)return 0|(a=0);n=0==(0|i[t>>2])&&0==(0|i[r+8>>2])?0!=(0|i[r+12>>2])&1:1}for(r=1;1&r?tA(t):iA(t),a=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),nA(t,7&a),r>>>0>>0;)r=r+1|0;return 0|n}function YA(A,e,r){r|=0;var t,n,o=0,a=0,f=0,s=0,u=0,l=0;n=I,I=I+16|0,t=n,l=0|Qe(0|(A|=0),0|(e|=0),45),M(),l&=127;A:do{if(0!=(0|S(l))&&(f=0|Qe(0|A,0|e,52),M(),0!=(0|(f&=15)))){o=1;e:for(;;){switch(u=0|Qe(0|A,0|e,3*(15-o|0)|0),M(),7&u){case 5:break e;case 0:break;default:o=e;break A}if(!(o>>>0>>0)){o=e;break A}o=o+1|0}for(a=1,o=e;s=0|ye(7,0,0|(e=3*(15-a|0)|0)),u=o&~(0|M()),o=0|Qe(0|A,0|o,0|e),M(),A=A&~s|(o=0|ye(0|sA(7&o),0,0|e)),o=0|u|M(),a>>>0>>0;)a=a+1|0}else o=e}while(0);if(u=7728+(28*l|0)|0,i[r>>2]=i[u>>2],i[r+4>>2]=i[u+4>>2],i[r+8>>2]=i[u+8>>2],i[r+12>>2]=i[u+12>>2],0|zA(A,o,r)){if(s=r+4|0,i[t>>2]=i[s>>2],i[t+4>>2]=i[s+4>>2],i[t+8>>2]=i[s+8>>2],f=0|Qe(0|A,0|o,52),M(),u=15&f,1&f?(iA(s),f=u+1|0):f=u,0|S(l)){A:do{if(u)for(e=1;;){if(a=0|Qe(0|A,0|o,3*(15-e|0)|0),M(),0|(a&=7)){o=a;break A}if(!(e>>>0>>0)){o=0;break}e=e+1|0}else o=0}while(0);o=4==(0|o)&1}else o=0;if(0|kA(r,f,o,0)){if(0|S(l))do{}while(0!=(0|kA(r,f,0,0)));(0|f)!=(0|u)&&rA(s)}else(0|f)!=(0|u)&&(i[s>>2]=i[t>>2],i[s+4>>2]=i[t+4>>2],i[s+8>>2]=i[t+8>>2]);I=n}else I=n}function OA(A,e,r){r|=0;var t,i;t=I,I=I+16|0,YA(A|=0,e|=0,i=t),e=0|Qe(0|A,0|e,52),M(),bA(i,15&e,r),I=t}function jA(A,e,r){r|=0;var t,i,n=0,o=0;i=I,I=I+16|0,YA(A|=0,e|=0,t=i),n=0|Qe(0|A,0|e,45),M(),n=0==(0|S(127&n)),o=0|Qe(0|A,0|e,52),M(),o&=15;A:do{if(!n){if(0|o)for(n=1;;){if(!(0==((0|ye(7,0,3*(15-n|0)|0))&A|0)&0==((0|M())&e|0)))break A;if(!(n>>>0>>0))break;n=n+1|0}return vA(t,o,0,5,r),void(I=i)}}while(0);QA(t,o,0,6,r),I=i}function NA(A,e){e|=0;var r,t=0,n=0,o=0,a=0,f=0,s=0;if(ye(0|(A|=0),0,52),r=134225919|M(),(0|A)<1){n=0,t=0;do{0|S(n)&&(ye(0|n,0,45),f=0|r|M(),i[(A=e+(t<<3)|0)>>2]=-1,i[A+4>>2]=f,t=t+1|0),n=n+1|0}while(122!=(0|n))}else{f=0,t=0;do{if(0|S(f)){for(ye(0|f,0,45),n=1,o=-1,a=0|r|M();o&=~(s=0|ye(7,0,3*(15-n|0)|0)),a&=~(0|M()),(0|n)!=(0|A);)n=n+1|0;i[(s=e+(t<<3)|0)>>2]=o,i[s+4>>2]=a,t=t+1|0}f=f+1|0}while(122!=(0|f))}}function ZA(A,e,r,t){var n,o=0,a=0,f=0,s=0,u=0;if(n=I,I=I+64|0,f=n,(0|(A|=0))==(0|(r|=0))&(0|(e|=0))==(0|(t|=0))|!1|134217728!=(2013265920&e|0)|!1|134217728!=(2013265920&t|0))return I=n,0|(f=0);if(o=0|Qe(0|A,0|e,52),M(),o&=15,a=0|Qe(0|r,0|t,52),M(),(0|o)!=(15&a|0))return I=n,0|(f=0);if(a=o+-1|0,o>>>0>1&&(u=0|CA(A,e,a),s=0|M(),(0|u)==(0|(a=0|CA(r,t,a)))&(0|s)==(0|M()))){if(o=0|Qe(0|A,0|e,0|(a=3*(15^o)|0)),M(),o&=7,a=0|Qe(0|r,0|t,0|a),M(),0==(0|o)|0==(0|(a&=7)))return I=n,0|(u=1);if((0|i[21136+(o<<2)>>2])==(0|a))return I=n,0|(u=1);if((0|i[21168+(o<<2)>>2])==(0|a))return I=n,0|(u=1)}a=(o=f)+56|0;do{i[o>>2]=0,o=o+4|0}while((0|o)<(0|a));return F(A,e,1,f),o=(0|i[(u=f)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+8|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+16|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+24|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+32|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+40|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)?1:1&((0|i[(o=f+48|0)>>2])==(0|r)?(0|i[o+4>>2])==(0|t):0),I=n,0|(u=o)}function WA(A,e,r){r|=0;var t,n,o,a,f=0;if(o=I,I=I+16|0,n=o,f=0|Qe(0|(A|=0),0|(e|=0),56),M(),-1==(0|(e=0|function(A,e,r){r|=0;var t=0,n=0;if(t=0|UA(A=A|0,e=e|0),(r+-1|0)>>>0>5)return 0|(r=-1);if(1==(0|r)&(n=0!=(0|t)))return 0|(r=-1);return t=0|function(A,e){var r=0,t=0,n=0,o=0,a=0,f=0,s=0,u=0;if(u=I,I=I+32|0,o=u,YA(A=A|0,e=e|0,n=u+16|0),a=0|IA(A,e),s=0|GA(A,e),function(A,e){A=7728+(28*(A|=0)|0)|0,i[(e|=0)>>2]=i[A>>2],i[e+4>>2]=i[A+4>>2],i[e+8>>2]=i[A+8>>2],i[e+12>>2]=i[A+12>>2]}(a,o),e=0|function(A,e){A|=0;var r=0,t=0;if((e|=0)>>>0>20)return-1;do{if((0|i[11152+(216*e|0)>>2])!=(0|A))if((0|i[11152+(216*e|0)+8>>2])!=(0|A))if((0|i[11152+(216*e|0)+16>>2])!=(0|A))if((0|i[11152+(216*e|0)+24>>2])!=(0|A))if((0|i[11152+(216*e|0)+32>>2])!=(0|A))if((0|i[11152+(216*e|0)+40>>2])!=(0|A))if((0|i[11152+(216*e|0)+48>>2])!=(0|A))if((0|i[11152+(216*e|0)+56>>2])!=(0|A))if((0|i[11152+(216*e|0)+64>>2])!=(0|A))if((0|i[11152+(216*e|0)+72>>2])!=(0|A))if((0|i[11152+(216*e|0)+80>>2])!=(0|A))if((0|i[11152+(216*e|0)+88>>2])!=(0|A))if((0|i[11152+(216*e|0)+96>>2])!=(0|A))if((0|i[11152+(216*e|0)+104>>2])!=(0|A))if((0|i[11152+(216*e|0)+112>>2])!=(0|A))if((0|i[11152+(216*e|0)+120>>2])!=(0|A))if((0|i[11152+(216*e|0)+128>>2])!=(0|A)){if((0|i[11152+(216*e|0)+136>>2])!=(0|A)){if((0|i[11152+(216*e|0)+144>>2])==(0|A)){A=0,r=2,t=0;break}if((0|i[11152+(216*e|0)+152>>2])==(0|A)){A=0,r=2,t=1;break}if((0|i[11152+(216*e|0)+160>>2])==(0|A)){A=0,r=2,t=2;break}if((0|i[11152+(216*e|0)+168>>2])==(0|A)){A=1,r=2,t=0;break}if((0|i[11152+(216*e|0)+176>>2])==(0|A)){A=1,r=2,t=1;break}if((0|i[11152+(216*e|0)+184>>2])==(0|A)){A=1,r=2,t=2;break}if((0|i[11152+(216*e|0)+192>>2])==(0|A)){A=2,r=2,t=0;break}if((0|i[11152+(216*e|0)+200>>2])==(0|A)){A=2,r=2,t=1;break}if((0|i[11152+(216*e|0)+208>>2])==(0|A)){A=2,r=2,t=2;break}return-1}A=2,r=1,t=2}else A=2,r=1,t=1;else A=2,r=1,t=0;else A=1,r=1,t=2;else A=1,r=1,t=1;else A=1,r=1,t=0;else A=0,r=1,t=2;else A=0,r=1,t=1;else A=0,r=1,t=0;else A=2,r=0,t=2;else A=2,r=0,t=1;else A=2,r=0,t=0;else A=1,r=0,t=2;else A=1,r=0,t=1;else A=1,r=0,t=0;else A=0,r=0,t=2;else A=0,r=0,t=1;else A=0,r=0,t=0}while(0);return 0|i[11152+(216*e|0)+(72*r|0)+(24*A|0)+(t<<3)+4>>2]}(a,0|i[n>>2]),!(0|S(a)))return I=u,0|(s=e);switch(0|a){case 4:A=0,r=14;break;case 14:A=1,r=14;break;case 24:A=2,r=14;break;case 38:A=3,r=14;break;case 49:A=4,r=14;break;case 58:A=5,r=14;break;case 63:A=6,r=14;break;case 72:A=7,r=14;break;case 83:A=8,r=14;break;case 97:A=9,r=14;break;case 107:A=10,r=14;break;case 117:A=11,r=14;break;default:f=0,t=0}14==(0|r)&&(f=0|i[22096+(24*A|0)+8>>2],t=0|i[22096+(24*A|0)+16>>2]);(0|(A=0|i[n>>2]))!=(0|i[o>>2])&&(a=0|T(a))|(0|(A=0|i[n>>2]))==(0|t)&&(e=(e+1|0)%6|0);if(3==(0|s)&(0|A)==(0|t))return I=u,0|(s=(e+5|0)%6|0);if(!(5==(0|s)&(0|A)==(0|f)))return I=u,0|(s=e);return I=u,0|(s=(e+1|0)%6|0)}(A,e),n?0|(r=(5-t+(0|i[22384+(r<<2)>>2])|0)%5|0):0|(r=(6-t+(0|i[22416+(r<<2)>>2])|0)%6|0)}(t=(a=!0&268435456==(2013265920&e|0))?A:0,A=a?-2130706433&e|134217728:0,7&f))))return i[r>>2]=0,void(I=o);YA(t,A,n),f=0|Qe(0|t,0|A,52),M(),f&=15,0|UA(t,A)?vA(n,f,e,2,r):QA(n,f,e,2,r),I=o}function JA(A){A|=0;var e,r,t=0;return(e=0|be(1,12))||Q(22691,22646,49,22704),0|(t=0|i[(r=A+4|0)>>2])?(i[(t=t+8|0)>>2]=e,i[r>>2]=e,0|e):(0|i[A>>2]&&Q(22721,22646,61,22744),i[(t=A)>>2]=e,i[r>>2]=e,0|e)}function KA(A,e){A|=0,e|=0;var r,t;return(t=0|pe(24))||Q(22758,22646,78,22772),i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2],i[t+16>>2]=0,0|(r=0|i[(e=A+4|0)>>2])?(i[r+16>>2]=t,i[e>>2]=t,0|t):(0|i[A>>2]&&Q(22787,22646,82,22772),i[A>>2]=t,i[e>>2]=t,0|t)}function XA(A){var e,r,t=0,o=0,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,y=0,E=0,x=0,D=0,_=0,I=0,F=0,C=0,P=0,U=0,G=0,S=0;if(0|i[(s=(A|=0)+8|0)>>2])return 0|(S=1);if(!(a=0|i[A>>2]))return 0|(S=0);t=a,o=0;do{o=o+1|0,t=0|i[t+8>>2]}while(0!=(0|t));if(o>>>0<2)return 0|(S=0);(r=0|pe(o<<2))||Q(22807,22646,317,22826),(e=0|pe(o<<5))||Q(22848,22646,321,22826),i[A>>2]=0,i[(D=A+4|0)>>2]=0,i[s>>2]=0,o=0,U=0,x=0,w=0;A:for(;;){if(g=0|i[a>>2]){u=0,l=g;do{if(c=+n[l+8>>3],t=l,l=0|i[l+16>>2],h=+n[(s=(d=0==(0|l))?g:l)+8>>3],+f(+(c-h))>3.141592653589793){S=14;break}u+=(h-c)*(+n[t>>3]+ +n[s>>3])}while(!d);if(14==(0|S)){S=0,u=0,t=g;do{E=+n[t+8>>3],C=0|i[(P=t+16|0)>>2],y=+n[(C=0==(0|C)?g:C)+8>>3],u+=(+n[t>>3]+ +n[C>>3])*((y<0?y+6.283185307179586:y)-(E<0?E+6.283185307179586:E)),t=0|i[(0==(0|t)?a:P)>>2]}while(0!=(0|t))}u>0?(i[r+(U<<2)>>2]=a,U=U+1|0,s=x,t=w):S=19}else S=19;if(19==(0|S)){S=0;do{if(!o){if(w){s=D,l=w+8|0,t=a,o=A;break}if(0|i[A>>2]){S=27;break A}s=D,l=A,t=a,o=A;break}if(0|i[(t=o+8|0)>>2]){S=21;break A}if(!(o=0|be(1,12))){S=23;break A}i[t>>2]=o,s=o+4|0,l=o,t=w}while(0);if(i[l>>2]=a,i[s>>2]=a,l=e+(x<<5)|0,d=0|i[a>>2]){for(n[(g=e+(x<<5)+8|0)>>3]=17976931348623157e292,n[(w=e+(x<<5)+24|0)>>3]=17976931348623157e292,n[l>>3]=-17976931348623157e292,n[(p=e+(x<<5)+16|0)>>3]=-17976931348623157e292,k=17976931348623157e292,M=-17976931348623157e292,s=0,B=d,c=17976931348623157e292,v=17976931348623157e292,m=-17976931348623157e292,h=-17976931348623157e292;u=+n[B>>3],E=+n[B+8>>3],B=0|i[B+16>>2],y=+n[((b=0==(0|B))?d:B)+8>>3],u>3]=u,c=u),E>3]=E,v=E),u>m?n[l>>3]=u:u=m,E>h&&(n[p>>3]=E,h=E),k=E>0&EM?E:M,s|=+f(+(E-y))>3.141592653589793,!b;)m=u;s&&(n[p>>3]=M,n[w>>3]=k)}else i[l>>2]=0,i[l+4>>2]=0,i[l+8>>2]=0,i[l+12>>2]=0,i[l+16>>2]=0,i[l+20>>2]=0,i[l+24>>2]=0,i[l+28>>2]=0;s=x+1|0}if(a=0|i[(P=a+8|0)>>2],i[P>>2]=0,!a){S=45;break}x=s,w=t}if(21==(0|S))Q(22624,22646,35,22658);else if(23==(0|S))Q(22678,22646,37,22658);else if(27==(0|S))Q(22721,22646,61,22744);else if(45==(0|S)){A:do{if((0|U)>0){for(P=0==(0|s),F=s<<2,C=0==(0|A),I=0,t=0;;){if(_=0|i[r+(I<<2)>>2],P)S=73;else{if(!(x=0|pe(F))){S=50;break}if(!(D=0|pe(F))){S=52;break}e:do{if(C)o=0;else{for(s=0,o=0,l=A;a=e+(s<<5)|0,0|qA(0|i[l>>2],a,0|i[_>>2])?(i[x+(o<<2)>>2]=l,i[D+(o<<2)>>2]=a,b=o+1|0):b=o,l=0|i[l+8>>2];)s=s+1|0,o=b;if((0|b)>0)if(a=0|i[x>>2],1==(0|b))o=a;else for(p=0,B=-1,o=a,w=a;;){for(d=0|i[w>>2],a=0,l=0;g=(0|(s=0|i[i[x+(l<<2)>>2]>>2]))==(0|d)?a:a+(1&(0|qA(s,0|i[D+(l<<2)>>2],0|i[d>>2])))|0,(0|(l=l+1|0))!=(0|b);)a=g;if(o=(s=(0|g)>(0|B))?w:o,(0|(a=p+1|0))==(0|b))break e;p=a,B=s?g:B,w=0|i[x+(a<<2)>>2]}else o=0}}while(0);if(Be(x),Be(D),o){if(a=0|i[(s=o+4|0)>>2])o=a+8|0;else if(0|i[o>>2]){S=70;break}i[o>>2]=_,i[s>>2]=_}else S=73}if(73==(0|S)){if(S=0,0|(t=0|i[_>>2]))do{D=t,t=0|i[t+16>>2],Be(D)}while(0!=(0|t));Be(_),t=2}if((0|(I=I+1|0))>=(0|U)){G=t;break A}}50==(0|S)?Q(22863,22646,249,22882):52==(0|S)?Q(22901,22646,252,22882):70==(0|S)&&Q(22721,22646,61,22744)}else G=0}while(0);return Be(r),Be(e),0|(S=G)}return 0}function qA(A,e,r){A|=0;var t,o=0,a=0,f=0,s=0,u=0,l=0,h=0;if(!(0|O(e|=0,r|=0)))return 0|(A=0);if(e=0|Y(e),t=+n[r>>3],o=e&(o=+n[r+8>>3])<0?o+6.283185307179586:o,!(A=0|i[A>>2]))return 0|(A=0);if(e){e=0,r=A;A:for(;;){for(;s=+n[r>>3],l=+n[r+8>>3],h=0|i[(r=r+16|0)>>2],f=+n[(h=0==(0|h)?A:h)>>3],a=+n[h+8>>3],s>f?(u=s,s=l):(u=f,f=s,s=a,a=l),tu;)if(!(r=0|i[r>>2])){r=22;break A}if(o=(s=s<0?s+6.283185307179586:s)==o|(l=a<0?a+6.283185307179586:a)==o?o+-2220446049250313e-31:o,((l+=(t-f)/(u-f)*(s-l))<0?l+6.283185307179586:l)>o&&(e^=1),!(r=0|i[r>>2])){r=22;break}}if(22==(0|r))return 0|e}else{e=0,r=A;A:for(;;){for(;s=+n[r>>3],l=+n[r+8>>3],h=0|i[(r=r+16|0)>>2],f=+n[(h=0==(0|h)?A:h)>>3],a=+n[h+8>>3],s>f?(u=s,s=l):(u=f,f=s,s=a,a=l),tu;)if(!(r=0|i[r>>2])){r=22;break A}if(a+(t-f)/(u-f)*(s-a)>(o=s==o|a==o?o+-2220446049250313e-31:o)&&(e^=1),!(r=0|i[r>>2])){r=22;break}}if(22==(0|r))return 0|e}return 0}function $A(A,e,r,n,o){r|=0,n|=0,o|=0;var a,f,s,u,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0;if(u=I,I=I+32|0,v=u+16|0,s=u,l=0|Qe(0|(A|=0),0|(e|=0),52),M(),l&=15,p=0|Qe(0|r,0|n,52),M(),(0|l)!=(15&p|0))return I=u,0|(v=1);if(g=0|Qe(0|A,0|e,45),M(),g&=127,w=0|Qe(0|r,0|n,45),M(),p=(0|g)!=(0|(w&=127))){if(7==(0|(c=0|z(g,w))))return I=u,0|(v=2);7==(0|(d=0|z(w,g)))?Q(22925,22949,151,22959):(B=c,h=d)}else B=0,h=0;a=0|S(g),f=0|S(w),i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0;do{if(B){if(c=(0|(w=0|i[4304+(28*g|0)+(B<<2)>>2]))>0,f)if(c){g=0,d=r,c=n;do{d=0|VA(d,c),c=0|M(),1==(0|(h=0|sA(h)))&&(h=0|sA(1)),g=g+1|0}while((0|g)!=(0|w));w=h,g=d,d=c}else w=h,g=r,d=n;else if(c){g=0,d=r,c=n;do{d=0|HA(d,c),c=0|M(),h=0|sA(h),g=g+1|0}while((0|g)!=(0|w));w=h,g=d,d=c}else w=h,g=r,d=n;if(zA(g,d,v),p||Q(22972,22949,181,22959),(c=0!=(0|a))&(h=0!=(0|f))&&Q(22999,22949,182,22959),c){if(h=0|GA(A,e),0|t[22032+(7*h|0)+B>>0]){l=3;break}g=d=0|i[21200+(28*h|0)+(B<<2)>>2],b=26}else if(h){if(h=0|GA(g,d),0|t[22032+(7*h|0)+w>>0]){l=4;break}g=0,d=0|i[21200+(28*w|0)+(h<<2)>>2],b=26}else h=0;if(26==(0|b))if((0|d)<=-1&&Q(23030,22949,212,22959),(0|g)<=-1&&Q(23053,22949,213,22959),(0|d)>0){c=v+4|0,h=0;do{aA(c),h=h+1|0}while((0|h)!=(0|d));h=g}else h=g;if(i[s>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,nA(s,B),0|l)for(;0|RA(l)?tA(s):iA(s),(0|l)>1;)l=l+-1|0;if((0|h)>0){l=0;do{aA(s),l=l+1|0}while((0|l)!=(0|h))}X(b=v+4|0,s,b),J(b),b=50}else if(zA(r,n,v),0!=(0|a)&0!=(0|f))if((0|w)!=(0|g)&&Q(23077,22949,243,22959),h=0|GA(A,e),l=0|GA(r,n),0|t[22032+(7*h|0)+l>>0])l=5;else if((0|(h=0|i[21200+(28*h|0)+(l<<2)>>2]))>0){c=v+4|0,l=0;do{aA(c),l=l+1|0}while((0|l)!=(0|h));b=50}else b=50;else b=50}while(0);return 50==(0|b)&&(l=v+4|0,i[o>>2]=i[l>>2],i[o+4>>2]=i[l+4>>2],i[o+8>>2]=i[l+8>>2],l=0),I=u,0|(v=l)}function Ae(A,e,r,t){r|=0,t|=0;var n,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0;if(o=I,I=I+48|0,s=o+36|0,u=o+24|0,l=o+12|0,h=o,f=0|Qe(0|(A|=0),0|(e|=0),52),M(),f&=15,d=0|Qe(0|A,0|e,45),M(),n=0|S(d&=127),ye(0|f,0,52),p=134225919|M(),i[(w=t)>>2]=-1,i[w+4>>2]=p,!f)return(0|i[r>>2])>1||(0|i[r+4>>2])>1||(0|i[r+8>>2])>1||127==(0|(a=0|L(d,0|AA(r))))?(I=o,0|(p=1)):(g=0|ye(0|a,0,45),w=0|M(),w=-1040385&i[(d=t)+4>>2]|w,i[(p=t)>>2]=i[d>>2]|g,i[p+4>>2]=w,I=o,0|(p=0));for(i[s>>2]=i[r>>2],i[s+4>>2]=i[r+4>>2],i[s+8>>2]=i[r+8>>2];i[u>>2]=i[s>>2],i[u+4>>2]=i[s+4>>2],i[u+8>>2]=i[s+8>>2],0|RA(f)?(eA(s),i[l>>2]=i[s>>2],i[l+4>>2]=i[s+4>>2],i[l+8>>2]=i[s+8>>2],tA(l)):(rA(s),i[l>>2]=i[s>>2],i[l+4>>2]=i[s+4>>2],i[l+8>>2]=i[s+8>>2],iA(l)),q(u,l,h),J(h),B=0|i[(w=t)>>2],w=0|i[w+4>>2],r=0|ye(7,0,0|(b=3*(15-f|0)|0)),w&=~(0|M()),b=0|ye(0|AA(h),0,0|b),w=0|M()|w,i[(p=t)>>2]=b|B&~r,i[p+4>>2]=w,(0|f)>1;)f=f+-1|0;A:do{if((0|i[s>>2])<=1&&(0|i[s+4>>2])<=1&&(0|i[s+8>>2])<=1){h=127==(0|(u=0|L(d,f=0|AA(s))))?0:0|S(u);e:do{if(f){if(n){if(s=21408+(28*(0|GA(A,e))|0)+(f<<2)|0,(0|(s=0|i[s>>2]))>0){r=0;do{f=0|fA(f),r=r+1|0}while((0|r)!=(0|s))}if(1==(0|f)){a=3;break A}127==(0|(r=0|L(d,f)))&&Q(23104,22949,376,23134),0|S(r)?Q(23147,22949,377,23134):(g=s,c=f,a=r)}else g=0,c=f,a=u;if((0|(l=0|i[4304+(28*d|0)+(c<<2)>>2]))<=-1&&Q(23178,22949,384,23134),!h){if((0|g)<=-1&&Q(23030,22949,417,23134),0|g){f=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];do{r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,f=f+1|0}while((0|f)<(0|g))}if((0|l)<=0){f=54;break}for(f=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];;)if(r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,(0|(f=f+1|0))==(0|l)){f=54;break e}}if(7==(0|(u=0|z(a,d)))&&Q(22925,22949,393,23134),r=0|i[(f=t)>>2],f=0|i[f+4>>2],(0|l)>0){s=0;do{r=0|TA(r,f),f=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=f,s=s+1|0}while((0|s)!=(0|l))}if(r=0|GA(r,f),b=0|T(a),(0|(r=0|i[(b?21824:21616)+(28*u|0)+(r<<2)>>2]))<=-1&&Q(23030,22949,412,23134),r){f=0,s=0|i[(u=t)>>2],u=0|i[u+4>>2];do{s=0|SA(s,u),u=0|M(),i[(b=t)>>2]=s,i[b+4>>2]=u,f=f+1|0}while((0|f)<(0|r));f=54}else f=54}else if(0!=(0|n)&0!=(0|h))if(f=21408+(28*(b=0|GA(A,e))|0)+((0|GA(0|i[(f=t)>>2],0|i[f+4>>2]))<<2)|0,(0|(f=0|i[f>>2]))<=-1&&Q(23201,22949,433,23134),f){a=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];do{r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,a=a+1|0}while((0|a)<(0|f));a=u,f=54}else a=u,f=55;else a=u,f=54}while(0);if(54==(0|f)&&h&&(f=55),55==(0|f)&&1==(0|GA(0|i[(b=t)>>2],0|i[b+4>>2]))){a=4;break}p=0|i[(b=t)>>2],b=-1040385&i[b+4>>2],B=0|ye(0|a,0,45),b=0|b|M(),i[(a=t)>>2]=p|B,i[a+4>>2]=b,a=0}else a=2}while(0);return I=o,0|(b=a)}function ee(A,e){var r=0;if(!(e|=0))return 0|(r=1);r=A|=0,A=1;do{A=0|b(0==(1&e|0)?1:r,A),e>>=1,r=0|b(r,r)}while(0!=(0|e));return 0|A}function re(A,e,r){A|=0;var t,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0;if(!(0|O(e|=0,r|=0)))return 0|(d=0);if(e=0|Y(e),o=+n[r>>3],a=e&(a=+n[r+8>>3])<0?a+6.283185307179586:a,(0|(d=0|i[A>>2]))<=0)return 0|(d=0);if(t=0|i[A+4>>2],e){e=0,r=-1,A=0;A:for(;;){for(c=A;u=+n[t+(c<<4)>>3],h=+n[t+(c<<4)+8>>3],s=+n[t+((A=(r+2|0)%(0|d)|0)<<4)>>3],f=+n[t+(A<<4)+8>>3],u>s?(l=u,u=h):(l=s,s=u,u=f,f=h),ol;){if(!((0|(r=c+1|0))<(0|d))){r=22;break A}A=c,c=r,r=A}if(a=(u=u<0?u+6.283185307179586:u)==a|(h=f<0?f+6.283185307179586:f)==a?a+-2220446049250313e-31:a,((h+=(o-s)/(l-s)*(u-h))<0?h+6.283185307179586:h)>a&&(e^=1),(0|(A=c+1|0))>=(0|d)){r=22;break}r=c}if(22==(0|r))return 0|e}else{e=0,r=-1,A=0;A:for(;;){for(c=A;u=+n[t+(c<<4)>>3],h=+n[t+(c<<4)+8>>3],s=+n[t+((A=(r+2|0)%(0|d)|0)<<4)>>3],f=+n[t+(A<<4)+8>>3],u>s?(l=u,u=h):(l=s,s=u,u=f,f=h),ol;){if(!((0|(r=c+1|0))<(0|d))){r=22;break A}A=c,c=r,r=A}if(f+(o-s)/(l-s)*(u-f)>(a=u==a|f==a?a+-2220446049250313e-31:a)&&(e^=1),(0|(A=c+1|0))>=(0|d)){r=22;break}r=c}if(22==(0|r))return 0|e}return 0}function te(A,e){e|=0;var r,t,o,a,s,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0;if(!(t=0|i[(A|=0)>>2]))return i[e>>2]=0,i[e+4>>2]=0,i[e+8>>2]=0,i[e+12>>2]=0,i[e+16>>2]=0,i[e+20>>2]=0,i[e+24>>2]=0,void(i[e+28>>2]=0);if(n[(o=e+8|0)>>3]=17976931348623157e292,n[(a=e+24|0)>>3]=17976931348623157e292,n[e>>3]=-17976931348623157e292,n[(s=e+16|0)>>3]=-17976931348623157e292,!((0|t)<=0)){for(r=0|i[A+4>>2],p=17976931348623157e292,B=-17976931348623157e292,b=0,A=-1,c=17976931348623157e292,d=17976931348623157e292,w=-17976931348623157e292,l=-17976931348623157e292,v=0;u=+n[r+(v<<4)>>3],g=+n[r+(v<<4)+8>>3],h=+n[r+(((0|(A=A+2|0))==(0|t)?0:A)<<4)+8>>3],u>3]=u,c=u),g>3]=g,d=g),u>w?n[e>>3]=u:u=w,g>l&&(n[s>>3]=g,l=g),p=g>0&gB?g:B,b|=+f(+(g-h))>3.141592653589793,(0|(A=v+1|0))!=(0|t);)m=v,w=u,v=A,A=m;b&&(n[s>>3]=B,n[a>>3]=p)}}function ie(A,e){e|=0;var r,t=0,o=0,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,Q=0,y=0,E=0;if(B=0|i[(A|=0)>>2]){if(n[(b=e+8|0)>>3]=17976931348623157e292,n[(v=e+24|0)>>3]=17976931348623157e292,n[e>>3]=-17976931348623157e292,n[(m=e+16|0)>>3]=-17976931348623157e292,(0|B)>0){for(a=0|i[A+4>>2],w=17976931348623157e292,p=-17976931348623157e292,o=0,t=-1,h=17976931348623157e292,c=17976931348623157e292,g=-17976931348623157e292,u=-17976931348623157e292,k=0;s=+n[a+(k<<4)>>3],d=+n[a+(k<<4)+8>>3],l=+n[a+(((0|(y=t+2|0))==(0|B)?0:y)<<4)+8>>3],s>3]=s,h=s),d>3]=d,c=d),s>g?n[e>>3]=s:s=g,d>u&&(n[m>>3]=d,u=d),w=d>0&dp?d:p,o|=+f(+(d-l))>3.141592653589793,(0|(t=k+1|0))!=(0|B);)y=k,g=s,k=t,t=y;o&&(n[m>>3]=p,n[v>>3]=w)}}else i[e>>2]=0,i[e+4>>2]=0,i[e+8>>2]=0,i[e+12>>2]=0,i[e+16>>2]=0,i[e+20>>2]=0,i[e+24>>2]=0,i[e+28>>2]=0;if(!((0|(t=0|i[(y=A+8|0)>>2]))<=0)){r=A+12|0,Q=0;do{if(a=0|i[r>>2],o=Q,v=e+((Q=Q+1|0)<<5)|0,m=0|i[a+(o<<3)>>2]){if(n[(k=e+(Q<<5)+8|0)>>3]=17976931348623157e292,n[(A=e+(Q<<5)+24|0)>>3]=17976931348623157e292,n[v>>3]=-17976931348623157e292,n[(M=e+(Q<<5)+16|0)>>3]=-17976931348623157e292,(0|m)>0){for(B=0|i[a+(o<<3)+4>>2],w=17976931348623157e292,p=-17976931348623157e292,a=0,o=-1,b=0,h=17976931348623157e292,c=17976931348623157e292,d=-17976931348623157e292,u=-17976931348623157e292;s=+n[B+(b<<4)>>3],g=+n[B+(b<<4)+8>>3],l=+n[B+(((0|(o=o+2|0))==(0|m)?0:o)<<4)+8>>3],s>3]=s,h=s),g>3]=g,c=g),s>d?n[v>>3]=s:s=d,g>u&&(n[M>>3]=g,u=g),w=g>0&gp?g:p,a|=+f(+(g-l))>3.141592653589793,(0|(o=b+1|0))!=(0|m);)E=b,b=o,d=s,o=E;a&&(n[M>>3]=p,n[A>>3]=w)}}else i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0,i[v+16>>2]=0,i[v+20>>2]=0,i[v+24>>2]=0,i[v+28>>2]=0,t=0|i[y>>2]}while((0|Q)<(0|t))}}function ne(A,e,r){var t=0,n=0,o=0;if(!(0|re(A|=0,e|=0,r|=0)))return 0|(n=0);if((0|i[(n=A+8|0)>>2])<=0)return 0|(n=1);for(t=A+12|0,A=0;;){if(o=A,A=A+1|0,0|re((0|i[t>>2])+(o<<3)|0,e+(A<<5)|0,r)){A=0,t=6;break}if((0|A)>=(0|i[n>>2])){A=1,t=6;break}}return 6==(0|t)?0|A:0}function oe(A,e,r,t,i){e|=0,r|=0,t|=0,i|=0;var o,a,f,s,u,l,h,c=0;s=+n[(A|=0)>>3],f=+n[e>>3]-s,a=+n[A+8>>3],o=+n[e+8>>3]-a,l=+n[r>>3],c=((c=+n[t>>3]-l)*(a-(h=+n[r+8>>3]))-(s-l)*(u=+n[t+8>>3]-h))/(f*u-o*c),n[i>>3]=s+f*c,n[i+8>>3]=a+o*c}function ae(A,e){return e|=0,+n[(A|=0)>>3]!=+n[e>>3]?0|(e=0):0|(e=+n[A+8>>3]==+n[e+8>>3])}function fe(A,e){e|=0;var r,t,i;return+((i=+n[(A|=0)>>3]-+n[e>>3])*i+(t=+n[A+8>>3]-+n[e+8>>3])*t+(r=+n[A+16>>3]-+n[e+16>>3])*r)}function se(A,e,r){A|=0,r|=0;var t=0;(0|(e|=0))>0?(t=0|be(e,4),i[A>>2]=t,t||Q(23230,23253,40,23267)):i[A>>2]=0,i[A+4>>2]=e,i[A+8>>2]=0,i[A+12>>2]=r}function ue(A){var e,r,t,o=0,a=0,s=0,l=0;e=(A|=0)+4|0,r=A+12|0,t=A+8|0;A:for(;;){for(a=0|i[e>>2],o=0;;){if((0|o)>=(0|a))break A;if(s=0|i[A>>2],l=0|i[s+(o<<2)>>2])break;o=o+1|0}o=s+(~~(+f(+ +u(10,+ +(15-(0|i[r>>2])|0))*(+n[l>>3]+ +n[l+8>>3]))%+(0|a))>>>0<<2)|0,a=0|i[o>>2];e:do{if(0|a){if(s=l+32|0,(0|a)==(0|l))i[o>>2]=i[s>>2];else{if(!(o=0|i[(a=a+32|0)>>2]))break;for(;(0|o)!=(0|l);)if(!(o=0|i[(a=o+32|0)>>2]))break e;i[a>>2]=i[s>>2]}Be(l),i[t>>2]=(0|i[t>>2])-1}}while(0)}Be(0|i[A>>2])}function le(A){var e,r=0,t=0;for(e=0|i[(A|=0)+4>>2],t=0;;){if((0|t)>=(0|e)){r=0,t=4;break}if(r=0|i[(0|i[A>>2])+(t<<2)>>2]){t=4;break}t=t+1|0}return 4==(0|t)?0|r:0}function he(A,e){e|=0;var r=0,t=0,o=0,a=0;if(r=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,r=(0|i[A>>2])+(r<<2)|0,!(t=0|i[r>>2]))return 0|(a=1);a=e+32|0;do{if((0|t)!=(0|e)){if(!(r=0|i[t+32>>2]))return 0|(a=1);for(o=r;;){if((0|o)==(0|e)){o=8;break}if(!(r=0|i[o+32>>2])){r=1,o=10;break}t=o,o=r}if(8==(0|o)){i[t+32>>2]=i[a>>2];break}if(10==(0|o))return 0|r}else i[r>>2]=i[a>>2]}while(0);return Be(e),i[(a=A+8|0)>>2]=(0|i[a>>2])-1,0|(a=0)}function ce(A,e,r){A|=0,e|=0,r|=0;var t,o=0,a=0,s=0;(t=0|pe(40))||Q(23283,23253,98,23296),i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2],i[(a=t+16|0)>>2]=i[r>>2],i[a+4>>2]=i[r+4>>2],i[a+8>>2]=i[r+8>>2],i[a+12>>2]=i[r+12>>2],i[t+32>>2]=0,a=~~(+f(+ +u(10,+ +(15-(0|i[A+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,a=(0|i[A>>2])+(a<<2)|0,o=0|i[a>>2];do{if(o){for(;!(0|xA(o,e)&&0|xA(o+16|0,r));)if(a=0|i[o+32>>2],!(0|i[(o=0==(0|a)?o:a)+32>>2])){s=10;break}if(10==(0|s)){i[o+32>>2]=t;break}return Be(t),0|(s=o)}i[a>>2]=t}while(0);return i[(s=A+8|0)>>2]=1+(0|i[s>>2]),0|(s=t)}function de(A,e,r){e|=0,r|=0;var t=0,o=0;if(o=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,!(o=0|i[(0|i[A>>2])+(o<<2)>>2]))return 0|(r=0);if(!r){for(A=o;;){if(0|xA(A,e)){t=10;break}if(!(A=0|i[A+32>>2])){A=0,t=10;break}}if(10==(0|t))return 0|A}for(A=o;;){if(0|xA(A,e)&&0|xA(A+16|0,r)){t=10;break}if(!(A=0|i[A+32>>2])){A=0,t=10;break}}return 10==(0|t)?0|A:0}function ge(A,e){e|=0;var r=0;if(r=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,!(A=0|i[(0|i[A>>2])+(r<<2)>>2]))return 0|(r=0);for(;;){if(0|xA(A,e)){e=5;break}if(!(A=0|i[A+32>>2])){A=0,e=5;break}}return 5==(0|e)?0|A:0}function we(A){return 0|~~+function(A){return+ +Ie(+(A=+A))}(A=+A)}function pe(A){A|=0;var e,r=0,t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0;e=I,I=I+16|0,d=e;do{if(A>>>0<245){if(A=(l=A>>>0<11?16:A+11&-8)>>>3,3&(t=(c=0|i[5829])>>>A)|0)return n=0|i[(t=(A=23356+((r=(1&t^1)+A|0)<<1<<2)|0)+8|0)>>2],(0|(a=0|i[(o=n+8|0)>>2]))==(0|A)?i[5829]=c&~(1<>2]=A,i[t>>2]=a),k=r<<3,i[n+4>>2]=3|k,i[(k=n+k+4|0)>>2]=1|i[k>>2],I=e,0|(k=o);if(l>>>0>(h=0|i[5831])>>>0){if(0|t)return r=((r=t<>>=s=r>>>12&16)>>>5&8)|s|(a=(r>>>=t)>>>2&4)|(A=(r>>>=a)>>>1&2)|(n=(r>>>=A)>>>1&1))+(r>>>n)|0)<<1<<2)|0)+8|0)>>2],(0|(t=0|i[(s=a+8|0)>>2]))==(0|r)?(A=c&~(1<>2]=r,i[A>>2]=t,A=c),f=(k=n<<3)-l|0,i[a+4>>2]=3|l,i[(o=a+l|0)+4>>2]=1|f,i[a+k>>2]=f,0|h&&(n=0|i[5834],t=23356+((r=h>>>3)<<1<<2)|0,A&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=n,i[r+12>>2]=n,i[n+8>>2]=r,i[n+12>>2]=t),i[5831]=f,i[5834]=o,I=e,0|(k=s);if(a=0|i[5830]){for(t=(a&0-a)-1|0,t=u=0|i[23620+(((n=(t>>>=o=t>>>12&16)>>>5&8)|o|(f=(t>>>=n)>>>2&4)|(s=(t>>>=f)>>>1&2)|(u=(t>>>=s)>>>1&1))+(t>>>u)<<2)>>2],s=u,u=(-8&i[u+4>>2])-l|0;(A=0|i[t+16>>2])||(A=0|i[t+20>>2]);)t=A,s=(o=(f=(-8&i[A+4>>2])-l|0)>>>0>>0)?A:s,u=o?f:u;if((f=s+l|0)>>>0>s>>>0){o=0|i[s+24>>2],r=0|i[s+12>>2];do{if((0|r)==(0|s)){if(!(r=0|i[(A=s+20|0)>>2])&&!(r=0|i[(A=s+16|0)>>2])){t=0;break}for(;;)if(t=0|i[(n=r+20|0)>>2])r=t,A=n;else{if(!(t=0|i[(n=r+16|0)>>2]))break;r=t,A=n}i[A>>2]=0,t=r}else t=0|i[s+8>>2],i[t+12>>2]=r,i[r+8>>2]=t,t=r}while(0);do{if(0|o){if(r=0|i[s+28>>2],(0|s)==(0|i[(A=23620+(r<<2)|0)>>2])){if(i[A>>2]=t,!t){i[5830]=a&~(1<>2])==(0|s)?k:o+20|0)>>2]=t,!t)break;i[t+24>>2]=o,0|(r=0|i[s+16>>2])&&(i[t+16>>2]=r,i[r+24>>2]=t),0|(r=0|i[s+20>>2])&&(i[t+20>>2]=r,i[r+24>>2]=t)}}while(0);return u>>>0<16?(k=u+l|0,i[s+4>>2]=3|k,i[(k=s+k+4|0)>>2]=1|i[k>>2]):(i[s+4>>2]=3|l,i[f+4>>2]=1|u,i[f+u>>2]=u,0|h&&(n=0|i[5834],t=23356+((r=h>>>3)<<1<<2)|0,(r=1<>2]:(i[5829]=r|c,r=t,A=t+8|0),i[A>>2]=n,i[r+12>>2]=n,i[n+8>>2]=r,i[n+12>>2]=t),i[5831]=u,i[5834]=f),I=e,0|(k=s+8|0)}c=l}else c=l}else c=l}else if(A>>>0<=4294967231)if(l=-8&(A=A+11|0),n=0|i[5830]){o=0-l|0,u=(A>>>=8)?l>>>0>16777215?31:l>>>((u=14-((s=((p=A<<(c=(A+1048320|0)>>>16&8))+520192|0)>>>16&4)|c|(u=((p<<=s)+245760|0)>>>16&2))+(p<>>15)|0)+7|0)&1|u<<1:0,t=0|i[23620+(u<<2)>>2];A:do{if(t)for(A=0,s=l<<(31==(0|u)?0:25-(u>>>1)|0),a=0;;){if((f=(-8&i[t+4>>2])-l|0)>>>0>>0){if(!f){A=t,o=0,p=65;break A}A=t,o=f}if(a=0==(0|(p=0|i[t+20>>2]))|(0|p)==(0|(t=0|i[t+16+(s>>>31<<2)>>2]))?a:p,!t){t=a,p=61;break}s<<=1}else t=0,A=0,p=61}while(0);if(61==(0|p)){if(0==(0|t)&0==(0|A)){if(!(A=((A=2<>>=f=c>>>12&16)>>>5&8)|f|(s=(c>>>=a)>>>2&4)|(u=(c>>>=s)>>>1&2)|(t=(c>>>=u)>>>1&1))+(c>>>t)<<2)>>2]}t?p=65:(s=A,f=o)}if(65==(0|p))for(a=t;;){if(o=(t=(c=(-8&i[a+4>>2])-l|0)>>>0>>0)?c:o,A=t?a:A,(t=0|i[a+16>>2])||(t=0|i[a+20>>2]),!t){s=A,f=o;break}a=t}if(0!=(0|s)&&f>>>0<((0|i[5831])-l|0)>>>0&&(h=s+l|0)>>>0>s>>>0){a=0|i[s+24>>2],r=0|i[s+12>>2];do{if((0|r)==(0|s)){if(!(r=0|i[(A=s+20|0)>>2])&&!(r=0|i[(A=s+16|0)>>2])){r=0;break}for(;;)if(t=0|i[(o=r+20|0)>>2])r=t,A=o;else{if(!(t=0|i[(o=r+16|0)>>2]))break;r=t,A=o}i[A>>2]=0}else k=0|i[s+8>>2],i[k+12>>2]=r,i[r+8>>2]=k}while(0);do{if(a){if(A=0|i[s+28>>2],(0|s)==(0|i[(t=23620+(A<<2)|0)>>2])){if(i[t>>2]=r,!r){n&=~(1<>2])==(0|s)?k:a+20|0)>>2]=r,!r)break;i[r+24>>2]=a,0|(A=0|i[s+16>>2])&&(i[r+16>>2]=A,i[A+24>>2]=r),(A=0|i[s+20>>2])&&(i[r+20>>2]=A,i[A+24>>2]=r)}}while(0);A:do{if(f>>>0<16)k=f+l|0,i[s+4>>2]=3|k,i[(k=s+k+4|0)>>2]=1|i[k>>2];else{if(i[s+4>>2]=3|l,i[h+4>>2]=1|f,i[h+f>>2]=f,r=f>>>3,f>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=h,i[r+12>>2]=h,i[h+8>>2]=r,i[h+12>>2]=t;break}if(r=23620+((t=(r=f>>>8)?f>>>0>16777215?31:f>>>((t=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(t=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|t<<1:0)<<2)|0,i[h+28>>2]=t,i[(A=h+16|0)+4>>2]=0,i[A>>2]=0,!(n&(A=1<>2]=h,i[h+24>>2]=r,i[h+12>>2]=h,i[h+8>>2]=h;break}r=0|i[r>>2];e:do{if((-8&i[r+4>>2]|0)!=(0|f)){for(n=f<<(31==(0|t)?0:25-(t>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|f)){r=A;break e}n<<=1,r=A}i[t>>2]=h,i[h+24>>2]=r,i[h+12>>2]=h,i[h+8>>2]=h;break A}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=h,i[m>>2]=h,i[h+8>>2]=k,i[h+12>>2]=r,i[h+24>>2]=0}}while(0);return I=e,0|(k=s+8|0)}c=l}else c=l;else c=-1}while(0);if((t=0|i[5831])>>>0>=c>>>0)return r=t-c|0,A=0|i[5834],r>>>0>15?(k=A+c|0,i[5834]=k,i[5831]=r,i[k+4>>2]=1|r,i[A+t>>2]=r,i[A+4>>2]=3|c):(i[5831]=0,i[5834]=0,i[A+4>>2]=3|t,i[(k=A+t+4|0)>>2]=1|i[k>>2]),I=e,0|(k=A+8|0);if((f=0|i[5832])>>>0>c>>>0)return v=f-c|0,i[5832]=v,m=(k=0|i[5835])+c|0,i[5835]=m,i[m+4>>2]=1|v,i[k+4>>2]=3|c,I=e,0|(k=k+8|0);if(0|i[5947]?A=0|i[5949]:(i[5949]=4096,i[5948]=4096,i[5950]=-1,i[5951]=-1,i[5952]=0,i[5940]=0,i[5947]=-16&d^1431655768,A=4096),s=c+48|0,(l=(a=A+(u=c+47|0)|0)&(o=0-A|0))>>>0<=c>>>0)return I=e,0|(k=0);if(0|(A=0|i[5939])&&(d=(h=0|i[5937])+l|0)>>>0<=h>>>0|d>>>0>A>>>0)return I=e,0|(k=0);A:do{if(4&i[5940])r=0,p=143;else{t=0|i[5835];e:do{if(t){for(n=23764;!((d=0|i[n>>2])>>>0<=t>>>0&&(d+(0|i[n+4>>2])|0)>>>0>t>>>0);){if(!(A=0|i[n+8>>2])){p=128;break e}n=A}if((r=a-f&o)>>>0<2147483647)if((0|(A=0|Fe(0|r)))==((0|i[n>>2])+(0|i[n+4>>2])|0)){if(-1!=(0|A)){f=r,a=A,p=145;break A}}else n=A,p=136;else r=0}else p=128}while(0);do{if(128==(0|p))if(-1!=(0|(t=0|Fe(0)))&&(r=t,w=(r=(0==((w=(g=0|i[5948])+-1|0)&r|0)?0:(w+r&0-g)-r|0)+l|0)+(g=0|i[5937])|0,r>>>0>c>>>0&r>>>0<2147483647)){if(0|(d=0|i[5939])&&w>>>0<=g>>>0|w>>>0>d>>>0){r=0;break}if((0|(A=0|Fe(0|r)))==(0|t)){f=r,a=t,p=145;break A}n=A,p=136}else r=0}while(0);do{if(136==(0|p)){if(t=0-r|0,!(s>>>0>r>>>0&r>>>0<2147483647&-1!=(0|n))){if(-1==(0|n)){r=0;break}f=r,a=n,p=145;break A}if((A=u-r+(A=0|i[5949])&0-A)>>>0>=2147483647){f=r,a=n,p=145;break A}if(-1==(0|Fe(0|A))){Fe(0|t),r=0;break}f=A+r|0,a=n,p=145;break A}}while(0);i[5940]=4|i[5940],p=143}}while(0);if(143==(0|p)&&l>>>0<2147483647&&!(-1==(0|(v=0|Fe(0|l)))|1^(b=(B=(w=0|Fe(0))-v|0)>>>0>(c+40|0)>>>0)|v>>>0>>0&-1!=(0|v)&-1!=(0|w)^1)&&(f=b?B:r,a=v,p=145),145==(0|p)){r=(0|i[5937])+f|0,i[5937]=r,r>>>0>(0|i[5938])>>>0&&(i[5938]=r),u=0|i[5835];A:do{if(u){for(r=23764;;){if((0|a)==((A=0|i[r>>2])+(t=0|i[r+4>>2])|0)){p=154;break}if(!(n=0|i[r+8>>2]))break;r=n}if(154==(0|p)&&(m=r+4|0,0==(8&i[r+12>>2]|0))&&a>>>0>u>>>0&A>>>0<=u>>>0){i[m>>2]=t+f,m=u+(v=0==(7&(v=u+8|0)|0)?0:0-v&7)|0,v=(k=(0|i[5832])+f|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[u+k+4>>2]=40,i[5836]=i[5951];break}for(a>>>0<(0|i[5833])>>>0&&(i[5833]=a),t=a+f|0,r=23764;;){if((0|i[r>>2])==(0|t)){p=162;break}if(!(A=0|i[r+8>>2]))break;r=A}if(162==(0|p)&&0==(8&i[r+12>>2]|0)){i[r>>2]=a,i[(h=r+4|0)>>2]=(0|i[h>>2])+f,l=(h=a+(0==(7&(h=a+8|0)|0)?0:0-h&7)|0)+c|0,s=(r=t+(0==(7&(r=t+8|0)|0)?0:0-r&7)|0)-h-c|0,i[h+4>>2]=3|c;e:do{if((0|u)==(0|r))k=(0|i[5832])+s|0,i[5832]=k,i[5835]=l,i[l+4>>2]=1|k;else{if((0|i[5834])==(0|r)){k=(0|i[5831])+s|0,i[5831]=k,i[5834]=l,i[l+4>>2]=1|k,i[l+k>>2]=k;break}if(1==(3&(A=0|i[r+4>>2])|0)){f=-8&A,n=A>>>3;r:do{if(A>>>0<256){if(A=0|i[r+8>>2],(0|(t=0|i[r+12>>2]))==(0|A)){i[5829]=i[5829]&~(1<>2]=t,i[t+8>>2]=A;break}a=0|i[r+24>>2],A=0|i[r+12>>2];do{if((0|A)==(0|r)){if(A=0|i[(n=(t=r+16|0)+4|0)>>2])t=n;else if(!(A=0|i[t>>2])){A=0;break}for(;;)if(n=0|i[(o=A+20|0)>>2])A=n,t=o;else{if(!(n=0|i[(o=A+16|0)>>2]))break;A=n,t=o}i[t>>2]=0}else k=0|i[r+8>>2],i[k+12>>2]=A,i[A+8>>2]=k}while(0);if(!a)break;n=23620+((t=0|i[r+28>>2])<<2)|0;do{if((0|i[n>>2])==(0|r)){if(i[n>>2]=A,0|A)break;i[5830]=i[5830]&~(1<>2])==(0|r)?k:a+20|0)>>2]=A,!A)break r}while(0);if(i[A+24>>2]=a,0|(n=0|i[(t=r+16|0)>>2])&&(i[A+16>>2]=n,i[n+24>>2]=A),!(t=0|i[t+4>>2]))break;i[A+20>>2]=t,i[t+24>>2]=A}while(0);r=r+f|0,o=f+s|0}else o=s;if(i[(r=r+4|0)>>2]=-2&i[r>>2],i[l+4>>2]=1|o,i[l+o>>2]=o,r=o>>>3,o>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=l,i[r+12>>2]=l,i[l+8>>2]=r,i[l+12>>2]=t;break}r=o>>>8;do{if(r){if(o>>>0>16777215){n=31;break}n=o>>>((n=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(n=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|n<<1}else n=0}while(0);if(r=23620+(n<<2)|0,i[l+28>>2]=n,i[(A=l+16|0)+4>>2]=0,i[A>>2]=0,!((A=0|i[5830])&(t=1<>2]=l,i[l+24>>2]=r,i[l+12>>2]=l,i[l+8>>2]=l;break}r=0|i[r>>2];r:do{if((-8&i[r+4>>2]|0)!=(0|o)){for(n=o<<(31==(0|n)?0:25-(n>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|o)){r=A;break r}n<<=1,r=A}i[t>>2]=l,i[l+24>>2]=r,i[l+12>>2]=l,i[l+8>>2]=l;break e}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=l,i[m>>2]=l,i[l+8>>2]=k,i[l+12>>2]=r,i[l+24>>2]=0}}while(0);return I=e,0|(k=h+8|0)}for(r=23764;!((A=0|i[r>>2])>>>0<=u>>>0&&(k=A+(0|i[r+4>>2])|0)>>>0>u>>>0);)r=0|i[r+8>>2];r=(A=(A=(o=k+-47|0)+(0==(7&(A=o+8|0)|0)?0:0-A&7)|0)>>>0<(o=u+16|0)>>>0?u:A)+8|0,m=a+(v=0==(7&(v=a+8|0)|0)?0:0-v&7)|0,v=(t=f+-40|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[a+t+4>>2]=40,i[5836]=i[5951],i[(t=A+4|0)>>2]=27,i[r>>2]=i[5941],i[r+4>>2]=i[5942],i[r+8>>2]=i[5943],i[r+12>>2]=i[5944],i[5941]=a,i[5942]=f,i[5944]=0,i[5943]=r,r=A+24|0;do{m=r,i[(r=r+4|0)>>2]=7}while((m+8|0)>>>0>>0);if((0|A)!=(0|u)){if(a=A-u|0,i[t>>2]=-2&i[t>>2],i[u+4>>2]=1|a,i[A>>2]=a,r=a>>>3,a>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=u,i[r+12>>2]=u,i[u+8>>2]=r,i[u+12>>2]=t;break}if(t=23620+((n=(r=a>>>8)?a>>>0>16777215?31:a>>>((n=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(n=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|n<<1:0)<<2)|0,i[u+28>>2]=n,i[u+20>>2]=0,i[o>>2]=0,!((r=0|i[5830])&(A=1<>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break}r=0|i[t>>2];e:do{if((-8&i[r+4>>2]|0)!=(0|a)){for(n=a<<(31==(0|n)?0:25-(n>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|a)){r=A;break e}n<<=1,r=A}i[t>>2]=u,i[u+24>>2]=r,i[u+12>>2]=u,i[u+8>>2]=u;break A}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=u,i[m>>2]=u,i[u+8>>2]=k,i[u+12>>2]=r,i[u+24>>2]=0}}else 0==(0|(k=0|i[5833]))|a>>>0>>0&&(i[5833]=a),i[5941]=a,i[5942]=f,i[5944]=0,i[5838]=i[5947],i[5837]=-1,i[5842]=23356,i[5841]=23356,i[5844]=23364,i[5843]=23364,i[5846]=23372,i[5845]=23372,i[5848]=23380,i[5847]=23380,i[5850]=23388,i[5849]=23388,i[5852]=23396,i[5851]=23396,i[5854]=23404,i[5853]=23404,i[5856]=23412,i[5855]=23412,i[5858]=23420,i[5857]=23420,i[5860]=23428,i[5859]=23428,i[5862]=23436,i[5861]=23436,i[5864]=23444,i[5863]=23444,i[5866]=23452,i[5865]=23452,i[5868]=23460,i[5867]=23460,i[5870]=23468,i[5869]=23468,i[5872]=23476,i[5871]=23476,i[5874]=23484,i[5873]=23484,i[5876]=23492,i[5875]=23492,i[5878]=23500,i[5877]=23500,i[5880]=23508,i[5879]=23508,i[5882]=23516,i[5881]=23516,i[5884]=23524,i[5883]=23524,i[5886]=23532,i[5885]=23532,i[5888]=23540,i[5887]=23540,i[5890]=23548,i[5889]=23548,i[5892]=23556,i[5891]=23556,i[5894]=23564,i[5893]=23564,i[5896]=23572,i[5895]=23572,i[5898]=23580,i[5897]=23580,i[5900]=23588,i[5899]=23588,i[5902]=23596,i[5901]=23596,i[5904]=23604,i[5903]=23604,m=a+(v=0==(7&(v=a+8|0)|0)?0:0-v&7)|0,v=(k=f+-40|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[a+k+4>>2]=40,i[5836]=i[5951]}while(0);if((r=0|i[5832])>>>0>c>>>0)return v=r-c|0,i[5832]=v,m=(k=0|i[5835])+c|0,i[5835]=m,i[m+4>>2]=1|v,i[k+4>>2]=3|c,I=e,0|(k=k+8|0)}return i[(k=23312)>>2]=12,I=e,0|(k=0)}function Be(A){var e=0,r=0,t=0,n=0,o=0,a=0,f=0,s=0;if(A|=0){r=A+-8|0,n=0|i[5833],s=r+(e=-8&(A=0|i[A+-4>>2]))|0;do{if(1&A)f=r,a=r;else{if(t=0|i[r>>2],!(3&A))return;if(o=t+e|0,(a=r+(0-t)|0)>>>0>>0)return;if((0|i[5834])==(0|a)){if(3!=(3&(e=0|i[(A=s+4|0)>>2])|0)){f=a,e=o;break}return i[5831]=o,i[A>>2]=-2&e,i[a+4>>2]=1|o,void(i[a+o>>2]=o)}if(r=t>>>3,t>>>0<256){if(A=0|i[a+8>>2],(0|(e=0|i[a+12>>2]))==(0|A)){i[5829]=i[5829]&~(1<>2]=e,i[e+8>>2]=A,f=a,e=o;break}n=0|i[a+24>>2],A=0|i[a+12>>2];do{if((0|A)==(0|a)){if(A=0|i[(r=(e=a+16|0)+4|0)>>2])e=r;else if(!(A=0|i[e>>2])){A=0;break}for(;;)if(r=0|i[(t=A+20|0)>>2])A=r,e=t;else{if(!(r=0|i[(t=A+16|0)>>2]))break;A=r,e=t}i[e>>2]=0}else f=0|i[a+8>>2],i[f+12>>2]=A,i[A+8>>2]=f}while(0);if(n){if(e=0|i[a+28>>2],(0|i[(r=23620+(e<<2)|0)>>2])==(0|a)){if(i[r>>2]=A,!A){i[5830]=i[5830]&~(1<>2])==(0|a)?f:n+20|0)>>2]=A,!A){f=a,e=o;break}i[A+24>>2]=n,0|(r=0|i[(e=a+16|0)>>2])&&(i[A+16>>2]=r,i[r+24>>2]=A),(e=0|i[e+4>>2])?(i[A+20>>2]=e,i[e+24>>2]=A,f=a,e=o):(f=a,e=o)}else f=a,e=o}}while(0);if(!(a>>>0>=s>>>0)&&1&(t=0|i[(A=s+4|0)>>2])){if(2&t)i[A>>2]=-2&t,i[f+4>>2]=1|e,i[a+e>>2]=e,n=e;else{if((0|i[5835])==(0|s)){if(s=(0|i[5832])+e|0,i[5832]=s,i[5835]=f,i[f+4>>2]=1|s,(0|f)!=(0|i[5834]))return;return i[5834]=0,void(i[5831]=0)}if((0|i[5834])==(0|s))return s=(0|i[5831])+e|0,i[5831]=s,i[5834]=a,i[f+4>>2]=1|s,void(i[a+s>>2]=s);n=(-8&t)+e|0,r=t>>>3;do{if(t>>>0<256){if(e=0|i[s+8>>2],(0|(A=0|i[s+12>>2]))==(0|e)){i[5829]=i[5829]&~(1<>2]=A,i[A+8>>2]=e;break}o=0|i[s+24>>2],A=0|i[s+12>>2];do{if((0|A)==(0|s)){if(A=0|i[(r=(e=s+16|0)+4|0)>>2])e=r;else if(!(A=0|i[e>>2])){r=0;break}for(;;)if(r=0|i[(t=A+20|0)>>2])A=r,e=t;else{if(!(r=0|i[(t=A+16|0)>>2]))break;A=r,e=t}i[e>>2]=0,r=A}else r=0|i[s+8>>2],i[r+12>>2]=A,i[A+8>>2]=r,r=A}while(0);if(0|o){if(A=0|i[s+28>>2],(0|i[(e=23620+(A<<2)|0)>>2])==(0|s)){if(i[e>>2]=r,!r){i[5830]=i[5830]&~(1<>2])==(0|s)?t:o+20|0)>>2]=r,!r)break;i[r+24>>2]=o,0|(e=0|i[(A=s+16|0)>>2])&&(i[r+16>>2]=e,i[e+24>>2]=r),0|(A=0|i[A+4>>2])&&(i[r+20>>2]=A,i[A+24>>2]=r)}}while(0);if(i[f+4>>2]=1|n,i[a+n>>2]=n,(0|f)==(0|i[5834]))return void(i[5831]=n)}if(A=n>>>3,n>>>0<256)return r=23356+(A<<1<<2)|0,(e=0|i[5829])&(A=1<>2]:(i[5829]=e|A,A=r,e=r+8|0),i[e>>2]=f,i[A+12>>2]=f,i[f+8>>2]=A,void(i[f+12>>2]=r);A=23620+((t=(A=n>>>8)?n>>>0>16777215?31:n>>>((t=14-((o=((s=A<<(a=(A+1048320|0)>>>16&8))+520192|0)>>>16&4)|a|(t=((s<<=o)+245760|0)>>>16&2))+(s<>>15)|0)+7|0)&1|t<<1:0)<<2)|0,i[f+28>>2]=t,i[f+20>>2]=0,i[f+16>>2]=0,e=0|i[5830],r=1<>2];e:do{if((-8&i[A+4>>2]|0)!=(0|n)){for(t=n<<(31==(0|t)?0:25-(t>>>1)|0);e=0|i[(r=A+16+(t>>>31<<2)|0)>>2];){if((-8&i[e+4>>2]|0)==(0|n)){A=e;break e}t<<=1,A=e}i[r>>2]=f,i[f+24>>2]=A,i[f+12>>2]=f,i[f+8>>2]=f;break A}}while(0);s=0|i[(a=A+8|0)>>2],i[s+12>>2]=f,i[a>>2]=f,i[f+8>>2]=s,i[f+12>>2]=A,i[f+24>>2]=0}else i[5830]=e|r,i[A>>2]=f,i[f+24>>2]=A,i[f+12>>2]=f,i[f+8>>2]=f}while(0);if(s=(0|i[5837])-1|0,i[5837]=s,!(0|s)){for(A=23772;A=0|i[A>>2];)A=A+8|0;i[5837]=-1}}}}function be(A,e){e|=0;var r=0;return(A|=0)?(r=0|b(e,A),(e|A)>>>0>65535&&(r=(0|(r>>>0)/(A>>>0))==(0|e)?r:-1)):r=0,(A=0|pe(r))&&3&i[A+-4>>2]?(_e(0|A,0,0|r),0|A):0|A}function ve(A,e,r,t){return 0|(k(0|(t=(e|=0)-(t|=0)-((r|=0)>>>0>(A|=0)>>>0|0)>>>0)),A-r>>>0|0)}function me(A){return 0|((A|=0)?31-(0|m(A^A-1))|0:32)}function ke(A,e,r,t,n){n|=0;var o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0;if(l=A|=0,a=r|=0,f=c=t|=0,!(u=s=e|=0))return o=0!=(0|n),f?o?(i[n>>2]=0|A,i[n+4>>2]=0&e,n=0,0|(k(0|(c=0)),n)):(n=0,0|(k(0|(c=0)),n)):(o&&(i[n>>2]=(l>>>0)%(a>>>0),i[n+4>>2]=0),n=(l>>>0)/(a>>>0)>>>0,0|(k(0|(c=0)),n));o=0==(0|f);do{if(a){if(!o){if((o=(0|m(0|f))-(0|m(0|u))|0)>>>0<=31){a=h=o+1|0,A=l>>>(h>>>0)&(e=o-31>>31)|u<<(f=31-o|0),e&=u>>>(h>>>0),o=0,f=l<>2]=0|A,i[n+4>>2]=s|0&e,n=0,0|(k(0|(c=0)),n)):(n=0,0|(k(0|(c=0)),n))}if((o=a-1|0)&a|0){a=f=33+(0|m(0|a))-(0|m(0|u))|0,A=(h=32-f|0)-1>>31&u>>>((d=f-32|0)>>>0)|(u<>>(f>>>0))&(e=d>>31),e&=u>>>(f>>>0),o=l<<(g=64-f|0)&(s=h>>31),f=(u<>>(d>>>0))&s|l<>31;break}return 0|n&&(i[n>>2]=o&l,i[n+4>>2]=0),1==(0|a)?(g=0|A,0|(k(0|(d=s|0&e)),g)):(d=u>>>((g=0|me(0|a))>>>0)|0,g=u<<32-g|l>>>(g>>>0)|0,0|(k(0|d),g))}if(o)return 0|n&&(i[n>>2]=(u>>>0)%(a>>>0),i[n+4>>2]=0),g=(u>>>0)/(a>>>0)>>>0,0|(k(0|(d=0)),g);if(!l)return 0|n&&(i[n>>2]=0,i[n+4>>2]=(u>>>0)%(f>>>0)),g=(u>>>0)/(f>>>0)>>>0,0|(k(0|(d=0)),g);if(!((o=f-1|0)&f))return 0|n&&(i[n>>2]=0|A,i[n+4>>2]=o&u|0&e),d=0,g=u>>>((0|me(0|f))>>>0),0|(k(0|d),g);if((o=(0|m(0|f))-(0|m(0|u))|0)>>>0<=30){a=e=o+1|0,A=u<<(f=31-o|0)|l>>>(e>>>0),e=u>>>(e>>>0),o=0,f=l<>2]=0|A,i[n+4>>2]=s|0&e,g=0,0|(k(0|(d=0)),g)):(g=0,0|(k(0|(d=0)),g))}while(0);if(a){u=0|function(A,e,r,t){return 0|(k((e|=0)+(t|=0)+((r=(A|=0)+(r|=0)>>>0)>>>0>>0|0)>>>0|0),0|r)}(0|(h=0|r),0|(l=c|0&t),-1,-1),r=0|M(),s=f,f=0;do{t=s,s=o>>>31|s<<1,o=f|o<<1,ve(0|u,0|r,0|(t=A<<1|t>>>31|0),0|(c=A>>>31|e<<1|0)),f=1&(d=(g=0|M())>>31|((0|g)<0?-1:0)<<1),A=0|ve(0|t,0|c,d&h|0,(((0|g)<0?-1:0)>>31|((0|g)<0?-1:0)<<1)&l|0),e=0|M(),a=a-1|0}while(0!=(0|a));u=s,s=0}else u=f,s=0,f=0;return a=0,0|n&&(i[n>>2]=A,i[n+4>>2]=e),g=-2&(o<<1|0)|f,0|(k(0|(d=(0|o)>>>31|(u|a)<<1|0&(a<<1|o>>>31)|s)),g)}function Me(A,e,r,t){var n,o;return o=I,I=I+16|0,ke(A|=0,e|=0,r|=0,t|=0,n=0|o),I=o,0|(k(0|i[n+4>>2]),0|i[n>>2])}function Qe(A,e,r){return A|=0,e|=0,(0|(r|=0))<32?(k(e>>>r|0),A>>>r|(e&(1<>>r-32|0)}function ye(A,e,r){return A|=0,e|=0,(0|(r|=0))<32?(k(e<>>32-r|0),A<=0?+a(A+.5):+B(A-.5)}function De(A,e,r){A|=0,e|=0;var n,o,a=0;if((0|(r|=0))>=8192)return x(0|A,0|e,0|r),0|A;if(o=0|A,n=A+r|0,(3&A)==(3&e)){for(;3&A;){if(!r)return 0|o;t[A>>0]=0|t[e>>0],A=A+1|0,e=e+1|0,r=r-1|0}for(a=(r=-4&n|0)-64|0;(0|A)<=(0|a);)i[A>>2]=i[e>>2],i[A+4>>2]=i[e+4>>2],i[A+8>>2]=i[e+8>>2],i[A+12>>2]=i[e+12>>2],i[A+16>>2]=i[e+16>>2],i[A+20>>2]=i[e+20>>2],i[A+24>>2]=i[e+24>>2],i[A+28>>2]=i[e+28>>2],i[A+32>>2]=i[e+32>>2],i[A+36>>2]=i[e+36>>2],i[A+40>>2]=i[e+40>>2],i[A+44>>2]=i[e+44>>2],i[A+48>>2]=i[e+48>>2],i[A+52>>2]=i[e+52>>2],i[A+56>>2]=i[e+56>>2],i[A+60>>2]=i[e+60>>2],A=A+64|0,e=e+64|0;for(;(0|A)<(0|r);)i[A>>2]=i[e>>2],A=A+4|0,e=e+4|0}else for(r=n-4|0;(0|A)<(0|r);)t[A>>0]=0|t[e>>0],t[A+1>>0]=0|t[e+1>>0],t[A+2>>0]=0|t[e+2>>0],t[A+3>>0]=0|t[e+3>>0],A=A+4|0,e=e+4|0;for(;(0|A)<(0|n);)t[A>>0]=0|t[e>>0],A=A+1|0,e=e+1|0;return 0|o}function _e(A,e,r){e|=0;var n,o=0,a=0,f=0;if(n=(A|=0)+(r|=0)|0,e&=255,(0|r)>=67){for(;3&A;)t[A>>0]=e,A=A+1|0;for(f=e|e<<8|e<<16|e<<24,a=(o=-4&n|0)-64|0;(0|A)<=(0|a);)i[A>>2]=f,i[A+4>>2]=f,i[A+8>>2]=f,i[A+12>>2]=f,i[A+16>>2]=f,i[A+20>>2]=f,i[A+24>>2]=f,i[A+28>>2]=f,i[A+32>>2]=f,i[A+36>>2]=f,i[A+40>>2]=f,i[A+44>>2]=f,i[A+48>>2]=f,i[A+52>>2]=f,i[A+56>>2]=f,i[A+60>>2]=f,A=A+64|0;for(;(0|A)<(0|o);)i[A>>2]=f,A=A+4|0}for(;(0|A)<(0|n);)t[A>>0]=e,A=A+1|0;return n-r|0}function Ie(A){return(A=+A)>=0?+a(A+.5):+B(A-.5)}function Fe(A){A|=0;var e,r,t;return t=0|E(),(0|A)>0&(0|(e=(r=0|i[o>>2])+A|0))<(0|r)|(0|e)<0?(_(0|e),y(12),-1):(0|e)>(0|t)&&!(0|D(0|e))?(y(12),-1):(i[o>>2]=e,0|r)}return{___uremdi3:Me,_bitshift64Lshr:Qe,_bitshift64Shl:ye,_calloc:be,_cellAreaKm2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))>0){if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1!=(0|e)){A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e))}}else o=0;return I=n,6371.007180918475*o*6371.007180918475},_cellAreaM2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))>0){if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1!=(0|e)){A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e))}}else o=0;return I=n,6371.007180918475*o*6371.007180918475*1e3*1e3},_cellAreaRads2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))<=0)return I=n,+(o=0);if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1==(0|e))return I=n,+o;A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e));return I=n,+o},_compact:function(A,e,r){e|=0;var t,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,Q=0,y=0,E=0;if(!(r|=0))return 0|(y=0);if(n=0|i[(o=A|=0)>>2],!0&0==(15728640&(o=0|i[o+4>>2])|0)){if((0|r)<=0)return 0|(y=0);if(i[(y=e)>>2]=n,i[y+4>>2]=o,1==(0|r))return 0|(y=0);n=1;do{Q=0|i[(k=A+(n<<3)|0)+4>>2],i[(y=e+(n<<3)|0)>>2]=i[k>>2],i[y+4>>2]=Q,n=n+1|0}while((0|n)!=(0|r));return 0|(n=0)}if(!(Q=0|pe(k=r<<3)))return 0|(y=-3);if(De(0|Q,0|A,0|k),!(t=0|be(r,8)))return Be(Q),0|(y=-3);n=r;A:for(;;){v=0|Qe(0|(h=0|i[(f=Q)>>2]),0|(f=0|i[f+4>>2]),52),M(),m=(v&=15)+-1|0,b=(0|n)>0;e:do{if(b){if(B=((0|n)<0)<<31>>31,w=0|ye(0|m,0,52),p=0|M(),m>>>0>15)for(o=0,A=h,r=f;;){if(!(0==(0|A)&0==(0|r))){if(a=0|Qe(0|A,0|r,52),M(),s=(0|(a&=15))<(0|m),a=(0|a)==(0|m),r=0|Me(0|(l=s?0:a?A:0),0|(A=s?0:a?r:0),0|n,0|B),M(),0==(0|(u=0|i[(s=a=t+(r<<3)|0)>>2]))&0==(0|(s=0|i[s+4>>2])))r=l;else for(w=0,g=r,d=s,r=l;;){if((0|w)>(0|n)){y=41;break A}if((0|u)==(0|r)&(-117440513&d|0)==(0|A)){l=0|Qe(0|u,0|d,56),M(),c=(l&=7)+1|0,p=0|Qe(0|u,0|d,45),M();r:do{if(0|S(127&p)){if(u=0|Qe(0|u,0|d,52),M(),!(u&=15)){s=6;break}for(s=1;;){if(!(0==((p=0|ye(7,0,3*(15-s|0)|0))&r|0)&0==((0|M())&A|0))){s=7;break r}if(!(s>>>0>>0)){s=6;break}s=s+1|0}}else s=7}while(0);if((l+2|0)>>>0>s>>>0){y=51;break A}p=0|ye(0|c,0,56),A=0|M()|-117440513&A,i[(s=a)>>2]=0,i[s+4>>2]=0,s=g,r|=p}else s=(g+1|0)%(0|n)|0;if(0==(0|(u=0|i[(d=a=t+(s<<3)|0)>>2]))&0==(0|(d=0|i[d+4>>2])))break;w=w+1|0,g=s}i[(p=a)>>2]=r,i[p+4>>2]=A}if((0|(o=o+1|0))>=(0|n))break e;A=0|i[(r=Q+(o<<3)|0)>>2],r=0|i[r+4>>2]}for(o=0,A=h,r=f;;){if(!(0==(0|A)&0==(0|r))){if(s=0|Qe(0|A,0|r,52),M(),(0|(s&=15))>=(0|m)){if((0|s)!=(0|m)&&(A|=w,r=-15728641&r|p,s>>>0>=v>>>0)){a=m;do{g=0|ye(7,0,3*(14-a|0)|0),a=a+1|0,A|=g,r=0|M()|r}while(a>>>0>>0)}}else A=0,r=0;if(s=0|Me(0|A,0|r,0|n,0|B),M(),!(0==(0|(l=0|i[(u=a=t+(s<<3)|0)>>2]))&0==(0|(u=0|i[u+4>>2]))))for(g=0;;){if((0|g)>(0|n)){y=41;break A}if((0|l)==(0|A)&(-117440513&u|0)==(0|r)){c=0|Qe(0|l,0|u,56),M(),d=(c&=7)+1|0,E=0|Qe(0|l,0|u,45),M();r:do{if(0|S(127&E)){if(l=0|Qe(0|l,0|u,52),M(),!(l&=15)){u=6;break}for(u=1;;){if(!(0==((E=0|ye(7,0,3*(15-u|0)|0))&A|0)&0==((0|M())&r|0))){u=7;break r}if(!(u>>>0>>0)){u=6;break}u=u+1|0}}else u=7}while(0);if((c+2|0)>>>0>u>>>0){y=51;break A}E=0|ye(0|d,0,56),r=0|M()|-117440513&r,i[(d=a)>>2]=0,i[d+4>>2]=0,A|=E}else s=(s+1|0)%(0|n)|0;if(0==(0|(l=0|i[(u=a=t+(s<<3)|0)>>2]))&0==(0|(u=0|i[u+4>>2])))break;g=g+1|0}i[(E=a)>>2]=A,i[E+4>>2]=r}if((0|(o=o+1|0))>=(0|n))break e;A=0|i[(r=Q+(o<<3)|0)>>2],r=0|i[r+4>>2]}}}while(0);if((n+5|0)>>>0<11){y=99;break}if(!(p=0|be((0|n)/6|0,8))){y=58;break}e:do{if(b){g=0,d=0;do{if(!(0==(0|(o=0|i[(A=s=t+(g<<3)|0)>>2]))&0==(0|(A=0|i[A+4>>2])))){u=0|Qe(0|o,0|A,56),M(),r=(u&=7)+1|0,l=-117440513&A,E=0|Qe(0|o,0|A,45),M();r:do{if(0|S(127&E)){if(c=0|Qe(0|o,0|A,52),M(),0|(c&=15))for(a=1;;){if(!(0==(o&(E=0|ye(7,0,3*(15-a|0)|0))|0)&0==(l&(0|M())|0)))break r;if(!(a>>>0>>0))break;a=a+1|0}o|=A=0|ye(0|r,0,56),A=0|M()|l,i[(r=s)>>2]=o,i[r+4>>2]=A,r=u+2|0}}while(0);7==(0|r)&&(i[(E=p+(d<<3)|0)>>2]=o,i[E+4>>2]=-117440513&A,d=d+1|0)}g=g+1|0}while((0|g)!=(0|n));if(b){if(w=((0|n)<0)<<31>>31,c=0|ye(0|m,0,52),g=0|M(),m>>>0>15)for(A=0,o=0;;){do{if(!(0==(0|h)&0==(0|f))){for(u=0|Qe(0|h,0|f,52),M(),a=(0|(u&=15))<(0|m),u=(0|u)==(0|m),a=0|Me(0|(s=a?0:u?h:0),0|(u=a?0:u?f:0),0|n,0|w),M(),r=0;;){if((0|r)>(0|n)){y=98;break A}if((-117440513&(l=0|i[(E=t+(a<<3)|0)+4>>2])|0)==(0|u)&&(0|i[E>>2])==(0|s)){y=70;break}if((0|i[(E=t+((a=(a+1|0)%(0|n)|0)<<3)|0)>>2])==(0|s)&&(0|i[E+4>>2])==(0|u))break;r=r+1|0}if(70==(0|y)&&(y=0,!0&100663296==(117440512&l|0)))break;i[(E=e+(o<<3)|0)>>2]=h,i[E+4>>2]=f,o=o+1|0}}while(0);if((0|(A=A+1|0))>=(0|n)){n=d;break e}h=0|i[(f=Q+(A<<3)|0)>>2],f=0|i[f+4>>2]}for(A=0,o=0;;){do{if(!(0==(0|h)&0==(0|f))){if(u=0|Qe(0|h,0|f,52),M(),(0|(u&=15))>=(0|m))if((0|u)!=(0|m))if(r=h|c,a=-15728641&f|g,u>>>0>>0)u=a;else{s=m;do{E=0|ye(7,0,3*(14-s|0)|0),s=s+1|0,r|=E,a=0|M()|a}while(s>>>0>>0);u=a}else r=h,u=f;else r=0,u=0;for(s=0|Me(0|r,0|u,0|n,0|w),M(),a=0;;){if((0|a)>(0|n)){y=98;break A}if((-117440513&(l=0|i[(E=t+(s<<3)|0)+4>>2])|0)==(0|u)&&(0|i[E>>2])==(0|r)){y=93;break}if((0|i[(E=t+((s=(s+1|0)%(0|n)|0)<<3)|0)>>2])==(0|r)&&(0|i[E+4>>2])==(0|u))break;a=a+1|0}if(93==(0|y)&&(y=0,!0&100663296==(117440512&l|0)))break;i[(E=e+(o<<3)|0)>>2]=h,i[E+4>>2]=f,o=o+1|0}}while(0);if((0|(A=A+1|0))>=(0|n)){n=d;break e}h=0|i[(f=Q+(A<<3)|0)>>2],f=0|i[f+4>>2]}}else o=0,n=d}else o=0,n=0}while(0);if(_e(0|t,0,0|k),De(0|Q,0|p,n<<3|0),Be(p),!n)break;e=e+(o<<3)|0}return 41==(0|y)?(Be(Q),Be(t),0|(E=-1)):51==(0|y)?(Be(Q),Be(t),0|(E=-2)):58==(0|y)?(Be(Q),Be(t),0|(E=-3)):98==(0|y)?(Be(p),Be(Q),Be(t),0|(E=-1)):(99==(0|y)&&De(0|e,0|Q,n<<3|0),Be(Q),Be(t),0|(E=0))},_destroyLinkedPolygon:function(A){var e=0,r=0,t=0,n=0;if(A|=0)for(t=1;;){if(0|(e=0|i[A>>2]))do{if(0|(r=0|i[e>>2]))do{n=r,r=0|i[r+16>>2],Be(n)}while(0!=(0|r));n=e,e=0|i[e+8>>2],Be(n)}while(0!=(0|e));if(e=A,A=0|i[A+8>>2],t||Be(e),!A)break;t=0}},_edgeLengthKm:function(A){return+ +n[20752+((A|=0)<<3)>>3]},_edgeLengthM:function(A){return+ +n[20880+((A|=0)<<3)>>3]},_emscripten_replace_memory:function(A){return t=new Int8Array(A),new Uint8Array(A),i=new Int32Array(A),new Float32Array(A),n=new Float64Array(A),r=A,!0},_exactEdgeLengthKm:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+c)*+l(+a)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)!=(0|e));return I=t,+(d=6371.007180918475*o)},_exactEdgeLengthM:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+c)*+l(+a)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)!=(0|e));return I=t,+(d=6371.007180918475*o*1e3)},_exactEdgeLengthRads:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+a)*+l(+c)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)<(0|e));return I=t,+o},_experimentalH3ToLocalIj:function(A,e,r,t,i){var n,o;return i|=0,o=I,I=I+16|0,(A=0|$A(A|=0,e|=0,r|=0,t|=0,n=o))||(cA(n,i),A=0),I=o,0|A},_experimentalLocalIjToH3:function(A,e,r,t){var i,n;return A|=0,e|=0,t|=0,i=I,I=I+16|0,dA(r|=0,n=i),t=0|Ae(A,e,n,t),I=i,0|t},_free:Be,_geoToH3:LA,_getDestinationH3IndexFromUnidirectionalEdge:function(A,e){A|=0;var r,t,n=0;return r=I,I=I+16|0,n=r,!0&268435456==(2013265920&(e|=0)|0)?(t=0|Qe(0|A,0|e,56),M(),i[n>>2]=0,n=0|U(A,-2130706433&e|134217728,7&t,n),e=0|M(),k(0|e),I=r,0|n):(n=0,k(0|(e=0)),I=r,0|n)},_getH3IndexesFromUnidirectionalEdge:function(A,e,r){A|=0;var t,n,o,a,f=0;o=I,I=I+16|0,t=o,a=!0&268435456==(2013265920&(e|=0)|0),n=-2130706433&e|134217728,i[(f=r|=0)>>2]=a?A:0,i[f+4>>2]=a?n:0,a?(e=0|Qe(0|A,0|e,56),M(),i[t>>2]=0,A=0|U(A,n,7&e,t),e=0|M()):(A=0,e=0),i[(f=r+8|0)>>2]=A,i[f+4>>2]=e,I=o},_getH3UnidirectionalEdge:function(A,e,r,t){var n,o,a=0,f=0,s=0,u=0,l=0;if(o=I,I=I+16|0,n=o,!(0|ZA(A|=0,e|=0,r|=0,t|=0)))return u=0,k(0|(s=0)),I=o,0|u;for(s=-2130706433&e,a=(a=0==(0|UA(A,e)))?1:2;i[n>>2]=0,f=a+1|0,!((0|(l=0|U(A,e,a,n)))==(0|r)&(0|M())==(0|t));){if(!(f>>>0<7)){a=0,A=0,u=6;break}a=f}return 6==(0|u)?(k(0|a),I=o,0|A):(l=0|ye(0|a,0,56),u=0|s|M()|268435456,l|=A,k(0|u),I=o,0|l)},_getH3UnidirectionalEdgeBoundary:WA,_getH3UnidirectionalEdgesFromHexagon:function(A,e,r){r|=0;var t,n=0;t=0==(0|UA(A|=0,e|=0)),e&=-2130706433,i[(n=r)>>2]=t?A:0,i[n+4>>2]=t?285212672|e:0,i[(n=r+8|0)>>2]=A,i[n+4>>2]=301989888|e,i[(n=r+16|0)>>2]=A,i[n+4>>2]=318767104|e,i[(n=r+24|0)>>2]=A,i[n+4>>2]=335544320|e,i[(n=r+32|0)>>2]=A,i[n+4>>2]=352321536|e,i[(r=r+40|0)>>2]=A,i[r+4>>2]=369098752|e},_getOriginH3IndexFromUnidirectionalEdge:function(A,e){var r;return A|=0,k(0|((r=!0&268435456==(2013265920&(e|=0)|0))?-2130706433&e|134217728:0)),0|(r?A:0)},_getPentagonIndexes:NA,_getRes0Indexes:function(A){A|=0;var e=0,r=0,t=0;e=0;do{ye(0|e,0,45),t=134225919|M(),i[(r=A+(e<<3)|0)>>2]=-1,i[r+4>>2]=t,e=e+1|0}while(122!=(0|e))},_h3Distance:function(A,e,r,t){var i,n,o;return r|=0,t|=0,o=I,I=I+32|0,n=o,A=0==(0|$A(A|=0,e|=0,A,e,i=o+12|0))&&0==(0|$A(A,e,r,t,n))?0|hA(i,n):-1,I=o,0|A},_h3GetBaseCell:IA,_h3GetFaces:function A(e,r,t){t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0;n=I,I=I+128|0,h=n+112|0,f=n+96|0,c=n,a=0|Qe(0|(e|=0),0|(r|=0),52),M(),u=15&a,i[h>>2]=u,s=0|Qe(0|e,0|r,45),M(),s&=127;A:do{if(0|S(s)){if(0|u)for(o=1;;){if(!(0==((l=0|ye(7,0,3*(15-o|0)|0))&e|0)&0==((0|M())&r|0))){a=0;break A}if(!(o>>>0>>0))break;o=o+1|0}if(!(1&a))return l=0|ye(u+1|0,0,52),c=0|M()|-15728641&r,A((l|e)&~(h=0|ye(7,0,3*(14-u|0)|0)),c&~(0|M()),t),void(I=n);a=1}else a=0}while(0);YA(e,r,f),a?(mA(f,h,c),l=5):(yA(f,h,c),l=6);A:do{if(0|S(s))if(u)for(o=1;;){if(!(0==((s=0|ye(7,0,3*(15-o|0)|0))&e|0)&0==((0|M())&r|0))){o=8;break A}if(!(o>>>0>>0)){o=20;break}o=o+1|0}else o=20;else o=8}while(0);if(_e(0|t,-1,0|o),a){a=0;do{for(MA(f=c+(a<<4)|0,0|i[h>>2]),f=0|i[f>>2],o=0;!(-1==(0|(u=0|i[(s=t+(o<<2)|0)>>2]))|(0|u)==(0|f));)o=o+1|0;i[s>>2]=f,a=a+1|0}while((0|a)!=(0|l))}else{a=0;do{for(kA(f=c+(a<<4)|0,0|i[h>>2],0,1),f=0|i[f>>2],o=0;!(-1==(0|(u=0|i[(s=t+(o<<2)|0)>>2]))|(0|u)==(0|f));)o=o+1|0;i[s>>2]=f,a=a+1|0}while((0|a)!=(0|l))}I=n},_h3GetResolution:function(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),52),M(),15&e|0},_h3IndexesAreNeighbors:ZA,_h3IsPentagon:UA,_h3IsResClassIII:function(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),52),M(),1&e|0},_h3IsValid:FA,_h3Line:function(A,e,r,t,n){r|=0,t|=0,n|=0;var o,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,Q=0;if(o=I,I=I+48|0,s=o+12|0,M=o,0==(0|$A(A|=0,e|=0,A,e,a=o+24|0))&&0==(0|$A(A,e,r,t,s))){if((0|(k=0|hA(a,s)))<0)return I=o,0|(M=k);for(i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,i[s>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,$A(A,e,A,e,a),$A(A,e,r,t,s),gA(a),gA(s),k?(w=+(0|k),m=a,r=c=0|i[a>>2],t=d=0|i[(b=a+4|0)>>2],a=g=0|i[(v=a+8|0)>>2],p=+((0|i[s>>2])-c|0)/w,B=+((0|i[s+4>>2])-d|0)/w,w=+((0|i[s+8>>2])-g|0)/w):(b=t=a+4|0,v=g=a+8|0,m=a,r=0|i[a>>2],t=0|i[t>>2],a=0|i[g>>2],p=0,B=0,w=0),i[M>>2]=r,i[(g=M+4|0)>>2]=t,i[(d=M+8|0)>>2]=a,c=0;;){Q=p*(l=+(0|c))+ +(0|r),u=B*l+ +(0|i[b>>2]),l=w*l+ +(0|i[v>>2]),t=~~+xe(+Q),s=~~+xe(+u),r=~~+xe(+l),Q=+f(+(+(0|t)-Q)),u=+f(+(+(0|s)-u)),l=+f(+(+(0|r)-l));do{if(!(Q>u&Q>l)){if(h=0-t|0,u>l){a=h-r|0;break}a=s,r=h-s|0;break}t=0-(s+r)|0,a=s}while(0);if(i[M>>2]=t,i[g>>2]=a,i[d>>2]=r,wA(M),Ae(A,e,M,n+(c<<3)|0),(0|c)==(0|k))break;c=c+1|0,r=0|i[m>>2]}return I=o,0|(M=0)}return I=o,0|(M=-1)},_h3LineSize:function(A,e,r,t){var i,n,o;return r|=0,t|=0,o=I,I=I+32|0,n=o,A=0==(0|$A(A|=0,e|=0,A,e,i=o+12|0))&&0==(0|$A(A,e,r,t,n))?0|hA(i,n):-1,I=o,(A>>>31^1)+A|0},_h3SetToLinkedGeo:function(A,e,r){r|=0;var t,n,o,a=0;if(o=I,I=I+32|0,t=o,function(A,e,r){A|=0,r|=0;var t,n,o=0,a=0,f=0,s=0,u=0;if(n=I,I=I+176|0,t=n,(0|(e|=0))<1)return se(r,0,0),void(I=n);s=0|Qe(0|i[(s=A)>>2],0|i[s+4>>2],52),M(),se(r,(0|e)>6?e:6,15&s),s=0;do{if(jA(0|i[(o=A+(s<<3)|0)>>2],0|i[o+4>>2],t),(0|(o=0|i[t>>2]))>0){u=0;do{f=t+8+(u<<4)|0,(a=0|de(r,o=t+8+(((0|(u=u+1|0))%(0|o)|0)<<4)|0,f))?he(r,a):ce(r,f,o),o=0|i[t>>2]}while((0|u)<(0|o))}s=s+1|0}while((0|s)!=(0|e));I=n}(A|=0,e|=0,n=o+16|0),i[r>>2]=0,i[r+4>>2]=0,i[r+8>>2]=0,!(A=0|le(n)))return XA(r),ue(n),void(I=o);do{e=0|JA(r);do{KA(e,A),a=A+16|0,i[t>>2]=i[a>>2],i[t+4>>2]=i[a+4>>2],i[t+8>>2]=i[a+8>>2],i[t+12>>2]=i[a+12>>2],he(n,A),A=0|ge(n,t)}while(0!=(0|A));A=0|le(n)}while(0!=(0|A));XA(r),ue(n),I=o},_h3ToCenterChild:function(A,e,r){r|=0;var t=0,i=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(t&=15))<=(0|r)){if((0|t)!=(0|r)&&(A|=i=0|ye(0|r,0,52),e=0|M()|-15728641&e,(0|t)<(0|r)))do{i=0|ye(7,0,3*(14-t|0)|0),t=t+1|0,A&=~i,e&=~(0|M())}while((0|t)<(0|r))}else e=0,A=0;return k(0|e),0|A},_h3ToChildren:PA,_h3ToGeo:OA,_h3ToGeoBoundary:jA,_h3ToParent:CA,_h3UnidirectionalEdgeIsValid:function(A,e){var r=0;if(!(!0&268435456==(2013265920&(e|=0)|0)))return 0|(r=0);switch(r=0|Qe(0|(A|=0),0|e,56),M(),7&r){case 0:case 7:return 0|(r=0)}return!0&16777216==(117440512&e|0)&0!=(0|UA(A,r=-2130706433&e|134217728))?0|(r=0):0|(r=0|FA(A,r))},_hexAreaKm2:function(A){return+ +n[20496+((A|=0)<<3)>>3]},_hexAreaM2:function(A){return+ +n[20624+((A|=0)<<3)>>3]},_hexRing:function(A,e,r,t){A|=0,e|=0,t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0,h=0;if(n=I,I=I+16|0,h=n,!(r|=0))return i[(h=t)>>2]=A,i[h+4>>2]=e,I=n,0|(h=0);i[h>>2]=0;A:do{if(0|UA(A,e))A=1;else{if(a=(0|r)>0){o=0,l=A;do{if(0==(0|(l=0|U(l,e,4,h)))&0==(0|(e=0|M()))){A=2;break A}if(o=o+1|0,0|UA(l,e)){A=1;break A}}while((0|o)<(0|r));if(i[(u=t)>>2]=l,i[u+4>>2]=e,u=r+-1|0,a){a=0,f=1,o=l,A=e;do{if(0==(0|(o=0|U(o,A,2,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(f<<3)|0)>>2]=o,i[s+4>>2]=A,f=f+1|0,0|UA(o,A)){A=1;break A}a=a+1|0}while((0|a)<(0|r));s=0,a=f;do{if(0==(0|(o=0|U(o,A,3,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(f=t+(a<<3)|0)>>2]=o,i[f+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}s=s+1|0}while((0|s)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,1,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,5,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,4,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));for(f=0;;){if(0==(0|(o=0|U(o,A,6,h)))&0==(0|(A=0|M()))){A=2;break A}if((0|f)!=(0|u)){if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,0|UA(o,A)){A=1;break A}a=a+1|0}if((0|(f=f+1|0))>=(0|r)){f=l,a=e;break}}}else f=l,o=l,a=e,A=e}else i[(f=t)>>2]=A,i[f+4>>2]=e,f=A,o=A,a=e,A=e;A=1&((0|f)!=(0|o)|(0|a)!=(0|A))}}while(0);return I=n,0|(h=A)},_i64Subtract:ve,_kRing:F,_kRingDistances:function(A,e,r,t,i){var n;if(0|C(A|=0,e|=0,r|=0,t|=0,i|=0)){if(_e(0|t,0,(n=1+(0|b(3*r|0,r+1|0))|0)<<3|0),0|i)return _e(0|i,0,n<<2|0),void P(A,e,r,t,i,n,0);(i=0|be(n,4))&&(P(A,e,r,t,i,n,0),Be(i))}},_llvm_minnum_f64:Ee,_llvm_round_f64:xe,_malloc:pe,_maxFaceCount:function(A,e){var r=0,t=0;if(t=0|Qe(0|(A|=0),0|(e|=0),45),M(),!(0|S(127&t)))return 0|(t=2);if(t=0|Qe(0|A,0|e,52),M(),!(t&=15))return 0|(t=5);for(r=1;;){if(!(0==((0|ye(7,0,3*(15-r|0)|0))&A|0)&0==((0|M())&e|0))){r=2,A=6;break}if(!(r>>>0>>0)){r=5,A=6;break}r=r+1|0}return 6==(0|A)?0|r:0},_maxH3ToChildrenSize:function(A,e,r){return r|=0,A=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(A&=15))<=(0|r)?0|(r=0|ee(7,r-A|0)):0|(r=0)},_maxKringSize:function(A){return 1+(0|b(3*(A|=0)|0,A+1|0))|0},_maxPolyfillSize:function(A,e){e|=0;var r,t=0,n=0,o=0,a=0,f=0;if(r=I,I=I+48|0,o=r+8|0,n=r,a=0|i[(f=A|=0)+4>>2],i[(t=n)>>2]=i[f>>2],i[t+4>>2]=a,te(n,o),o=0|j(o,e),e=0|i[n>>2],(0|(n=0|i[A+8>>2]))<=0)return I=r,0|(f=(f=(a=(0|o)<(0|(f=e)))?f:o)+12|0);t=0|i[A+12>>2],A=0;do{e=(0|i[t+(A<<3)>>2])+e|0,A=A+1|0}while((0|A)<(0|n));return I=r,0|(f=(f=(f=(0|o)<(0|e))?e:o)+12|0)},_maxUncompactSize:function(A,e,r){A|=0,r|=0;var t=0,n=0,o=0,a=0;if((0|(e|=0))<=0)return 0|(r=0);if((0|r)>=16){for(t=0;;){if(!(0==(0|i[(a=A+(t<<3)|0)>>2])&0==(0|i[a+4>>2]))){t=-1,n=13;break}if((0|(t=t+1|0))>=(0|e)){t=0,n=13;break}}if(13==(0|n))return 0|t}t=0,a=0;A:for(;;){o=0|i[(n=A+(a<<3)|0)>>2],n=0|i[n+4>>2];do{if(!(0==(0|o)&0==(0|n))){if(n=0|Qe(0|o,0|n,52),M(),(0|(n&=15))>(0|r)){t=-1,n=13;break A}if((0|n)==(0|r)){t=t+1|0;break}t=(0|ee(7,r-n|0))+t|0;break}}while(0);if((0|(a=a+1|0))>=(0|e)){n=13;break}}return 13==(0|n)?0|t:0},_memcpy:De,_memset:_e,_numHexagons:function(A){var e;return A=0|i[(e=21008+((A|=0)<<3)|0)>>2],k(0|i[e+4>>2]),0|A},_pentagonIndexCount:function(){return 12},_pointDistKm:DA,_pointDistM:function(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))*6371.007180918475*1e3},_pointDistRads:function(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))},_polyfill:function(A,e,r){var t,n=0,o=0,a=0,f=0,s=0;if(t=I,I=I+48|0,n=t+8|0,o=t,0|function(A,e,r){e|=0,r|=0;var t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,y=0,E=0,x=0,D=0,_=0,F=0,U=0,S=0,T=0,V=0,H=0;H=I,I=I+112|0,U=H+80|0,s=H+72|0,S=H,T=H+56|0,(V=0|pe(32+(i[(u=(A=A|0)+8|0)>>2]<<5)|0))||Q(22848,22448,800,22456);if(ie(A,V),t=0|i[(o=A)+4>>2],i[(f=s)>>2]=i[o>>2],i[f+4>>2]=t,te(s,U),f=0|j(U,e),t=0|i[s>>2],(0|(o=0|i[u>>2]))>0){a=0|i[A+12>>2],n=0;do{t=(0|i[a+(n<<3)>>2])+t|0,n=n+1|0}while((0|n)!=(0|o))}if(n=0|be(F=(f=(0|f)<(0|t)?t:f)+12|0,8),l=0|be(F,8),i[U>>2]=0,_=0|i[(D=A)+4>>2],i[(t=s)>>2]=i[D>>2],i[t+4>>2]=_,0|(t=0|G(s,F,e,U,n,l)))return Be(n),Be(l),Be(V),I=H,0|(V=t);A:do{if((0|i[u>>2])>0){for(o=A+12|0,t=0;a=0|G((0|i[o>>2])+(t<<3)|0,F,e,U,n,l),t=t+1|0,!(0|a);)if((0|t)>=(0|i[u>>2]))break A;return Be(n),Be(l),Be(V),I=H,0|(V=a)}}while(0);(0|f)>-12&&_e(0|l,0,((0|F)>1?F:1)<<3|0);A:do{if((0|i[U>>2])>0){_=((0|F)<0)<<31>>31,m=n,k=l,y=n,E=n,x=l,D=n,t=n,p=n,B=l,b=l,v=l,n=l;e:for(;;){for(w=0|i[U>>2],d=0,g=0,o=0;;){f=(a=S)+56|0;do{i[a>>2]=0,a=a+4|0}while((0|a)<(0|f));if(0|C(s=0|i[(e=m+(d<<3)|0)>>2],e=0|i[e+4>>2],1,S,0)){f=(a=S)+56|0;do{i[a>>2]=0,a=a+4|0}while((0|a)<(0|f));0|(a=0|be(7,4))&&(P(s,e,1,S,a,7,0),Be(a))}c=0;do{l=0|i[(h=S+(c<<3)|0)>>2],h=0|i[h+4>>2];r:do{if(!(0==(0|l)&0==(0|h))){if(s=0|Me(0|l,0|h,0|F,0|_),M(),!(0==(0|(e=0|i[(f=a=r+(s<<3)|0)>>2]))&0==(0|(f=0|i[f+4>>2]))))for(u=0;;){if((0|u)>(0|F))break e;if((0|e)==(0|l)&(0|f)==(0|h))break r;if(0==(0|(e=0|i[(f=a=r+((s=(s+1|0)%(0|F)|0)<<3)|0)>>2]))&0==(0|(f=0|i[f+4>>2])))break;u=u+1|0}0==(0|l)&0==(0|h)||(OA(l,h,T),0|ne(A,V,T)&&(i[(u=a)>>2]=l,i[u+4>>2]=h,i[(u=k+(o<<3)|0)>>2]=l,i[u+4>>2]=h,o=o+1|0))}}while(0);c=c+1|0}while(c>>>0<7);if((0|(g=g+1|0))>=(0|w))break;d=d+1|0}if((0|w)>0&&_e(0|y,0,w<<3|0),i[U>>2]=o,!((0|o)>0))break A;l=n,h=v,c=D,d=b,g=B,w=k,n=p,v=t,b=E,B=y,p=l,t=h,D=x,x=c,E=d,y=g,k=m,m=w}return Be(E),Be(x),Be(V),I=H,0|(V=-1)}t=l}while(0);return Be(V),Be(n),Be(t),I=H,0|(V=0)}(A|=0,e|=0,r|=0)){if(a=0|i[(s=A)+4>>2],i[(f=o)>>2]=i[s>>2],i[f+4>>2]=a,te(o,n),f=0|j(n,e),e=0|i[o>>2],(0|(a=0|i[A+8>>2]))>0){o=0|i[A+12>>2],n=0;do{e=(0|i[o+(n<<3)>>2])+e|0,n=n+1|0}while((0|n)!=(0|a))}(0|(e=(0|f)<(0|e)?e:f))<=-12||_e(0|r,0,8+(((0|(s=e+11|0))>0?s:0)<<3)|0),I=t}else I=t},_res0IndexCount:function(){return 122},_round:Ie,_sbrk:Fe,_sizeOfCoordIJ:function(){return 8},_sizeOfGeoBoundary:function(){return 168},_sizeOfGeoCoord:function(){return 16},_sizeOfGeoPolygon:function(){return 16},_sizeOfGeofence:function(){return 8},_sizeOfH3Index:function(){return 8},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompact:function(A,e,r,t,n){A|=0,r|=0,t|=0,n|=0;var o=0,a=0,f=0,s=0,u=0,l=0;if((0|(e|=0))<=0)return 0|(n=0);if((0|n)>=16){for(o=0;;){if(!(0==(0|i[(l=A+(o<<3)|0)>>2])&0==(0|i[l+4>>2]))){o=14;break}if((0|(o=o+1|0))>=(0|e)){a=0,o=16;break}}if(14==(0|o))return 0|((0|t)>0?-2:-1);if(16==(0|o))return 0|a}o=0,l=0;A:for(;;){a=0|i[(f=u=A+(l<<3)|0)>>2],f=0|i[f+4>>2];do{if(!(0==(0|a)&0==(0|f))){if((0|o)>=(0|t)){a=-1,o=16;break A}if(s=0|Qe(0|a,0|f,52),M(),(0|(s&=15))>(0|n)){a=-2,o=16;break A}if((0|s)==(0|n)){i[(u=r+(o<<3)|0)>>2]=a,i[u+4>>2]=f,o=o+1|0;break}if((0|(a=(0|ee(7,n-s|0))+o|0))>(0|t)){a=-1,o=16;break A}PA(0|i[u>>2],0|i[u+4>>2],n,r+(o<<3)|0),o=a}}while(0);if((0|(l=l+1|0))>=(0|e)){a=0,o=16;break}}return 16==(0|o)?0|a:0},establishStackSpace:function(A,e){I=A|=0},stackAlloc:function(A){var e;return e=I,I=(I=I+(A|=0)|0)+15&-16,0|e},stackRestore:function(A){I=A|=0},stackSave:function(){return 0|I}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{a:fA,b:function(A){s=A},c:u,d:function(A,e,r,t){fA("Assertion failed: "+g(A)+", at: "+[e?g(e):"unknown filename",r,t?g(t):"unknown function"])},e:function(A){return r.___errno_location&&(v[r.___errno_location()>>2]=A),A},f:N,g:function(A,e,r){B.set(B.subarray(e,e+r),A)},h:function(A){var e=N(),r=16777216,t=2130706432;if(A>t)return!1;for(var i=Math.max(e,16777216);i>0]=e;break;case"i16":b[A>>1]=e;break;case"i32":v[A>>2]=e;break;case"i64":H=[e>>>0,(V=e,+F(V)>=1?V>0?(0|U(+P(V/4294967296),4294967295))>>>0:~~+C((V-+(~~V>>>0))/4294967296)>>>0:0)],v[A>>2]=H[0],v[A+4>>2]=H[1];break;case"float":m[A>>2]=e;break;case"double":k[A>>3]=e;break;default:fA("invalid type for setValue: "+r)}},r.getValue=function(A,e,r){switch("*"===(e=e||"i8").charAt(e.length-1)&&(e="i32"),e){case"i1":case"i8":return p[A>>0];case"i16":return b[A>>1];case"i32":case"i64":return v[A>>2];case"float":return m[A>>2];case"double":return k[A>>3];default:fA("invalid type for getValue: "+e)}return null},r.getTempRet0=u,R){z(R)||(K=R,R=r.locateFile?r.locateFile(K,o):o+K),G++,r.monitorRunDependencies&&r.monitorRunDependencies(G);var tA=function(A){A.byteLength&&(A=new Uint8Array(A)),B.set(A,8),r.memoryInitializerRequest&&delete r.memoryInitializerRequest.response,function(A){if(G--,r.monitorRunDependencies&&r.monitorRunDependencies(G),0==G&&(null!==S&&(clearInterval(S),S=null),T)){var e=T;T=null,e()}}()},iA=function(){i(R,tA,(function(){throw"could not load memory initializer "+R}))},nA=J(R);if(nA)tA(nA.buffer);else if(r.memoryInitializerRequest){var oA=function(){var A=r.memoryInitializerRequest,e=A.response;if(200!==A.status&&0!==A.status){var t=J(r.memoryInitializerRequestURL);if(!t)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+A.status+", retrying "+R),void iA();e=t.buffer}tA(e)};r.memoryInitializerRequest.response?setTimeout(oA,0):r.memoryInitializerRequest.addEventListener("load",oA)}else iA()}function aA(A){function e(){X||(X=!0,l||(E(D),E(_),r.onRuntimeInitialized&&r.onRuntimeInitialized(),function(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)A=r.postRun.shift(),I.unshift(A);var A;E(I)}()))}A=A||n,G>0||(!function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)A=r.preRun.shift(),x.unshift(A);var A;E(x)}(),G>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),e()}),1)):e()))}function fA(A){throw r.onAbort&&r.onAbort(A),a(A+=""),f(A),l=!0,"abort("+A+"). Build with -s ASSERTIONS=1 for more info."}if(T=function A(){X||aA(),X||(T=A)},r.run=aA,r.abort=fA,r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return aA(),A}("object"==typeof t?t:{}),i="number",n={};[["sizeOfH3Index",i],["sizeOfGeoCoord",i],["sizeOfGeoBoundary",i],["sizeOfGeoPolygon",i],["sizeOfGeofence",i],["sizeOfLinkedGeoPolygon",i],["sizeOfCoordIJ",i],["h3IsValid",i,[i,i]],["geoToH3",i,[i,i,i]],["h3ToGeo",null,[i,i,i]],["h3ToGeoBoundary",null,[i,i,i]],["maxKringSize",i,[i]],["kRing",null,[i,i,i,i]],["kRingDistances",null,[i,i,i,i,i]],["hexRing",null,[i,i,i,i]],["maxPolyfillSize",i,[i,i]],["polyfill",null,[i,i,i]],["h3SetToLinkedGeo",null,[i,i,i]],["destroyLinkedPolygon",null,[i]],["compact",i,[i,i,i]],["uncompact",i,[i,i,i,i,i]],["maxUncompactSize",i,[i,i,i]],["h3IsPentagon",i,[i,i]],["h3IsResClassIII",i,[i,i]],["h3GetBaseCell",i,[i,i]],["h3GetResolution",i,[i,i]],["maxFaceCount",i,[i,i]],["h3GetFaces",null,[i,i,i]],["h3ToParent",i,[i,i,i]],["h3ToChildren",null,[i,i,i,i]],["h3ToCenterChild",i,[i,i,i]],["maxH3ToChildrenSize",i,[i,i,i]],["h3IndexesAreNeighbors",i,[i,i,i,i]],["getH3UnidirectionalEdge",i,[i,i,i,i]],["getOriginH3IndexFromUnidirectionalEdge",i,[i,i]],["getDestinationH3IndexFromUnidirectionalEdge",i,[i,i]],["h3UnidirectionalEdgeIsValid",i,[i,i]],["getH3IndexesFromUnidirectionalEdge",null,[i,i,i]],["getH3UnidirectionalEdgesFromHexagon",null,[i,i,i]],["getH3UnidirectionalEdgeBoundary",null,[i,i,i]],["h3Distance",i,[i,i,i,i]],["h3Line",i,[i,i,i,i,i]],["h3LineSize",i,[i,i,i,i]],["experimentalH3ToLocalIj",i,[i,i,i,i,i]],["experimentalLocalIjToH3",i,[i,i,i,i]],["hexAreaM2",i,[i]],["hexAreaKm2",i,[i]],["edgeLengthM",i,[i]],["edgeLengthKm",i,[i]],["pointDistM",i,[i,i]],["pointDistKm",i,[i,i]],["pointDistRads",i,[i,i]],["cellAreaM2",i,[i,i]],["cellAreaKm2",i,[i,i]],["cellAreaRads2",i,[i,i]],["exactEdgeLengthM",i,[i,i]],["exactEdgeLengthKm",i,[i,i]],["exactEdgeLengthRads",i,[i,i]],["numHexagons",i,[i]],["getRes0Indexes",null,[i]],["res0IndexCount",i],["getPentagonIndexes",null,[i,i]],["pentagonIndexCount",i]].forEach((function(A){n[A[0]]=t.cwrap.apply(t,A)}));var o=16,a=n.sizeOfH3Index(),f=n.sizeOfGeoCoord(),s=n.sizeOfGeoBoundary(),u=n.sizeOfGeoPolygon(),l=n.sizeOfGeofence(),h=n.sizeOfLinkedGeoPolygon(),c=n.sizeOfCoordIJ(),d={m:"m",m2:"m2",km:"km",km2:"km2",rads:"rads",rads2:"rads2"};function g(A){if("number"!=typeof A||A<0||A>15||Math.floor(A)!==A)throw new Error("Invalid resolution: "+A)}var w=/[^0-9a-fA-F]/;function p(A){if(Array.isArray(A)&&2===A.length&&Number.isInteger(A[0])&&Number.isInteger(A[1]))return A;if("string"!=typeof A||w.test(A))return[0,0];var e=parseInt(A.substring(0,A.length-8),o);return[parseInt(A.substring(A.length-8),o),e]}function B(A){if(A>=0)return A.toString(o);var e=v(8,(A&=2147483647).toString(o));return e=(parseInt(e[0],o)+8).toString(o)+e.substring(1)}function b(A,e){return B(e)+v(8,B(A))}function v(A,e){for(var r=A-e.length,t="",i=0;i=0&&r.push(n)}return r}(a,o);return t._free(a),f},r.h3GetResolution=function(A){var e=p(A),r=e[0],t=e[1];return n.h3IsValid(r,t)?n.h3GetResolution(r,t):-1},r.geoToH3=function(A,e,r){var i=t._malloc(f);t.HEAPF64.set([A,e].map(U),i/8);var o=M(n.geoToH3(i,r));return t._free(i),o},r.h3ToGeo=function(A){var e=t._malloc(f),r=p(A),i=r[0],o=r[1];n.h3ToGeo(i,o,e);var a=I(e);return t._free(e),a},r.h3ToGeoBoundary=function(A,e){var r=t._malloc(s),i=p(A),o=i[0],a=i[1];n.h3ToGeoBoundary(o,a,r);var f=C(r,e,e);return t._free(r),f},r.h3ToParent=function(A,e){var r=p(A),t=r[0],i=r[1];return M(n.h3ToParent(t,i,e))},r.h3ToChildren=function(A,e){if(!P(A))return[];var r=p(A),i=r[0],o=r[1],f=n.maxH3ToChildrenSize(i,o,e),s=t._calloc(f,a);n.h3ToChildren(i,o,e,s);var u=E(s,f);return t._free(s),u},r.h3ToCenterChild=function(A,e){var r=p(A),t=r[0],i=r[1];return M(n.h3ToCenterChild(t,i,e))},r.kRing=function(A,e){var r=p(A),i=r[0],o=r[1],f=n.maxKringSize(e),s=t._calloc(f,a);n.kRing(i,o,e,s);var u=E(s,f);return t._free(s),u},r.kRingDistances=function(A,e){var r=p(A),i=r[0],o=r[1],f=n.maxKringSize(e),s=t._calloc(f,a),u=t._calloc(f,4);n.kRingDistances(i,o,e,s,u);for(var l=[],h=0;h0){r=t._calloc(i,l);for(var f=0;f0){for(var n=t.getValue(A+r,"i32"),o=0;o */ +r.read=function(A,e,r,t,i){var n,o,a=8*i-t-1,f=(1<>1,u=-7,l=r?i-1:0,h=r?-1:1,c=A[e+l];for(l+=h,n=c&(1<<-u)-1,c>>=-u,u+=a;u>0;n=256*n+A[e+l],l+=h,u-=8);for(o=n&(1<<-u)-1,n>>=-u,u+=t;u>0;o=256*o+A[e+l],l+=h,u-=8);if(0===n)n=1-s;else{if(n===f)return o?NaN:1/0*(c?-1:1);o+=Math.pow(2,t),n-=s}return(c?-1:1)*o*Math.pow(2,n-t)},r.write=function(A,e,r,t,i,n){var o,a,f,s=8*n-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,c=t?0:n-1,d=t?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),(e+=o+l>=1?h/f:h*Math.pow(2,1-l))*f>=2&&(o++,f/=2),o+l>=u?(a=0,o=u):o+l>=1?(a=(e*f-1)*Math.pow(2,i),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;A[r+c]=255&a,c+=d,a/=256,i-=8);for(o=o<0;A[r+c]=255&o,c+=d,o/=256,s-=8);A[r+c-d]|=128*g}},{}],9:[function(A,e,r){"use strict";e.exports=i;var t=A("ieee754");function i(A){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(A)?A:new Uint8Array(A||0),this.pos=0,this.type=0,this.length=this.buf.length}i.Varint=0,i.Fixed64=1,i.Bytes=2,i.Fixed32=5;var n=4294967296,o=1/n,a="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function f(A){return A.type===i.Bytes?A.readVarint()+A.pos:A.pos+1}function s(A,e,r){return r?4294967296*e+(A>>>0):4294967296*(e>>>0)+(A>>>0)}function u(A,e,r){var t=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(t);for(var i=r.pos-1;i>=A;i--)r.buf[i+t]=r.buf[i]}function l(A,e){for(var r=0;r>>8,A[r+2]=e>>>16,A[r+3]=e>>>24}function k(A,e){return(A[e]|A[e+1]<<8|A[e+2]<<16)+(A[e+3]<<24)}i.prototype={destroy:function(){this.buf=null},readFields:function(A,e,r){for(r=r||this.length;this.pos>3,n=this.pos;this.type=7&t,A(i,e,this),this.pos===n&&this.skip(t)}return e},readMessage:function(A,e){return this.readFields(A,e,this.readVarint()+this.pos)},readFixed32:function(){var A=v(this.buf,this.pos);return this.pos+=4,A},readSFixed32:function(){var A=k(this.buf,this.pos);return this.pos+=4,A},readFixed64:function(){var A=v(this.buf,this.pos)+v(this.buf,this.pos+4)*n;return this.pos+=8,A},readSFixed64:function(){var A=v(this.buf,this.pos)+k(this.buf,this.pos+4)*n;return this.pos+=8,A},readFloat:function(){var A=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,A},readDouble:function(){var A=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,A},readVarint:function(A){var e,r,t=this.buf;return e=127&(r=t[this.pos++]),r<128?e:(e|=(127&(r=t[this.pos++]))<<7,r<128?e:(e|=(127&(r=t[this.pos++]))<<14,r<128?e:(e|=(127&(r=t[this.pos++]))<<21,r<128?e:function(A,e,r){var t,i,n=r.buf;if(i=n[r.pos++],t=(112&i)>>4,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<3,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<10,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<17,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<24,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(1&i)<<31,i<128)return s(A,t,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=t[this.pos]))<<28,A,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var A=this.readVarint();return A%2==1?(A+1)/-2:A/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var A=this.readVarint()+this.pos,e=this.pos;return this.pos=A,A-e>=12&&a?function(A,e,r){return a.decode(A.subarray(e,r))}(this.buf,e,A):function(A,e,r){var t="",i=e;for(;i239?4:f>223?3:f>191?2:1;if(i+u>r)break;1===u?f<128&&(s=f):2===u?128==(192&(n=A[i+1]))&&(s=(31&f)<<6|63&n)<=127&&(s=null):3===u?(n=A[i+1],o=A[i+2],128==(192&n)&&128==(192&o)&&((s=(15&f)<<12|(63&n)<<6|63&o)<=2047||s>=55296&&s<=57343)&&(s=null)):4===u&&(n=A[i+1],o=A[i+2],a=A[i+3],128==(192&n)&&128==(192&o)&&128==(192&a)&&((s=(15&f)<<18|(63&n)<<12|(63&o)<<6|63&a)<=65535||s>=1114112)&&(s=null)),null===s?(s=65533,u=1):s>65535&&(s-=65536,t+=String.fromCharCode(s>>>10&1023|55296),s=56320|1023&s),t+=String.fromCharCode(s),i+=u}return t}(this.buf,e,A)},readBytes:function(){var A=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,A);return this.pos=A,e},readPackedVarint:function(A,e){if(this.type!==i.Bytes)return A.push(this.readVarint(e));var r=f(this);for(A=A||[];this.pos127;);else if(e===i.Bytes)this.pos=this.readVarint()+this.pos;else if(e===i.Fixed32)this.pos+=4;else{if(e!==i.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(A,e){this.writeVarint(A<<3|e)},realloc:function(A){for(var e=this.length||16;e268435455||A<0?function(A,e){var r,t;A>=0?(r=A%4294967296|0,t=A/4294967296|0):(t=~(-A/4294967296),4294967295^(r=~(-A%4294967296))?r=r+1|0:(r=0,t=t+1|0));if(A>=0x10000000000000000||A<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(A,e,r){r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos]=127&A}(r,0,e),function(A,e){var r=(7&A)<<4;if(e.buf[e.pos++]|=r|((A>>>=3)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;e.buf[e.pos++]=127&A}(t,e)}(A,this):(this.realloc(4),this.buf[this.pos++]=127&A|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=A>>>7&127))))},writeSVarint:function(A){this.writeVarint(A<0?2*-A-1:2*A)},writeBoolean:function(A){this.writeVarint(Boolean(A))},writeString:function(A){A=String(A),this.realloc(4*A.length),this.pos++;var e=this.pos;this.pos=function(A,e,r){for(var t,i,n=0;n55295&&t<57344){if(!i){t>56319||n+1===e.length?(A[r++]=239,A[r++]=191,A[r++]=189):i=t;continue}if(t<56320){A[r++]=239,A[r++]=191,A[r++]=189,i=t;continue}t=i-55296<<10|t-56320|65536,i=null}else i&&(A[r++]=239,A[r++]=191,A[r++]=189,i=null);t<128?A[r++]=t:(t<2048?A[r++]=t>>6|192:(t<65536?A[r++]=t>>12|224:(A[r++]=t>>18|240,A[r++]=t>>12&63|128),A[r++]=t>>6&63|128),A[r++]=63&t|128)}return r}(this.buf,A,this.pos);var r=this.pos-e;r>=128&&u(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(A){this.realloc(4),t.write(this.buf,A,this.pos,!0,23,4),this.pos+=4},writeDouble:function(A){this.realloc(8),t.write(this.buf,A,this.pos,!0,52,8),this.pos+=8},writeBytes:function(A){var e=A.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&u(r,t,this),this.pos=r-1,this.writeVarint(t),this.pos+=t},writeMessage:function(A,e,r){this.writeTag(A,i.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(A,e){e.length&&this.writeMessage(A,l,e)},writePackedSVarint:function(A,e){e.length&&this.writeMessage(A,h,e)},writePackedBoolean:function(A,e){e.length&&this.writeMessage(A,g,e)},writePackedFloat:function(A,e){e.length&&this.writeMessage(A,c,e)},writePackedDouble:function(A,e){e.length&&this.writeMessage(A,d,e)},writePackedFixed32:function(A,e){e.length&&this.writeMessage(A,w,e)},writePackedSFixed32:function(A,e){e.length&&this.writeMessage(A,p,e)},writePackedFixed64:function(A,e){e.length&&this.writeMessage(A,B,e)},writePackedSFixed64:function(A,e){e.length&&this.writeMessage(A,b,e)},writeBytesField:function(A,e){this.writeTag(A,i.Bytes),this.writeBytes(e)},writeFixed32Field:function(A,e){this.writeTag(A,i.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(A,e){this.writeTag(A,i.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(A,e){this.writeTag(A,i.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(A,e){this.writeTag(A,i.Fixed64),this.writeSFixed64(e)},writeVarintField:function(A,e){this.writeTag(A,i.Varint),this.writeVarint(e)},writeSVarintField:function(A,e){this.writeTag(A,i.Varint),this.writeSVarint(e)},writeStringField:function(A,e){this.writeTag(A,i.Bytes),this.writeString(e)},writeFloatField:function(A,e){this.writeTag(A,i.Fixed32),this.writeFloat(e)},writeDoubleField:function(A,e){this.writeTag(A,i.Fixed64),this.writeDouble(e)},writeBooleanField:function(A,e){this.writeVarintField(A,Boolean(e))}}},{ieee754:8}],10:[function(A,e,r){var t=A("pbf"),i=A("./lib/geojson_wrapper");function n(A){var e=new t;return function(A,e){for(var r in A.layers)e.writeMessage(3,o,A.layers[r])}(A,e),e.finish()}function o(A,e){var r;e.writeVarintField(15,A.version||1),e.writeStringField(1,A.name||""),e.writeVarintField(5,A.extent||4096);var t={keys:[],values:[],keycache:{},valuecache:{}};for(r=0;r>31}function l(A,e){for(var r=A.loadGeometry(),t=A.type,i=0,n=0,o=r.length,a=0;anew Promise(((r,t)=>{var i;r((i=e,{type:"FeatureCollection",features:A.cells.map((A=>{const e={properties:A,geometry:{type:i.geometry_type,coordinates:i.generate(A.h3id)}};return i.promoteID||(e.id=parseInt(A.h3id,16)),e}))}))})),a=A=>{const e=["type","data","maxzoom","attribution","buffer","filter","tolerance","cluster","clusterRadius","clusterMaxZoom","clusterMinPoints","clusterProperties","lineMetrics","generateId","promoteId"];return f(A,((A,r)=>e.includes(A)))},f=(A,e)=>Object.fromEntries(Object.entries(A).filter((([A,r])=>e(A,r))));t.Map.prototype.addH3TSource=function(A,e){const r=Object.assign({},n,e,{type:"vector",format:"pbf"});r.generate=A=>"Polygon"===r.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),r.promoteId&&(r.promoteId="h3id"),t.addProtocol("h3tiles",((A,e)=>{const t=`http${!1===r.https?"":"s"}://${A.url.split("://")[1]}`,n=A.url.split(/\/|\./i),a=n.length,f=n.slice(a-4,a-1).map((A=>1*A)),s=new AbortController,u=s.signal;let l;r.timeout>0&&setTimeout((()=>s.abort()),r.timeout),fetch(t,{signal:u}).then((A=>{if(A.ok)return l=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,r))).then((A=>{const t=i.tovt(A).getTile(...f),n={};n[r.sourcelayer]=t;const o=i.topbf.fromGeojsonVt(n,{version:2});r.debug&&console.log(`${f}: ${A.features.length} features, ${(performance.now()-l).toFixed(0)} ms`),e(null,o,null,null)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Tile .../${f.join("/")}.h3t is taking too long to fetch`),e(new Error(A))}))})),this.addSource(A,(A=>{const e=["type","url","tiles","bounds","scheme","minzoom","maxzoom","attribution","promoteId","volatile"];return f(A,((A,r)=>e.includes(A)))})(r))};t.Map.prototype.addH3JSource=function(A,e){const r=new AbortController,t=r.signal,f=Object.assign({},n,e,{type:"geojson"});let s;if(f.generate=A=>"Polygon"===f.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),f.promoteId&&(f.promoteId="h3id"),f.timeout>0&&setTimeout((()=>r.abort()),f.timeout),"string"==typeof f.data)return f.timeout>0&&setTimeout((()=>r.abort()),f.timeout),new Promise(((e,r)=>{fetch(f.data,{signal:t}).then((A=>{if(A.ok)return s=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,f))).then((r=>{f.data=r,this.addSource(A,a(f)),f.debug&&console.log(`${r.features.length} features, ${(performance.now()-s).toFixed(0)} ms`),e(this)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Source file ${f.data} is taking too long to fetch`),console.error(A.message)}))}));o(f.data,f).then((e=>(f.data=e,this.addSource(A,a(f)),new Promise(((A,e)=>A(this))))))};t.Map.prototype.setH3JData=function(A,e,r){const t=Object.assign({},n,r);t.generate=A=>"Polygon"===t.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),t.promoteId&&(t.promoteId="h3id");const a=new AbortController,f=a.signal,s=this.getSource(A);let u;"string"==typeof e?(t.timeout>0&&setTimeout((()=>a.abort()),t.timeout),fetch(e,{signal:f}).then((A=>{if(A.ok)return u=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,t))).then((A=>{s.setData(A),t.debug&&console.log(`${A.features.length} features, ${(performance.now()-u).toFixed(0)} ms`)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Data file ${e} is taking too long to fetch`),console.error(A.message)}))):o(e,t).then((A=>s.setData(A)))}},{"geojson-vt":6,"h3-js":7,"vt-pbf":10}]},{},[12])(12)})); \ No newline at end of file diff --git a/docs/articles/getting-started_files/layers-control-1.0.0/filter-control.css b/docs/articles/getting-started_files/layers-control-1.0.0/filter-control.css new file mode 100644 index 00000000..e6096c34 --- /dev/null +++ b/docs/articles/getting-started_files/layers-control-1.0.0/filter-control.css @@ -0,0 +1,65 @@ +.filter-control { + background: #fff; + position: absolute; + z-index: 1; + border-radius: 3px; + width: 200px; + border: 1px solid rgba(0, 0, 0, 0.4); + font-family: 'Open Sans', sans-serif; + margin: 10px; + padding: 10px; +} + +.filter-control .filter-title { + font-weight: bold; + margin-bottom: 10px; + text-align: center; +} + +.filter-control input[type="range"] { + width: 100%; + margin: 10px 0; +} + +.filter-control .range-value { + text-align: center; + margin-top: 5px; +} + +.filter-control .checkbox-group { + display: flex; + flex-direction: column; + gap: 5px; +} + +.filter-control .checkbox-group label { + display: flex; + align-items: center; + gap: 5px; +} + +.filter-control .toggle-button { + background: darkgrey; + color: #ffffff; + text-align: center; + cursor: pointer; + padding: 5px 0; + border-radius: 3px 3px 0 0; + margin: -10px -10px 10px -10px; +} + +.filter-control .toggle-button:hover { + background: grey; +} + +.filter-control .filter-content { + display: block; +} + +.filter-control.collapsible .filter-content { + display: none; +} + +.filter-control.collapsible.open .filter-content { + display: block; +} \ No newline at end of file diff --git a/docs/articles/getting-started_files/layers-control-1.0.0/layers-control.css b/docs/articles/getting-started_files/layers-control-1.0.0/layers-control.css index 07ebdcc1..85512288 100644 --- a/docs/articles/getting-started_files/layers-control-1.0.0/layers-control.css +++ b/docs/articles/getting-started_files/layers-control-1.0.0/layers-control.css @@ -2,11 +2,14 @@ background: #fff; position: absolute; z-index: 1; - border-radius: 3px; + border-radius: 4px; width: 120px; - border: 1px solid rgba(0, 0, 0, 0.4); - font-family: 'Open Sans', sans-serif; - margin: 10px; + border: 1px solid rgba(0, 0, 0, 0.15); + font-family: "Open Sans", sans-serif; + margin: 0px; + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); + overflow: hidden; + transition: all 0.2s ease-in-out; } .layers-control a { @@ -14,11 +17,12 @@ color: #404040; display: block; margin: 0; - padding: 0; padding: 10px; text-decoration: none; - border-bottom: 1px solid rgba(0, 0, 0, 0.25); + border-bottom: 1px solid rgba(0, 0, 0, 0.1); text-align: center; + transition: all 0.15s ease-in-out; + font-weight: normal; } .layers-control a:last-child { @@ -27,32 +31,35 @@ .layers-control a:hover { background-color: #f8f8f8; - color: #404040; + color: #1a1a1a; } .layers-control a.active { - background-color: darkgrey; + background-color: #4a90e2; color: #ffffff; + font-weight: 500; } .layers-control a.active:hover { - background: grey; + background: #3b7ed2; } .layers-control .toggle-button { display: none; - background: darkgrey; + background: #4a90e2; color: #ffffff; text-align: center; cursor: pointer; - padding: 5px 0; - border-radius: 3px 3px 0 0; - + padding: 8px 0; + border-radius: 4px 4px 0 0; + font-weight: 500; + letter-spacing: 0.3px; + box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05) inset; + transition: all 0.15s ease-in-out; } - .layers-control .toggle-button:hover { - background: grey; + background: #3b7ed2; } .layers-control .layers-list { @@ -66,8 +73,51 @@ .layers-control.collapsible .layers-list { display: none; + opacity: 0; + max-height: 0; + transition: + opacity 0.25s ease, + max-height 0.25s ease; } .layers-control.collapsible.open .layers-list { display: block; + opacity: 1; + max-height: 500px; /* Large enough value to accommodate all content */ +} + +/* Compact icon styling */ +.layers-control.collapsible.icon-only { + width: auto; + min-width: 36px; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); + transform: translateZ( + 0 + ); /* Force hardware acceleration for smoother animations */ +} + +.layers-control.collapsible.icon-only .toggle-button { + border-radius: 4px; + padding: 8px; + width: 36px; + height: 36px; + box-sizing: border-box; + margin: 0; + border-bottom: none; + display: flex; + align-items: center; + justify-content: center; + box-shadow: none; +} + +.layers-control.collapsible.icon-only.open { + width: 120px; + box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25); +} + +.layers-control.collapsible.icon-only.open .toggle-button { + border-radius: 4px 4px 0 0; + border-bottom: 1px solid rgba(0, 0, 0, 0.1); + width: 100%; } diff --git a/docs/articles/getting-started_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js b/docs/articles/getting-started_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js new file mode 100644 index 00000000..510cfcca --- /dev/null +++ b/docs/articles/getting-started_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js @@ -0,0 +1,1897 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js b/docs/articles/getting-started_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js new file mode 100644 index 00000000..1a2fb15e --- /dev/null +++ b/docs/articles/getting-started_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js @@ -0,0 +1,2102 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/mapboxgl-binding-0.2.0/mapboxgl.js b/docs/articles/getting-started_files/mapboxgl-binding-0.2.0/mapboxgl.js new file mode 100644 index 00000000..510cfcca --- /dev/null +++ b/docs/articles/getting-started_files/mapboxgl-binding-0.2.0/mapboxgl.js @@ -0,0 +1,1897 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/mapboxgl-binding-0.2.1/mapboxgl.js b/docs/articles/getting-started_files/mapboxgl-binding-0.2.1/mapboxgl.js new file mode 100644 index 00000000..1a2fb15e --- /dev/null +++ b/docs/articles/getting-started_files/mapboxgl-binding-0.2.1/mapboxgl.js @@ -0,0 +1,2102 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js b/docs/articles/getting-started_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js new file mode 100644 index 00000000..fc5462ee --- /dev/null +++ b/docs/articles/getting-started_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js @@ -0,0 +1,2684 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case 'get': + return properties[expression[1]]; + case 'concat': + return expression.slice(1).map(item => evaluateExpression(item, properties)).join(''); + case 'to-string': + return String(evaluateExpression(expression[1], properties)); + case 'to-number': + return Number(evaluateExpression(expression[1], properties)); + case 'number-format': + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || 'en-US'; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty('min-fraction-digits')) { + formatOptions.minimumFractionDigits = options['min-fraction-digits']; + } + if (options.hasOwnProperty('max-fraction-digits')) { + formatOptions.maximumFractionDigits = options['max-fraction-digits']; + } + if (options.hasOwnProperty('min-integer-digits')) { + formatOptions.minimumIntegerDigits = options['min-integer-digits']; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty('useGrouping')) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(tooltipProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + window._mapboxPopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layerId] === popup) { + delete window._mapboxPopups[layerId]; + } + }); +} + +// Helper function to generate draw styles based on parameters +function generateDrawStyles(styling) { + if (!styling) return null; + + return [ + // Point styles + { + 'id': 'gl-draw-point-active', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'true']], + 'paint': { + 'circle-radius': styling.vertex_radius + 2, + 'circle-color': styling.active_color + } + }, + { + 'id': 'gl-draw-point', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'false']], + 'paint': { + 'circle-radius': styling.vertex_radius, + 'circle-color': styling.point_color + } + }, + // Line styles + { + 'id': 'gl-draw-line', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'LineString']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Polygon fill + { + 'id': 'gl-draw-polygon-fill', + 'type': 'fill', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'paint': { + 'fill-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-outline-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-opacity': styling.fill_opacity + } + }, + // Polygon outline + { + 'id': 'gl-draw-polygon-stroke', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Midpoints + { + 'id': 'gl-draw-polygon-midpoint', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'midpoint']], + 'paint': { + 'circle-radius': 3, + 'circle-color': styling.active_color + } + }, + // Vertex point halos + { + 'id': 'gl-draw-vertex-halo-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 4, + styling.vertex_radius + 2 + ], + 'circle-color': '#FFF' + } + }, + // Vertex points + { + 'id': 'gl-draw-vertex-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 2, + styling.vertex_radius + ], + 'circle-color': styling.active_color + } + } + ]; +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, layer.popup, layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + // Set rain effect if provided + if (x.rain) { + map.setRain(x.rain); + } + + // Set snow effect if provided + if (x.snow) { + map.setSnow(x.snow); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + // Generate styles if styling parameters provided + if (x.draw_control.styling) { + const generatedStyles = generateDrawStyles(x.draw_control.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (x.draw_control.source) { + addSourceFeaturesToDraw(draw, x.draw_control.source, map); + } + + // Process any queued features + if (x.draw_features_queue) { + x.draw_features_queue.forEach(function(data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn('Source not found or has no data:', sourceId); + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + // Initialize with empty object, will be populated after map loads + let initialView = {}; + + // Capture the initial view after the map has loaded and all view operations are complete + map.once('load', function() { + initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + }); + + resetControl.onclick = function () { + // Only reset if we have captured the initial view + if (initialView.center) { + map.easeTo(initialView); + } + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDraw: function () { + return draw; // Return the draw instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + + // Helper function to update drawn features + function updateDrawnFeatures() { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + var drawnFeatures = drawControl.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(drawnFeatures) + ); + } + // Store drawn features in the widget's data + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, message.layer.popup, message.layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + if (window._mapboxPopups && window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer] + ) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll('style[data-mapgl-legend-css]'); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + // Identify user-added sources (those not in the original style) + // We'll assume any source that's not "composite", "mapbox", or starts with "mapbox-" is user-added + for (const sourceId in currentStyle.sources) { + if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") + ) { + userSourceIds.push(sourceId); + const source = currentStyle.sources[sourceId]; + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + } + + // Identify layers using user-added sources + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source)) { + userLayers.push(layer); + } + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + }); + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + // Create the draw control + var drawControl = new MapboxDraw(drawOptions); + map.addControl(drawControl, message.position); + map.controls.push(drawControl); + + // Store the draw control on the widget for later access + widget.drawControl = drawControl; + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(drawControl, message.source, map); + } + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + const features = drawControl.getAll(); + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + drawControl.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_features_to_draw") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + if (message.data.clear_existing) { + drawControl.deleteAll(); + } + addSourceFeaturesToDraw(drawControl, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn('Draw control not initialized'); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + // Remove all legend elements + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + + // Clean up any legend styles associated with this map + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => { + style.remove(); + }); + } + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_popup") { + const layerId = message.layer; + const newPopupProperty = message.popup; + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + delete window._mapboxPopups[layerId]; + } + + // Remove old click handler if any + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + delete window._mapboxClickHandlers[layerId]; + } + + // Remove old hover handlers for cursor change + map.off("mouseenter", layerId); + map.off("mouseleave", layerId); + + // Create new click handler + const clickHandler = function (e) { + onClickPopup(e, map, newPopupProperty, layerId); + }; + + // Add the new event handler + map.on("click", layerId, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_rain") { + if (message.rain) { + map.setRain(message.rain); + } else { + map.setRain(null); + } + } else if (message.type === "set_snow") { + if (message.snow) { + map.setSnow(message.snow); + } else { + map.setSnow(null); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/mapboxgl-binding-0.2.2/mapboxgl.js b/docs/articles/getting-started_files/mapboxgl-binding-0.2.2/mapboxgl.js new file mode 100644 index 00000000..faedbb1b --- /dev/null +++ b/docs/articles/getting-started_files/mapboxgl-binding-0.2.2/mapboxgl.js @@ -0,0 +1,2367 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[layer.id]) { + window._mapboxPopups[layer.id].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layer.id] === popup) { + delete window._mapboxPopups[layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + // Set rain effect if provided + if (x.rain) { + map.setRain(x.rain); + } + + // Set snow effect if provided + if (x.snow) { + map.setSnow(x.snow); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[message.layer.popup]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[message.layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[message.layer.id] === popup) { + delete window._mapboxPopups[message.layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + if (window._mapboxPopups && window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer] + ) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll('style[data-mapgl-legend-css]'); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + // Identify user-added sources (those not in the original style) + // We'll assume any source that's not "composite", "mapbox", or starts with "mapbox-" is user-added + for (const sourceId in currentStyle.sources) { + if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") + ) { + userSourceIds.push(sourceId); + const source = currentStyle.sources[sourceId]; + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + } + + // Identify layers using user-added sources + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source)) { + userLayers.push(layer); + } + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + }); + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + // Remove all legend elements + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + + // Clean up any legend styles associated with this map + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => { + style.remove(); + }); + } + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_rain") { + if (message.rain) { + map.setRain(message.rain); + } else { + map.setRain(null); + } + } else if (message.type === "set_snow") { + if (message.snow) { + map.setSnow(message.snow); + } else { + map.setSnow(null); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/maplibre-gl-5.0.0/LICENSE.txt b/docs/articles/getting-started_files/maplibre-gl-5.0.0/LICENSE.txt new file mode 100644 index 00000000..1e8acbb5 --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.0.0/LICENSE.txt @@ -0,0 +1,116 @@ +Copyright (c) 2023, MapLibre contributors + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of MapLibre GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from mapbox-gl-js v1.13 and earlier + +Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license + +Copyright (c) 2020, Mapbox +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Mapbox GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from glfx.js + +Copyright (C) 2011 by Evan Wallace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +Contains a portion of d3-color https://github.com/d3/d3-color + +Copyright 2010-2016 Mike Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/articles/getting-started_files/maplibre-gl-5.0.0/maplibre-gl.css b/docs/articles/getting-started_files/maplibre-gl-5.0.0/maplibre-gl.css new file mode 100644 index 00000000..f0162fd1 --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.0.0/maplibre-gl.css @@ -0,0 +1 @@ +.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file diff --git a/docs/articles/getting-started_files/maplibre-gl-5.0.0/maplibre-gl.js b/docs/articles/getting-started_files/maplibre-gl-5.0.0/maplibre-gl.js new file mode 100644 index 00000000..f7f839bc --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.0.0/maplibre-gl.js @@ -0,0 +1,59 @@ +/** + * MapLibre GL JS + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.0.0/LICENSE.txt + */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); +})(this, (function () { 'use strict'; + +/* eslint-disable */ + +var maplibregl = {}; +var modules = {}; +function define(moduleName, _dependencies, moduleFactory) { + modules[moduleName] = moduleFactory; + + // to get the list of modules see generated dist/maplibre-gl-dev.js file (look for `define(` calls) + if (moduleName !== 'index') { + return; + } + + // we assume that when an index module is initializing then other modules are loaded already + var workerBundleString = 'var sharedModule = {}; (' + modules.shared + ')(sharedModule); (' + modules.worker + ')(sharedModule);' + + var sharedModule = {}; + // the order of arguments of a module factory depends on rollup (it decides who is whose dependency) + // to check the correct order, see dist/maplibre-gl-dev.js file (look for `define(` calls) + // we assume that for our 3 chunks it will generate 3 modules and their order is predefined like the following + modules.shared(sharedModule); + modules.index(maplibregl, sharedModule); + + if (typeof window !== 'undefined') { + maplibregl.setWorkerUrl(window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }))); + } + + return maplibregl; +}; + + + +define("shared",["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t));}catch(t){s(t);}}function o(t){try{l(n.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(a,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n,i;function s(){if(i)return n;function t(t,e){this.x=t,this.y=e;}return i=1,n=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},n}"function"==typeof SuppressedError&&SuppressedError;var a,o,l=r(s()),u=function(){if(o)return a;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return o=1,a=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},a}(),c=r(u);let h,p;function f(){return null==h&&(h="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),h}function d(){if(null==p&&(p=!1,f())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function B(t,e,r,n){const i=new c(t,e,r,n);return t=>i.solve(t)}const V=B(.25,.1,.25,1);function E(t,e,r){return Math.min(r,Math.max(e,t))}function T(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function F(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let $=1;function L(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function D(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function O(t){return Array.isArray(t)?t.map(O):"object"==typeof t&&t?L(t,O):t}const R={};function j(t){R[t]||("undefined"!=typeof console&&console.warn(t),R[t]=!0);}function N(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function U(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let q=null;function G(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const Z="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function X(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,r,n,i){const s=4*Math.max(-e,0),a=(Math.max(0,r)-r)*n*4+s,o=4*n,l=Math.max(0,e),u=Math.max(0,r);return {rect:{x:l,y:u,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-u},layout:[{offset:a,stride:o}]}}(t,r,n,i,s)),o)for(let t=0;tU(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,it=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=tt(t.url);if(e)return e(t,r);if(U(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:et},r)}if(!(/^file:/.test(n=t.url)||/^file:/.test(nt())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:nt(),signal:r.signal});let n,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e);}catch(e){throw new rt(0,e.message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new rt(n.status,n.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw W();return {data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(U(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:et},r)}var n;return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new rt(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),n(W());})),s.send(t.body);}))}(t,r)};function st(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function at(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function ot(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class lt{constructor(t,e={}){F(this,e),this.type=t;}}class ut extends lt{constructor(t,e={}){super("error",F({error:t},e));}}class ct{on(t,e){return this._listeners=this._listeners||{},at(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e);}}}off(t,e){return ot(t,e,this._listeners),ot(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},at(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new lt(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)ot(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(F(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof ut&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var ht={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const pt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ft(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return pt.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function dt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Nt=[It,zt,Pt,Ct,Bt,Vt,$t,Et,Rt(Tt),Lt,Dt,Ot];function Ut(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ut(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Nt)if(!Ut(t,e))return null}return `Expected ${jt(t)} but found ${jt(e)} instead.`}function qt(t,e){return e.some((e=>e.kind===t.kind))}function Gt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function Zt(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Xt=.96422,Kt=.82521,Ht=4/29,Yt=6/29,Jt=3*Yt*Yt,Wt=Yt*Yt*Yt,Qt=Math.PI/180,te=180/Math.PI;function ee(t){return (t%=360)<0&&(t+=360),t}function re([t,e,r,n]){let i,s;const a=ie((.2225045*(t=ne(t))+.7168786*(e=ne(e))+.0606169*(r=ne(r)))/1);t===e&&e===r?i=s=a:(i=ie((.4360747*t+.3850649*e+.1430804*r)/Xt),s=ie((.0139322*t+.0971045*e+.7141733*r)/Kt));const o=116*a-16;return [o<0?0:o,500*(i-a),200*(a-s),n]}function ne(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ie(t){return t>Wt?Math.pow(t,1/3):t/Jt+Ht}function se([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*oe(i),s=Xt*oe(s),a=Kt*oe(a),[ae(3.1338561*s-1.6168667*i-.4906146*a),ae(-.9787684*s+1.9161415*i+.033454*a),ae(.0719453*s-.2289914*i+1.4052427*a),n]}function ae(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function oe(t){return t>Yt?t*t*t:Jt*(t-Ht)}function le(t){return parseInt(t.padEnd(2,t),16)/255}function ue(t,e){return ce(e?t/100:t,0,1)}function ce(t,e,r){return Math.min(Math.max(e,t),r)}function he(t){return !t.some(Number.isNaN)}const pe={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function fe(t,e,r){return t+r*(e-t)}function de(t,e,r){return t.map(((t,n)=>fe(t,e[n],r)))}class ye{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof ye)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=pe[t];if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [le(t.slice(r,r+=e)),le(t.slice(r,r+=e)),le(t.slice(r,r+=e)),le(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[ce(+r/e,0,1),ce(+s/e,0,1),ce(+l/e,0,1),h?ue(+h,p):1];if(he(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,ce(+i,0,100),ce(+a,0,100),l?ue(+l,u):1];if(he(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=ee(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new ye(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=re(t),s=Math.sqrt(r*r+n*n);return [Math.round(1e4*s)?ee(Math.atan2(n,r)*te):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",re(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}static interpolate(t,e,r,n="rgb"){switch(n){case"rgb":{const[n,i,s,a]=de(t.rgb,e.rgb,r);return new ye(n,i,s,a,!1)}case"hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*Qt,se([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:fe(i,l,r),fe(s,u,r),fe(a,c,r)]);return new ye(f,d,y,m,!1)}case"lab":{const[n,i,s,a]=se(de(t.lab,e.lab,r));return new ye(n,i,s,a,!1)}}}}ye.black=new ye(0,0,0,1),ye.white=new ye(1,1,1,1),ye.transparent=new ye(0,0,0,0),ye.red=new ye(1,0,0,1);class me{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ge{constructor(t,e,r,n,i){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i;}}class xe{constructor(t){this.sections=t;}static fromString(t){return new xe([new ge(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof xe?t:xe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class ve{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof ve)return t;if("number"==typeof t)return new ve([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new ve(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new ve(de(t.values,e.values,r))}}class be{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}}const we=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class _e{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof _e)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Me(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Ae||t instanceof ye||t instanceof me||t instanceof xe||t instanceof ve||t instanceof _e||t instanceof Se)return !0;if(Array.isArray(t)){for(const e of t)if(!Me(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!Me(t[e]))return !1;return !0}return !1}function Ie(t){if(null===t)return It;if("string"==typeof t)return Pt;if("boolean"==typeof t)return Ct;if("number"==typeof t)return zt;if(t instanceof ye)return Bt;if(t instanceof Ae)return Vt;if(t instanceof me)return Ft;if(t instanceof xe)return $t;if(t instanceof ve)return Lt;if(t instanceof _e)return Ot;if(t instanceof Se)return Dt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=Ie(e);if(r){if(r===t)continue;r=Tt;break}r=t;}return Rt(r||Tt,e)}return Et}function ze(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ye||t instanceof Ae||t instanceof xe||t instanceof ve||t instanceof _e||t instanceof Se?t.toString():JSON.stringify(t)}class Pe{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Me(t[1]))return e.error("invalid value");const r=t[1];let n=Ie(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Pe(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}const Ce={string:Pt,number:zt,boolean:Ct,object:Et};class Be{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in Ce)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Ce[r],n++;}else i=Tt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=Rt(i,s);}else {if(!Ce[i])throw new Error(`Types doesn't contain name = ${i}`);r=Ce[i];}const s=[];for(;nt.outputDefined()))}}const Ve={"to-boolean":Ct,"to-color":Bt,"to-number":zt,"to-string":Pt};class Ee{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!Ve[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=Ve[r],i=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ke(e[0],e[1],e[2],e[3]),!r))return new ye(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new be(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=ve.parse(e);if(n)return n}throw new be(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=_e.parse(e);if(n)return n}throw new be(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new be(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return xe.fromString(ze(this.args[0].evaluate(t)));case"resolvedImage":return Se.fromString(ze(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return ze(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function Te(t,e,r=0,n=t.length-1,i=$e){for(;n>r;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Te(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(Fe(t,r,e),i(t[n],s)>0&&Fe(t,r,n);a0;)o--;}0===i(t[r],s)?Fe(t,r,o):(o++,Fe(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function Fe(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function $e(t,e){return te?1:0}function Le(t,e){if(t.length<=1)return [t];const r=[];let n,i;for(const e of t){const t=Oe(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e));}if(n&&r.push(n),e>1)for(let t=0;t`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new Be(e,[t]):"coerce"===r?new Ee(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("projectionDefinition"!==t.kind||"string"!==i.kind&&"array"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind)if("padding"!==t.kind||"value"!==i.kind&&"number"!==i.kind&&"array"!==i.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==i.kind&&"array"!==i.kind){if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof Pe)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Ne;try{n=new Pe(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new Ue(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new kt(r,t));}checkSubtype(t,e){const r=Ut(t,e);return r&&this.error(r),r}}class qe{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new be(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new be(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class Xe{constructor(t,e){this.type=Ct,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Tt),n=e.parse(t[2],2,Tt);return r&&n?qt(r.type,[Ct,Pt,zt,It,Tt])?new Xe(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${jt(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!Gt(e,["boolean","string","number","null"]))throw new be(`Expected first argument to be of type boolean, string, number or null, but found ${jt(Ie(e))} instead.`);if(!Gt(r,["string","array"]))throw new be(`Expected second argument to be of type array or string, but found ${jt(Ie(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class Ke{constructor(t,e,r){this.type=zt,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Tt),n=e.parse(t[2],2,Tt);if(!r||!n)return null;if(!qt(r.type,[Ct,Pt,zt,It,Tt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${jt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,zt);return i?new Ke(r,n,i):null}return new Ke(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Gt(e,["boolean","string","number","null"]))throw new be(`Expected first argument to be of type boolean, string, number or null, but found ${jt(Ie(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),Gt(r,["string"])){const t=r.indexOf(e,n);return -1===t?-1:[...r.slice(0,t)].length}if(Gt(r,["array"]))return r.indexOf(e,n);throw new be(`Expected second argument to be of type array or string, but found ${jt(Ie(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class He{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,Ie(t)))return null}else r=Ie(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,Tt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new He(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (Ie(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class Ye{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class Je{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Tt),n=e.parse(t[2],2,zt);if(!r||!n)return null;if(!qt(r.type,[Rt(Tt),Pt,Tt]))return e.error(`Expected first argument to be of type array or string, but found ${jt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,zt);return i?new Je(r.type,r,n,i):null}return new Je(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),Gt(e,["string"]))return [...e].slice(r,n).join("");if(Gt(e,["array"]))return e.slice(r,n);throw new be(`Expected first argument to be of type array or string, but found ${jt(Ie(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function We(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new be("Input is not a number.");a=o-1;}return 0}class Qe{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,zt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Qe(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[We(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function tr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var er,rr,nr=function(){if(rr)return er;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return rr=1,er=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},er}(),ir=tr(nr);class sr{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=ar(e,t.base,r,n);else if("linear"===t.name)i=ar(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new ir(s[0],s[1],s[2],s[3]).solve(ar(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,zt),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Bt:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return Zt(o,zt)||Zt(o,Vt)||Zt(o,Bt)||Zt(o,Lt)||Zt(o,Ot)||Zt(o,Rt(zt))?new sr(o,r,n,i,a):e.error(`Type ${jt(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=We(e,n),a=sr.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return fe(o,l,a);case"color":return ye.interpolate(o,l,a);case"padding":return ve.interpolate(o,l,a);case"variableAnchorOffsetCollection":return _e.interpolate(o,l,a);case"array":return de(o,l,a);case"projectionDefinition":return Ae.interpolate(o,l,a)}case"interpolate-hcl":return ye.interpolate(o,l,a,"hcl");case"interpolate-lab":return ye.interpolate(o,l,a,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function ar(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}const or={color:ye.interpolate,number:fe,padding:ve.interpolate,variableAnchorOffsetCollection:_e.interpolate,array:de};class lr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const s=n&&i.some((t=>Ut(n,t.type)));return new lr(s?Tt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof Se&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function ur(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function cr(t,e,r,n){return 0===n.compare(e,r)}function hr(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=Ct,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,Tt);if(!s)return null;if(!ur(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${jt(s.type)}'.`);let a=e.parse(t[2],2,Tt);if(!a)return null;if(!ur(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${jt(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${jt(s.type)}' and '${jt(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new Be(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new Be(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ft),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=Ie(s),r=Ie(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new be(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=Ie(s),r=Ie(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const pr=hr("==",(function(t,e,r){return e===r}),cr),fr=hr("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !cr(0,e,r,n)})),dr=hr("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),mr=hr("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),gr=hr(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class xr{constructor(t,e,r){this.type=Ft,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,Ct);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Ct);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,Pt),!s)?null:new xr(n,i,s)}evaluate(t){return new me(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class vr{constructor(t,e,r,n,i){this.type=Pt,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,zt);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,Pt),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Pt),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,zt),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,zt),!o)?null:new vr(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class br{constructor(t){this.type=$t,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,zt),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,Rt(Pt)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,Bt),!a))return null;const o=n[n.length-1];o.scale=t,o.font=r,o.textColor=a;}else {const s=e.parse(t[r],1,Tt);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new br(n)}evaluate(t){return new xe(this.sections.map((e=>{const r=e.content.evaluate(t);return Ie(r)===Dt?new ge("",r,null,null,null):new ge(ze(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor);}outputDefined(){return !1}}class wr{constructor(t){this.type=Dt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Pt);return r?new wr(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=Se.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class _r{constructor(t){this.type=zt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${jt(r.type)} instead.`):new _r(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new be(`Expected value to be of type string or array, but found ${jt(Ie(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const Sr=8192;function Ar(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*Sr),Math.round(n*i*Sr)]}function kr(t,e){const r=Math.pow(2,e.z);return [(i=(t[0]/Sr+e.x)/r,360*i-180),(n=(t[1]/Sr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i;}function Mr(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function Ir(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function zr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Pr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Fr(t,e,r,n)||!Fr(r,n,t,e));var i,s;}function Cr(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(a=o[e+1])[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}var i,s,a;return n}function Vr(t,e){for(const r of e)if(Br(t,r))return !0;return !1}function Er(t,e){for(const r of t)if(!Br(r,e))return !1;for(let r=0;r0&&o<0||a<0&&o>0}function $r(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Mr(e,t);}function Or(t,e,r,n){const i=Math.pow(2,n.z)*Sr,s=[n.x*Sr,n.y*Sr],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Dr(n,e,r,i),a.push(n);}return a}function Rr(t,e,r,n){const i=Math.pow(2,n.z)*Sr,s=[n.x*Sr,n.y*Sr],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Mr(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)Dr(n,e,r,i);}var o;return a}class jr{constructor(t,e){this.type=Ct,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Me(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n);}if(t.length)return new jr(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new jr(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new jr(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryDollarType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=$r(e.coordinates,n,i),a=Or(t.geometry(),r,n,i);if(!Ir(r,n))return !1;for(const t of a)if(!Br(t,s))return !1}if("MultiPolygon"===e.type){const s=Lr(e.coordinates,n,i),a=Or(t.geometry(),r,n,i);if(!Ir(r,n))return !1;for(const t of a)if(!Vr(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryDollarType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=$r(e.coordinates,n,i),a=Rr(t.geometry(),r,n,i);if(!Ir(r,n))return !1;for(const t of a)if(!Er(t,s))return !1}if("MultiPolygon"===e.type){const s=Lr(e.coordinates,n,i),a=Rr(t.geometry(),r,n,i);if(!Ir(r,n))return !1;for(const t of a)if(!Tr(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let Nr=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}};const Ur=1/298.257223563,qr=Ur*(2-Ur),Gr=Math.PI/180;class Zr{constructor(t){const e=6378.137*Gr*1e3,r=Math.cos(t*Gr),n=1/(1-qr*(1-r*r)),i=Math.sqrt(n);this.kx=e*i*r,this.ky=e*i*n*(1-qr);}distance(t,e){const r=this.wrap(t[0]-e[0])*this.kx,n=(t[1]-e[1])*this.ky;return Math.sqrt(r*r+n*n)}pointOnLine(t,e){let r,n,i,s,a=1/0;for(let o=0;o1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function Xr(t,e){return e[0]-t[0]}function Kr(t){return t[1]-t[0]+1}function Hr(t,e){return t[1]>=t[0]&&t[1]t[1])return [null,null];const r=Kr(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return [t,null];const n=Math.floor(r/2)-1;return [[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function Jr(t,e){if(!Hr(e,t.length))return [1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)Mr(r,t[n]);return r}function Wr(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)Mr(e,t);return e}function Qr(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function tn(t,e,r){if(!Qr(t)||!Qr(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Ir(i,s)){if(ln(t,e))return 0}else if(ln(e,t))return 0;let a=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=a.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(Kr(l)<=u){if(!Hr(l,t.length))return NaN;if(e){const e=on(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=an(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else {const r=Yr(l,e);cn(a,s,n,t,o,r[0]),cn(a,s,n,t,o,r[1]);}}return s}function fn(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new Nr([[0,[0,t.length-1],[0,r.length-1]]],Xr);for(;o.length>0;){const s=o.pop();if(s[0]>=a)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(Kr(l)<=c&&Kr(u)<=h){if(!Hr(l,t.length)&&Hr(u,r.length))return NaN;let s;if(e&&n)s=nn(t,l,r,u,i),a=Math.min(a,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=en(r[t],e,i),a=Math.min(a,s),0===a)return a}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=en(t[r],e,i),a=Math.min(a,s),0===a)return a}else s=sn(t,l,r,u,i),a=Math.min(a,s);}else {const s=Yr(l,e),c=Yr(u,n);hn(o,a,i,t,r,s[0],c[0]),hn(o,a,i,t,r,s[0],c[1]),hn(o,a,i,t,r,s[1],c[0]),hn(o,a,i,t,r,s[1],c[1]);}}return a}function dn(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class yn{constructor(t,e){this.type=zt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Me(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new yn(e,e.features.map((t=>dn(t.geometry))).flat());if("Feature"===e.type)return new yn(e,dn(e.geometry));if("type"in e&&"coordinates"in e)return new yn(e,dn(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>kr([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Zr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,fn(n,!1,[t.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,fn(n,!1,t.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,pn(n,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>kr([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Zr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,fn(n,!0,[t.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,fn(n,!0,t.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,pn(n,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Le(r,0).map((e=>e.map((e=>e.map((e=>kr([e.x,e.y],t.canonical))))))),i=new Zr(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case"Point":s=Math.min(s,pn([t.coordinates],!1,e,i,s));break;case"LineString":s=Math.min(s,pn(t.coordinates,!0,e,i,s));break;case"Polygon":s=Math.min(s,un(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}const mn={"==":pr,"!=":fr,">":yr,"<":dr,">=":gr,"<=":mr,array:Be,at:Ze,boolean:Be,case:Ye,coalesce:lr,collator:xr,format:br,image:wr,in:Xe,"index-of":Ke,interpolate:sr,"interpolate-hcl":sr,"interpolate-lab":sr,length:_r,let:qe,literal:Pe,match:He,number:Be,"number-format":vr,object:Be,slice:Je,step:Qe,string:Be,"to-boolean":Ee,"to-color":Ee,"to-number":Ee,"to-string":Ee,var:Ge,within:jr,distance:yn};class gn{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const r=t[0],n=gn.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new Ue(e.registry,_n,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(jt).join(", ")})`:`(${jt(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&_n(t):r&&t instanceof Pe;})),!!r&&Sn(t)&&kn(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Sn(t){if(t instanceof gn){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof jr)return !1;if(t instanceof yn)return !1;let e=!0;return t.eachChild((t=>{e&&!Sn(t)&&(e=!1);})),e}function An(t){if(t instanceof gn&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!An(t)&&(e=!1);})),e}function kn(t,e){if(t instanceof gn&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!kn(t,e)&&(r=!1);})),r}function Mn(t){return {result:"success",value:t}}function In(t){return {result:"error",value:t}}function zn(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Pn(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Cn(t){return !!t.expression&&t.expression.interpolated}function Bn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Vn(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function En(t){return t}function Tn(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(Cn(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?ye.parse:ve.parse;(t=At({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default);}if(t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;let o,l,u;if("exponential"===s)o=Dn;else if("interval"===s)o=Ln;else if("categorical"===s){o=$n,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=On;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Dn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:sr.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Fn(t.default,e.default):o(t,e,i,l,u)}}}function Fn(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function $n(t,e,r,n,i){return Fn(typeof r===i?n[r]:void 0,t.default,e.default)}function Ln(t,e,r){if("number"!==Bn(r))return Fn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=We(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Dn(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Bn(r))return Fn(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=We(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=or[e.type]||En;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function On(t,e,r){switch(e.type){case"color":r=ye.parse(r);break;case"formatted":r=xe.fromString(r.toString());break;case"resolvedImage":r=Se.fromString(r.toString());break;case"padding":r=ve.parse(r);break;default:Bn(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return Fn(r,t.default,e.default)}gn.register(mn,{error:[{kind:"error"},[Pt],(t,[e])=>{throw new be(e.evaluate(t))}],typeof:[Pt,[Tt],(t,[e])=>jt(Ie(e.evaluate(t)))],"to-rgba":[Rt(zt,4),[Bt],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return [255*r,255*n,255*i,s]}],rgb:[Bt,[zt,zt,zt],xn],rgba:[Bt,[zt,zt,zt,zt],xn],has:{type:Ct,overloads:[[[Pt],(t,[e])=>vn(e.evaluate(t),t.properties())],[[Pt,Et],(t,[e,r])=>vn(e.evaluate(t),r.evaluate(t))]]},get:{type:Tt,overloads:[[[Pt],(t,[e])=>bn(e.evaluate(t),t.properties())],[[Pt,Et],(t,[e,r])=>bn(e.evaluate(t),r.evaluate(t))]]},"feature-state":[Tt,[Pt],(t,[e])=>bn(e.evaluate(t),t.featureState||{})],properties:[Et,[],t=>t.properties()],"geometry-type":[Pt,[],t=>t.geometryType()],id:[Tt,[],t=>t.id()],zoom:[zt,[],t=>t.globals.zoom],"heatmap-density":[zt,[],t=>t.globals.heatmapDensity||0],"line-progress":[zt,[],t=>t.globals.lineProgress||0],accumulated:[Tt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[zt,wn(zt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[zt,wn(zt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:zt,overloads:[[[zt,zt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[zt],(t,[e])=>-e.evaluate(t)]]},"/":[zt,[zt,zt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[zt,[zt,zt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[zt,[],()=>Math.LN2],pi:[zt,[],()=>Math.PI],e:[zt,[],()=>Math.E],"^":[zt,[zt,zt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[zt,[zt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[zt,[zt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[zt,[zt],(t,[e])=>Math.log(e.evaluate(t))],log2:[zt,[zt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[zt,[zt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[zt,[zt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[zt,[zt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[zt,[zt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[zt,[zt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[zt,[zt],(t,[e])=>Math.atan(e.evaluate(t))],min:[zt,wn(zt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[zt,wn(zt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[zt,[zt],(t,[e])=>Math.abs(e.evaluate(t))],round:[zt,[zt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[zt,[zt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[zt,[zt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Ct,[Pt,Tt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[Ct,[Tt],(t,[e])=>t.id()===e.value],"filter-type-==":[Ct,[Pt],(t,[e])=>t.geometryDollarType()===e.value],"filter-<":[Ct,[Pt,Tt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[Ct,[Pt,Tt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Ct,[Tt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Ct,[Pt,Tt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Ct,[Tt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Ct,[Pt,Tt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Ct,[Tt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Ct,[Tt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Ct,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Ct,[Rt(Pt)],(t,[e])=>e.value.indexOf(t.geometryDollarType())>=0],"filter-id-in":[Ct,[Rt(Tt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Ct,[Pt,Rt(Tt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Ct,[Pt,Rt(Tt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Ct,overloads:[[[Ct,Ct],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[wn(Ct),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:Ct,overloads:[[[Ct,Ct],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[wn(Ct),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[Ct,[Ct],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Ct,[Pt],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Pt,[Pt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Pt,[Pt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Pt,wn(Tt),(t,e)=>e.map((e=>ze(e.evaluate(t)))).join("")],"resolved-locale":[Pt,[Ft],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Rn{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new Ne,this._defaultValue=e?"color"===(r=e).type&&Vn(r.default)?new ye(0,0,0,0):"color"===r.type?ye.parse(r.default)||null:"padding"===r.type?ve.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?_e.parse(r.default)||null:"projectionDefinition"===r.type?Ae.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new be(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function jn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in mn}function Nn(t,e){const r=new Ue(mn,_n,[],e?function(t){const e={color:Bt,string:Pt,number:zt,enum:Pt,boolean:Ct,formatted:$t,padding:Lt,projectionDefinition:Vt,resolvedImage:Dt,variableAnchorOffsetCollection:Ot};return "array"===t.type?Rt(e[t.value]||Tt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Mn(new Rn(n,e)):In(r.errors)}class Un{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!An(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class qn{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!An(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?sr.interpolationFactor(this.interpolationType,t,e,r):0}}function Gn(t,e){const r=Nn(t,e);if("error"===r.result)return r;const n=r.value.expression,i=Sn(n);if(!i&&!zn(e))return In([new kt("","data expressions not supported")]);const s=kn(n,["zoom"]);if(!s&&!Pn(e))return In([new kt("","zoom expressions not supported")]);const a=Xn(n);return a||s?a instanceof kt?In([a]):a instanceof sr&&!Cn(e)?In([new kt("",'"interpolate" expressions cannot be used with this property')]):Mn(a?new qn(i?"camera":"composite",r.value,a.labels,a instanceof sr?a.interpolation:void 0):new Un(i?"constant":"source",r.value)):In([new kt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Zn{constructor(t,e){this._parameters=t,this._specification=e,At(this,Tn(this._parameters,this._specification));}static deserialize(t){return new Zn(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function Xn(t){let e=null;if(t instanceof qe)e=Xn(t.result);else if(t instanceof lr){for(const r of t.args)if(e=Xn(r),e)break}else (t instanceof Qe||t instanceof sr)&&t.input instanceof gn&&"zoom"===t.input.name&&(e=t);return e instanceof kt||t.eachChild((t=>{const r=Xn(t);r instanceof kt?e=r:!e&&r?e=new kt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new kt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function Kn(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Kn(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const Hn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Yn(t){if(null==t)return {filter:()=>!0,needGeometry:!1};Kn(t)||(t=Qn(t));const e=Nn(t,Hn);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:Wn(t)}}function Jn(t,e){return te?1:0}function Wn(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0]||"geometry-type"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?ti(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(Qn))):"all"===e?["all"].concat(t.slice(1).map(Qn)):"none"===e?["all"].concat(t.slice(1).map(Qn).map(ni)):"in"===e?ei(t[1],t.slice(2)):"!in"===e?ni(ei(t[1],t.slice(2))):"has"===e?ri(t[1]):"!has"!==e||ni(ri(t[1]));var r;}function ti(t,e,r){switch(t){case"$type":return [`filter-type-${r}`,e];case"$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function ei(t,e){if(0===e.length)return !1;switch(t){case"$type":return ["filter-type-in",["literal",e]];case"$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(Jn)]]:["filter-in-small",t,["literal",e]]}}function ri(t){switch(t){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",t]}}function ni(t){return ["!",t]}function ii(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${ii(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new St(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function pi(t){const e=t.valueSpec,r=oi(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===Bn(t.value.stops)&&"array"===Bn(t.value.stops[0])&&"object"===Bn(t.value.stops[0][0]),c=ui({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new St(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(ci({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Bn(n)&&0===n.length&&e.push(new St(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new St(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new St(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!Cn(t.valueSpec)&&c.push(new St(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!zn(t.valueSpec)?c.push(new St(t.key,t.value,"property functions not supported")):o&&!Pn(t.valueSpec)&&c.push(new St(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new St(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==Bn(n))return [new St(o,n,`array expected, ${Bn(n)} found`)];if(2!==n.length)return [new St(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==Bn(n[0]))return [new St(o,n,`object expected, ${Bn(n[0])} found`)];if(void 0===n[0].zoom)return [new St(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new St(o,n,"object stop key must have value")];if(s&&s>oi(n[0].zoom))return [new St(o,n[0].zoom,"stop zoom values must appear in ascending order")];oi(n[0].zoom)!==s&&(s=oi(n[0].zoom),i=void 0,a={}),r=r.concat(ui({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:hi,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return jn(li(n[1]))?r.concat([new St(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=Bn(t.value),l=oi(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return [new St(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new St(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return zn(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new St(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew St(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new St(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!An(r))return [new St(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!An(r))return [new St(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!kn(r,["zoom","feature-state"]))return [new St(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Sn(r))return [new St(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function di(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(oi(r))&&i.push(new St(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(oi(r))&&i.push(new St(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function yi(t){return Kn(li(t.value))?fi(At({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):mi(t)}function mi(t){const e=t.value,r=t.key;if("array"!==Bn(e))return [new St(r,e,`array expected, ${Bn(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return [new St(r,e,"filter array must have at least 1 element")];switch(s=s.concat(di({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),oi(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===oi(e[1])&&s.push(new St(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new St(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=Bn(e[1]),"string"!==i&&s.push(new St(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new St(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{oi(e.id)===o&&(t=e);})),t?t.ref?e.push(new St(n,r.ref,"ref cannot reference another ref layer")):a=oi(t.type):e.push(new St(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&oi(t.type);t?"vector"===s&&"raster"===a?e.push(new St(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new St(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new St(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new St(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new St(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new St(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new St(n,r.source,`source "${r.source}" not found`));}else e.push(new St(n,r,'missing required property "source"'));return e=e.concat(ui({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:yi,layout:t=>ui({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>vi(At({layerType:a},t))}}),paint:t=>ui({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>xi(At({layerType:a},t))}})}})),e}function wi(t){const e=t.value,r=t.key,n=Bn(e);return "string"!==n?[new St(r,e,`string expected, ${n} found`)]:[]}const _i={promoteId:function({key:t,value:e}){if("string"===Bn(e))return wi({key:t,value:e});{const r=[];for(const n in e)r.push(...wi({key:`${t}.${n}`,value:e[n]}));return r}}};function Si(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new St(r,e,'"type" is required')];const a=oi(e.type);let o;switch(a){case"vector":case"raster":return o=ui({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:_i,validateSpec:s}),o;case"raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=Bn(n);if(void 0===n)return o;if("object"!==l)return o.push(new St("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===oi(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new St(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new St(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case"geojson":if(o=ui({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:_i}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],a="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...fi({key:`${r}.${t}.map`,value:i,validateSpec:s,expressionContext:"cluster-map"})),o.push(...fi({key:`${r}.${t}.reduce`,value:a,validateSpec:s,expressionContext:"cluster-reduce"}));}return o;case"video":return ui({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case"image":return ui({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case"canvas":return [new St(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return di({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:s,styleSpec:n})}}function Ai(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=Bn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new St("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new St(a,e[a],`unknown property "${a}"`)]);}return s}function ki(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=Bn(e);if(void 0===e)return [];if("object"!==s)return [new St("sky",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new St(s,e[s],`unknown property "${s}"`)]);return a}function Mi(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=Bn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new St("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new St(a,e[a],`unknown property "${a}"`)]);return s}function Ii(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new St(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new St(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(ui({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return wi({key:n,value:r})}const zi={"*":()=>[],array:ci,boolean:function(t){const e=t.value,r=t.key,n=Bn(e);return "boolean"!==n?[new St(r,e,`boolean expected, ${n} found`)]:[]},number:hi,color:function(t){const e=t.key,r=t.value,n=Bn(r);return "string"!==n?[new St(e,r,`color expected, ${n} found`)]:ye.parse(String(r))?[]:[new St(e,r,`color expected, "${r}" found`)]},constants:ai,enum:di,filter:yi,function:pi,layer:bi,object:ui,source:Si,light:Ai,sky:ki,terrain:Mi,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=Bn(e);if(void 0===e)return [];if("object"!==s)return [new St("projection",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new St(s,e[s],`unknown property "${s}"`)]);return a},projectionDefinition:function(t){const e=t.key;let r=t.value;r=r instanceof String?r.valueOf():r;const n=Bn(r);return "array"!==n||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(r)||function(t){return !!["interpolate","step","literal"].includes(t[0])}(r)?["array","string"].includes(n)?[]:[new St(e,r,`projection expected, invalid type "${n}" found`)]:[new St(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:wi,formatted:function(t){return 0===wi(t).length?[]:fi(t)},resolvedImage:function(t){return 0===wi(t).length?[]:fi(t)},padding:function(t){const e=t.key,r=t.value;if("array"===Bn(r)){if(r.length<1||r.length>4)return [new St(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(ai({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:Pi}))),Ei(r)}function Vi(t){return function(e){return t({...e,validateSpec:Pi})}}function Ei(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function Ti(t){return function(...e){return Ei(t.apply(this,e))}}Bi.source=Ti(Vi(Si)),Bi.sprite=Ti(Vi(Ii)),Bi.glyphs=Ti(Vi(Ci)),Bi.light=Ti(Vi(Ai)),Bi.sky=Ti(Vi(ki)),Bi.terrain=Ti(Vi(Mi)),Bi.layer=Ti(Vi(bi)),Bi.filter=Ti(Vi(yi)),Bi.paintProperty=Ti(Vi(xi)),Bi.layoutProperty=Ti(Vi(vi));const Fi=Bi,$i=Fi.light,Li=Fi.sky,Di=Fi.paintProperty,Oi=Fi.layoutProperty;function Ri(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new ut(new Error(n.message))),r=!0;return r}class ji{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1;}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const s=t[n];i[n]=Ni[r].shallow.indexOf(n)>=0?s:Xi(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(i.$name=r),i}function Ki(t){if(Zi(t))return t;if(Array.isArray(t))return t.map(Ki);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=Gi(t)||"Object";if(!Ni[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Ni[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=Ni[e].shallow.indexOf(r)>=0?i:Ki(i);}return n}class Hi{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function Ji(t){for(const e of t)if(ns(e.charCodeAt(0)))return !0;return !1}function Wi(t){for(const e of t)if(!es(e.charCodeAt(0)))return !1;return !0}function Qi(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const ts=Qi(["Arab","Dupl","Mong","Ougr","Syrc"]);function es(t){return !ts.test(String.fromCodePoint(t))}const rs=Qi(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function ns(t){return !(746!==t&&747!==t&&(t<4352||!(Yi["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Yi["CJK Compatibility"](t)||Yi["CJK Strokes"](t)||!(!Yi["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Yi["Enclosed CJK Letters and Months"](t)||Yi["Ideographic Description Characters"](t)||Yi.Kanbun(t)||Yi.Katakana(t)&&12540!==t||!(!Yi["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Yi["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Yi["Vertical Forms"](t)||Yi["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||rs.test(String.fromCodePoint(t)))))}function is(t){return !(ns(t)||function(t){return !!(Yi["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Yi["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||Yi["Letterlike Symbols"](t)||Yi["Number Forms"](t)||Yi["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||Yi["Control Pictures"](t)&&9251!==t||Yi["Optical Character Recognition"](t)||Yi["Enclosed Alphanumerics"](t)||Yi["Geometric Shapes"](t)||Yi["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Yi["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Yi["CJK Symbols and Punctuation"](t)||Yi.Katakana(t)||Yi["Private Use Area"](t)||Yi["CJK Compatibility Forms"](t)||Yi["Small Form Variants"](t)||Yi["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const ss=Qi(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function as(t){return ss.test(String.fromCodePoint(t))}function os(t,e){return !(!e&&as(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Yi.Khmer(t))}function ls(t){for(const e of t)if(as(e.charCodeAt(0)))return !0;return !1}const us=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{};}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(us.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve();}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,r){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((t=>{this.loadScriptResolve=t;}));r(e);const i=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([n,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class cs{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Hi,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!os(r.charCodeAt(0),e))return !1;return !0}(t,"loaded"===us.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class hs{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Vn(t))return new Zn(t,e);if(jn(t)){const r=Gn(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=ye.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?r=_e.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(r=Ae.parse(t)):r=ve.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class ps{constructor(t){this.property=t,this.value=new hs(t,void 0);}transitioned(t,e){return new ds(this.property,this.value,e,F({},t.transition,this.transition),t.now)}untransitioned(){return new ds(this.property,this.value,null,{},0)}}class fs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return O(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ps(this._values[t].property)),this._values[t].value=new hs(this._values[t].property,null===e?void 0:O(e));}getTransition(t){return O(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ps(this._values[t].property)),this._values[t].transition=O(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new ys(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new ys(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class ds{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(nn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class _s{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new cs(Math.floor(e.zoom-1),e)),t.expression.evaluate(new cs(Math.floor(e.zoom),e)),t.expression.evaluate(new cs(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Ss{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class As{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new hs(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new ps(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}Ui("DataDrivenProperty",bs),Ui("DataConstantProperty",vs),Ui("CrossFadedDataDrivenProperty",ws),Ui("CrossFadedProperty",_s),Ui("ColorRampProperty",Ss);const ks="-transition";class Ms extends ct{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new ms(e.layout)),e.paint)){this._transitionablePaint=new fs(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new xs(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(Oi,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(ks)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(Di,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(ks))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),D(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&Ri(this,t.call(Fi,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:ht,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof gs&&zn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const Is={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class zs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class Ps{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Cs(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=Is[t.type].BYTES_PER_ELEMENT,s=r=Bs(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Bs(r,Math.max(n,e)),alignment:e}}function Bs(t,e){return Math.ceil(t/e)*e}class Vs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Vs.prototype.bytesPerElement=4,Ui("StructArrayLayout2i4",Vs);class Es extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}Es.prototype.bytesPerElement=6,Ui("StructArrayLayout3i6",Es);class Ts extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Ts.prototype.bytesPerElement=8,Ui("StructArrayLayout4i8",Ts);class Fs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Fs.prototype.bytesPerElement=12,Ui("StructArrayLayout2i4i12",Fs);class $s extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}$s.prototype.bytesPerElement=8,Ui("StructArrayLayout2i4ub8",$s);class Ls extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Ls.prototype.bytesPerElement=8,Ui("StructArrayLayout2f8",Ls);class Ds extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}Ds.prototype.bytesPerElement=20,Ui("StructArrayLayout10ui20",Ds);class Os extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}Os.prototype.bytesPerElement=24,Ui("StructArrayLayout4i4ui4i24",Os);class Rs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Rs.prototype.bytesPerElement=12,Ui("StructArrayLayout3f12",Rs);class js extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}js.prototype.bytesPerElement=4,Ui("StructArrayLayout1ul4",js);class Ns extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}Ns.prototype.bytesPerElement=20,Ui("StructArrayLayout6i1ul2ui20",Ns);class Us extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Us.prototype.bytesPerElement=12,Ui("StructArrayLayout2i2i2i12",Us);class qs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}qs.prototype.bytesPerElement=16,Ui("StructArrayLayout2f1f2i16",qs);class Gs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=16*t,l=4*t,u=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=a,t}}Gs.prototype.bytesPerElement=16,Ui("StructArrayLayout2ub2f2i16",Gs);class Zs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Zs.prototype.bytesPerElement=6,Ui("StructArrayLayout3ui6",Zs);class Xs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}Xs.prototype.bytesPerElement=48,Ui("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Xs);class Ks extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=S,this.uint32[C+12]=A,this.float32[C+13]=k,this.float32[C+14]=M,this.uint16[P+30]=I,this.uint16[P+31]=z,t}}Ks.prototype.bytesPerElement=64,Ui("StructArrayLayout8i15ui1ul2f2ui64",Ks);class Hs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Hs.prototype.bytesPerElement=4,Ui("StructArrayLayout1f4",Hs);class Ys extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Ys.prototype.bytesPerElement=12,Ui("StructArrayLayout1ui2f12",Ys);class Js extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}Js.prototype.bytesPerElement=8,Ui("StructArrayLayout1ul2ui8",Js);class Ws extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}Ws.prototype.bytesPerElement=4,Ui("StructArrayLayout2ui4",Ws);class Qs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Qs.prototype.bytesPerElement=2,Ui("StructArrayLayout1ui2",Qs);class ta extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}ta.prototype.bytesPerElement=16,Ui("StructArrayLayout4f16",ta);class ea extends zs{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}ea.prototype.size=20;class ra extends Ns{get(t){return new ea(this,t)}}Ui("CollisionBoxArray",ra);class na extends zs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}na.prototype.size=48;class ia extends Xs{get(t){return new na(this,t)}}Ui("PlacedSymbolArray",ia);class sa extends zs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}sa.prototype.size=64;class aa extends Ks{get(t){return new sa(this,t)}}Ui("SymbolInstanceArray",aa);class oa extends Hs{getoffsetX(t){return this.float32[1*t+0]}}Ui("GlyphOffsetArray",oa);class la extends Es{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Ui("SymbolLineVertexArray",la);class ua extends zs{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}ua.prototype.size=12;class ca extends Ys{get(t){return new ua(this,t)}}Ui("TextAnchorOffsetArray",ca);class ha extends zs{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}ha.prototype.size=8;class pa extends Js{get(t){return new ha(this,t)}}Ui("FeatureIndexArray",pa);class fa extends Vs{}class da extends Vs{}class ya extends Vs{}class ma extends Fs{}class ga extends $s{}class xa extends Ls{}class va extends Ds{}class ba extends Os{}class wa extends Rs{}class _a extends js{}class Sa extends Us{}class Aa extends Gs{}class ka extends Zs{}class Ma extends Ws{}const Ia=Cs([{name:"a_pos",components:2,type:"Int16"}],4),{members:za}=Ia;class Pa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t;}prepareSegment(t,e,r,n){const i=this.segments[this.segments.length-1];return t>Pa.MAX_VERTEX_ARRAY_LENGTH&&j(`Max vertices per segment is ${Pa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Pa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+t>Pa.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n?this.createNewSegment(e,r,n):i}createNewSegment(t,e,r){const n={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==r&&(n.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(t,e,r){return this.prepareSegment(0,t,e,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0;}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new Pa([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ca(t,e){return 256*(t=E(Math.floor(t),0,255))+E(Math.floor(e),0,255)}Pa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ui("SegmentVector",Pa);const Ba=Cs([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Va,Ea,Ta,Fa={exports:{}},$a={exports:{}},La={exports:{}},Da=function(){if(Ta)return Fa.exports;Ta=1;var t=(Va||(Va=1,$a.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),$a.exports),e=(Ea||(Ea=1,La.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),La.exports);return Fa.exports=t,Fa.exports.murmur3=t,Fa.exports.murmur2=e,Fa.exports}(),Oa=r(Da);class Ra{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(ja(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=ja(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Na(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new Ra;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function ja(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Oa(String(t))}function Na(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;Ua(t,s,a),Ua(e,3*s,3*a),Ua(e,3*s+1,3*a+1),Ua(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new Xa(t,e):new Ga(t,e)}}class Ja{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new Za(t,e):new Ga(t,e)}}class Wa{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new cs(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=Ha(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new cs(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new cs(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Ha(r),s=Ha(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Wa||r instanceof Qa)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new eo(n,e,r);this.needsUpload=!1,this._featureMap=new Ra,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function no(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function io(t,e,r){const n={color:{source:Ls,composite:ta},number:{source:Hs,composite:Ls}},i=function(t){return {"line-pattern":{source:va,composite:va},"fill-pattern":{source:va,composite:va},"fill-extrusion-pattern":{source:va,composite:va}}[t]}(t);return i&&i[r]||n[e][r]}Ui("ConstantBinder",Ya),Ui("CrossFadedConstantBinder",Ja),Ui("SourceExpressionBinder",Wa),Ui("CrossFadedCompositeBinder",to),Ui("CompositeExpressionBinder",Qa),Ui("ProgramConfiguration",eo,{omit:["_buffers"]}),Ui("ProgramConfigurationSet",ro);const so=Math.pow(2,14)-1,ao=-so-1;function oo(t){const e=M/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&j("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function lo(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?oo(t):[]}}const uo=-32768;function co(t,e,r,n,i){t.emplaceBack(uo+8*e+n,uo+8*r+i);}class ho{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new da,this.indexArray=new ka,this.segments=new Pa,this.programConfigurations=new ro(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1,o="heatmap"===n.type;if("circle"===n.type){const t=n;s=t.layout.get("circle-sort-key"),a=!s.isConstant(),o=o||"map"===t.paint.get("circle-pitch-alignment");}const l=o?e.subdivisionGranularity.circle:1;for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=lo(e,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:oo(e),patterns:{},sortKey:c};i.push(h);}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r,l),e.featureIndex.insert(o,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,za),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const a=s.length;for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=M||n<0||n>=M)continue;const i=this.segments.prepareSegment(a*a,this.layoutVertexArray,this.indexArray,t.sortKey),o=i.vertexLength;for(let t=0;t1){if(go(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function wo(t,e){let r,n,i,s=!1;for(let a=0;ae.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function _o(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function So(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=N(t,e,r[0]);return s!==N(t,e,r[1])||s!==N(t,e,r[2])||s!==N(t,e,r[3])}function Ao(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function ko(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Mo(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=l.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let e=0;eBo(t,e)))}(o,a),h=u?l*s:l;for(const t of n)for(const e of t){const t=u?e:Bo(e,a);let r=h;const n=_([],[e.x,e.y,0,1],a);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n[3]/i.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=i.cameraToCenterDistance/n[3]),fo(c,t,r))return !0}return !1}}function Bo(t,e){const r=_([],[t.x,t.y,0,1],e);return new l(r[0]/r[3],r[1]/r[3])}class Vo extends ho{}let Eo;Ui("HeatmapBucket",Vo,{omit:["layers"]});var To={get paint(){return Eo=Eo||new As({"heatmap-radius":new bs(ht.paint_heatmap["heatmap-radius"]),"heatmap-weight":new bs(ht.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new vs(ht.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ss(ht.paint_heatmap["heatmap-color"]),"heatmap-opacity":new vs(ht.paint_heatmap["heatmap-opacity"])})}};function Fo(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function $o(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Fo({},{width:e,height:r},n);Lo(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function Lo(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a);};if(t.clips)for(let e=0,i=0;e0)for(let i=e;i=e;i-=n)s=xl(i/n|0,t[i],t[i+1],s);return s&&pl(s,s.next)&&(vl(s),s=s.next),s}function Jo(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!pl(n,n.next)&&0!==hl(n.prev,n,n.next))n=n.next;else {if(vl(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function Wo(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=al(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?tl(t,n,i,s):Qo(t))e.push(l.i,t.i,u.i),vl(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?Wo(t=el(Jo(t),e),e,r,n,i,s,2):2===a&&rl(t,e,r,n,i,s):Wo(Jo(t),e,r,n,i,s,1);break}}}function Qo(t){const e=t.prev,r=t,n=t.next;if(hl(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),p=Math.max(i,s,a),f=Math.max(o,l,u);let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&ul(i,o,s,l,a,u,d.x,d.y)&&hl(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function tl(t,e,r,n){const i=t.prev,s=t,a=t.next;if(hl(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=Math.min(o,l,u),d=Math.min(c,h,p),y=Math.max(o,l,u),m=Math.max(c,h,p),g=al(f,d,e,r,n),x=al(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&ul(o,c,l,h,u,p,v.x,v.y)&&hl(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&ul(o,c,l,h,u,p,b.x,b.y)&&hl(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&ul(o,c,l,h,u,p,v.x,v.y)&&hl(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&ul(o,c,l,h,u,p,b.x,b.y)&&hl(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function el(t,e){let r=t;do{const n=r.prev,i=r.next.next;!pl(n,i)&&fl(n,r,r.next,i)&&ml(n,i)&&ml(i,n)&&(e.push(n.i,r.i,i.i),vl(r),vl(r.next),r=t=i),r=r.next;}while(r!==t);return Jo(r)}function rl(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&cl(a,t)){let o=gl(a,t);return a=Jo(a,a.next),o=Jo(o,o.next),Wo(a,e,r,n,i,s,0),void Wo(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function nl(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function il(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;if(pl(t,r))return r;do{if(pl(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&ll(is.x||r.x===s.x&&sl(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=gl(r,t);return Jo(n,n.next),Jo(r,r.next)}function sl(t,e){return hl(t.prev,t,e.prev)<0&&hl(e.next,t,t.next)<0}function al(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ol(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function ul(t,e,r,n,i,s,a,o){return !(t===a&&e===o)&&ll(t,e,r,n,i,s,a,o)}function cl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&fl(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(ml(t,e)&&ml(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(hl(t.prev,t,e.prev)||hl(t,e.prev,e))||pl(t,e)&&hl(t.prev,t,t.next)>0&&hl(e.prev,e,e.next)>0)}function hl(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function pl(t,e){return t.x===e.x&&t.y===e.y}function fl(t,e,r,n){const i=yl(hl(t,e,r)),s=yl(hl(t,e,n)),a=yl(hl(r,n,t)),o=yl(hl(r,n,e));return i!==s&&a!==o||!(0!==i||!dl(t,r,e))||!(0!==s||!dl(t,n,e))||!(0!==a||!dl(r,t,n))||!(0!==o||!dl(r,e,n))}function dl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function yl(t){return t>0?1:t<0?-1:0}function ml(t,e){return hl(t.prev,t,t.next)<0?hl(t,e,t.next)>=0&&hl(t,t.prev,e)>=0:hl(t,e,t.prev)<0||hl(t,t.next,e)<0}function gl(t,e){const r=bl(t.i,t.x,t.y),n=bl(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function xl(t,e,r,n){const i=bl(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function vl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function bl(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class wl{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e;}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const r=0|Math.round(t),n=0|Math.round(e),i=this._getKey(r,n);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(r,n),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const r=[];for(let n=0;n0?(r.push(i),r.push(a),r.push(s)):(r.push(i),r.push(s),r.push(a));}return r}(this._vertexBuffer,t);const e=[],r=t.length;for(let n=0;n=1||v<=0)||y&&(oi)){u>=n&&u<=i&&s.push(r[(t+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(a+p*x,o+f*x));const b=a+p*Math.max(x,0),w=a+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,a,o,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(a+p*v,o+f*v)),(y||u>=n&&u<=i)&&s.push(r[(t+1)%3]),!y&&(u<=n||u>=i)&&this._generateInterEdgeVertices(s,a,o,l,u,c,h,w,n,i);}return s}_generateIntraEdgeVertices(t,e,r,n,i,s,a){const o=n-e,l=i-r,u=0===l,c=u?Math.min(e,n):Math.min(s,a),h=u?Math.max(e,n):Math.max(s,a),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?e=p;n--){const i=n*this._granularityCellSize;t.push(this._vertexToIndex(i,r+l*(i-e)/o));}}_generateInterEdgeVertices(t,e,r,n,i,s,a,o,l,u){const c=i-r,h=s-n,p=a-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=n+h*y;let x=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,b=o=1||m<=0){const t=r-a,n=s+(e-s)*Math.min((l-a)/t,(u-a)/t);x=Math.floor(Math.min(n,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,o)/this._granularityCellSize)-1,b=o0?u:l;if(b)for(let e=x;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,_));else for(let e=v;e>=x;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,_));}_generateOutline(t){const e=[];for(const r of t){const t=Il(r,this._granularity,!0),n=this._pointArrayToIndices(t),i=[];for(let t=1;ti!=(s===Sl)?(t.push(e),t.push(r),t.push(this._vertexToIndex(n,s)),t.push(r),t.push(this._vertexToIndex(i,s)),t.push(this._vertexToIndex(n,s))):(t.push(r),t.push(e),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(i,s)),t.push(r),t.push(this._vertexToIndex(n,s)));}_fillPoles(t,e,r){const n=this._vertexBuffer,i=M,s=t.length;for(let a=2;a80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return Wo(s,a,r,o,l,u,0),a}(r,n),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e);}catch(t){console.error(t);}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(t,e){const r=[];for(let n=0;n0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,e=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(x-t),n=Math.abs(v-e),i=Math.abs(x-c),s=Math.abs(v-h),u=p?r/m:Number.POSITIVE_INFINITY,b=f?n/g:Number.POSITIVE_INFINITY;if((i<=r||!p)&&(s<=n||!f))break;if(u=0?a-1:s-1,i=(o+1)%s,l=t[2*e[n]],u=t[2*e[i]],c=t[2*e[a]],h=t[2*e[a]+1],p=t[2*e[o]+1];let f=!1;if(lu)f=!1;else {const r=p-h,s=-(t[2*e[o]]-c),a=h((u-c)*r+(t[2*e[i]+1]-h)*s)*a&&(f=!0);}if(f){const t=e[n],i=e[a],l=e[o];t!==i&&t!==l&&i!==l&&r.push(l,i,t),a--,a<0&&(a=s-1);}else {const t=e[i],n=e[a],l=e[o];t!==n&&t!==l&&n!==l&&r.push(l,n,t),o++,o>=s&&(o=0);}if(n===i)break}}function Pl(t,e,r,n,i,s,a,o,l){const u=i.length/2,c=a&&o&&l;if(uPa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,g=!0,c=0);const x=Cl(a,n,s,o,p,y,u),v=Cl(a,n,s,o,f,m,u),b=Cl(a,n,s,o,d,g,u);r.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++;}}(e,r,n,i,s,t),c&&function(t,e,r,n,i,s){const a=[];for(let t=0;tPa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,d=!0,y=!0,c=0);const m=Cl(a,n,s,o,i,d,u),g=Cl(a,n,s,o,h,y,u);r.emplaceBack(c+m-l,c+g-l),u.primitiveLength++;}}}(a,r,o,i,l,t),e.forceNewSegmentOnNextPrepare(),null==a||a.forceNewSegmentOnNextPrepare();}function Cl(t,e,r,n,i,s,a){if(s){const s=n.count;return r(e[2*i],e[2*i+1]),t[i]=n.count,n.count++,a.vertexLength++,s}return t[i]}class Bl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ya,this.indexArray=new ka,this.indexArray2=new Ma,this.programConfigurations=new ro(t.layers,t.zoom),this.segments=new Pa,this.segments2=new Pa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Ko("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=lo(a,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:oo(a),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Ho("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Xo),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s){for(const t of Le(e,500)){const e=Ml(t,n,s.fill.getGranularityForZoomLevel(n.z)),r=this.layoutVertexArray;Pl(((t,e)=>{r.emplaceBack(t,e);}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}}let Vl,El;Ui("FillBucket",Bl,{omit:["layers","patternFeatures"]});var Tl={get paint(){return El=El||new As({"fill-antialias":new vs(ht.paint_fill["fill-antialias"]),"fill-opacity":new bs(ht.paint_fill["fill-opacity"]),"fill-color":new bs(ht.paint_fill["fill-color"]),"fill-outline-color":new bs(ht.paint_fill["fill-outline-color"]),"fill-translate":new vs(ht.paint_fill["fill-translate"]),"fill-translate-anchor":new vs(ht.paint_fill["fill-translate-anchor"]),"fill-pattern":new ws(ht.paint_fill["fill-pattern"])})},get layout(){return Vl=Vl||new As({"fill-sort-key":new bs(ht.layout_fill["fill-sort-key"])})}};class Fl extends Ms{constructor(t){super(t,Tl);}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Bl(t)}queryRadius(){return ko(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:r,pixelsToTileUnits:n}){return yo(Mo(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,n),e)}isTileClipped(){return !0}}const $l=Cs([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ll=Cs([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Dl}=$l;var Ol,Rl,jl,Nl,Ul,ql,Gl,Zl={};function Xl(){if(Rl)return Ol;Rl=1;var t=s();function e(t,e,n,i,s){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=s,t.readFields(r,this,e);}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){for(var r=t.readVarint()+t.pos;t.pos>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(a,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var s,a,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return jl=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},jl}function Hl(){return Gl||(Gl=1,Zl.VectorTile=function(){if(ql)return Ul;ql=1;var t=Kl();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return Ul=function(t,r){this.layers=t.readFields(e,{},r);},Ul}(),Zl.VectorTileFeature=Xl(),Zl.VectorTileLayer=Kl()),Zl}var Yl=r(Hl());const Jl=Yl.VectorTileFeature.types,Wl=Math.pow(2,13);function Ql(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*Wl)+a,i*Wl*2,s*Wl*2,Math.round(o));}class tu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ma,this.centroidVertexArray=new fa,this.indexArray=new ka,this.programConfigurations=new ro(t.layers,t.zoom),this.segments=new Pa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=Ko("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=lo(n,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:oo(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Ho("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{},e.subdivisionGranularity),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0);}}addFeatures(t,e,r){for(const n of this.features){const{geometry:i}=n;this.addFeature(n,i,n.index,e,r,t.subdivisionGranularity);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Dl),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Ll.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i,s){for(const r of Le(e,500)){const e={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(e,n,t,r,s);const a=this.layoutVertexArray.length-i,o=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t{Ql(u,t,e,0,0,1,1,0);}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles);}_generateSideFaces(t,e){let r=0;for(let n=1;nPa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const a=i.sub(s)._perp()._unit(),o=s.dist(i);r+o>32768&&(r=0),Ql(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,0,r),Ql(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,1,r),r+=o,Ql(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,0,r),Ql(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,1,r);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2;}}}function eu(t,e){for(let r=0;rM)||t.y===e.y&&(t.y<0||t.y>M)}function nu(t){return t.every((t=>t.x<0))||t.every((t=>t.x>M))||t.every((t=>t.y<0))||t.every((t=>t.y>M))}let iu;Ui("FillExtrusionBucket",tu,{omit:["layers","features"]});var su={get paint(){return iu=iu||new As({"fill-extrusion-opacity":new vs(ht["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new bs(ht["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new vs(ht["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new vs(ht["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ws(ht["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new bs(ht["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new bs(ht["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new vs(ht["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class au extends Ms{constructor(t){super(t,su);}createBucket(t){return new tu(t)}queryRadius(){return ko(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s,pixelPosMatrix:a}){const o=Mo(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-i.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(e,r),c=this.paint.get("fill-extrusion-base").evaluate(e,r),h=function(t,e,r){const n=[];for(const r of t){const t=[r.x,r.y,0,1];_(t,t,e),n.push(new l(t[0]/t[3],t[1]/t[3]));}return n}(o,a),p=function(t,e,r,n){const i=[],s=[],a=n[8]*e,o=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,s=i.y,y=n[0]*e+n[4]*s+n[12],m=n[1]*e+n[5]*s+n[13],g=n[2]*e+n[6]*s+n[14],x=n[3]*e+n[7]*s+n[15],v=g+u,b=x+c,w=y+h,_=m+p,S=g+f,A=x+d,k=new l((y+a)/b,(m+o)/b);k.z=v/b,t.push(k);const M=new l(w/A,_/A);M.z=S/A,r.push(M);}i.push(t),s.push(r);}return [i,s]}(n,c,u,a);return function(t,e,r){let n=1/0;yo(r,e)&&(n=lu(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new ga,this.layoutVertexArray2=new xa,this.indexArray=new ka,this.programConfigurations=new ro(t.layers,t.zoom),this.segments=new Pa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Ko("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=lo(e,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:oo(e),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Ho("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,pu)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,cu),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),l=a.get("line-cap"),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,s,a,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Il(t,a?o.line.getGranularityForZoomLevel(a.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c0;if(w&&e>c){const t=f.dist(d);if(t>2*h){const e=f.sub(f.sub(d)._mult(h/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,m,0,0,p),d=e;}}const S=d&&y;let A=S?r:l?"butt":n;if(S&&"round"===A&&(vi&&(A="bevel"),"bevel"===A&&(v>2&&(A="flipbevel"),v100)a=g.mult(-1);else {const t=v*m.add(g).mag()/m.sub(g).mag();a._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(f,a,0,0,p),this.addCurrentVertex(f,a.mult(-1),0,0,p);}else if("bevel"===A||"fakeround"===A){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(d&&this.addCurrentVertex(f,m,e,r,p),"fakeround"===A){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*h){const e=f.add(y.sub(f)._mult(h/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,p),f=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>yu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s));}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(yu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let gu,xu;Ui("LineBucket",mu,{omit:["layers","patternFeatures"]});var vu={get paint(){return xu=xu||new As({"line-opacity":new bs(ht.paint_line["line-opacity"]),"line-color":new bs(ht.paint_line["line-color"]),"line-translate":new vs(ht.paint_line["line-translate"]),"line-translate-anchor":new vs(ht.paint_line["line-translate-anchor"]),"line-width":new bs(ht.paint_line["line-width"]),"line-gap-width":new bs(ht.paint_line["line-gap-width"]),"line-offset":new bs(ht.paint_line["line-offset"]),"line-blur":new bs(ht.paint_line["line-blur"]),"line-dasharray":new _s(ht.paint_line["line-dasharray"]),"line-pattern":new ws(ht.paint_line["line-pattern"]),"line-gradient":new Ss(ht.paint_line["line-gradient"])})},get layout(){return gu=gu||new As({"line-cap":new vs(ht.layout_line["line-cap"]),"line-join":new bs(ht.layout_line["line-join"]),"line-miter-limit":new vs(ht.layout_line["line-miter-limit"]),"line-round-limit":new vs(ht.layout_line["line-round-limit"]),"line-sort-key":new bs(ht.layout_line["line-sort-key"])})}};class bu extends bs{possiblyEvaluate(t,e){return e=new cs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=F({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let wu;class _u extends Ms{constructor(t){super(t,vu),this.gradientVersion=0,wu||(wu=new bu(vu.paint.properties["line-width"].specification),wu.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Qe,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=wu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new mu(t)}queryRadius(t){const e=t,r=Su(Ao("line-width",this,e),Ao("line-gap-width",this,e)),n=Ao("line-offset",this,e);return r/2+Math.abs(n)+ko(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s}){const a=Mo(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-i.bearingInRadians,s),o=s/2*Su(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Au=Cs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ku=Cs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Cs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Mu=Cs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Cs([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Iu=Cs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),zu=Cs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Pu(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),us.applyArabicShaping&&(t=us.applyArabicShaping(t)),t}(t.text,e,r);})),t}Cs([{name:"triangle",components:3,type:"Uint16"}]),Cs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Cs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Cs([{type:"Float32",name:"offsetX"}]),Cs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Cs([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Cu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Bu,Vu,Eu,Tu=24,Fu={};function $u(){return Bu||(Bu=1,Fu.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},Fu.write=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;}),Fu}function Lu(){if(Eu)return Vu;Eu=1,Vu=e;var t=$u();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function v(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return a(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=s(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},Vu}var Du=r(Lu());const Ou=3;function Ru(t,e,r){1===t&&r.readMessage(ju,e);}function ju(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(Nu,{});e.push({id:t,bitmap:new Do({width:i+2*Ou,height:s+2*Ou},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}}function Nu(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const Uu=Ou;function qu(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&Qu[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new Ju;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yu.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Wu(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=Ju.fromFeature(e,s);let g;p===t.ai.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=us;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),oc(m,c,a,r,i,d));for(const e of t){const t=new Ju;t.text=e,t.sections=m.sections;for(let r=0;r0&&n>_&&(_=n);}else {const t=n[y.fontStack],e=t&&t[g];if(e&&e.rect)S=e.rect,b=e.metrics;else {const t=r[y.fontStack],e=t&&t[g];if(!e)continue;b=e.metrics;}x=(s-y.scale)*Tu;}M?(e.verticalizable=!0,w.push({glyph:g,imageName:A,x:f,y:d+x,vertical:M,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:b,rect:S}),f+=k*y.scale+c):(w.push({glyph:g,imageName:A,x:f,y:d+x,vertical:M,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:b,rect:S}),f+=b.advance*y.scale+c);}0!==w.length&&(y=Math.max(f-c,y),uc(w,0,w.length-1,g,_)),f=0;const S=a*s+_;b.lineOffset=Math.max(_,l),d+=S,m=Math.max(S,m),++x;}var v;const b=d-Hu,{horizontalAlign:w,verticalAlign:_}=lc(o);((function(t,e,r,n,i,s,a,o,l){const u=(e-r)*i;let c=0;c=s!==a?-o*n-Hu:(-n*l+.5)*a;for(const e of t)for(const t of e.positionedGlyphs)t.x+=u,t.y+=c;}))(e.positionedLines,g,w,_,y,m,a,b,s.length),e.top+=-_*b,e.bottom=e.top+b,e.left+=-w*y,e.right=e.left+y;}(w,r,n,i,g,o,l,u,p,c,f,y),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return !1;return !0}(b)&&w}const Qu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},tc={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},ec={40:!0};function rc(t,e,r,n,i,s){if(e.imageName){const t=n[e.imageName];return t?t.displaySize[0]*e.scale*Tu/s+i:0}{const n=r[e.fontStack],s=n&&n[t];return s?s.metrics.advance*e.scale+i:0}}function nc(t,e,r,n){const i=Math.pow(t-e,2);return n?t=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/a,a=t;}return {x1:n,y1:i,x2:n+s,y2:i+a}}function pc(t,e,r,n,i,s){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-a.displaySize[1])/2,p=c+a.displaySize[1]),{image:a,top:c,right:h,bottom:p,left:f,collisionPadding:o}}const fc=255,dc=128,yc=fc*dc;function mc(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new cs(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=mc(this.zoom,r["text-size"]),this.iconSizeData=mc(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap="never"!==gc(n,"text-overlap","text-allow-overlap")||"never"!==gc(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ai[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Sc(new ro(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Sc(new ro(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new oa,this.lineVertexArray=new la,this.symbolInstances=new aa,this.textAnchorOffsets=new ca;}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new cs(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=lo(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=oo(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=xe.factory(t),r=this.hasRTLText=this.hasRTLText||_c(e);(!r||"unavailable"===us.getRTLTextPluginStatus()||r&&us.isParsed())&&(x=Pu(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof Se?t:Se.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:xc[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=a.evaluate(g,{},n).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ai.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=Ji(x.toString()),i=t.fontStack||e,s=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,s,r,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Mc,Ic;Ui("SymbolBucket",kc,{omit:["layers","collisionBoxArray","features","compareText"]}),kc.MAX_GLYPHS=65535,kc.addDynamicAttributes=wc;var zc={get paint(){return Ic=Ic||new As({"icon-opacity":new bs(ht.paint_symbol["icon-opacity"]),"icon-color":new bs(ht.paint_symbol["icon-color"]),"icon-halo-color":new bs(ht.paint_symbol["icon-halo-color"]),"icon-halo-width":new bs(ht.paint_symbol["icon-halo-width"]),"icon-halo-blur":new bs(ht.paint_symbol["icon-halo-blur"]),"icon-translate":new vs(ht.paint_symbol["icon-translate"]),"icon-translate-anchor":new vs(ht.paint_symbol["icon-translate-anchor"]),"text-opacity":new bs(ht.paint_symbol["text-opacity"]),"text-color":new bs(ht.paint_symbol["text-color"],{runtimeType:Bt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new bs(ht.paint_symbol["text-halo-color"]),"text-halo-width":new bs(ht.paint_symbol["text-halo-width"]),"text-halo-blur":new bs(ht.paint_symbol["text-halo-blur"]),"text-translate":new vs(ht.paint_symbol["text-translate"]),"text-translate-anchor":new vs(ht.paint_symbol["text-translate-anchor"])})},get layout(){return Mc=Mc||new As({"symbol-placement":new vs(ht.layout_symbol["symbol-placement"]),"symbol-spacing":new vs(ht.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new vs(ht.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new bs(ht.layout_symbol["symbol-sort-key"]),"symbol-z-order":new vs(ht.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new vs(ht.layout_symbol["icon-allow-overlap"]),"icon-overlap":new vs(ht.layout_symbol["icon-overlap"]),"icon-ignore-placement":new vs(ht.layout_symbol["icon-ignore-placement"]),"icon-optional":new vs(ht.layout_symbol["icon-optional"]),"icon-rotation-alignment":new vs(ht.layout_symbol["icon-rotation-alignment"]),"icon-size":new bs(ht.layout_symbol["icon-size"]),"icon-text-fit":new vs(ht.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new vs(ht.layout_symbol["icon-text-fit-padding"]),"icon-image":new bs(ht.layout_symbol["icon-image"]),"icon-rotate":new bs(ht.layout_symbol["icon-rotate"]),"icon-padding":new bs(ht.layout_symbol["icon-padding"]),"icon-keep-upright":new vs(ht.layout_symbol["icon-keep-upright"]),"icon-offset":new bs(ht.layout_symbol["icon-offset"]),"icon-anchor":new bs(ht.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new vs(ht.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new vs(ht.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new vs(ht.layout_symbol["text-rotation-alignment"]),"text-field":new bs(ht.layout_symbol["text-field"]),"text-font":new bs(ht.layout_symbol["text-font"]),"text-size":new bs(ht.layout_symbol["text-size"]),"text-max-width":new bs(ht.layout_symbol["text-max-width"]),"text-line-height":new vs(ht.layout_symbol["text-line-height"]),"text-letter-spacing":new bs(ht.layout_symbol["text-letter-spacing"]),"text-justify":new bs(ht.layout_symbol["text-justify"]),"text-radial-offset":new bs(ht.layout_symbol["text-radial-offset"]),"text-variable-anchor":new vs(ht.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new bs(ht.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new bs(ht.layout_symbol["text-anchor"]),"text-max-angle":new vs(ht.layout_symbol["text-max-angle"]),"text-writing-mode":new vs(ht.layout_symbol["text-writing-mode"]),"text-rotate":new bs(ht.layout_symbol["text-rotate"]),"text-padding":new vs(ht.layout_symbol["text-padding"]),"text-keep-upright":new vs(ht.layout_symbol["text-keep-upright"]),"text-transform":new bs(ht.layout_symbol["text-transform"]),"text-offset":new bs(ht.layout_symbol["text-offset"]),"text-allow-overlap":new vs(ht.layout_symbol["text-allow-overlap"]),"text-overlap":new vs(ht.layout_symbol["text-overlap"]),"text-ignore-placement":new vs(ht.layout_symbol["text-ignore-placement"]),"text-optional":new vs(ht.layout_symbol["text-optional"])})}};class Pc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:It,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Ui("FormatSectionOverride",Pc,{omit:["defaultValue"]});class Cc extends Ms{constructor(t){super(t,zc);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||jn(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new kc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of zc.paint.overridableProperties){if(!Cc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Pc(e),n=new Rn(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Un("source",n):new qn("composite",n,e.value.zoomStops),this.paint._values[t]=new gs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&Cc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=zc.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof xe)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof Pe&&Ie(e.value)===$t?s(e.value.sections):e instanceof br?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Bc;var Vc={get paint(){return Bc=Bc||new As({"background-color":new vs(ht.paint_background["background-color"]),"background-pattern":new _s(ht.paint_background["background-pattern"]),"background-opacity":new vs(ht.paint_background["background-opacity"])})}};class Ec extends Ms{constructor(t){super(t,Vc);}}let Tc;var Fc={get paint(){return Tc=Tc||new As({"raster-opacity":new vs(ht.paint_raster["raster-opacity"]),"raster-hue-rotate":new vs(ht.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new vs(ht.paint_raster["raster-brightness-min"]),"raster-brightness-max":new vs(ht.paint_raster["raster-brightness-max"]),"raster-saturation":new vs(ht.paint_raster["raster-saturation"]),"raster-contrast":new vs(ht.paint_raster["raster-contrast"]),"raster-resampling":new vs(ht.paint_raster["raster-resampling"]),"raster-fade-duration":new vs(ht.paint_raster["raster-fade-duration"])})}};class $c extends Ms{constructor(t){super(t,Fc);}}class Lc extends Ms{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Dc{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle();}),0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const Oc=6371008.8;class Rc{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Rc(T(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Oc*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof Rc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Rc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Rc(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const jc=2*Math.PI*Oc;function Nc(t){return jc*Math.cos(t*Math.PI/180)}function Uc(t){return (180+t)/360}function qc(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Gc(t,e){return t/Nc(e)}function Zc(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Xc(t,e){return t*Nc(Zc(e))}class Kc{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=Rc.convert(t);return new Kc(Uc(r.lng),qc(r.lat),Gc(e,r.lat))}toLngLat(){return new Rc(360*this.x-180,Zc(this.y))}toAltitude(){return Xc(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/jc*(t=Zc(this.y),1/Math.cos(t*Math.PI/180));var t;}}function Hc(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Yc{constructor(t,e,r){if(!function(t,e,r){return !(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=Qc(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=Hc(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=Hc(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*M,(t.y*e-this.y)*M)}toString(){return `${this.z}/${this.x}/${this.y}`}}class Jc{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Qc(t,e.z,e.z,e.x,e.y);}}class Wc{constructor(t,e,r,n,i){if(this.terrainRttPosMatrix32f=null,t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Yc(r,+n,+i),this.key=Qc(e,t,r,n,i);}clone(){return new Wc(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new Wc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Wc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?Qc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Qc(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new Wc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new Wc(e,this.wrap,e,r,n),new Wc(e,this.wrap,e,r+1,n),new Wc(e,this.wrap,e,r,n+1),new Wc(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new Oo({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class rh{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class nh{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new ji(M,16,0),this.grid3D=new ji(M,16,0),this.featureIndexArray=new pa,this.promoteId=e;}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Yl.VectorTile(new Du(this.rawTileData)).layers,this.sourceLayerCoder=new eh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params,s=M/t.tileSize/t.scale,a=Yn(i.filter),o=t.queryGeometry,u=t.queryPadding*s,c=sh(o),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=sh(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new l(e,r),new l(e,i),new l(n,i),new l(n,r)];if(t.length>2)for(const e of s)if(_o(t,e))return !0;for(let e=0;e(p||(p=oo(e)),r.queryIntersectsFeature({queryGeometry:o,feature:e,featureState:n,geometry:p,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix}))));}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!h.some((t=>s.has(t))))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=lo(f,!0);if(!i.filter(new cs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new cs(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const a=e instanceof xs?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function sh(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {minX:e,minY:r,maxX:n,maxY:i}}function ah(t,e){return e-t}function oh(t,e,r,n,i){const s=[];for(let a=0;a=n&&c.x>=n||(a.x>=n?a=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=n&&(c=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=i&&c.y>=i||(a.y>=i?a=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y>=i&&(c=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),u&&a.equals(u[u.length-1])||(u=[a],s.push(u)),u.push(c)))));}}return s}Ui("FeatureIndex",nh,{omit:["rawTileData","sourceLayerCoder"]});class lh extends l{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new lh(this.x,this.y,this.angle,this.segment)}}function uh(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function ch(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=or.number(n.x,i.x,c),p=or.number(n.y,i.y,c),f=new lh(h,p,i.angleTo(n),r);return f._round(),!a||uh(t,f,o,a,e)?f:void 0}l+=s;}}function dh(t,e,r,n,i,s,a,o,l){const u=hh(n,s,a),c=ph(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new lh(g,x,y,e);r._round(),n&&!uh(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=yh(t,h/2,r,n,i,s,a,!0,l)),f}Ui("Anchor",lh);const mh=Gu;function gh(t,e,r,n){const i=[],s=t.image,a=s.pixelRatio,o=s.paddedRect.w-2*mh,u=s.paddedRect.h-2*mh;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=s.stretchX||[[0,o]],p=s.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=o-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,S=m,A=0,k=g;if(s.content&&n){const e=s.content,r=e[2]-e[0],n=e[3]-e[1];(s.textFitWidth||s.textFitHeight)&&(c=hc(t)),x=xh(h,0,e[0]),b=xh(p,0,e[1]),v=xh(h,e[0],e[2]),w=xh(p,e[1],e[3]),_=e[0]-x,A=e[1]-b,S=r-v,k=n-w;}const M=c.x1,I=c.y1,z=c.x2-M,P=c.y2-I,C=(t,n,i,o)=>{const u=bh(t.stretch-x,v,z,M),c=wh(t.fixed-_,S,t.stretch,d),h=bh(n.stretch-b,w,P,I),p=wh(n.fixed-A,k,n.stretch,y),f=bh(i.stretch-x,v,z,M),m=wh(i.fixed-_,S,i.stretch,d),g=bh(o.stretch-b,w,P,I),C=wh(o.fixed-A,k,o.stretch,y),B=new l(u,h),V=new l(f,h),E=new l(f,g),T=new l(u,g),F=new l(c/a,p/a),$=new l(m/a,C/a),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),r=[e,-t,t,e];B._matMult(r),V._matMult(r),T._matMult(r),E._matMult(r);}const D=t.stretch+t.fixed,O=n.stretch+n.fixed;return {tl:B,tr:V,bl:T,br:E,tex:{x:s.paddedRect.x+mh+D,y:s.paddedRect.y+mh+O,w:i.stretch+i.fixed-D,h:o.stretch+o.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:$,minFontScaleX:S/a/z,minFontScaleY:k/a/P,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=vh(h,m,d),e=vh(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {const u=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?hc(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};u.y1=u.y1*a-o[0],u.y2=u.y2*a+o[2],u.x1=u.x1*a-o[3],u.x2=u.x2*a+o[1];const p=s.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const t=new l(u.x1,u.y1),e=new l(u.x2,u.y1),r=new l(u.x1,u.y2),n=new l(u.x2,u.y2),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,i);}this.boxEndIndex=t.length;}}class Sh{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}function Ah(t,e=1,r=!1){let n=1/0,i=1/0,s=-1/0,a=-1/0;const o=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const u=Math.min(s-n,a-i);let c=u/2;const h=new Sh([],kh);if(0===u)return new l(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Mh(n.p.x-c,n.p.y-c,c,t)),h.push(new Mh(n.p.x+c,n.p.y-c,c,t)),h.push(new Mh(n.p.x-c,n.p.y+c,c,t)),h.push(new Mh(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function kh(t,e){return e.max-t.max}function Mh(t,e,r,n){this.p=new l(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,bo(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var Ih;t.av=void 0,(Ih=t.av||(t.av={}))[Ih.center=1]="center",Ih[Ih.left=2]="left",Ih[Ih.right=3]="right",Ih[Ih.top=4]="top",Ih[Ih.bottom=5]="bottom",Ih[Ih["top-left"]=6]="top-left",Ih[Ih["top-right"]=7]="top-right",Ih[Ih["bottom-left"]=8]="bottom-left",Ih[Ih["bottom-right"]=9]="bottom-right";const zh=7,Ph=Number.POSITIVE_INFINITY;function Ch(t,e){return e[1]!==Ph?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-zh;break;case"bottom-right":case"bottom-left":case"bottom":i=-r+zh;}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case"top-right":case"top-left":n=i-zh;break;case"bottom-right":case"bottom-left":n=-i+zh;break;case"bottom":n=-e+zh;break;case"top":n=e-zh;}switch(t){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=e;break;case"right":r=-e;}return [r,n]}(t,e[0])}function Bh(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*Tu));n.startsWith("top")?i[1]-=zh:n.startsWith("bottom")&&(i[1]+=zh),e[r+1]=i;}return new _e(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Tu,Ph]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Tu));const s=[];for(const t of a)s.push(t,Ch(t,n));return new _e(s)}return null}function Vh(t){switch(t){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function Eh(e,r,n,i,s,a,o,l,u,c,h,p){let f=a.textMaxSize.evaluate(r,{});void 0===f&&(f=o);const d=e.layers[0].layout,y=d.get("icon-offset").evaluate(r,{},h),m=Fh(n.horizontal),g=o/24,x=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*d.get("symbol-spacing"),_=d.get("text-padding")*e.tilePixelRatio,S=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),s=i&&i.values;return [s[0]*n,s[1]*n,s[2]*n,s[3]*n]}(d,r,h,e.tilePixelRatio),A=d.get("text-max-angle")/180*Math.PI,k="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),I="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),z=d.get("symbol-placement"),P=w/2,C=d.get("icon-text-fit");let B;i&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(B=pc(i,n.vertical,C,d.get("icon-text-fit-padding"),y,g)),m&&(i=pc(i,m,C,d.get("icon-text-fit-padding"),y,g)));const V=h?p.line.getGranularityForZoomLevel(h.z):1,E=(l,p)=>{p.x<0||p.x>=M||p.y<0||p.y>=M||function(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k){const M=e.addToLineVertexArray(r,n);let I,z,P,C,B=0,V=0,E=0,T=0,F=-1,$=-1;const L={};let D=Oa("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},A)+90;P=new _h(u,r,c,h,p,i.vertical,f,d,y,t),o&&(C=new _h(u,r,c,h,p,o,g,x,y,t));}if(s){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),a=gh(s,n,S,i),f=o?gh(o,n,S,i):void 0;z=new _h(u,r,c,h,p,s,g,x,!1,n),B=4*a.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[dc*l.layout.get("icon-size").evaluate(w,{})],y[0]>yc&&j(`${e.layerIds[0]}: Value for "icon-size" is >= ${fc}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[dc*_.compositeIconSizes[0].evaluate(w,{},A),dc*_.compositeIconSizes[1].evaluate(w,{},A)],(y[0]>yc||y[1]>yc)&&j(`${e.layerIds[0]}: Value for "icon-size" is >= ${fc}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,y,b,v,w,t.ai.none,r,M.lineStartIndex,M.lineLength,-1,A),F=e.icon.placedSymbolArray.length-1,f&&(V=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.ai.vertical,r,M.lineStartIndex,M.lineLength,-1,A),$=e.icon.placedSymbolArray.length-1);}const O=Object.keys(i.horizontal);for(const n of O){const s=i.horizontal[n];if(!I){D=Oa(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},A);I=new _h(u,r,c,h,p,s,f,d,y,t);}const o=1===s.positionedLines.length;if(E+=Th(e,r,s,a,l,y,w,m,M,i.vertical?t.ai.horizontal:t.ai.horizontalOnly,o?O:[n],L,F,_,A),o)break}i.vertical&&(T+=Th(e,r,i.vertical,a,l,y,w,m,M,t.ai.vertical,["vertical"],L,$,_,A));const R=I?I.boxStartIndex:e.collisionBoxArray.length,N=I?I.boxEndIndex:e.collisionBoxArray.length,U=P?P.boxStartIndex:e.collisionBoxArray.length,q=P?P.boxEndIndex:e.collisionBoxArray.length,G=z?z.boxStartIndex:e.collisionBoxArray.length,Z=z?z.boxEndIndex:e.collisionBoxArray.length,X=C?C.boxStartIndex:e.collisionBoxArray.length,K=C?C.boxEndIndex:e.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(I,H),H=Y(P,H),H=Y(z,H),H=Y(C,H);const J=H>-1?1:0;J&&(H*=k/Tu),e.glyphOffsetArray.length>=kc.MAX_GLYPHS&&j("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=Bh(l,w,A),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,F,$,D,R,N,U,q,G,Z,X,K,c,E,T,B,V,J,0,f,H,Q,tt);}(e,p,l,n,i,s,B,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,x,[_,_,_,_],k,u,b,S,I,y,r,a,c,h,o);};if("line"===z)for(const t of oh(r.geometry,0,0,M,M)){const r=Il(t,V),s=dh(r,w,A,n.vertical||m,i,24,v,e.overscaling,M);for(const t of s)m&&$h(e,m.text,P,t)||E(r,t);}else if("line-center"===z){for(const t of r.geometry)if(t.length>1){const e=Il(t,V),r=fh(e,A,n.vertical||m,i,24,v);r&&E(e,r);}}else if("Polygon"===r.type)for(const t of Le(r.geometry,0)){const e=Ah(t,16);E(Il(t[0],V,!0),new lh(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry){const e=Il(t,V);E(e,new lh(e[0].x,e[0].y,0));}else if("Point"===r.type)for(const t of r.geometry)for(const e of t)E([e],new lh(e.x,e.y,0));}function Th(t,e,r,n,i,s,a,o,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,s,a,o){const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=Uu+1,p=!0,f=1,d=0;const y=(i||o)&&n.vertical,m=n.metrics.advance*n.scale/2;if(o&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Tu-n.metrics.width*n.scale)/2:(n.scale-1)*Tu)),n.imageName){const t=a[n.imageName];p=t.sdf,f=t.pixelRatio,h=Gu/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],S=w+s.w/b*n.scale/f,A=_+s.h/b*n.scale/f,k=new l(w,_),M=new l(S,_),I=new l(w,A),z=new l(S,A);if(y){const t=new l(-m,m-Hu),e=-Math.PI/2,r=Tu/2-m,i=new l(5-Hu-r,-(n.imageName?r:0)),s=new l(...v);k._rotateAround(e,t)._add(i)._add(s),M._rotateAround(e,t)._add(i)._add(s),I._rotateAround(e,t)._add(i)._add(s),z._rotateAround(e,t)._add(i)._add(s);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),M._matMult(r),I._matMult(r),z._matMult(r);}const P=new l(0,0),C=new l(0,0);c.push({tl:k,tr:M,bl:I,br:z,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,o,i,s,a,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[dc*i.layout.get("text-size").evaluate(a,{})],x[0]>yc&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${fc}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[dc*d.compositeTextSizes[0].evaluate(a,{},y),dc*d.compositeTextSizes[1].evaluate(a,{},y)],(x[0]>yc||x[1]>yc)&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${fc}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,o,s,a,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function Fh(t){for(const e in t)return t[e];return null}function $h(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=Lh[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Dh(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Lh.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Oh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)Uh(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Uh(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function Oh(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;Rh(t,e,a,n,i,s),Oh(t,e,r,n,a-1,1-s),Oh(t,e,r,a+1,i,1-s);}function Rh(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);Rh(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(jh(t,e,n,r),e[2*i+s]>a&&jh(t,e,n,i);oa;)l--;}e[2*n+s]===a?jh(t,e,n,l):(l++,jh(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function jh(t,e,r,n){Nh(t,r,n),Nh(e,2*r,2*n),Nh(e,2*r+1,2*n+1);}function Nh(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Uh(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}var qh;t.ce=void 0,(qh=t.ce||(t.ce={})).create="create",qh.load="load",qh.fullLoad="fullLoad";let Gh=null,Zh=[];const Xh=1e3/60,Kh="loadTime",Hh="fullLoadTime",Yh={mark(t){performance.mark(t);},frame(t){const e=t;null!=Gh&&Zh.push(e-Gh),Gh=e;},clearMetrics(){Gh=null,Zh=[],performance.clearMeasures(Kh),performance.clearMeasures(Hh);for(const e in t.ce)performance.clearMarks(t.ce[e]);},getPerformanceMetrics(){performance.measure(Kh,t.ce.create,t.ce.load),performance.measure(Hh,t.ce.create,t.ce.fullLoad);const e=performance.getEntriesByName(Kh)[0].duration,r=performance.getEntriesByName(Hh)[0].duration,n=Zh.length,i=1/(Zh.reduce(((t,e)=>t+e),0)/n/1e3),s=Zh.filter((t=>t>Xh)).reduce(((t,e)=>t+(e-Xh)/Xh),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:s/(n+s)*100,totalFrames:n}}};t.$=St,t.A=g,t.B=Li,t.C=function(t){if(null==q){const e=t.navigator?t.navigator.userAgent:null;q=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return q},t.D=vs,t.E=ct,t.F=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Dc((()=>this.process())),this.subscription=function(t,e,r,n){return t.addEventListener(e,r,!1),{unsubscribe:()=>{t.removeEventListener(e,r,!1);}}}(this.target,"message",(t=>this.receive(t))),this.globalScope=U(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[i]={resolve:r,reject:n},e&&e.signal.addEventListener("abort",(()=>{delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),{once:!0});const s=[],a=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:Xi(t.data,s)});this.target.postMessage(a,{transfer:s});}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(U(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(Ki(r.error)):e.resolve(Ki(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=Ki(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i);}catch(e){this.completeTask(t,e);}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?Xi(e):null,data:Xi(r,n)};this.target.postMessage(i,{transfer:n});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.G=et,t.H=function(){var t=new g(16);return g!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.I=Zu,t.J=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=a*y+c*m+d*g+e[15]),t},t.K=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.L=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*o+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*s+b*u+w*f+_*g,t[3]=v*a+b*c+w*d+_*x,t[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*s+b*u+w*f+_*g,t[7]=v*a+b*c+w*d+_*x,t[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*s+b*u+w*f+_*g,t[11]=v*a+b*c+w*d+_*x,t[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*s+b*u+w*f+_*g,t[15]=v*a+b*c+w*d+_*x,t},t.M=function(t,e){const r={};for(let n=0;n{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e);};for(const r of t){const t=window.document.createElement("source");st(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t);}}))},t.a1=function(){return $++},t.a2=ra,t.a3=kc,t.a4=Yn,t.a5=lo,t.a6=rh,t.a7=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.a8=function(t){return Math.log(t)/Math.LN2},t.a9=function(t){var e=t[0],r=t[1];return e*e+r*r},t.aA=Cs,t.aB=_l,t.aC=fa,t.aD=Pa,t.aE=ka,t.aF=85.051129,t.aG=function(t){return Math.pow(2,t)},t.aH=Gc,t.aI=T,t.aJ=Y,t.aK=Xc,t.aL=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},t.aM=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},t.aN=function(t){var e=new g(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aO=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},t.aP=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},t.aQ=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.aR=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},t.aS=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aT=Jc,t.aU=Qc,t.aV=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.aW=function(t){var e=new g(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.aX=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.aY=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[4],a=e[5],o=e[6],l=e[7],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*i+u*n,t[5]=a*i+c*n,t[6]=o*i+h*n,t[7]=l*i+p*n,t[8]=u*i-s*n,t[9]=c*i-a*n,t[10]=h*i-o*n,t[11]=p*i-l*n,t},t.aZ=function(){const t=new Float32Array(16);return v(t),t},t.a_=function(){const t=new Float64Array(16);return v(t),t},t.aa=function(t){return t*Math.PI/180},t.ab=E,t.ac=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ad=A,t.ae=function(t){return Math.hypot(t[0],t[1])},t.af=function(t){return t[0]=0,t[1]=0,t},t.ag=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},t.ah=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:a}=t,o=i?E(sr.interpolationFactor(i,e,s,a),0,1):0;"camera"===t.kind?n=or.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.aj=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/dc:"composite"===t.kind?or.number(n/dc,i/dc,r):e},t.ak=wc,t.al=_,t.am=function(t,e,r,n){const i=e.y-t.y,s=e.x-t.x,a=n.y-r.y,o=n.x-r.x,u=a*s-o*i;if(0===u)return null;const c=(o*(t.y-r.y)-a*(t.x-r.x))/u;return new l(t.x+c*s,t.y+c*i)},t.an=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,S=i*u-s*l,A=c*y-h*d,k=c*m-p*d,M=c*g-f*d,I=h*m-p*y,z=h*g-f*y,P=p*g-f*m,C=x*P-v*z+b*I+w*M-_*k+S*A;return C?(t[0]=(o*P-l*z+u*I)*(C=1/C),t[1]=(i*z-n*P-s*I)*C,t[2]=(y*S-m*_+g*w)*C,t[3]=(p*_-h*S-f*w)*C,t[4]=(l*M-a*P-u*k)*C,t[5]=(r*P-i*M+s*k)*C,t[6]=(m*b-d*S-g*v)*C,t[7]=(c*S-p*b+f*v)*C,t[8]=(a*z-o*M+u*A)*C,t[9]=(n*M-r*z-s*A)*C,t[10]=(d*_-y*b+g*x)*C,t[11]=(h*b-c*_-f*x)*C,t[12]=(o*k-a*I-l*A)*C,t[13]=(r*I-n*k+i*A)*C,t[14]=(y*v-d*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null},t.ao=oh,t.ap=po,t.aq=v,t.ar=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return [e,r,n,i]},t.as=Tu,t.at=I,t.au=function(t,e,r,n,i=!1){if(!r[0]&&!r[1])return [0,0];const s=i?"map"===n?-t.bearingInRadians:0:"viewport"===n?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e];}return [i?r[0]:I(e,r[0],t.zoom),i?r[1]:I(e,r[1],t.zoom)]},t.aw=gc,t.ax=Vh,t.ay=lc,t.az=Dh,t.b=G,t.b$=t=>"line"===t.type,t.b0=function(t,e,r){const n=new Float64Array(4);return function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u;}(n,t,e-90,r),n},t.b1=function(t,e,r,n){var i,s,a,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],y=r[2],g=r[3];return (s=u*f+c*d+h*y+p*g)<0&&(s=-s,f=-f,d=-d,y=-y,g=-g),1-s>m?(i=Math.acos(s),a=Math.sin(i),o=Math.sin((1-n)*i)/a,l=Math.sin(n*i)/a):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*y,t[3]=o*p+l*g,t},t.b2=function(t){const e=new Float64Array(9);var r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v;h=(i=(n=t)[0])*(l=i+i),p=(s=n[1])*l,d=(a=n[2])*l,y=a*(u=s+s),g=(o=n[3])*l,x=o*u,v=o*(c=a+a),(r=e)[0]=1-(f=s*u)-(m=a*c),r[3]=p-v,r[6]=d+x,r[1]=p+v,r[4]=1-h-m,r[7]=y-g,r[2]=d-x,r[5]=y+g,r[8]=1-h-f;const b=Y(-Math.asin(E(e[2],-1,1)));let w,_;return Math.hypot(e[5],e[8])<.001?(w=0,_=-Y(Math.atan2(e[3],e[4]))):(w=Y(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),_=Y(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:w,pitch:b+90,bearing:_}},t.b3=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b4=ye,t.b5=Ga,t.b6=Sl,t.b7=Al,t.b8=wl,t.b9=P,t.bA=L,t.bB=D,t.bC=class extends qa{constructor(t,e){super(t,e),this.current=0;}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t));}},t.bD=class extends qa{constructor(t,e){super(t,e),this.current=Ka;}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.bE=Za,t.bF=Xa,t.bG=class extends qa{constructor(t,e){super(t,e),this.current=[0,0,0];}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]));}},t.bH=class extends qa{constructor(t,e){super(t,e),this.current=[0,0];}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]));}},t.bI=x,t.bJ=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.bK=function(t,e,r){var n=e[0],i=e[1],s=e[2];return t[0]=n*r[0]+i*r[3]+s*r[6],t[1]=n*r[1]+i*r[4]+s*r[7],t[2]=n*r[2]+i*r[5]+s*r[8],t},t.bL=function(t,e,r,n,i,s,a){var o=1/(e-r),l=1/(n-i),u=1/(s-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=(a+s)*u,t[15]=1,t},t.bM=class extends qs{},t.bN=zu,t.bO=class extends Zs{},t.bP=jo,t.bQ=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.bR=Ro,t.bS=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[3]*n+r[7]*i+r[11]*s+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/a,t},t.bT=class extends Ts{},t.bU=class extends Qs{},t.bV=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},t.bW=function(t,e){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],p=t[10],f=t[11],d=t[12],y=t[13],g=t[14],x=t[15],v=e[0],b=e[1],w=e[2],_=e[3],S=e[4],A=e[5],k=e[6],M=e[7],I=e[8],z=e[9],P=e[10],C=e[11],B=e[12],V=e[13],E=e[14],T=e[15];return Math.abs(r-v)<=m*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-b)<=m*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(i-w)<=m*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(s-_)<=m*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(a-S)<=m*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(o-A)<=m*Math.max(1,Math.abs(o),Math.abs(A))&&Math.abs(l-k)<=m*Math.max(1,Math.abs(l),Math.abs(k))&&Math.abs(u-M)<=m*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(c-I)<=m*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-z)<=m*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(p-P)<=m*Math.max(1,Math.abs(p),Math.abs(P))&&Math.abs(f-C)<=m*Math.max(1,Math.abs(f),Math.abs(C))&&Math.abs(d-B)<=m*Math.max(1,Math.abs(d),Math.abs(B))&&Math.abs(y-V)<=m*Math.max(1,Math.abs(y),Math.abs(V))&&Math.abs(g-E)<=m*Math.max(1,Math.abs(g),Math.abs(E))&&Math.abs(x-T)<=m*Math.max(1,Math.abs(x),Math.abs(T))},t.bX=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.bY=t=>"symbol"===t.type,t.bZ=t=>"circle"===t.type,t.b_=t=>"heatmap"===t.type,t.ba=C,t.bb=Ae,t.bc=function(t,e,r,n,i){return P(n,i,E((t-e)/(r-e),0,1))},t.bd=z,t.be=function(){return new Float64Array(4)},t.bf=function(){return new Float64Array(3)},t.bg=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),s[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),s[2]=i[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},t.bh=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[0],s[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),s[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},t.bi=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),s[1]=i[1],s[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},t.bj=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i-u*n,t[1]=a*i-c*n,t[2]=o*i-h*n,t[3]=l*i-p*n,t[8]=s*n+u*i,t[9]=a*n+c*i,t[10]=o*n+h*i,t[11]=l*n+p*i,t},t.bk=function(t,e){const r=z(t,360),n=z(e,360),i=n-r,s=n>r?i-360:i+360;return Math.abs(i)0?a:-a},t.bn=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bo=Oc,t.bp=function(t,e){const r=z(t,2*Math.PI),n=z(e,2*Math.PI);return Math.min(Math.abs(r-n),Math.abs(r-n+2*Math.PI),Math.abs(r-n-2*Math.PI))},t.bq=function(t){return Math.hypot(t[0],t[1],t[2])},t.br=function(){const t={},e=ht.$version;for(const r in ht.$root){const n=ht.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.bs=Hi,t.bt=nt,t.bu=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):s.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(wt),i=e.map(wt),s=t.reduce(_t,{}),a=e.reduce(_t,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;t"fill"===t.type,t.c1=t=>"fill-extrusion"===t.type,t.c2=t=>"hillshade"===t.type,t.c3=t=>"raster"===t.type,t.c4=t=>"background"===t.type,t.c5=t=>"custom"===t.type,t.c6=B,t.c7=function(t,e,r){const n=k(e.x-r.x,e.y-r.y),i=k(t.x-r.x,t.y-r.y);var s,a;return Y(Math.atan2(n[0]*i[1]-n[1]*i[0],(s=n)[0]*(a=i)[0]+s[1]*a[1]))},t.c8=V,t.c9=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},t.cA=Lu,t.cB=Nn,t.cC=us,t.ca=function(t,e){const{x:r,y:n}=Kc.fromLngLat(e);return !(t<0||t>25||n<0||n>=1||r<0||r>=1)},t.cb=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cc=class extends Es{},t.cd=Yh,t.cf=function(t){return t.message===J},t.cg=rt,t.ch=function(t,e){Q.REGISTERED_PROTOCOLS[t]=e;},t.ci=function(t){delete Q.REGISTERED_PROTOCOLS[t];},t.cj=function(t,e){const r={};for(let n=0;nt*Tu));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(i,{},e.canonical)*Tu:1/0,w=()=>{e.bucket.allowVerticalPlacement&&Ji(s)&&(d.vertical=Wu(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,b,a,m,"left",f,g,t.ai.vertical,!0,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.e=F,t.f=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=Z;}));},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):Z;})),t.g=tt,t.h=(t,e)=>it(F(t,{type:"json"}),e),t.i=U,t.j=ut,t.k=lt,t.l=(t,e)=>it(F(t,{type:"arrayBuffer"}),e),t.m=it,t.n=function(t){return new Du(t).readFields(Ru,[])},t.o=Do,t.p=qu,t.q=As,t.r=$i,t.s=st,t.t=Ri,t.u=Fi,t.v=ht,t.w=j,t.x=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}},t.y=or,t.z=cs;})); + +define("worker",["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const o of t){this._layerConfigs[o.id]=o;const t=this._layers[o.id]=e.bv(o);t._featureFilter=e.a4(t.filter),this.keyCache[o.id]&&delete this.keyCache[o.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=e.cj(Object.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let r=this.familiesBySource[i];r||(r=this.familiesBySource[i]={});const s=o.sourceLayer||"_geojsonTileLayer";let n=r[s];n||(n=r[s]=[]),n.push(t);}}}class o{constructor(t){const o={},i=[];for(const e in t){const r=t[e],s=o[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};i.push(o),s[e]={rect:o,metrics:t.metrics};}}const{w:r,h:s}=e.p(i),n=new e.o({width:r||1,height:s||1});for(const i in t){const r=t[i];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=o[i][t].rect;e.o.copy(s.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap);}}this.image=n,this.positions=o;}}e.ck("GlyphAtlas",o);class i{constructor(t){this.tileID=new e.S(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,i,s,n,a){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a2;const l=new e.cl(Object.keys(t.layers).sort()),c=new e.cm(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:s,subdivisionGranularity:a},d=i.familiesBySource[this.source];for(const o in d){const i=t.layers[o];if(!i)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(o),a=[];for(let e=0;e=o.maxzoom||"none"!==o.visibility&&(r(t,this.zoom,s),(u[o.id]=o.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}const f=e.bA(h.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let g=Promise.resolve({});if(Object.keys(f).length){const e=new AbortController;this.inFlightDependencies.push(e),g=n.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const p=Object.keys(h.iconDependencies);let m=Promise.resolve({});if(p.length){const e=new AbortController;this.inFlightDependencies.push(e),m=n.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},e);}const y=Object.keys(h.patternDependencies);let v=Promise.resolve({});if(y.length){const e=new AbortController;this.inFlightDependencies.push(e),v=n.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const[w,x,_]=yield Promise.all([g,m,v]),b=new o(w),M=new e.cn(x,_);for(const t in u){const o=u[t];o instanceof e.a3?(r(o.layers,this.zoom,s),e.co({bucket:o,glyphMap:w,glyphPositions:b.positions,imageMap:x,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):o.hasPattern&&(o instanceof e.cp||o instanceof e.cq||o instanceof e.cr)&&(r(o.layers,this.zoom,s),o.addFeatures(h,this.tileID.canonical,M.patternPositions));}return this.status="done",{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:M,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function r(t,o,i){const r=new e.z(o);for(const e of t)e.recalculate(r,i);}class s{constructor(e,t,o){this.actor=e,this.layerIndex=t,this.availableImages=o,this.fetching={},this.loading={},this.loaded={};}loadVectorTile(t,o){return e._(this,void 0,void 0,(function*(){const i=yield e.l(t.request,o);try{return {vectorTile:new e.cs.VectorTile(new e.ct(i.data)),rawData:i.data,cacheControl:i.cacheControl,expires:i.expires}}catch(e){const o=new Uint8Array(i.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cu(t.request),s=new i(t);this.loading[o]=s;const n=new AbortController;s.abort=n;try{const i=yield this.loadVectorTile(t,n);if(delete this.loading[o],!i)return null;const a=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}s.vectorTile=i.vectorTile;const u=s.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[o]=s,this.fetching[o]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[o];}}catch(e){throw delete this.loading[o],s.status="done",this.loaded[o]=s,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid;if(!this.loaded||!this.loaded[o])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const i=this.loaded[o];if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=yield i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let s;if(this.fetching[o]){const{rawTileData:t,cacheControl:i,resourceTiming:n}=this.fetching[o];delete this.fetching[o],s=e.e({rawTileData:t.slice(0)},r,i,n);}else s=r;return s}if("done"===i.status&&i.vectorTile)return i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){const e=this.loading,o=t.uid;e&&e[o]&&e[o].abort&&(e[o].abort.abort(),delete e[o]);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid];}))}}class n{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:i,rawImageData:r,redFactor:s,greenFactor:n,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cv(r,-1,-1,c,u)):r,d=new e.cw(o,h,i,s,n,a,l);return this.loaded=this.loaded||{},this.loaded[o]=d,d}))}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}var a,l,c=function(){if(l)return a;function e(e,o){if(0!==e.length){t(e[0],o);for(var i=1;i=Math.abs(a)?o-l+a:a-l+o,o=l;}o+i>=0!=!!t&&e.reverse();}return l=1,a=function t(o,i){var r,s=o&&o.type;if("FeatureCollection"===s)for(r=0;r>31}function c(e,t){for(var o=e.loadGeometry(),i=e.type,r=0,s=0,n=o.length,c=0;ce},_=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;const M=3,S=5,I=6;class P{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const s=[];for(let t=0;t=o;e--){const o=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,r=180;else if(o>r){const e=this.getClusters([o,i,180,s],t),n=this.getClusters([-180,i,r,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(D(o),C(s),D(r),C(i)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+S]>1?k(l,t,this.clusterProps):this.points[l[t+M]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(i);const s=r.data;if(t*this.stride>=s.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const o=t*this.stride;s[o+4]===e&&l.push(s[o+S]>1?k(s,o,this.clusterProps):this.points[s[o+M]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(o-a)/r,c=(o+1+a)/r,u={features:[]};return this._addTileFeatures(i.range((t-a)/r,l,(t+1+a)/r,c),i.data,t,o,r,u),0===t&&this._addTileFeatures(i.range(1-a/r,l,1,c),i.data,r,o,r,u),t===r-1&&this._addTileFeatures(i.range(0,l,a/r,c),i.data,-1,o,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=i?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,o,i,r):r1;let l,c,u;if(a)l=T(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+M]];l=o.properties;const[i,r]=o.geometry.coordinates;c=D(i),u=C(r);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-o)),Math.round(this.options.extent*(u*r-i))]],tags:l};let d;d=a||this.options.generateId?t[e+M]:this.points[t[e+M]].id,void 0!==d&&(h.id=d),s.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:r,minPoints:s}=this.options,n=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+S]);}if(f>d&&f>=s){let e,s=i*d,n=u*d,g=-1;const p=((o/c|0)<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+S];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=p,r&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)));}a[o+4]=p,l.push(s/f,n/f,1/0,p,-1,f),r&&l.push(g);}else {for(let e=0;e1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+S]>1){const i=this.clusterProps[e[t+I]];return o?Object.assign({},i):i}const i=this.points[e[t+M]].properties,r=this.options.map(i);return o&&r===i?Object.assign({},r):r}}function k(e,t,o){return {type:"Feature",id:e[t+M],properties:T(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),O(e[t+1])]}};var i;}function T(e,t,o){const i=e[t+S],r=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,s=e[t+I],n=-1===s?{}:Object.assign({},o[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+M],point_count:i,point_count_abbreviated:r})}function D(e){return e/360+.5}function C(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function O(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function L(e,t,o,i){let r=i;const s=t+(o-t>>1);let n,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;ir)n=i,r=t;else if(t===r){const e=Math.abs(i-s);ei&&(n-t>3&&L(e,t,n,i),e[n+2]=r,o-n>3&&L(e,n,o,i));}function F(e,t,o,i,r,s){let n=r-o,a=s-i;if(0!==n||0!==a){const l=((e-o)*n+(t-i)*a)/(n*n+a*a);l>1?(o=r,i=s):l>0&&(o+=n*l,i+=a*l);}return n=e-o,a=t-i,n*n+a*a}function z(e,t,o,i){const r={id:null==e?null:e,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)G(r,o);else if("Polygon"===t)G(r,o[0]);else if("MultiLineString"===t)for(const e of o)G(r,e);else if("MultiPolygon"===t)for(const e of o)G(r,e[0]);return r}function G(e,t){for(let o=0;o0&&(n+=i?(r*l-a*s)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-s,2))),r=a,s=l;}const a=t.length-3;t[2]=1,L(t,0,a,o),t[a+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function Z(e,t,o,i){for(let r=0;r1?1:o}function W(e,t,o,i,r,s,n,a){if(i/=t,s>=(o/=t)&&n=i)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const n=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(n>=o&&c=i)continue;let u=[];if("Point"===s||"MultiPoint"===s)R(e,u,o,i,r);else if("LineString"===s)Y(e,u,o,i,r,!1,a.lineMetrics);else if("MultiLineString"===s)X(e,u,o,i,r,!1);else if("Polygon"===s)X(e,u,o,i,r,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];X(t,e,o,i,r,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(z(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(z(t.id,s,u,t.tags));}}return l.length?l:null}function R(e,t,o,i,r){for(let s=0;s=o&&n<=i&&q(t,e[s],e[s+1],e[s+2]);}}function Y(e,t,o,i,r,s,n){let a=V(e);const l=0===r?B:H;let c,u,h=e.start;for(let d=0;do&&(u=l(a,f,g,m,y,o),n&&(a.start=h+c*u)):v>i?w=o&&(u=l(a,f,g,m,y,o),x=!0),w>i&&v<=i&&(u=l(a,f,g,m,y,i),x=!0),!s&&x&&(n&&(a.end=h+c*u),t.push(a),a=V(e)),n&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===r?f:g;p>=o&&p<=i&&q(a,f,g,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&q(a,a[0],a[1],a[2]),a.length&&t.push(a);}function V(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function X(e,t,o,i,r,s){for(const n of e)Y(n,t,o,i,r,s,!1);}function q(e,t,o,i){e.push(t,o,i);}function B(e,t,o,i,r,s){const n=(s-t)/(i-t);return q(e,s,o+(r-o)*n,1),n}function H(e,t,o,i,r,s){const n=(s-o)/(r-o);return q(e,t+(i-t)*n,s,1),n}function $(e,t){const o=[];for(let i=0;i0&&t.size<(r?n:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;en)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;r&&function(e,t){let o=0;for(let t=0,i=e.length,r=i-2;t0===t)for(let t=0,o=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=ee(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(o!==s>>e||i!==n>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,v=null,w=null,x=null,_=W(e,u,o-f,o+p,0,d.minX,d.maxX,l),b=W(e,u,o+g,o+m,0,d.minX,d.maxX,l);e=null,_&&(y=W(_,u,i-f,i+p,1,d.minY,d.maxY,l),v=W(_,u,i+g,i+m,1,d.minY,d.maxY,l),_=null),b&&(w=W(b,u,i-f,i+p,1,d.minY,d.maxY,l),x=W(b,u,i+g,i+m,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(v||[],t+1,2*o,2*i+1),a.push(w||[],t+1,2*o+1,2*i),a.push(x||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:r,debug:s}=i;if(e<0||e>24)return null;const n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[se(c,u,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),s>1&&console.timeEnd("drilling down"),this.tiles[a]?K(this.tiles[a],r):null):null}}function se(e,t,o){return 32*((1<{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,n);},t}(t)).load((yield this._pendingData).features):(r=yield this._pendingData,new re(r,t.geojsonVtOptions)),this.loaded={};const o={};if(i){const e=i.finish();e&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}return o}catch(t){if(delete this._pendingRequest,e.cf(t))return {abandoned:!0};throw t}var r;}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){let i=yield this.loadGeoJSON(t,o);if(delete this._pendingRequest,"object"!=typeof i)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(i,!0),t.filter){const o=e.cB(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const r=i.features.filter((e=>o.value.evaluate({zoom:0},e)));i={type:"FeatureCollection",features:r};}return i}))}loadGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){const{promoteId:i}=t;if(t.request){const r=yield e.h(t.request,o);return this._dataUpdateable=ae(r.data,i)?le(r.data,i):void 0,r.data}if("string"==typeof t.data)try{const e=JSON.parse(t.data);return this._dataUpdateable=ae(e,i)?le(e,i):void 0,e}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return function(e,t,o){var i,r,s,n;if(t.removeAll&&e.clear(),t.remove)for(const o of t.remove)e.delete(o);if(t.add)for(const i of t.add){const t=ne(i,o);null!=t&&e.set(t,i);}if(t.update)for(const o of t.update){let t=e.get(o.id);if(null==t)continue;const a=!o.removeAllProperties&&((null===(i=o.removeProperties)||void 0===i?void 0:i.length)>0||(null===(r=o.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((o.newGeometry||o.removeAllProperties||a)&&(t=Object.assign({},t),e.set(o.id,t),a&&(t.properties=Object.assign({},t.properties))),o.newGeometry&&(t.geometry=o.newGeometry),o.removeAllProperties)t.properties={};else if((null===(s=o.removeProperties)||void 0===s?void 0:s.length)>0)for(const e of o.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:i}of o.addOrUpdateProperties)t.properties[e]=i;}}(this._dataUpdateable,t.dataDiff,i),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class ue{constructor(t){this.self=t,this.actor=new e.F(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.ch,this.self.removeProtocol=e.ci,this.self.registerRTLTextPlugin=t=>{e.cC.setMethods(t);},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,o)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,o.source).removeTile(o);})))),this.actor.registerMessageHandler("GCEZ",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterExpansionZoom(o)})))),this.actor.registerMessageHandler("GCC",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterChildren(o)})))),this.actor.registerMessageHandler("GCL",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterLeaves(o)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,o)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][o.type]||!this.workerSources[t][o.type][o.source])return;const e=this.workerSources[t][o.type][o.source];delete this.workerSources[t][o.type][o.source],void 0!==e.removeSource&&e.removeSource(o);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t];})))),this.actor.registerMessageHandler("SR",((t,o)=>e._(this,void 0,void 0,(function*(){this.referrer=o;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,o)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(o);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(o.layers,o.removedIds);})))),this.actor.registerMessageHandler("SL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(o);}))));}_setImages(t,o){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=o;for(const e in this.workerSources[t]){const i=this.workerSources[t][e];for(const e in i)i[e].availableImages=o;}}))}_syncRTLPluginState(t,o){return e._(this,void 0,void 0,(function*(){return yield e.cC.syncState(o,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let o=this.layerIndexes[e];return o||(o=this.layerIndexes[e]=new t),o}_getWorkerSource(e,t,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][o]){const i={sendAsync:(t,o)=>(t.targetMapId=e,this.actor.sendAsync(t,o))};switch(t){case"vector":this.workerSources[e][t][o]=new s(i,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][o]=new ce(i,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][o]=new this.externalWorkerSourceTypes[t](i,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][o]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue})); + +define("index",["exports","./shared"],(function(e,t){"use strict";var i="5.0.0";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let o,s;const a={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:e=>new Promise(((i,r)=>{const o=requestAnimationFrame(i);e.signal.addEventListener("abort",(()=>{cancelAnimationFrame(o),r(t.c());}));})),getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(o||(o=document.createElement("a")),o.href=e,o.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==s&&(s=matchMedia("(prefers-reduced-motion: reduce)")),s.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",n.suppressClickInternal,!0);}),0);}static getScale(e){const t=e.getBoundingClientRect();return {x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const o=i.boundingClientRect;return new t.P((r.clientX-o.left)/i.x-e.clientLeft,(r.clientY-o.top)/i.y-e.clientTop)}static mousePos(e,t){const i=n.getScale(e);return n.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=n.getScale(e);for(let o=0;o{c&&_(c),c=null,d=!0;},h.onerror=()=>{u=!0,c=null;},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,r,o,s;e.resetRequestQueue=()=>{i=[],r=0,o=0,s={};},e.addThrottleControl=e=>{const t=o++;return s[t]=e,t},e.removeThrottleControl=e=>{delete s[e],n();},e.getImage=(e,r,o=!0)=>new Promise(((s,a)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:o,state:"queued",onError:e=>{a(e);},onSuccess:e=>{s(e);}}),n();}));const a=e=>t._(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:i,supportImageRefresh:o,onError:s,onSuccess:a,abortController:l}=e,h=!1===o&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((e,t)=>e&&"accept"===t),!0));r++;const u=h?c(i,l):t.m(i,l);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?a(i):i.data&&a({data:yield(d=i.data,"function"==typeof createImageBitmap?t.d(d):t.f(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(t){delete e.abortController,s(t);}finally{r--,n();}var d;})),n=()=>{const e=(()=>{for(const e of Object.keys(s))if(s[e]())return !0;return !1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:a(e);}},c=(e,i)=>new Promise(((r,o)=>{const s=new Image,a=e.url,n=e.credentials;n&&"include"===n?s.crossOrigin="use-credentials":(n&&"same-origin"===n||!t.s(a))&&(s.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{s.src="",o(t.c());})),s.fetchPriority="high",s.onload=()=>{s.onerror=s.onload=null,r({data:s});},s.onerror=()=>{s.onerror=s.onload=null,i.signal.aborted||o(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},s.src=a;}));}(p||(p={})),p.resetRequestQueue();class m{constructor(e){this._transformRequestFn=e;}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e;}}function f(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:o}of e){const e=`${r}${o}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:o}));}}return t}function g(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}class v{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:o,height:s}=e,a=!(this.size&&this.size[0]===o&&this.size[1]===s||r),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),a)this.size=[o,s],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,o,s,0,this.format,l.UNSIGNED_BYTE,e.data);else {const{x:i,y:a}=r||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,a,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,a,o,s,l.RGBA,l.UNSIGNED_BYTE,e.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D);}bind(e,t,i){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),i!==o.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=o.LINEAR),e!==this.filter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,t),this.wrap=t);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t);}_validate(e,i){let r=!0;const o=i.data||i.spriteData;return this._validateStretch(i.stretchX,o&&o.width)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,o&&o.height)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return !0;let i=0;for(const r of e){if(r[0]{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t});}))}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.k("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return {width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else {const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},o=new t.I(i,r);this.patterns[e]={bin:i,position:o};}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new v(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE);}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),o=this.atlasImage;o.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,s=i.y+1,a=this.getImage(e).data,n=a.width,l=a.height;t.R.copy(a,o,{x:0,y:0},{x:r,y:s},{width:n,height:l}),t.R.copy(a,o,{x:0,y:l-1},{x:r,y:s-1},{width:n,height:1}),t.R.copy(a,o,{x:0,y:0},{x:r,y:s+l},{width:n,height:1}),t.R.copy(a,o,{x:n-1,y:0},{x:r-1,y:s},{width:1,height:l}),t.R.copy(a,o,{x:0,y:0},{x:r+n,y:s},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e);}}}const y=1e20;function w(e,t,i,r,o,s,a,n,l){for(let c=t;c-1);l++,s[l]=n,a[l]=c,a[l+1]=y;}for(let n=0,l=0;n65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[o])return {stack:e,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[o]){const i=P.loadGlyphRange(e,o,this.url,this.requestManager);t.requests[o]=i;}const s=yield t.requests[o];for(const e in s)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=s[+e]);return t.ranges[o]=!0,{stack:e,id:i,glyph:s[i]||null}}))}_doesCharSupportLocalGlyph(e){return !!this.localIdeographFontFamily&&/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))}_tinySDF(e,i,r){const o=this.localIdeographFontFamily;if(!o)return;if(!this._doesCharSupportLocalGlyph(r))return;let s=e.tinySDF;if(!s){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),s=e.tinySDF=new P.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:t});}const a=s.draw(String.fromCharCode(r));return {id:r,bitmap:new t.o({width:a.width||60,height:a.height||60},a.data),metrics:{width:a.glyphWidth/2||24,height:a.glyphHeight/2||24,left:a.glyphLeft/2+.5||0,top:a.glyphTop/2-27.5||-8,advance:a.glyphAdvance/2||24,isDoubleResolution:!0}}}}P.loadGlyphRange=function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const s=256*i,a=s+255,n=o.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${s}-${a}`),"Glyphs"),l=yield t.l(n,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${s}-${a}`);const c={};for(const e of t.n(l.data))c[e.id]=e;return c}))},P.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:s="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const n=this.size=e+4*t,l=this._createCanvas(n),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${s} ${e}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:s}=this.ctx.measureText(e),a=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-o))),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=n+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),_={data:d,width:c,height:h,glyphWidth:n,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(e,m,m+a);const v=p.getImageData(m,m,n,l);g.fill(y,0,u),f.fill(0,0,u);for(let e=0;e0?e*e:0,f[r]=e<0?e*e:0;}}w(g,0,0,c,h,c,this.f,this.v,this.z),w(f,m,m,n,l,c,this.f,this.v,this.z);for(let e=0;e1&&(a=e[++s]);const l=Math.abs(n-a.left),c=Math.abs(n-a.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(a.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.data[o+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let o=0,s=e[o];for(let t=0;t1&&(s=e[++o]);const i=Math.abs(t-s.left),a=Math.abs(t-s.right),n=Math.min(i,a);this.data[r+t]=Math.max(0,Math.min(255,(s.isDash?n:-n)+128));}}addDash(e,i){const r=i?7:0,o=2*r+1;if(this.nextRow+o>this.height)return t.w("LineAtlas out of space"),null;let s=0;for(let t=0;t{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[D]}numActive(){return Object.keys(this.active).length}}const A=Math.floor(a.hardwareConcurrency/2);let L,k;function F(){return L||(L=new z),L}z.workerCount=t.C(globalThis)?Math.max(Math.min(A,3),1):1;class B{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let e=0;e{e.remove();})),this.actors=[],e&&this.workerPool.release(this.id);}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t);}}function j(){return k||(k=new B(F(),t.G),k.registerMessageHandler("GR",((e,i,r)=>t.m(i,r)))),k}function O(e,i){const r=t.H();return t.J(r,r,[1,1,0]),t.K(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.L(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function N(e,t,i,r,o,s){var a;const n=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return !0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return !0}return !1}(null!==(a=null==o?void 0:o.layers)&&void 0!==a?a:null,t,e.id),l=s.maxPitchScaleFactor(),c=e.tilesIn(r,l,n);c.sort(Z);const h=[];for(const r of c)h.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,o,s,l,O(e.transform,r.tileID))});return function(e,t){for(const i in e)for(const r of e[i])G(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,o=r.wrappedTileID,s=i[o]=i[o]||{};for(const i in e){const r=e[i],o=s[i]=s[i]||{},a=t[i]=t[i]||[];for(const e of r)o[e.featureIndex]||(o[e.featureIndex]=!0,a.push(e));}}return t}(h),e)}function Z(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function G(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r;}function U(e,i,r){return t._(this,void 0,void 0,(function*(){let o=e;if(e.url?o=(yield t.h(i.transformRequest(e.url,"Source"),r)).data:yield a.frameAsync(r),!o)return null;const s=t.M(t.e(o,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in o&&o.vector_layers&&(s.vectorLayerIds=o.vector_layers.map((e=>e.id))),s}))}class V{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])));}setNorthEast(e){return this._ne=e instanceof t.N?new t.N(e.lng,e.lat):t.N.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.N?new t.N(e.lng,e.lat):t.N.convert(e),this}extend(e){const i=this._sw,r=this._ne;let o,s;if(e instanceof t.N)o=e,s=e;else {if(!(e instanceof V))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(V.convert(e)):this.extend(t.N.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.N.convert(e)):this;if(o=e._sw,s=e._ne,!o||!s)return this}return i||r?(i.lng=Math.min(o.lng,i.lng),i.lat=Math.min(o.lat,i.lat),r.lng=Math.max(s.lng,r.lng),r.lat=Math.max(s.lat,r.lat)):(this._sw=new t.N(o.lng,o.lat),this._ne=new t.N(s.lng,s.lat)),this}getCenter(){return new t.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.N(this.getWest(),this.getNorth())}getSouthEast(){return new t.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:r}=t.N.convert(e);let o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&o}static convert(e){return e instanceof V?e:e?new V(e):e}static fromLngLat(e,i=0){const r=360*i/40075017,o=r/Math.cos(Math.PI/180*e.lat);return new V(new t.N(e.lng-o,e.lat-r),new t.N(e.lng+o,e.lat+r))}adjustAntiMeridian(){const e=new t.N(this._sw.lng,this._sw.lat),i=new t.N(this._ne.lng,this._ne.lat);return new V(e,e.lng>i.lng?new t.N(i.lng+360,i.lat):i)}}class q{constructor(e,t,i){this.bounds=V.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.O(this.bounds.getWest())*i),o=Math.floor(t.Q(this.bounds.getNorth())*i),s=Math.ceil(t.O(this.bounds.getEast())*i),a=Math.ceil(t.Q(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((t,i)=>{e.reloadPromise={resolve:t,reject:i};}))}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null);}}))}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject);}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class W extends t.E{constructor(e,i,r,o){super(),this.id=e,this.dispatcher=r,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.M(i,["url","scheme","tileSize"]));}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield U(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.k("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this.fire(new t.j(e));}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}serialize(){return t.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const i=yield p.getImage(this.map._requestManager.transformRequest(t,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const t=this.map.painter.context,r=t.gl,o=i.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new v(t,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController);}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture);}))}hasTransition(){return !1}}class X extends W{constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield p.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const o=t.b(r)&&t.U()?r:yield this.readImageNow(r),s={type:this.type,uid:e.uid,source:this.id,rawImageData:o,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:s});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded";}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.V()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.W(e,-1,-1,i,r))}catch(e){}}return a.getImageData(e,1)}))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,s=0===i.x?e.wrap-1:e.wrap,a=(i.x+1+r)%r,n=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.S(e.overscaledZ,s,i.z,o,i.y).key]={backfilled:!1},l[new t.S(e.overscaledZ,n,i.z,a,i.y).key]={backfilled:!1},i.y>0&&(l[new t.S(e.overscaledZ,s,i.z,o,i.y-1).key]={backfilled:!1},l[new t.S(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.S(e.overscaledZ,n,i.z,a,i.y-1).key]={backfilled:!1}),i.y+10&&t.e(o,{resourceTiming:r}),this.fire(new t.k("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.k("data",Object.assign(Object.assign({},o),{sourceDataType:"content"})));}catch(e){if(this._pendingLoads--,this._removed)return void this.fire(new t.k("dataabort",{dataType:"source"}));this.fire(new t.j(e));}}))}loaded(){return 0===this._pendingLoads}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t);}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0;}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}}class K extends t.E{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t;}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield p.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading());}catch(e){this._request=null,this._loaded=!0,this.fire(new t.j(e));}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.k("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.Y.fromLngLat);var r;return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,s=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y);const a=Math.max(o-i,s-r),n=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,n);return new t.Z(n,Math.floor((i+o)/2*l),Math.floor((r+s)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new v(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}}class Y extends K{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a0(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading();}catch(e){this.fire(new t.j(e));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.j(new t.$(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new v(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class J extends K{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new t.j(new t.$(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.j(new t.$(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.j(new t.$(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.j(new t.$(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.j(new t.$(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new v(i,this.canvas,r.RGBA,{premultiply:!0});let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}}const Q={},ee=e=>{switch(e){case"geojson":return $;case"image":return K;case"raster":return W;case"raster-dem":return X;case"vector":return H;case"video":return Y;case"canvas":return J}return Q[e]},te="RTLPluginLoaded";class ie extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=j();}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.k(te));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let re=null;function oe(){return re||(re=new ie),re}class se{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a1(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r;}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a3){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a3&&i.hasRTLText){this.hasRTLText=!0,oe().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage);}else this.collisionBoxArray=new t.a2;}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new v(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new v(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null);}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture);}queryRenderedFeatures(e,t,i,r,o,s,a,n,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:o,scale:s,tileSize:this.tileSize,pixelPosMatrix:c,transform:n,params:a,queryPadding:this.queryPadding*l},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const o=r.loadVTLayers(),s=i&&i.sourceLayer?i.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const n=t.a4(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,o);}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class ne{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,i,r){const o=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},t.e(this.stateChanges[e][o],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null);}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,i){const r=String(i),o=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete o[e];}return o}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,i){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}r[e]=r[e]||{},t.e(r[e],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i);}}function le(e,t,i){const r=t.intersectsFrustum(e);if(!i)return r;const o=t.intersectsPlane(i);return 0===r||0===o?0:2===r&&2===o?2:1}function ce(e,i,r,o,s){let a=e;const n=Math.atan(i/r),l=Math.hypot(i,r);return a=e+t.a8(o/l/Math.max(.5,Math.cos(t.aa(s/2)))),a+=1*t.a8(Math.cos(n))/2,a+=t.ab(e-a,-0,0),a}function he(e,i){const r=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.a8(e.tileSize/i.tileSize));return Math.max(0,r)}function ue(e,i){const r=e.getCameraFrustum(),o=e.getClippingPlane(),s=e.screenPointToMercatorCoordinate(e.getCameraPoint()),a=t.Y.fromLngLat(e.center,e.elevation);s.z=a.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const n=e.getCoveringTilesDetailsProvider(),l=n.allowVariableZoom(e,i),c=he(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),_=Math.pow(2,d),p=[_*s.x,_*s.y,0],m=[_*a.x,_*a.y,0],f=Math.hypot(a.x-s.x,a.y-s.y),g=Math.abs(a.z-s.z),v=Math.hypot(f,g),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],y=[];if(e.renderWorldCopies&&n.allowWorldCopies())for(let e=1;e<=3;e++)b.push(x(-e)),b.push(x(e));for(b.push(x(0));b.length>0;){const _=b.pop(),f=_.x,x=_.y;let w=_.fullyVisible;const T={x:f,y:x,z:_.zoom},P=n.getTileAABB(T,_.wrap,e.elevation,i);if(!w){const e=le(r,P,o);if(0===e)continue;w=2===e;}const C=n.distanceToTile2d(s.x,s.y,T,P);let I=c;l&&(I=(i.calculateTileZoom||ce)(e.zoom+t.a8(e.tileSize/i.tileSize),C,g,v,e.fov)),I=(i.roundZoom?Math.round:Math.floor)(I),I=Math.max(0,I);const E=Math.min(I,u);if(_.wrap=n.getWrap(a,T,_.wrap),_.zoom>=E){if(_.zoom>1),wrap:_.wrap,fullyVisible:w});}return y.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}class de extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((e,t,i,r)=>{const o=new(ee(t.type))(e,t,i,r);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return o})(e,t,i,this),this._tiles={},this._cache=new ae(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ne,this._didEmitContent=!1,this._updated=!1;}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e);}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(e,i,r){return t._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,r);}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.j(i,{tile:e})):this.update(this.transform,this.terrain);}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e);}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.k("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(_e).map((e=>e.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,o=i.tileID,s=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),a=new t.P(o.canonical.x,o.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(_e).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)(e||"errored"!==this._tiles[t].state)&&this._reloadTile(t,"reloading");}}_reloadTile(e,i){return t._(this,void 0,void 0,(function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i));}))}_tileLoaded(e,i,r){e.timeAdded=a.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.k("data",{dataType:"source",tile:e,coord:e.tileID}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[s]&&(e.neighboringTiles[s].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const o in this._tiles){let s=this._tiles[o];if(r[o]||!s.hasData()||s.tileID.overscaledZ<=t||s.tileID.overscaledZ>i)continue;let a=s.tileID;for(;s&&s.tileID.overscaledZ>t+1;){const e=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[e.key],s&&s.hasData()&&(a=e);}let n=a;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]||e[n.canonical.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e]);}}_updateCoveredAndRetainedTiles(e,t,i,r,o,s){const n={},l={},c=Object.keys(e),h=a.now();for(const i of c){const r=e[i],o=this._tiles[i];if(!o||0!==o.fadeEndTime&&o.fadeEndTime<=h)continue;const s=this.findLoadedParent(r,t),a=this.findLoadedSibling(r),c=s||a||null;c&&(this._addTile(c.tileID),n[c.tileID.key]=c.tileID),l[i]=r;}this._retainLoadedChildren(l,r,i,e);for(const t in n)e[t]||(this._coveredTiles[t]=!0,e[t]=n[t]);if(s){const t={},i={};for(const e of o)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const r in i){const o=i[r].children(this._source.maxzoom);this._tiles[o[0].key]&&this._tiles[o[1].key]&&this._tiles[o[2].key]&&this._tiles[o[3].key]&&(t[o[0].key]=e[o[0].key]=o[0],t[o[1].key]=e[o[1].key]=o[1],t[o[2].key]=e[o[2].key]=o[2],t[o[3].key]=e[o[3].key]=o[3],delete i[r]);}for(const r in i){const o=i[r],s=this.findLoadedParent(o,this._source.minzoom),a=this.findLoadedSibling(o),n=s||a||null;if(n){t[n.tileID.key]=e[n.tileID.key]=n.tileID;for(const e in t)t[e].isChildOf(n.tileID)&&delete t[e];}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0);}}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.S(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=ue(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const o=he(e,this._source),s=Math.max(o-de.maxOverzooming,this._source.minzoom),a=Math.max(o+de.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of r)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const r=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[r.key]=r;}r=r.concat(Object.values(e));}const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,o);pe(this._source.type)&&this._updateCoveredAndRetainedTiles(l,s,a,o,r,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.ac(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e);}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e);}_updateRetainedTiles(e,t){var i;const r={},o={},s=Math.max(t-de.maxOverzooming,this._source.minzoom),a=Math.max(t+de.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);r[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=a.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){r[e.key]=e;continue}}else {const e=a.children(this._source.maxzoom);if(r[e[0].key]&&r[e[1].key]&&r[e[2].key]&&r[e[3].key])continue}let n=e.wasRequested();for(let t=a.overscaledZ-1;t>=s;--t){const s=a.scaledTo(t);if(o[s.key])break;if(o[s.key]=!0,e=this.getTile(s),!e&&n&&(e=this._addTile(s)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[s.key]=s),n=e.wasRequested(),t)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i;}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new se(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.k("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset();}tilesIn(e,i,r){const o=[],s=this.transform;if(!s)return o;const a=r?s.getCameraQueryGeometry(e):e,n=e.map((e=>s.screenPointToMercatorCoordinate(e,this.terrain))),l=a.map((e=>s.screenPointToMercatorCoordinate(e,this.terrain))),c=this.getIds();let h=1/0,u=1/0,d=-1/0,_=-1/0;for(const e of l)h=Math.min(h,e.x),u=Math.min(u,e.y),d=Math.max(d,e.x),_=Math.max(_,e.y);for(let e=0;e=0&&f[1].y+m>=0){const e=n.map((e=>a.getTilePoint(e))),t=l.map((e=>a.getTilePoint(e)));o.push({tile:r,tileID:a,queryGeometry:e,cameraQueryGeometry:t,scale:p});}}return o}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return !0;if(pe(this._source.type)){const e=a.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}}function _e(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function pe(e){return "raster"===e||"image"===e||"video"===e}de.maxOverzooming=10,de.maxUnderzooming=3;class me{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(o-a)/n:0;return this.points[s].mult(1-l).add(this.points[i].mult(l))}}function fe(e,t){let i=!0;return "always"===e||"never"!==e&&"never"!==t||(i=!1),i}class ge{constructor(e,t,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return [];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(o)return [{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e0}hitTestCircle(e,t,i,r,o){const s=e-i,a=e+i,n=t-i,l=t+i;if(a<0||s>this.width||l<0||n>this.height)return !1;const c=[];return this._forEachCell(s,n,a,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},o),c.length>0}_queryCell(e,t,i,r,o,s,a,n){const{seenUids:l,hitTest:c,overlapMode:h}=a,u=this.boxCells[o];if(null!==u){const o=this.bboxes;for(const a of u)if(!l.box[a]){l.box[a]=!0;const u=4*a,d=this.boxKeys[a];if(e<=o[u+2]&&t<=o[u+3]&&i>=o[u+0]&&r>=o[u+1]&&(!n||n(d))&&(!c||!fe(h,d.overlapMode))&&(s.push({key:d,x1:o[u],y1:o[u+1],x2:o[u+2],y2:o[u+3]}),c))return !0}}const d=this.circleCells[o];if(null!==d){const o=this.circles;for(const a of d)if(!l.circle[a]){l.circle[a]=!0;const u=3*a,d=this.circleKeys[a];if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],e,t,i,r)&&(!n||n(d))&&(!c||!fe(h,d.overlapMode))){const e=o[u],t=o[u+1],i=o[u+2];if(s.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return !0}}}return !1}_queryCellCircle(e,t,i,r,o,s,a,n){const{circle:l,seenUids:c,overlapMode:h}=a,u=this.boxCells[o];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(r))&&!fe(h,r.overlapMode))return s.push(!0),!0}}const d=this.circleCells[o];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!n||n(r))&&!fe(h,r.overlapMode))return s.push(!0),!0}}}_forEachCell(e,t,i,r,o,s,a,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(o.call(this,e,t,i,r,this.xCellCount*l+d,s,a,n))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,o,s){const a=r-e,n=o-t,l=i+s;return l*l>a*a+n*n}_circleAndRectCollide(e,t,i,r,o,s,a){const n=(s-r)/2,l=Math.abs(e-(r+n));if(l>n+i)return !1;const c=(a-o)/2,h=Math.abs(t-(o+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}function ve(e,i,o){const s=t.H();if(!e){const{vecSouth:e,vecEast:t}=be(i),o=r();o[0]=t[0],o[1]=t[1],o[2]=e[0],o[3]=e[1],a=o,(d=(l=(n=o)[0])*(u=n[3])-(h=n[2])*(c=n[1]))&&(a[0]=u*(d=1/d),a[1]=-c*d,a[2]=-h*d,a[3]=l*d),s[0]=o[0],s[1]=o[1],s[4]=o[2],s[5]=o[3];}var a,n,l,c,h,u,d;return t.K(s,s,[1/o,1/o,1]),s}function xe(e,i,r,o){if(e){const e=t.H();if(!i){const{vecSouth:t,vecEast:i}=be(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1];}return t.K(e,e,[o,o,1]),e}return r.pixelsToClipSpaceMatrix}function be(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),o=Math.cos(e.pitchInRadians),s=Math.cos(e.bearingInRadians),a=Math.sin(e.bearingInRadians),n=t.ad();n[0]=-s*o*r-a*i,n[1]=-a*o*r+s*i;const l=t.ae(n);l<1e-9?t.af(n):t.ag(n,n,1/l);const c=t.ad();c[0]=s*o*i-a*r,c[1]=a*o*i+s*r;const h=t.ae(c);return h<1e-9?t.af(c):t.ag(c,c,1/h),{vecEast:c,vecSouth:n}}function ye(e,i,r,o){let s;o?(s=[e,i,o(e,i),1],t.al(s,s,r)):(s=[e,i,0,1],je(s,s,r));const a=s[3];return {point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}function we(e,t){return .5+e/t*.5}function Te(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Pe(e,i,r,o,s,a,n,l,c,h,u,d,_){const p=r?e.textSizeData:e.iconSizeData,m=t.ah(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const v=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let y=!1;for(let r=0;rMath.abs(r.x-i.x)*o?{useVertical:!0}:(e===t.ai.vertical?i.yr.x)?{needsFlipping:!0}:null}function Ee(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:o,fontSize:s,flip:a,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=s/24,_=o.lineOffsetX*d,p=o.lineOffsetY*d;let m;if(o.numGlyphs>1){const e=o.glyphStartIndex+o.numGlyphs,t=o.lineStartIndex,s=o.lineStartIndex+o.lineLength,c=Ce(d,l,_,p,a,o,u,i);if(!c)return {notEnoughRoom:!0};const f=De(c.first.point.x,c.first.point.y,i,r),g=De(c.last.point.x,c.last.point.y,i,r);if(n&&!a){const e=Ie(o.writingMode,f,g,h);if(e)return e}m=[c.first];for(let r=o.glyphStartIndex+1;r0?n.point:Me(i.tileAnchorPoint,a,e,1,i),c=De(e.x,e.y,i,r),u=De(l.x,l.y,i,r),d=Ie(o.writingMode,c,u,h);if(d)return d}const e=ke(d*l.getoffsetX(o.glyphStartIndex),_,p,a,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[e];}for(const e of m)t.ak(c,e.point,e.angle);return {}}function Me(e,t,i,r,o){const s=e.add(e.sub(t)._unit()),a=Re(s.x,s.y,o).point,n=i.sub(a);return i.add(n._mult(r/n.mag()))}function Se(e,i,r){const o=i.projectionCache;if(o.projections[e])return o.projections[e];const s=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),a=Re(s.x,s.y,i);if(a.signedDistanceFromCamera>0)return o.projections[e]=a.point,o.anyProjectionOccluded=o.anyProjectionOccluded||a.isOccluded,a.point;const n=e-r.direction;return Me(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),s,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Re(e,t,i){const r=e+i.translation[0],o=t+i.translation[1];let s;return i.pitchWithMap?(s=ye(r,o,i.pitchedLabelPlaneMatrix,i.getElevation),s.isOccluded=!1):(s=i.transform.projectTileCoordinates(r,o,i.unwrappedTileID,i.getElevation),s.point.x=(.5*s.point.x+.5)*i.width,s.point.y=(.5*-s.point.y+.5)*i.height),s}function De(e,i,r,o){if(r.pitchWithMap){const s=[e,i,0,1];return t.al(s,s,o),r.transform.projectTileCoordinates(s[0]/s[3],s[1]/s[3],r.unwrappedTileID,r.getElevation).point}return {x:e/r.width*2-1,y:i/r.height*2-1}}function ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ae(e,t,i){return e._unit()._perp()._mult(t*i)}function Le(e,i,r,o,s,a,n,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=r.add(i);if(e+c.direction=s)return l.projectionCache.offsets[e]=h,h;const u=Se(e+c.direction,l,c),d=Ae(u.sub(r),n,c.direction),_=r.add(d),p=u.add(d);return l.projectionCache.offsets[e]=t.am(a,h,_,p)||h,l.projectionCache.offsets[e]}function ke(e,t,i,r,o,s,a,n,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,_=h>0?s+o:s+o+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=Re(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const b=Math.abs(c),y=[];let w;for(;v+x<=b;){if(_+=h,_=a)return null;v+=x,g=f,m=p;const e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:g};if(f=Se(_,n,e),0===i)y.push(g),w=f.sub(g);else {let t;const r=f.sub(g);t=0===r.mag()?Ae(Se(_+h,n,e).sub(f),i,h):Ae(r,i,h),m||(m=g.add(t)),p=Le(_,t,f,s,a,m,i,n,e),y.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((b-v)/x)._add(m||g),P=u+Math.atan2(f.y-g.y,f.x-g.x);return y.push(T),{point:T,angle:l?P:0,path:y}}const Fe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Be(e,t){for(let i=0;i=1;e--)_.push(a.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let f=[];if(_.length>0){const e=_[0].clone(),i=_[0].clone();for(let t=1;t<_.length;t++)e.x=Math.min(e.x,_[t].x),e.y=Math.min(e.y,_[t].y),i.x=Math.max(i.x,_[t].x),i.y=Math.max(i.y,_[t].y);f=e.x>=r.x&&i.x<=o.x&&e.y>=r.y&&i.y<=o.y?[_]:i.xo.x||i.yo.y?[]:t.ao([_],r.x,r.y,o.x,o.y);}for(const t of f){s.reset(t,.25*i);let r=0;r=s.length<=.5*i?1:Math.ceil(s.paddedLength/p)+1;for(let t=0;t{const t=ye(e.x,e.y,r,i.getElevation),o=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height,o}))}(e,i);return function(e){let t=0,i=0,r=0,o=0;for(let s=0;si&&(i=o,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let r=1/0,o=1/0,s=-1/0,a=-1/0;for(const n of e){const e=new t.P(n.x+Oe,n.y+Oe);r=Math.min(r,e.x),o=Math.min(o,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y),i.push(e);}const n=this.grid.query(r,o,s,a).concat(this.ignoredGrid.query(r,o,s,a)),l={},c={};for(const e of n){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const o=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.ap(i,o)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex));}return c}insertCollisionBox(e,t,i,r,o,s){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:o,collisionGroupID:s,overlapMode:t},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,r,o,s){const a=i?this.ignoredGrid:this.grid,n={bucketInstanceId:r,featureIndex:o,collisionGroupID:s,overlapMode:t};for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,o,c,u)));S=e.some((e=>!e.isOccluded)),M=e.map((e=>new t.P(e.x,e.y)));}else S=!0;return {box:t.ar(M),allPointsOccluded:!S}}}class Ze{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Ge{constructor(e,t,i,r,o){this.text=new Ze(e?e.text:null,t,i,o),this.icon=new Ze(e?e.icon:null,t,r,o);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ue{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i;}}class Ve{constructor(e,t,i,r,o){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=o;}}class qe{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function He(e,i,r,o,s){const{horizontalAlign:a,verticalAlign:n}=t.ay(e);return new t.P(-(a-.5)*i+o[0]*s,-(n-.5)*r+o[1]*s)}class We{constructor(e,t,i,r,o){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Ne(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new qe(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,o){const s=r.getBucket(i),a=r.latestFeatureIndex;if(!s||!a||i.id!==s.layerIds[0])return;const n=r.collisionBoxArray,l=s.layers[0].layout,c=s.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.X,d=r.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=t.at(r,1,this.transform.zoom),m=t.au(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),f=t.au(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),g=ve(_,this.transform,p);this.retainedQueryData[s.bucketInstanceId]=new Ve(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,r.tileID);const v={bucket:s,layout:l,translationText:m,translationIcon:f,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.ah(s.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(o)for(const t of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:v});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:v});}attemptAnchorPlacement(e,i,r,o,s,a,n,l,c,h,u,d,_,p,m,f,g,v,x,b){const y=t.av[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=He(y,r,o,w,s),P=this.collisionIndex.placeCollisionBox(i,d,l,c,h,n,a,f,u.predicate,x,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,c,h,n,a,g,u.predicate,x,T,b).placeable)&&P.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID].text&&(e=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:w,width:r,height:o,anchor:y,textBoxScale:s,prevAnchor:e},this.markUsedJustification(p,y,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:T,placedGlyphBoxes:P}}}placeLayerBucketPart(e,i,r){const{bucket:o,layout:s,translationText:a,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=e.parameters,m=s.get("text-optional"),f=s.get("icon-optional"),g=t.aw(s,"text-overlap","text-allow-overlap"),v="always"===g,x=t.aw(s,"icon-overlap","icon-allow-overlap"),b="always"===x,y="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),P="viewport-y"===s.get("symbol-z-order"),C=v&&(b||!o.hasIconData()||f),I=b&&(v||!o.hasTextData()||m);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d);const E=this.retainedQueryData[o.bucketInstanceId].tileID,M=this._getTerrainElevationFunc(E),S=this.transform.getFastPathSimpleProjectionMatrix(E),R=(e,d,b)=>{var P,R;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new Ue(!1,!1,!1));let D=!1,z=!1,A=!0,L=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},F={box:null,placeable:!1,offscreen:null},B=null,j=null,O=null,N=0,Z=0,G=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(Z=d.verticalTextFeatureIndex);const U=d.textBox;if(U){const i=i=>{let r=t.ai.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(o,r,e));}return r},s=(i,r)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===t.ai.vertical?(k=r(),F=k):k=i(),k&&k.placeable)break}else k=i();},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,h,E,l,w,y,a,p.predicate,M,void 0,S);return r&&r.placeable&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),r};s((()=>r(U,t.ai.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.ai.vertical):{box:null,offscreen:null}})),i(k&&k.placeable);}else {let _=t.av[null===(R=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[e.crossTileID])||void 0===R?void 0:R.anchor];const m=(t,i,s)=>{const d=t.x2-t.x1,m=t.y2-t.y1,f=e.textBoxScale,v=T&&"never"===x?i:null;let b=null,P="never"===g?1:2,C="never";_&&P++;for(let i=0;im(U,d.iconBox,t.ai.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ai.vertical):{box:null,occluded:!0,offscreen:null}})),k&&(D=k.placeable,A=k.offscreen);const f=i(k&&k.placeable);if(!D&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,f));}}}if(B=k,D=B&&B.placeable,A=B&&B.offscreen,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),n=t.aj(o.textSizeData,_,i),h=s.get("text-padding");j=this.collisionIndex.placeCollisionCircles(g,i,o.lineVertexArray,o.glyphOffsetArray,n,l,c,r,w,p.predicate,e.collisionCircleDiameter,h,a,M),j.circles.length&&j.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),D=v||j.circles.length>0&&!j.collisionDetected,A=A&&j.offscreen;}if(d.iconFeatureIndex&&(G=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,E,l,w,y,n,p.predicate,M,T&&L?L:void 0,S);F&&F.placeable&&d.verticalIconBox?(O=e(d.verticalIconBox),z=O.placeable):(O=e(d.iconBox),z=O.placeable),A=A&&O.offscreen;}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,q=f||0===e.numIconVertices;V||q?q?V||(z=z&&D):D=z&&D:z=D=z&&D;const H=z&&O.placeable;if(D&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,s.get("text-ignore-placement"),o.bucketInstanceId,F&&F.placeable&&Z?Z:N,p.ID),H&&this.collisionIndex.insertCollisionBox(O.box,x,s.get("icon-ignore-placement"),o.bucketInstanceId,G,p.ID),j&&D&&this.collisionIndex.insertCollisionCircles(j.circles,g,s.get("text-ignore-placement"),o.bucketInstanceId,N,p.ID),r&&this.storeCollisionData(o.bucketInstanceId,b,d,B,O,j),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===o.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Ue((D||C)&&!(null==B?void 0:B.occluded),(z||I)&&!(null==O?void 0:O.occluded),A||o.justReloaded),i[e.crossTileID]=!0;};if(P){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=o.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];R(o.symbolInstances.get(i),o.collisionArrays[i],i);}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=s>=0&&t!==s?0:r.crossTileID);}markUsedOrientation(e,i,r){const o=i===t.ai.horizontal||i===t.ai.horizontalOnly?i:0,s=i===t.ai.vertical?i:0,a=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of a)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=s);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,o=t?t.opacities:{},s=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],s=o[e];s?(this.opacities[e]=new Ge(s,r,t.text,t.icon),i=i||t.text!==s.text.placed||t.icon!==s.icon.placed):(this.opacities[e]=new Ge(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon);}for(const e in o){const t=o[e];if(!this.opacities[e]){const o=new Ge(t,r,!1,!1);o.isHidden()||(this.opacities[e]=o,i=i||t.text.placed||t.icon.placed);}}for(const e in s)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=s[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray);}}updateBucketOpacities(e,i,r,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const s=e.layers[0],a=s.layout,n=new Ge(null,0,!1,!1,!0),l=a.get("text-allow-overlap"),c=a.get("icon-allow-overlap"),h=s._unevaluatedLayout.hasValue("text-variable-anchor")||s._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===a.get("text-rotation-alignment"),d="map"===a.get("text-pitch-alignment"),_="none"!==a.get("icon-text-fit"),p=new Ge(null,0,l&&(c||!e.hasIconData()||a.get("icon-optional")),c&&(l||!e.hasTextData()||a.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const m=(e,t,i)=>{for(let r=0;r0,v=this.placedOrientations[o.crossTileID],x=v===t.ai.vertical,b=v===t.ai.horizontal||v===t.ai.horizontalOnly;if(s>0||a>0){const t=it(c.text);m(e.text,s,x?rt:t),m(e.text,a,b?rt:t);const i=c.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||x?1:0);})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||b?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o));}if(g){const t=it(c.icon),i=!(_&&o.verticalPlacedIconSymbolIndex&&x);o.placedIconSymbolIndex>=0&&(m(e.icon,o.numIconVertices,i?t:rt),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=c.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,o.numVerticalIconVertices,i?rt:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden());}const y=f&&f.has(i)?f.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const r=e.collisionArrays[i];if(r){let i=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(i=He(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1;}if(r.textBox||r.verticalTextBox){let o;r.textBox&&(o=x),r.verticalTextBox&&(o=b),Xe(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||o,y.text,i.x,i.y);}}if(r.iconBox||r.verticalIconBox){const t=Boolean(!b&&r.verticalIconBox);let o;r.iconBox&&(o=t),r.verticalIconBox&&(o=!t),Xe(e.iconCollisionBox.collisionVertexArray,c.icon.placed,o,y.icon,_?i.x:0,_?i.y:0);}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId]);}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function Xe(e,t,i,r,o,s){r&&0!==r.length||(r=[0,0,0,0]);const a=r[0]-Oe,n=r[1]-Oe,l=r[2]-Oe,c=r[3]-Oe;e.emplaceBack(t?1:0,i?1:0,o||0,s||0,a,n),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,l,n),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,l,c),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,a,c);}const $e=Math.pow(2,25),Ke=Math.pow(2,24),Ye=Math.pow(2,17),Je=Math.pow(2,16),Qe=Math.pow(2,9),et=Math.pow(2,8),tt=Math.pow(2,1);function it(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*$e+t*Ke+i*Ye+t*Je+i*Qe+t*et+i*tt+t}const rt=0;class ot{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,r,o){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex!this._forceFullPlacement&&a.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=s)&&(!r.maxzoom||r.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new ot(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const at=512/t.X/2;class nt{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const o=new Map;for(let e=0;e({x:Math.floor(e.anchorX*at),y:Math.floor(e.anchorY*at)}))),crossTileIDs:i.map((e=>e.crossTileID))};if(r.positions.length>128){const e=new t.az(r.positions.length,16,Uint16Array);for(const{x:t,y:i}of r.positions)e.add(t,i);e.finish(),delete r.positions,r.index=e;}this._symbolsByKey[e]=r;}}getScaledCoordinates(e,i){const{x:r,y:o,z:s}=this.tileID.canonical,{x:a,y:n,z:l}=i.canonical,c=at/Math.pow(2,l-s),h=(n*t.X+e.anchorY)*c,u=o*t.X*at;return {x:Math.floor((a*t.X+e.anchorX)*c-r*t.X*at),y:Math.floor(h-u)}}findMatches(e,t,i){const r=this.tileID.canonical.ze))}}class lt{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class ct{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const o=i[e];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),r[o.tileID.key]=o;}this.indexes[e]=r;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in o){const s=o[i];s.tileID.isChildOf(e)&&s.findMatches(t.symbolInstances,e,r);}else {const s=o[e.scaledTo(Number(i)).key];s&&s.findMatches(t.symbolInstances,e,r);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var ut="void main() {fragColor=vec4(1.0);}";const dt={prelude:_t("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:_t("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:_t("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:_t("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:_t("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:_t("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:_t(ut,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:_t("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:_t("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:_t("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:_t("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:_t("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:_t(ut,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:_t("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:_t("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:_t("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:_t("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:_t("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));fragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:_t("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:_t("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:_t("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:_t("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:_t("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:_t("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:_t("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:_t("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:_t("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:_t("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:_t("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:_t("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:_t("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:_t("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function _t(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=s?s.concat(o):o,n={};return {fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const s="float"===r?"vec2":"vec4",a=o.match(/color/)?"color":s;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${s} a_${o};\nout ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${a}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${s} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${a}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,staticUniforms:a}}class pt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}var mt=t.aA([{name:"a_pos",type:"Int16",components:2}]);const ft="#define PROJECTION_MERCATOR",gt="mercator";class vt{constructor(){this._cachedMesh=null;}get name(){return "mercator"}get useSubdivision(){return !1}get shaderVariantName(){return gt}get shaderDefine(){return ft}get shaderPreludeCode(){return dt.projectionMercator}get vertexShaderPreludeCode(){return dt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aB.noSubdivision}get useGlobeControls(){return !1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,o,s){if(this._cachedMesh)return this._cachedMesh;const a=new t.aC;a.emplaceBack(0,0),a.emplaceBack(t.X,0),a.emplaceBack(0,t.X),a.emplaceBack(t.X,t.X);const n=e.createVertexBuffer(a,mt.members),l=t.aD.simpleSegment(0,0,4,2),c=new t.aE;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new pt(n,h,l),this._cachedMesh}recalculate(){}hasTransition(){return !1}setErrorQueryLatitudeDegrees(e){}}function xt(e,i){const r=t.ab(i.lat,-t.aF,t.aF);return new t.P(t.O(i.lng)*e,t.Q(r)*e)}function bt(e,i){return new t.Y(i.x/e,i.y/e).toLngLat()}function yt(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.aa(90-e.pitch)),Math.tan(t.aa(89.25-e.pitch)))}function wt(e,i){const r=e.canonical,o=i/t.aG(r.z),s=r.x+Math.pow(2,r.z)*e.wrap,a=t.aq(new Float64Array(16));return t.J(a,a,[s*o,r.y*o,0]),t.K(a,a,[o/t.X,o/t.X,1]),a}function Tt(e,i,r,o,s){const a=t.Y.fromLngLat(e,i),n=s*t.aH(1,e.lat),l=n*Math.cos(t.aa(r)),c=Math.sqrt(n*n-l*l),h=c*Math.sin(t.aa(-o)),u=c*Math.cos(t.aa(-o));return new t.Y(a.x+h,a.y+u,a.z+l)}class Pt{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r;}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.y.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.y.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.y.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.y.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.ab((this.left+e-this.right)/2,0,e),o=t.ab((this.top+i-this.bottom)/2,0,i);return new t.P(r,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Pt(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ct(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0;}function It(e){return Math.max(0,Math.floor(e))}class Et{constructor(e,i,r,o,s,a){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===a||!!a,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==o?0:o,this._maxPitch=null==s?60:s,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.N(0,0),this._elevation=0,this._zoom=0,this._tileZoom=It(this._zoom),this._scale=t.aG(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Pt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0;}apply(e,i,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=It(this._zoom),this._scale=t.aG(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Pt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices();}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e;}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)));}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)));}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aI(e,-180,180)*Math.PI/180;var o,s,a,n,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),o=this._rotationMatrix,a=-this._bearingInRadians,n=(s=this._rotationMatrix)[0],l=s[1],c=s[2],h=s[3],u=Math.sin(a),d=Math.cos(a),o[0]=n*d+c*u,o[1]=l*d+h*u,o[2]=n*-u+c*d,o[3]=l*-u+h*d);}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ab(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices());}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices());}get fovInRadians(){return this._fovInRadians}get fov(){return t.aJ(this._fovInRadians)}setFov(e){e=t.ab(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.aa(e),this._calcMatrices());}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.aG(i),this._constrain(),this._calcMatrices());}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices();}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices();}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices();}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new V([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-t.aF,t.aF]);}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return [i[0],e];{let r=e.x,o=e.y,s=e.x,a=e.y;for(const e of i)r=Math.min(r,e.x),o=Math.min(o,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y);return [new t.P(r,o),new t.P(s,o),new t.P(s,a),new t.P(r,a),new t.P(r,o)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1;}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.aq(new Float64Array(16));t.K(e,e,[this._width/2,-this._height/2,1]),t.J(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.aq(new Float64Array(16)),t.K(e,e,[1,-1,1]),t.J(e,e,[-1,-1,0]),t.K(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height;}this._callbacks.calcMatrices();}calculateCenterFromCameraLngLatAlt(e,i,r,o){const s=void 0!==r?r:this.bearing,a=o=void 0!==o?o:this.pitch,n=t.Y.fromLngLat(e,i),l=-Math.cos(t.aa(a)),c=Math.sin(t.aa(a)),h=c*Math.sin(t.aa(s)),u=-c*Math.cos(t.aa(s));let d=this.elevation;const _=i-d;let p;l*_>=0||Math.abs(l)<.1?(p=1e4,d=i+p*l):p=-_/l;let m,f,g=t.aK(1,n.y),v=0;do{if(v+=1,v>10)break;f=p/g,m=new t.Y(n.x+h*f,n.y+u*f),g=1/m.meterInMercatorCoordinateUnits();}while(Math.abs(p-f*g)>1e-12);return {center:m.toLngLat(),elevation:d,zoom:t.a8(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.aH(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,o=t.Y.fromLngLat(this.center,this.elevation),s=Tt(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;const a=this.calculateCenterFromCameraLngLatAlt(s.toLngLat(),t.aK(s.z,o.y),this.bearing,this.pitch);this._elevation=a.elevation,this._center=a.center,this.setZoom(a.zoom);}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.aH(1,this.center.lat)*this.worldSize;return Tt(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return [0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class St{distanceToTile2d(e,t,i,r){const o=r.distanceX([e,t]),s=r.distanceY([e,t]);return Math.hypot(o,s)}getWrap(e,t,i){return i}getTileAABB(e,i,r,o){var s,a;let n=r,l=r;if(o.terrain){const c=new t.S(e.z,i,e.z,e.x,e.y),h=o.terrain.getMinMaxElevation(c);n=null!==(s=h.minElevation)&&void 0!==s?s:r,l=null!==(a=h.maxElevation)&&void 0!==a?a:r;}const c=1<o||e.padding.top>=.1}allowWorldCopies(){return !0}recalculateCache(){}}class Rt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i;}static fromInvProjectionMatrix(e,i=1,r=0){const o=Math.pow(2,r),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const s=1/(r=t.al([],r,e))[3]/i*o;return t.aO(r,r,[s,s,1/r[3],s])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.aP([],s[e[0]],s[e[1]]),r=t.aP([],s[e[2]],s[e[1]]),o=t.aQ([],t.aR([],i,r)),a=-t.aS(o,s[e[1]]);return o.concat(a)})),n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of s)for(let t=0;t<3;t++)n[t]=Math.min(n[t],e[t]),l[t]=Math.max(l[t],e[t]);return new Rt(s,a,new Mt(n,l))}}class Dt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,r,o){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Et({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,r,o),this._coveringTilesDetailsProvider=new St;}clone(){const e=new Dt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i);}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.aT(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),s=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),a=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),n=Math.floor(Math.min(r.x,o.x,s.x,a.x)),l=Math.floor(Math.max(r.x,o.x,s.x,a.x)),c=1;for(let r=n-c;r<=l+c;r++)0!==r&&i.push(new t.aT(r,e));}return i}getCameraFrustum(){return Rt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i);}setLocationAtPoint(e,i){const r=t.aH(this.elevation,this.center.lat),o=this.screenPointToMercatorCoordinateAtZ(i,r),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),a=t.Y.fromLngLat(e),n=new t.Y(a.x-(o.x-s.x),a.y-(o.y-s.y));this.setCenter(null==n?void 0:n.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap());}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.Y.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.Y.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,o=[e.x,e.y,0,1],s=[e.x,e.y,1,1];t.al(o,o,this._pixelMatrixInverse),t.al(s,s,this._pixelMatrixInverse);const a=o[3],n=s[3],l=o[1]/a,c=s[1]/n,h=o[2]/a,u=s[2]/n,d=h===u?0:(r-h)/(u-h);return new t.Y(t.y.number(o[0]/a,s[0]/n,d)/this.worldSize,t.y.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.al(o,o,r),new t.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this._helper._height/2-yt(this));return (new V).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-yt(this)}calculatePosMatrix(e,i=!1,r){var o;const s=null!==(o=e.key)&&void 0!==o?o:t.aU(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),a=i?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(s)){const e=a.get(s);return r?e.f32:e.f64}const n=wt(e,this.worldSize);t.L(n,i?this._alignedProjMatrix:this._viewProjMatrix,n);const l={f64:n,f32:new Float32Array(n)};return a.set(s,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const o=wt(e,this.worldSize);return t.L(o,this._fogMatrix,o),r.set(i,new Float32Array(o)),r.get(i)}getConstrained(e,i){i=t.ab(+i,this.minZoom,this.maxZoom);const r={center:new t.N(e.lng,e.lat),zoom:i};let o=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===o){const e=180-1e-10;o=[-e,e];}const s=this.tileSize*t.aG(r.zoom);let a=0,n=s,l=0,c=s,h=0,u=0;const{x:d,y:_}=this.size;if(this._helper._latRange){const e=this._helper._latRange;a=t.Q(e[1])*s,n=t.Q(e[0])*s,n-a<_&&(h=_/(n-a));}o&&(l=t.aI(t.O(o[0])*s,0,s),c=t.aI(t.O(o[1])*s,0,s),cn&&(g=n-e);}if(o){const e=(l+c)/2;let i=p;this._helper._renderWorldCopies&&(i=t.aI(p,e-s/2,e+s/2));const r=d/2;i-rc&&(f=c-r);}if(void 0!==f||void 0!==g){const e=new t.P(null!=f?f:p,null!=g?g:m);r.center=bt(s,e).wrap();}return r}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const o=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),s=e-o*this._helper._pixelPerMeter/Math.cos(i),a=o<0?s:e,n=Math.PI/2+this.pitchInRadians,l=t.aa(this.fov)*(Math.abs(Math.cos(t.aa(this.roll)))*this.height+Math.abs(Math.sin(t.aa(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*a/Math.sin(t.ab(Math.PI-n-l,.01,Math.PI-.01)),h=yt(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.aa(.75),_=u>d?2*u*(.5+r.y/(2*h)):d,p=Math.sin(_)*a/Math.sin(t.ab(Math.PI-n-_,.01,Math.PI-.01)),m=Math.min(c,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+a),this._helper._nearZ=this._helper._height/50;}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=xt(this.worldSize,this.center),r=i.x,o=i.y;this._helper._pixelPerMeter=t.aH(1,this.center.lat)*this.worldSize;const s=t.aa(Math.min(this.pitch,89.25)),a=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(s));let n;this._calculateNearFarZIfNeeded(a,s,e),n=new Float64Array(16),t.aV(n,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.an(this._invProjMatrix,n),n[8]=2*-e.x/this._helper._width,n[9]=2*e.y/this._helper._height,this._projectionMatrix=t.aW(n),t.K(n,n,[1,-1,1]),t.J(n,n,[0,0,-this._helper.cameraToCenterDistance]),t.aX(n,n,-this.rollInRadians),t.aY(n,n,this.pitchInRadians),t.aX(n,n,-this.bearingInRadians),t.J(n,n,[-r,-o,0]),this._mercatorMatrix=t.K([],n,[this.worldSize,this.worldSize,this.worldSize]),t.K(n,n,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.L(new Float64Array(16),this.clipSpaceToPixelsMatrix,n),t.J(n,n,[0,0,-this.elevation]),this._viewProjMatrix=n,this._invViewProjMatrix=t.an([],n);const l=[0,0,-1,1];t.al(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.aV(this._fogMatrix,this.fovInRadians,this.width/this.height,a,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.K(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.J(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.aX(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.aY(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.aX(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.J(this._fogMatrix,this._fogMatrix,[-r,-o,0]),t.K(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.J(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.L(new Float64Array(16),this.clipSpaceToPixelsMatrix,n);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),_=r-Math.round(r)+u*c+d*h,p=o-Math.round(o)+u*h+d*c,m=new Float64Array(n);if(t.J(m,m,[_>.5?_-1:_,p>.5?p-1:p,0]),this._alignedProjMatrix=m,n=t.an(new Float64Array(16),this._pixelMatrix),!n)throw new Error("failed to invert matrix");this._pixelMatrixInverse=n,this._clearMatrixCaches();}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear();}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.al(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.aH(1,this.center.lat)*this.worldSize;return Tt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.Y.fromLngLat(e),o=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.al(o,o,this._viewProjMatrix),o[2]/o[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:o}=e,s=this._helper.getMercatorTileCoordinates(i),a=i?this.calculatePosMatrix(i,r,!0):null;let n;return n=i&&i.terrainRttPosMatrix32f&&o?i.terrainRttPosMatrix32f:a||t.aZ(),{mainMatrix:n,tileMercatorCoords:s,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n}}isLocationOccluded(e){return !1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aN(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,o){const s=this.calculatePosMatrix(r);let a;o?(a=[e,i,o(e,i),1],t.al(a,a,s)):(a=[e,i,0,1],je(a,a,s));const n=a[3];return {point:new t.P(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t);}getMatrixForModel(e,i){const r=t.Y.fromLngLat(e,i),o=r.meterInMercatorCoordinateUnits(),s=t.a_();return t.J(s,s,[r.x,r.y,r.z]),t.aX(s,s,Math.PI),t.aY(s,s,Math.PI/2),t.K(s,s,[-o,o,o]),s}getProjectionDataForCustomLayer(e=!0){const i=new t.S(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),o=wt(i,this.worldSize);t.L(o,this._viewProjMatrix,o),r.tileMercatorCoords=[0,0,1,1];const s=[t.X,t.X,this.worldSize/this._helper.pixelsPerMeter],a=t.a$();return t.K(a,o,s),r.fallbackMatrix=a,r.mainMatrix=a,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function zt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");}function At(e){if(e.useSlerp)if(e.k<1){const i=t.b0(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.b0(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),o=new Float64Array(4);t.b1(o,i,r,e.k);const s=t.b2(o);e.tr.setRoll(s.roll),e.tr.setPitch(s.pitch),e.tr.setBearing(s.bearing);}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.y.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.y.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.y.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k));}function Lt(e,i,r,o,s){const a=s.padding,n=xt(s.worldSize,r.getNorthWest()),l=xt(s.worldSize,r.getNorthEast()),c=xt(s.worldSize,r.getSouthEast()),h=xt(s.worldSize,r.getSouthWest()),u=t.aa(-o),d=n.rotate(u),_=l.rotate(u),p=c.rotate(u),m=h.rotate(u),f=new t.P(Math.max(d.x,_.x,m.x,p.x),Math.max(d.y,_.y,m.y,p.y)),g=new t.P(Math.min(d.x,_.x,m.x,p.x),Math.min(d.y,_.y,m.y,p.y)),v=f.sub(g),x=(s.width-(a.left+a.right+i.left+i.right))/v.x,b=(s.height-(a.top+a.bottom+i.top+i.bottom))/v.y;if(b<0||x<0)return void zt();const y=Math.min(t.a8(s.scale*Math.min(x,b)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.aa(o)),P=w.add(T).mult(s.scale/t.aG(y));return {center:bt(s.worldSize,n.add(c).div(2).sub(P)),zoom:y,bearing:o}}class kt{get useGlobeControls(){return !1}handlePanInertia(e,t){return {easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around);}cameraForBoxAndBearing(e,t,i,r,o){return Lt(e,t,i,r,o)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.N.convert(i.center));}handleEaseTo(e,i){const r=e.zoom,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},n=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=n?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:_,zoom:p}=e.getConstrained(t.N.convert(i.center||d),null!=h?h:r);Ct(e,_);const m=xt(e.worldSize,d),f=xt(e.worldSize,_).sub(m),g=t.aG(p-r);return c=p!==r,{easeFunc:n=>{if(c&&e.setZoom(t.y.number(r,p,n)),t.b3(s,a)||At({startEulerAngles:s,endEulerAngles:a,tr:e,k:n,useSlerp:s.roll!=a.roll}),l&&(e.interpolatePadding(o,i.padding,n),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else {const i=t.aG(e.zoom-r),o=p>r?Math.min(2,g):Math.max(.5,g),s=Math.pow(o,1-n),a=bt(e.worldSize,m.add(f.mult(n*s)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?a.wrap():a,u);}},isZooming:c,elevationCenter:_}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.zoom,s=e.getConstrained(t.N.convert(i.center||i.locationAtOffset),r?+i.zoom:o),a=s.center,n=s.zoom;Ct(e,a);const l=xt(e.worldSize,i.locationAtOffset),c=xt(e.worldSize,a).sub(l),h=c.mag(),u=t.aG(n-o);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,o,n),s=e.getConstrained(a,r).zoom;d=t.aG(s-o);}return {easeFunc:(i,r,s,h)=>{e.setZoom(1===i?n:o+t.a8(r));const u=1===i?a:bt(e.worldSize,l.add(c.mult(s)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h);},scaleOfZoom:u,targetCenter:a,scaleOfMinZoom:d,pixelPathLength:h}}}class Ft{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i;}}Ft.Replace=[1,0],Ft.disabled=new Ft(Ft.Replace,t.b4.transparent,[!1,!1,!1,!1]),Ft.unblended=new Ft(Ft.Replace,t.b4.transparent,[!0,!0,!0,!0]),Ft.alphaBlended=new Ft([1,771],t.b4.transparent,[!0,!0,!0,!0]);const Bt=2305;class jt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}jt.disabled=new jt(!1,1029,Bt),jt.backCCW=new jt(!0,1029,Bt),jt.frontCCW=new jt(!0,1028,Bt);class Ot{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Ot.ReadOnly=!1,Ot.ReadWrite=!0,Ot.disabled=new Ot(519,Ot.ReadOnly,[0,1]);const Nt=7680;class Zt{constructor(e,t,i,r,o,s){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=o,this.pass=s;}}Zt.disabled=new Zt({func:519,mask:0},0,0,Nt,Nt,Nt);const Gt=new WeakMap;function Ut(e){var t;if(Gt.has(e))return Gt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Gt.set(e,i),i}}class Vt{get awaitingQuery(){return !!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const o=new t.aC;o.emplaceBack(-1,-1),o.emplaceBack(2,-1),o.emplaceBack(-1,2);const s=new t.aE;s.emplaceBack(0,1,2),this._fullscreenTriangle=new pt(i.createVertexBuffer(o,mt.members),i.createIndexBuffer(s),t.aD.simpleSegment(0,0,o.length,s.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(a),Ut(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null));}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null;}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer);}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,o=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.b4.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,o.TRIANGLES,Ot.disabled,Zt.disabled,Ft.unblended,jt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Ut(o)){o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.readBuffer(o.COLOR_ATTACHMENT0),o.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const e=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);o.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e};}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null};}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Ut(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Vt._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount;}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const qt=t.X/128;function Ht(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,o=r+(e.generateBorders?2:0),s=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),a=o+1,n=s+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=r+(e.generateBorders?1:0),u=r+(e.generateBorders||e.extendToSouthPole?1:0),d=a*n,_=o*s*6,p=a*n>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,f=new Int16Array(2*d);let g=0;for(let i=c;i<=u;i++)for(let o=l;o<=h;o++){let s=o/r*t.X;-1===o&&(s=-qt),o===r+1&&(s=t.X+qt);let a=i/r*t.X;-1===i&&(a=e.extendToNorthPole?t.b6:-qt),i===r+1&&(a=e.extendToSouthPole?t.b7:t.X+qt),f[g++]=s,f[g++]=a;}const v=m?new Uint32Array(_):new Uint16Array(_);let x=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return "globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy();}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e);}getMeshFromTileID(e,t,i,r,o){return this.currentProjection.getMeshFromTileID(e,t,i,r,o)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator");}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e);}}function Yt(e){const t=ei(e.worldSize,e.center.lat);return 2*Math.PI*t}function Jt(e,i,r,o,s){const a=1/(1<1e-6){const o=e[0]/r,s=Math.acos(e[2]/r),a=(o>0?s:-s)/Math.PI*180;return new t.N(t.aI(a,-180,180),i)}return new t.N(0,i)}function ii(e){return Math.cos(e*Math.PI/180)}function ri(e,i){const r=ii(e),o=ii(i);return t.a8(o/r)}function oi(e,i){const r=e.rotate(i.bearingInRadians),o=i.zoom+ri(i.center.lat,0),s=t.b9(1/ii(i.center.lat),1/ii(Math.min(Math.abs(i.center.lat),60)),t.bc(o,7,3,0,1)),a=360/Yt({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.N(i.center.lng-r.x*a*s,t.ab(i.center.lat+r.y*a,-t.aF,t.aF))}function si(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function ai(e,i,r,o){const s=e.lat+r*o;if(Math.abs(r)>1){const a=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,n=Math.abs(e.lat+r)*Math.PI/180,l=si(a+o*(n-a)),c=si(a),h=si(n);return new t.N(e.lng+i*((l-c)/(h-c)),s)}return new t.N(e.lng+i*o,s)}class ni{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=e;}recalculateCache(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1;}getTileAABB(e,t,i,r){const o=`${e.z}_${e.x}_${e.y}`,s=this._cache.get(o);if(s)return s;const a=this._cachePrevious.get(o);if(a)return this._cache.set(o,a),a;const n=this._aabbFactory(e,t,i,r);return this._cache.set(o,n),this._hadAnyChanges=!0,n}}function li(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function ci(e,t,i,r,o){const s=e-i;let a;return a=s<0?Math.min(-s,1+s-o):s>1?Math.min(Math.max(s-o,0),1-s):0,Math.max(a,li(t,r,o))}class hi{constructor(){this._aabbCache=new ni(this._computeTileAABB);}recalculateCache(){this._aabbCache.recalculateCache();}distanceToTile2d(e,t,i,r){const o=1<4}allowWorldCopies(){return !1}getTileAABB(e,t,i,r){return this._aabbCache.getTileAABB(e,t,i,r)}_computeTileAABB(e,i,r,o){if(e.z<=0)return new Mt([-1,-1,-1],[1,1,1]);if(1===e.z)return new Mt([0===e.x?-1:0,0===e.y?0:-1,-1],[0===e.x?0:1,0===e.y?1:0,1]);{const i=[Jt(0,0,e.x,e.y,e.z),Jt(t.X,0,e.x,e.y,e.z),Jt(t.X,t.X,e.x,e.y,e.z),Jt(0,t.X,e.x,e.y,e.z)],r=[1,1,1],o=[-1,-1,-1];for(const e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);if(0===e.y||e.y===(1<{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new hi;}clone(){const e=new ui;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e);}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bf();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return {mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,o=Math.sin(i)*r,s=Math.cos(i)*r+1,a=1/Math.sqrt(o*o+s*s)*1;let n=-o,l=s;const c=Math.sqrt(n*n+l*l);n/=c,l/=c;const h=[0,n,l];return t.bg(h,h,[0,0,0],-this.bearingInRadians),t.bh(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bi(h,h,[0,0,0],this.center.lng*Math.PI/180),t.aL(h,h,.25),[...h,.25*-a]}isLocationOccluded(e){return !this.isSurfacePointVisible(Qt(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,o=Math.cos(r),s=[Math.sin(i)*o,Math.sin(r),Math.cos(i)*o],a=[s[2],0,-s[0]],n=[0,0,0];t.aR(n,a,s),t.aQ(a,a),t.aQ(n,n);const l=[0,0,0];return t.aQ(l,[a[0]*e[0]+n[0]*e[1]+s[0]*e[2],a[1]*e[0]+n[1]*e[1]+s[1]*e[2],a[2]*e[0]+n[2]*e[1]+s[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const o=function(e,i,r){const o=1/(1<s&&(s=i),rn&&(n=r);}const h=[c.lng+a,c.lat+l,c.lng+s,c.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new V(h)}getConstrained(e,i){const r=t.ab(e.lat,-t.aF,t.aF),o=t.ab(+i,this.minZoom+ri(0,r),this.maxZoom);return {center:new t.N(e.lng,r),zoom:o}}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=Qt(this.unprojectScreenPoint(i)),o=Qt(e),s=t.bf();t.bl(s);const a=t.bf();t.bi(a,r,s,-this.center.lng*Math.PI/180),t.bh(a,a,s,this.center.lat*Math.PI/180);const n=o[0]*o[0]+o[2]*o[2],l=a[0]*a[0];if(n=-g&&p<=g,x=f>=-g&&f<=g;let b,y;if(v&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bp(u,e)+t.bp(p,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return !1;const i=t.be();return t.al(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.aS(e,i),o=t.bf(),s=t.bf();t.aL(s,i,r),t.aP(o,e,s);const a=1-t.aS(o,o);if(a<0)return null;const n=t.aS(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(a),c=n/l,h=l;return {tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),o=this.rayPlanetIntersection(i,r);if(o){const e=t.bf();t.aM(e,i,[r[0]*o.tMin,r[1]*o.tMin,r[2]*o.tMin]);const s=t.bf();return t.aQ(s,e),ti(s)}const s=this._cachedClippingPlane[0]*r[0]+this._cachedClippingPlane[1]*r[1]+this._cachedClippingPlane[2]*r[2],a=-t.bn(this._cachedClippingPlane,i)/s,n=t.bf();if(a>0)t.aM(n,i,[r[0]*a,r[1]*a,r[2]*a]);else {const e=t.bf();t.aM(e,i,[2*r[0],2*r[1],2*r[2]]);const o=t.bn(this._cachedClippingPlane,e);t.aP(n,e,[this._cachedClippingPlane[0]*o,this._cachedClippingPlane[1]*o,this._cachedClippingPlane[2]*o]);}const l=t.bf();return t.aQ(l,n),ti(l)}getMatrixForModel(e,i){const r=t.N.convert(e),o=1/t.bo,s=t.a_();return t.bj(s,s,r.lng/180*Math.PI),t.aY(s,s,-r.lat/180*Math.PI),t.J(s,s,[0,0,1+i/t.bo]),t.aY(s,s,.5*Math.PI),t.K(s,s,[o,o,o]),s}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.S(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class di{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache();}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Et({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Dt,this._verticalPerspectiveTransform=new ui;}clone(){const e=new di;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians);}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return {mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.b9(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.b9(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const o=this._mercatorTransform.getPitchedTextCorrection(e,i,r),s=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.b9(o,s,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ);}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e);}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e);}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform);}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class _i{get useGlobeControls(){return !0}handlePanInertia(e,i){const r=oi(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,o=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const s=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const a=i.zoom-s;if(0===a)return;const n=t.bk(i.center.lng,o.lng),l=n/(Math.abs(n/180)+1),c=t.bk(i.center.lat,o.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*t.aS(u,h),_=t.bf();t.aM(_,u,[h[0]*d,h[1]*d,h[2]*d]);const p=t.bq(_)-1,m=Math.exp(.5*-Math.max(p-.3,0)),f=ei(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=t.bc(f,.9,.5,1,.25),v=(1-t.aG(-a))*Math.min(m,g),x=i.center.lat,b=i.zoom,y=new t.N(i.center.lng+l*v,t.ab(i.center.lat+c*v,-t.aF,t.aF));i.setLocationAtPoint(o,r);const w=i.center,T=t.bc(Math.abs(n),45,85,0,1),P=t.bc(f,.75,.35,0,1),C=Math.pow(Math.max(T,P),.25),I=t.bk(w.lng,y.lng),E=t.bk(w.lat,y.lat);i.setCenter(new t.N(w.lng+I*C,w.lat+E*C).wrap()),i.setZoom(b+ri(x,i.center.lat));}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,o=t.zoom;t.setCenter(oi(e.panDelta,t).wrap()),t.setZoom(o+ri(r,t.center.lat));}cameraForBoxAndBearing(e,i,r,o,s){const a=Lt(e,i,r,o,s),n=i.left/s.width*2-1,l=(s.width-i.right)/s.width*2-1,c=i.top/s.height*-2+1,h=(s.height-i.bottom)/s.height*-2+1,u=t.bk(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),_=u?r.getWest():r.getEast(),p=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),f=d+.5*t.bk(d,_),g=p+.5*t.bk(p,m),v=s.clone();v.setCenter(a.center),v.setBearing(a.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(a.zoom);const x=v.modelViewProjectionMatrix,b=[Qt(r.getNorthWest()),Qt(r.getNorthEast()),Qt(r.getSouthWest()),Qt(r.getSouthEast()),Qt(new t.N(_,g)),Qt(new t.N(d,g)),Qt(new t.N(f,p)),Qt(new t.N(f,m))],y=Qt(a.center);let w=Number.POSITIVE_INFINITY;for(const e of b)n<0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"x",n))),l>0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"x",l))),c>0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"y",c))),h<0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"y",h)));if(Number.isFinite(w)&&0!==w)return a.zoom=v.zoom+t.a8(w),a;zt();}handleJumpToCenterZoom(e,i){const r=e.center.lat,o=e.getConstrained(i.center?t.N.convert(i.center):e.center,e.zoom).center;e.setCenter(o.wrap());const s=void 0!==i.zoom?+i.zoom:e.zoom+ri(r,o.lat);e.zoom!==s&&e.setZoom(s);}handleEaseTo(e,i){const r=e.zoom,o=e.center,s=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.N.convert(i.center):o,d=e.getConstrained(u,r).center;Ct(e,d);const _=e.clone();_.setCenter(d),_.setZoom(l?+i.zoom:r+ri(o.lat,u.lat)),_.setBearing(i.bearing);const p=new t.P(t.ab(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ab(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));_.setLocationAtPoint(d,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,f=l?+i.zoom:r+ri(o.lat,m.lat),g=r+ri(o.lat,0),v=f+ri(m.lat,0),x=t.bk(o.lng,m.lng),b=t.bk(o.lat,m.lat),y=t.aG(v-g);return h=f!==r,{easeFunc:r=>{if(t.b3(a,n)||At({startEulerAngles:a,endEulerAngles:n,tr:e,k:r,useSlerp:a.roll!=n.roll}),c&&e.interpolatePadding(s,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else {const t=v>g?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-r),s=ai(o,x,b,r*i);e.setCenter(s.wrap());}if(h){const i=t.y.number(g,v,r)+ri(0,e.center.lat);e.setZoom(i);}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.center,s=e.zoom,a=!e.isPaddingEqual(i.padding),n=e.getConstrained(t.N.convert(i.center||i.locationAtOffset),s).center,l=r?+i.zoom:e.zoom+ri(e.center.lat,n.lat),c=e.clone();c.setCenter(n),a&&c.setPadding(i.padding),c.setZoom(l),c.setBearing(i.bearing);const h=new t.P(t.ab(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ab(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));c.setLocationAtPoint(n,h);const u=c.center;Ct(e,u);const d=function(e,i,r){const o=Qt(i),s=Qt(r),a=t.aS(o,s),n=Math.acos(a),l=Yt(e);return n/(2*Math.PI)*l}(e,o,u),_=s+ri(o.lat,0),p=l+ri(u.lat,0),m=t.aG(p-_);let f;if("number"==typeof i.minZoom){const r=+i.minZoom+ri(u.lat,0),o=Math.min(r,_,p)+ri(0,u.lat),s=e.getConstrained(u,o).zoom+ri(u.lat,0);f=t.aG(s-_);}const g=t.bk(o.lng,u.lng),v=t.bk(o.lat,u.lat);return {easeFunc:(i,r,s,a)=>{const n=ai(o,g,v,s),c=1===i?u:n;e.setCenter(c.wrap());const h=_+t.a8(r);e.setZoom(1===i?l:h+ri(0,c.lat));},scaleOfZoom:m,targetCenter:u,scaleOfMinZoom:f,pixelPathLength:d}}static solveVectorScale(e,t,i,r,o){const s="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],a=[i[3],i[7],i[11],i[15]],n=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],l=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],c=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],h=t[0]*a[0]+t[1]*a[1]+t[2]*a[2];return c+o*l===n+o*h||a[3]*(n-c)+s[3]*(h-l)+n*h==c*l?null:(c+s[3]-o*h-o*a[3])/(c-n-o*h+o*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.t(e,i&&i.filter((e=>"source.canvas"!==e.identifier))),fi=t.br();class gi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload();}},this.map=e,this.dispatcher=new B(F(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler("GI",((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new P(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new R(256,512),this.crossTileSymbolIndex=new ht,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bs,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",t.bt()),oe().on(te,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t);}}));}loadURL(e,i={},r){this.fire(new t.k("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const s=this._loadStyleRequest;t.h(o,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,i,r);})).catch((e=>{this._loadStyleRequest=null,e&&!s.signal.aborted&&this.fire(new t.j(e));}));}loadJSON(e,i={},r){this.fire(new t.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r);})).catch((()=>{}));}loadEmpty(){this.fire(new t.k("dataloading",{dataType:"style"})),this._load(fi,{validate:!1});}_load(e,i,r){var o,s;const a=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!mi(this,t.u(a))){this._loaded=!0,this.stylesheet=a;for(const e in a.sources)this.addSource(e,a.sources[e],{validate:!1});a.sprite?this._loadSprite(a.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(a.glyphs),this._createLayers(),this.light=new E(this.stylesheet.light),this._setProjectionInternal((null===(o=this.stylesheet.projection)||void 0===o?void 0:o.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(s=this.stylesheet.terrain)&&void 0!==s?s:null),this.fire(new t.k("data",{dataType:"style"})),this.fire(new t.k("style.load"));}}_createLayers(){const e=t.bu(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.bv(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e;}}_loadSprite(e,i=!1,r=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const s=f(e),n=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of s){const s=i.transformRequest(g(r,n,".json"),"SpriteJSON");l[e]=t.h(s,o);const a=i.transformRequest(g(r,n,".png"),"SpriteImage");c[e]=p.getImage(a,o);}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,(function*(){const t={};for(const r in e){t[r]={};const o=a.getImageCanvasContext((yield i[r]).data),s=(yield e[r]).data;for(const e in s){const{width:i,height:a,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=s[e];t[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:a,x:n,y:l,context:o}};}}return t}))}(l,c)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[t]){const o="default"===t?r:`${t}:${r}`;this._spritesImagesIds[t].push(o),o in this.imageManager.images?this.imageManager.updateImage(o,e[t][r],!1):this.imageManager.addImage(o,e[t][r]),i&&(this._changedImages[o]=!0);}}})).catch((e=>{this._spriteRequest=null,o=e,this.fire(new t.j(o));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.k("data",{dataType:"style"})),r&&r(o);}));}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const o=i.getSource();("geojson"===o.type||o.vectorLayerIds&&-1===o.vectorLayerIds.indexOf(r))&&this.fire(new t.j(new Error(`Source layer "${r}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bw(r):r);const o=[];for(const s of e)if(r[s]){const e=i?t.bw(r[s]):r[s];o.push(e);}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize());}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return !0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return !0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return !0;for(const e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else {if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates();}const r={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const e in r){const i=this.sourceCaches[e];!!r[e]!=!!i.used&&i.fire(new t.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.k("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){var r;this._checkLoaded();const o=this.serialize();if(e=i.transformStyle?i.transformStyle(o,e):e,(null===(r=i.validate)||void 0===r||r)&&mi(this,t.u(e)))return !1;(e=t.bw(e)).layers=t.bu(e.layers);const s=t.bx(o,e),a=this._getOperationsToPerform(s);if(a.unimplemented.length>0)throw new Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(0===a.operations.length)return !1;for(const e of a.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push((()=>this.addLayer.apply(this,r.args)));break;case"removeLayer":t.push((()=>this.removeLayer.apply(this,r.args)));break;case"setPaintProperty":t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case"setLayoutProperty":t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case"setFilter":t.push((()=>this.setFilter.apply(this,r.args)));break;case"addSource":t.push((()=>this.addSource.apply(this,r.args)));break;case"removeSource":t.push((()=>this.removeSource.apply(this,r.args)));break;case"setLayerZoomRange":t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case"setLight":t.push((()=>this.setLight.apply(this,r.args)));break;case"setGeoJSONSourceData":t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case"setGlyphs":t.push((()=>this.setGlyphs.apply(this,r.args)));break;case"setSprite":t.push((()=>this.setSprite.apply(this,r.args)));break;case"setTerrain":t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case"setSky":t.push((()=>this.setSky.apply(this,r.args)));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setTransition":t.push((()=>{}));break;default:i.push(r.command);}return {operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(e,t){this.imageManager.updateImage(e,t);}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.j(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.u.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=this.sourceCaches[e]=new de(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,(()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e}))),o.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.j(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0;}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.j(new Error(`Layer "${o}" already exists on this map.`)));let s;if("custom"===e.type){if(mi(this,t.by(e)))return;s=t.bv(e);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(o,e.source),e=t.bw(e),e=t.e(e,{source:o})),this._validate(t.u.layer,`layers.${o}`,e,{arrayIndex:-1},r))return;s=t.bv(e),this._validateLayer(s),s.setEventedParent(this,{layer:{id:o}});}const a=i?this._order.indexOf(i):this._order.length;if(i&&-1===a)this.fire(new t.j(new Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));else {if(this._order.splice(a,0,o),this._layerOrderChanged=!0,this._layers[o]=s,this._removedLayers[o]&&s.source&&"custom"!==s.type){const e=this._removedLayers[o];delete this._removedLayers[o],e.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",this.sourceCaches[s.source].pause());}this._updateLayer(s),s.onAdd&&s.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.j(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.j(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(e){return this._layers[e]}getLayersOrder(){return [...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!t.bz(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.u.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.bw(i),this._updateLayer(o)))}else this.fire(new t.j(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.bw(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const s=this.getLayer(e);s?t.bz(s.getLayoutProperty(i),r)||(s.setLayoutProperty(i,r,o),this._updateLayer(s)):this.fire(new t.j(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.j(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,r,o={}){this._checkLoaded();const s=this.getLayer(e);s?t.bz(s.getPaintProperty(i),r)||(s.setPaintProperty(i,r,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.j(new Error(`Cannot style non-existing layer "${e}".`)));}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,s=this.sourceCaches[r];if(void 0===s)return void this.fire(new t.j(new Error(`The source '${r}' does not exist in the map's style.`)));const a=s.getSource().type;"geojson"===a&&o?this.fire(new t.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==a||o?(void 0===e.id&&this.fire(new t.j(new Error("The feature id parameter must be provided."))),s.setFeatureState(o,e.id,i)):this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new t.j(new Error(`The source '${r}' does not exist in the map's style.`)));const s=o.getSource().type,a="vector"===s?e.sourceLayer:void 0;"vector"!==s||a?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.j(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(a,e.id,i):this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.sourceCaches[i];if(void 0!==o)return "vector"!==o.getSource().type||r?(void 0===e.id&&this.fire(new t.j(new Error("The feature id parameter must be provided."))),o.getFeatureState(r,e.id)):void this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.j(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bA(this.sourceCaches,(e=>e.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,o=this.stylesheet;return t.bB({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,projection:o.projection,sources:e,layers:i,terrain:r},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s)){i[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=this._order.length-1;s>=0;s--){const a=this._order[s];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of o)t.push(e);}}return function(e,t,i){for(const r in e)for(const o of e[r])G(o,i[t[r].source]);return e}(n,e,i)}(this._layers,a,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.u.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],o={};for(let e=0;ee.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);s=s||r;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.now(),e.zoom))&&(this.pauseablePlacement=new st(e,this.map.terrain,this._order,o,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.now()),n=!0),s&&this.pauseablePlacement.placement.setStale()),n||s)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles();}getImages(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e}))}getGlyphs(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.u.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}addSprite(e,i,r={},o){this._checkLoaded();const s=[{id:e,url:i}],a=[...f(this.stylesheet.sprite),...s];this._validate(t.u.sprite,"sprite",a,null,r)||(this.stylesheet.sprite=a,this._loadSprite(s,!0,o));}removeSprite(e){this._checkLoaded();const i=f(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}else this.fire(new t.j(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return f(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.u.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)));}}var vi=t.aA([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class xi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(e,t,i,r,o,s,a,n,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.b4.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:s?0:r?r.calculateFogBlendOpacity(o):0,u_horizon_color:r?r.properties.get("horizon-color"):t.b4.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:s?1:0}),yi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function wi(e){const t=[];for(let i=0;i({u_depth:new t.bC(e,i.u_depth),u_terrain:new t.bC(e,i.u_terrain),u_terrain_dim:new t.b5(e,i.u_terrain_dim),u_terrain_matrix:new t.bD(e,i.u_terrain_matrix),u_terrain_unpack:new t.bE(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.b5(e,i.u_terrain_exaggeration)}))(e,P),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bD(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bE(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bE(e,i.u_projection_clipping_plane),u_projection_transition:new t.b5(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bD(e,i.u_projection_fallback_matrix)}))(e,P),this.binderUniforms=r?r.getUniforms(e,P):[];}draw(e,t,i,r,o,s,a,n,l,c,h,u,d,_,p,m,f,g,v){const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(o),e.setCullFace(s),n){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,n.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,n.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(n[e]);}if(l)for(const e in l)this.projectionUniforms[yi[e]].set(l[e]);if(a)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(a[e]);m&&m.setUniforms(e,this.binderUniforms,_,{zoom:p});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1;}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new xi)).bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,f,g,v),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2);}}}function Pi(e,i,r){const o=1/t.at(r,1,i.transform.tileZoom),s=Math.pow(2,r.tileID.overscaledZ),a=r.tileSize*Math.pow(2,i.transform.tileZoom)/s,n=a*(r.tileID.canonical.x+r.tileID.wrap*s),l=a*r.tileID.canonical.y;return {u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[o,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}const Ci=(e,i,r,o)=>{const s=e.style.light,a=s.properties.get("position"),n=[a.x,a.y,a.z],l=t.bI();"viewport"===s.properties.get("anchor")&&t.bJ(l,e.transform.bearingInRadians),t.bK(n,n,l);const c=e.transform.transformLightDirection(n),h=s.properties.get("color");return {u_lightpos:n,u_lightpos_globe:c,u_lightintensity:s.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:o}},Ii=(e,i,r,o,s,a,n)=>t.e(Ci(e,i,r,o),Pi(a,e,n),{u_height_factor:-Math.pow(2,s.overscaledZ)/n.tileSize/8}),Ei=(e,i,r,o)=>t.e(Pi(i,e,r),{u_fill_translate:o}),Mi=(e,t)=>({u_world:e,u_fill_translate:t}),Si=(e,i,r,o,s)=>t.e(Ei(e,i,r,s),{u_world:o}),Ri=(e,i,r,o,s)=>{const a=e.transform;let n,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.at(i,1,a.zoom);n=!0,l=[e,e],c=e/(t.X*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*s;}else n=!1,l=a.pixelsToGLUnits;return {u_camera_to_center_distance:a.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:o}},Di=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),zi=e=>({u_viewport_size:[e.width,e.height]}),Ai=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Li=(e,i,r,o)=>{const s=t.at(e,1,i)/(t.X*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*o;return {u_extrude_scale:t.at(e,1,i),u_intensity:r,u_globe_extrude_scale:s}},ki=(e,i,r,o)=>{const s=t.H();t.bL(s,0,e.width,e.height,0,0,1);const a=e.context.gl;return {u_matrix:s,u_world:[a.drawingBufferWidth,a.drawingBufferHeight],u_image:r,u_color_ramp:o,u_opacity:i.paint.get("heatmap-opacity")}},Fi=(e,t,i)=>{const r=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);return "viewport"===i.paint.get("hillshade-illumination-anchor")&&(a+=e.transform.bearingInRadians),{u_image:0,u_latrange:ji(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:r,u_highlight:o,u_accent:s}},Bi=(e,i)=>{const r=i.stride,o=t.H();return t.bL(o,0,t.X,-t.X,0,0,1),t.J(o,o,[0,-t.X,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function ji(e,i){const r=Math.pow(2,i.canonical.z),o=i.canonical.y;return [new t.Y(0,o/r).toLngLat().lat,new t.Y(0,(o+1)/r).toLngLat().lat]}const Oi=(e,i,r,o)=>{const s=e.transform;return {u_translation:Vi(e,i,r),u_ratio:o/t.at(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Ni=(e,i,r,o,s)=>t.e(Oi(e,i,r,o),{u_image:0,u_image_height:s}),Zi=(e,i,r,o,s)=>{const a=e.transform,n=Ui(i,a);return {u_translation:Vi(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:o/t.at(i,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[n,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Gi=(e,i,r,o,s,a)=>{const n=e.lineAtlas,l=Ui(i,e.transform),c="round"===r.layout.get("line-cap"),h=n.getDash(s.from,c),u=n.getDash(s.to,c),d=h.width*a.fromScale,_=u.width*a.toScale;return t.e(Oi(e,i,r,o),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:a.t})};function Ui(e,i){return 1/t.at(e,1,i.tileZoom)}function Vi(e,i,r){return t.au(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const qi=(e,t,i,r,o)=>{return {u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(a=r.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=r.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:Hi(r.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]};var s,a;};function Hi(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Wi=(e,t,i,r,o,s,a,n,l,c,h,u,d)=>{const _=a.transform;return {u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_pitch:_.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:a.options.fadeDuration?a.symbolFadeChange:1,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:o,u_is_variable_anchor:s,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},Xi=(e,i,r,o,s,a,n,l,c,h,u,d,_,p)=>{const m=n.transform;return t.e(Wi(e,i,r,o,s,a,n,l,c,h,u,d,p),{u_gamma_scale:o?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:+_})},$i=(e,i,r,o,s,a,n,l,c,h,u,d,_)=>t.e(Xi(e,i,r,o,s,a,n,l,c,h,!0,u,!0,_),{u_texsize_icon:d,u_texture_icon:1}),Ki=(e,t)=>({u_opacity:e,u_color:t}),Yi=(e,i,r,o,s)=>t.e(function(e,i,r,o){const s=r.imageManager.getPattern(e.from.toString()),a=r.imageManager.getPattern(e.to.toString()),{width:n,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(o.tileID.canonical.x+o.tileID.wrap*c),d=h*o.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.at(o,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,s,i,o),{u_opacity:e}),Ji=(e,t)=>{},Qi={fillExtrusion:(e,i)=>({u_lightpos:new t.bG(e,i.u_lightpos),u_lightpos_globe:new t.bG(e,i.u_lightpos_globe),u_lightintensity:new t.b5(e,i.u_lightintensity),u_lightcolor:new t.bG(e,i.u_lightcolor),u_vertical_gradient:new t.b5(e,i.u_vertical_gradient),u_opacity:new t.b5(e,i.u_opacity),u_fill_translate:new t.bH(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bG(e,i.u_lightpos),u_lightpos_globe:new t.bG(e,i.u_lightpos_globe),u_lightintensity:new t.b5(e,i.u_lightintensity),u_lightcolor:new t.bG(e,i.u_lightcolor),u_vertical_gradient:new t.b5(e,i.u_vertical_gradient),u_height_factor:new t.b5(e,i.u_height_factor),u_opacity:new t.b5(e,i.u_opacity),u_fill_translate:new t.bH(e,i.u_fill_translate),u_image:new t.bC(e,i.u_image),u_texsize:new t.bH(e,i.u_texsize),u_pixel_coord_upper:new t.bH(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bH(e,i.u_pixel_coord_lower),u_scale:new t.bG(e,i.u_scale),u_fade:new t.b5(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bH(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bC(e,i.u_image),u_texsize:new t.bH(e,i.u_texsize),u_pixel_coord_upper:new t.bH(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bH(e,i.u_pixel_coord_lower),u_scale:new t.bG(e,i.u_scale),u_fade:new t.b5(e,i.u_fade),u_fill_translate:new t.bH(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bH(e,i.u_world),u_fill_translate:new t.bH(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bH(e,i.u_world),u_image:new t.bC(e,i.u_image),u_texsize:new t.bH(e,i.u_texsize),u_pixel_coord_upper:new t.bH(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bH(e,i.u_pixel_coord_lower),u_scale:new t.bG(e,i.u_scale),u_fade:new t.b5(e,i.u_fade),u_fill_translate:new t.bH(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.b5(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bC(e,i.u_scale_with_map),u_pitch_with_map:new t.bC(e,i.u_pitch_with_map),u_extrude_scale:new t.bH(e,i.u_extrude_scale),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.b5(e,i.u_globe_extrude_scale),u_translate:new t.bH(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bH(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bH(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bF(e,i.u_color),u_overlay:new t.bC(e,i.u_overlay),u_overlay_scale:new t.b5(e,i.u_overlay_scale)}),depth:Ji,clippingMask:Ji,heatmap:(e,i)=>({u_extrude_scale:new t.b5(e,i.u_extrude_scale),u_intensity:new t.b5(e,i.u_intensity),u_globe_extrude_scale:new t.b5(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bD(e,i.u_matrix),u_world:new t.bH(e,i.u_world),u_image:new t.bC(e,i.u_image),u_color_ramp:new t.bC(e,i.u_color_ramp),u_opacity:new t.b5(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bC(e,i.u_image),u_latrange:new t.bH(e,i.u_latrange),u_light:new t.bH(e,i.u_light),u_shadow:new t.bF(e,i.u_shadow),u_highlight:new t.bF(e,i.u_highlight),u_accent:new t.bF(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bD(e,i.u_matrix),u_image:new t.bC(e,i.u_image),u_dimension:new t.bH(e,i.u_dimension),u_zoom:new t.b5(e,i.u_zoom),u_unpack:new t.bE(e,i.u_unpack)}),line:(e,i)=>({u_translation:new t.bH(e,i.u_translation),u_ratio:new t.b5(e,i.u_ratio),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bH(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bH(e,i.u_translation),u_ratio:new t.b5(e,i.u_ratio),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bH(e,i.u_units_to_pixels),u_image:new t.bC(e,i.u_image),u_image_height:new t.b5(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bH(e,i.u_translation),u_texsize:new t.bH(e,i.u_texsize),u_ratio:new t.b5(e,i.u_ratio),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_image:new t.bC(e,i.u_image),u_units_to_pixels:new t.bH(e,i.u_units_to_pixels),u_scale:new t.bG(e,i.u_scale),u_fade:new t.b5(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bH(e,i.u_translation),u_ratio:new t.b5(e,i.u_ratio),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bH(e,i.u_units_to_pixels),u_patternscale_a:new t.bH(e,i.u_patternscale_a),u_patternscale_b:new t.bH(e,i.u_patternscale_b),u_sdfgamma:new t.b5(e,i.u_sdfgamma),u_image:new t.bC(e,i.u_image),u_tex_y_a:new t.b5(e,i.u_tex_y_a),u_tex_y_b:new t.b5(e,i.u_tex_y_b),u_mix:new t.b5(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bH(e,i.u_tl_parent),u_scale_parent:new t.b5(e,i.u_scale_parent),u_buffer_scale:new t.b5(e,i.u_buffer_scale),u_fade_t:new t.b5(e,i.u_fade_t),u_opacity:new t.b5(e,i.u_opacity),u_image0:new t.bC(e,i.u_image0),u_image1:new t.bC(e,i.u_image1),u_brightness_low:new t.b5(e,i.u_brightness_low),u_brightness_high:new t.b5(e,i.u_brightness_high),u_saturation_factor:new t.b5(e,i.u_saturation_factor),u_contrast_factor:new t.b5(e,i.u_contrast_factor),u_spin_weights:new t.bG(e,i.u_spin_weights),u_coords_top:new t.bE(e,i.u_coords_top),u_coords_bottom:new t.bE(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bC(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bC(e,i.u_is_size_feature_constant),u_size_t:new t.b5(e,i.u_size_t),u_size:new t.b5(e,i.u_size),u_camera_to_center_distance:new t.b5(e,i.u_camera_to_center_distance),u_pitch:new t.b5(e,i.u_pitch),u_rotate_symbol:new t.bC(e,i.u_rotate_symbol),u_aspect_ratio:new t.b5(e,i.u_aspect_ratio),u_fade_change:new t.b5(e,i.u_fade_change),u_label_plane_matrix:new t.bD(e,i.u_label_plane_matrix),u_coord_matrix:new t.bD(e,i.u_coord_matrix),u_is_text:new t.bC(e,i.u_is_text),u_pitch_with_map:new t.bC(e,i.u_pitch_with_map),u_is_along_line:new t.bC(e,i.u_is_along_line),u_is_variable_anchor:new t.bC(e,i.u_is_variable_anchor),u_texsize:new t.bH(e,i.u_texsize),u_texture:new t.bC(e,i.u_texture),u_translation:new t.bH(e,i.u_translation),u_pitched_scale:new t.b5(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bC(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bC(e,i.u_is_size_feature_constant),u_size_t:new t.b5(e,i.u_size_t),u_size:new t.b5(e,i.u_size),u_camera_to_center_distance:new t.b5(e,i.u_camera_to_center_distance),u_pitch:new t.b5(e,i.u_pitch),u_rotate_symbol:new t.bC(e,i.u_rotate_symbol),u_aspect_ratio:new t.b5(e,i.u_aspect_ratio),u_fade_change:new t.b5(e,i.u_fade_change),u_label_plane_matrix:new t.bD(e,i.u_label_plane_matrix),u_coord_matrix:new t.bD(e,i.u_coord_matrix),u_is_text:new t.bC(e,i.u_is_text),u_pitch_with_map:new t.bC(e,i.u_pitch_with_map),u_is_along_line:new t.bC(e,i.u_is_along_line),u_is_variable_anchor:new t.bC(e,i.u_is_variable_anchor),u_texsize:new t.bH(e,i.u_texsize),u_texture:new t.bC(e,i.u_texture),u_gamma_scale:new t.b5(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_is_halo:new t.bC(e,i.u_is_halo),u_translation:new t.bH(e,i.u_translation),u_pitched_scale:new t.b5(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bC(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bC(e,i.u_is_size_feature_constant),u_size_t:new t.b5(e,i.u_size_t),u_size:new t.b5(e,i.u_size),u_camera_to_center_distance:new t.b5(e,i.u_camera_to_center_distance),u_pitch:new t.b5(e,i.u_pitch),u_rotate_symbol:new t.bC(e,i.u_rotate_symbol),u_aspect_ratio:new t.b5(e,i.u_aspect_ratio),u_fade_change:new t.b5(e,i.u_fade_change),u_label_plane_matrix:new t.bD(e,i.u_label_plane_matrix),u_coord_matrix:new t.bD(e,i.u_coord_matrix),u_is_text:new t.bC(e,i.u_is_text),u_pitch_with_map:new t.bC(e,i.u_pitch_with_map),u_is_along_line:new t.bC(e,i.u_is_along_line),u_is_variable_anchor:new t.bC(e,i.u_is_variable_anchor),u_texsize:new t.bH(e,i.u_texsize),u_texsize_icon:new t.bH(e,i.u_texsize_icon),u_texture:new t.bC(e,i.u_texture),u_texture_icon:new t.bC(e,i.u_texture_icon),u_gamma_scale:new t.b5(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_is_halo:new t.bC(e,i.u_is_halo),u_translation:new t.bH(e,i.u_translation),u_pitched_scale:new t.b5(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.b5(e,i.u_opacity),u_color:new t.bF(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.b5(e,i.u_opacity),u_image:new t.bC(e,i.u_image),u_pattern_tl_a:new t.bH(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bH(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bH(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bH(e,i.u_pattern_br_b),u_texsize:new t.bH(e,i.u_texsize),u_mix:new t.b5(e,i.u_mix),u_pattern_size_a:new t.bH(e,i.u_pattern_size_a),u_pattern_size_b:new t.bH(e,i.u_pattern_size_b),u_scale_a:new t.b5(e,i.u_scale_a),u_scale_b:new t.b5(e,i.u_scale_b),u_pixel_coord_upper:new t.bH(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bH(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.b5(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bC(e,i.u_texture),u_ele_delta:new t.b5(e,i.u_ele_delta),u_fog_matrix:new t.bD(e,i.u_fog_matrix),u_fog_color:new t.bF(e,i.u_fog_color),u_fog_ground_blend:new t.b5(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.b5(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bF(e,i.u_horizon_color),u_horizon_fog_blend:new t.b5(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.b5(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.b5(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bC(e,i.u_texture),u_terrain_coords_id:new t.b5(e,i.u_terrain_coords_id),u_ele_delta:new t.b5(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.b5(e,i.u_input),u_output_expected:new t.b5(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bG(e,i.u_sun_pos),u_atmosphere_blend:new t.b5(e,i.u_atmosphere_blend),u_globe_position:new t.bG(e,i.u_globe_position),u_globe_radius:new t.b5(e,i.u_globe_radius),u_inv_proj_matrix:new t.bD(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bF(e,i.u_sky_color),u_horizon_color:new t.bF(e,i.u_horizon_color),u_horizon:new t.bH(e,i.u_horizon),u_horizon_normal:new t.bH(e,i.u_horizon_normal),u_sky_horizon_blend:new t.b5(e,i.u_sky_horizon_blend),u_sky_blend:new t.b5(e,i.u_sky_blend)})};class er{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const tr={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ir{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const o=e.gl;this.buffer=o.createBuffer(),e.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&(h.push({circleArray:f,circleOffset:d,coord:_}),u+=f.length/4,d=u),m&&c.draw(a,l.LINES,Ot.disabled,Zt.disabled,e.colorModeForRenderPass(),jt.disabled,Di(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(_),n.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer);}if(!s||!h.length)return;const _=e.useProgram("collisionCircle"),p=new t.bM;p.resize(4*u),p._trim();let m=0;for(const e of h)for(let t=0;t=0&&(f[g.associatedIconIndex]={shiftedAnchor:M,angle:S});}else Be(g.numGlyphs,p);}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");Pe(c,e,s,j,O,v,h,i,l.toUnwrapped(),f.width,f.height,Z,t);}const q=s&&P||V,H=x||q?Vr:v?j:e.transform.clipSpaceToPixelsMatrix,W=p&&0!==r.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);let X;X=p?c.iconsInText?$i(T.kind,S,b,v,x,q,e,H,N,Z,D,k,I):Xi(T.kind,S,b,v,x,q,e,H,N,Z,s,D,!0,I):Wi(T.kind,S,b,v,x,q,e,H,N,Z,s,D,I);const $={program:M,buffers:u,uniformValues:X,projectionData:G,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:A,atlasInterpolationIcon:L,isSDF:p,hasHalo:W};if(y&&c.canOverlap){w=!0;const e=u.segments.get();for(const i of e)C.push({segments:new t.aD([i]),sortKey:i.sortKey,state:$,terrainData:R});}else C.push({segments:u.segments,sortKey:0,state:$,terrainData:R});}w&&C.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of C){const i=t.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,Kr(i.buffers,t.segments,r,e,i.program,T,u,d,o,i.projectionData,t.terrainData)),o.u_is_halo=0;}Kr(i.buffers,t.segments,r,e,i.program,T,u,d,i.uniformValues,i.projectionData,t.terrainData);}}function Kr(e,t,i,r,o,s,a,n,l,c,h){const u=r.context;o.draw(u,u.gl.TRIANGLES,s,a,n,jt.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer);}function Yr(e,i,r,o,s){const a=e.context,n=a.gl,l=Zt.disabled,c=new Ft([n.ONE,n.ONE],t.b4.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=o.key;let d=r.heatmapFbos.get(u);d||(d=Qr(a,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),a.bindFramebuffer.set(d.framebuffer),a.viewport.set([0,0,i.tileSize,i.tileSize]),a.clear({color:t.b4.transparent});const _=h.programConfigurations.get(r.id),p=e.useProgram("heatmap",_,!s),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),f=e.style.map.terrain.getTerrainData(o);p.draw(a,n.TRIANGLES,Ot.disabled,l,c,jt.disabled,Li(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),f,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,_);}function Jr(e,t,i,r,o){const s=e.context,a=s.gl,n=e.transform;s.setColorMode(e.colorModeForRenderPass());const l=eo(s,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,h.colorAttachment.get()),s.activeTexture.set(a.TEXTURE1),l.bind(a.LINEAR,a.CLAMP_TO_EDGE);const u=n.getProjectionData({overscaledTileID:i,applyTerrainMatrix:o,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(s,a.TRIANGLES,Ot.disabled,Zt.disabled,e.colorModeForRenderPass(),jt.disabled,ki(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,n.zoom),h.destroy(),t.heatmapFbos.delete(c);}function Qr(e,t,i){var r,o;const s=e.gl,a=s.createTexture();s.bindTexture(s.TEXTURE_2D,a),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR);const n=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:s.UNSIGNED_BYTE,l=null!==(o=e.RGBA16F)&&void 0!==o?o:s.RGBA;s.texImage2D(s.TEXTURE_2D,0,l,t,i,0,s.RGBA,n,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(a),c}function eo(e,t){return t.colorRampTexture||(t.colorRampTexture=new v(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function to(e,t,i,r,o){if(!i||!r||!r.imageAtlas)return;const s=r.imageAtlas.patternPositions;let a=s[i.to.toString()],n=s[i.from.toString()];if(!a&&n&&(a=n),!n&&a&&(n=a),!a||!n){const e=o.getPaintProperty(t);a=s[e],n=s[e];}a&&n&&e.setConstantPatternPositions(a,n);}function io(e,i,r,o,s,a,n,l){const c=e.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),_=r.getCrossfadeParameters();let p,m,f,g,v;const x=e.transform,b=r.paint.get("fill-translate"),y=r.paint.get("fill-translate-anchor");n?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=c.LINES):(m=d?"fillPattern":"fill",p=c.TRIANGLES);const w=u.constantOr(null);for(const u of o){const T=i.getTile(u);if(d&&!T.patternsLoaded())continue;const P=T.getBucket(r);if(!P)continue;const C=P.programConfigurations.get(r.id),I=e.useProgram(m,C),E=e.style.map.terrain&&e.style.map.terrain.getTerrainData(u);d&&(e.context.activeTexture.set(c.TEXTURE0),T.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),C.updatePaintBuffers(_)),to(C,h,w,T,r);const M=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),S=t.au(x,T,b,y);if(n){g=P.indexBuffer2,v=P.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];f="fillOutlinePattern"===m&&d?Si(e,_,T,t,S):Mi(t,S);}else g=P.indexBuffer,v=P.segments,f=d?Ei(e,_,T,S):{u_fill_translate:S};let R;if("translucent"===e.renderPass&&l){const[t]=e.getStencilConfigForOverlapAndUpdateStencilID(o);R=t[u.overscaledZ];}else R=e.stencilModeForClipping(u);I.draw(e.context,p,s,R,a,jt.backCCW,f,E,M,r.id,P.layoutVertexBuffer,g,v,r.paint,e.transform.zoom,C);}}function ro(e,i,r,o,s,a,n,l){const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),_=d.constantOr(1),p=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),f=d.constantOr(null),g=e.transform;for(const d of o){const o=i.getTile(d),v=o.getBucket(r);if(!v)continue;const x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),b=v.programConfigurations.get(r.id),y=e.useProgram(_?"fillExtrusionPattern":"fillExtrusion",b);_&&(e.context.activeTexture.set(h.TEXTURE0),o.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const w=g.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});to(b,u,f,o,r);const T=t.au(g,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),C=_?Ii(e,P,m,T,d,p,o):Ci(e,P,m,T);y.draw(c,c.gl.TRIANGLES,s,a,n,jt.backCCW,C,x,w,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer);}}function oo(e,t,i,r,o,s,a,n,l){var c;const h=e.style.projection,u=e.context,d=e.transform,_=u.gl,p=e.useProgram("hillshade"),m=!e.options.moving;for(const f of r){const r=t.getTile(f),g=r.fbo;if(!g)continue;const v=h.getMeshFromTileID(u,f.canonical,n,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);u.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,g.colorAttachment.get());const b=d.getProjectionData({overscaledTileID:f,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(u,_.TRIANGLES,s,o[f.overscaledZ],a,jt.backCCW,Fi(e,r,i),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments);}}const so=[new t.P(0,0),new t.P(t.X,0),new t.P(t.X,t.X),new t.P(0,t.X)];function ao(e,t,i,r,o,s,a,n,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=e.context,d=u.gl,_=e.useProgram("raster"),p=e.transform,m=e.style.projection,f=e.colorModeForRenderPass(),g=!e.options.moving;for(const v of r){const r=e.getDepthModeForSublayer(v.overscaledZ-h,1===i.paint.get("raster-opacity")?Ot.ReadWrite:Ot.ReadOnly,d.LESS),x=t.getTile(v);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const b=t.findLoadedParent(v,0),y=t.findLoadedSibling(v),w=no(x,b||y||null,t,i,e.transform,e.style.map.terrain);let T,P;const C="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),b?(b.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,b.tileID.overscaledZ-x.tileID.overscaledZ),P=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),E=p.getProjectionData({overscaledTileID:v,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),M=qi(P||[0,0],T||1,w,i,n),S=m.getMeshFromTileID(u,v.canonical,s,a,"raster");_.draw(u,d.TRIANGLES,r,o?o[v.overscaledZ]:Zt.disabled,f,l?jt.frontCCW:jt.backCCW,M,I,E,i.id,S.vertexBuffer,S.indexBuffer,S.segments);}}function no(e,i,r,o,s,n){const l=o.paint.get("raster-fade-duration");if(!n&&l>0){const o=a.now(),n=(o-e.timeAdded)/l,c=i?(o-i.timeAdded)/l:-1,h=r.getSource(),u=he(s,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),_=d&&e.refreshedUponExpiration?1:t.ab(d?n:1-c,0,1);return e.refreshedUponExpiration&&n>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-_}:{opacity:_,mix:0}}return {opacity:1,mix:0}}const lo=new t.b4(1,0,0,1),co=new t.b4(0,1,0,1),ho=new t.b4(0,0,1,1),uo=new t.b4(1,0,1,1),_o=new t.b4(0,1,1,1);function po(e,t,i,r){fo(e,0,t+i/2,e.transform.width,i,r);}function mo(e,t,i,r){fo(e,t-i/2,0,i,e.transform.height,r);}function fo(e,t,i,r,o,s){const a=e.context,n=a.gl;n.enable(n.SCISSOR_TEST),n.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,o*e.pixelRatio),a.clear({color:s}),n.disable(n.SCISSOR_TEST);}function go(e,i,r){const o=e.context,s=o.gl,a=e.useProgram("debug"),n=Ot.disabled,l=Zt.disabled,c=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);o.activeTexture.set(s.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,_=Math.floor((d&&d.byteLength||0)/1024),p=i.getTile(r).tileSize,m=512/Math.min(p,512)*(r.overscaledZ/e.transform.zoom)*.5;let f=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(f+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,o=e.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(t,5,5),o.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,`${f} ${_}kB`);const g=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(o,s.TRIANGLES,n,l,Ft.alphaBlended,jt.disabled,Ai(t.b4.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),a.draw(o,s.LINE_STRIP,n,l,c,jt.disabled,Ai(t.b4.red),u,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function vo(e,t,i,r){const{isRenderingGlobe:o}=r,s=e.context,a=s.gl,n=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");s.bindFramebuffer.set(null),s.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),u=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,u.texture);const _=t.getMeshFrameDelta(n.zoom),p=n.calculateFogMatrix(r.tileID.toUnwrapped()),m=bi(_,p,e.style.sky,n.pitch,o),f=n.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(s,a.TRIANGLES,c,Zt.disabled,l,jt.backCCW,m,d,f,"terrain",i.vertexBuffer,i.indexBuffer,i.segments);}}function xo(e,i){if(!i.mesh){const r=new t.aC;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const o=new t.aE;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),i.mesh=new pt(e.createVertexBuffer(r,mt.members),e.createIndexBuffer(o),t.aD.simpleSegment(0,0,r.length,o.length));}return i.mesh}class bo{constructor(e,i){this.context=new Zr(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.aq(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=de.maxUnderzooming+de.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ht;}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize();}setup(){const e=this.context,i=new t.aC;i.emplaceBack(0,0),i.emplaceBack(t.X,0),i.emplaceBack(0,t.X),i.emplaceBack(t.X,t.X),this.tileExtentBuffer=e.createVertexBuffer(i,mt.members),this.tileExtentSegments=t.aD.simpleSegment(0,0,4,2);const r=new t.aC;r.emplaceBack(0,0),r.emplaceBack(t.X,0),r.emplaceBack(0,t.X),r.emplaceBack(t.X,t.X),this.debugBuffer=e.createVertexBuffer(r,mt.members),this.debugSegments=t.aD.simpleSegment(0,0,4,5);const o=new t.bT;o.emplaceBack(0,0,0,0),o.emplaceBack(t.X,0,t.X,0),o.emplaceBack(0,t.X,0,t.X),o.emplaceBack(t.X,t.X,t.X,t.X),this.rasterBoundsBuffer=e.createVertexBuffer(o,vi.members),this.rasterBoundsSegments=t.aD.simpleSegment(0,0,4,2);const s=new t.aC;s.emplaceBack(0,0),s.emplaceBack(t.X,0),s.emplaceBack(0,t.X),s.emplaceBack(t.X,t.X),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(s,mt.members),this.rasterBoundsSegmentsPosOnly=t.aD.simpleSegment(0,0,4,5);const a=new t.aC;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(a,mt.members),this.viewportSegments=t.aD.simpleSegment(0,0,4,2);const n=new t.bU;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);const l=new t.aE;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Zt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new pt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.H();t.bL(r,0,this.width,this.height,0,0,1),t.K(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const o={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,Ot.disabled,this.stencilClearMode,Ft.disabled,jt.disabled,null,null,o,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Ft.disabled),r.setDepthMode(Ot.disabled);const o={};for(const e of t)o[e.key]=this.nextStencilID++;this._renderTileMasks(o,t,i,!0),this._renderTileMasks(o,t,i,!1),this._tileClippingMaskIDs=o;}_renderTileMasks(e,t,i,r){const o=this.context,s=o.gl,a=this.style.projection,n=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=a.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=n.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});l.draw(o,s.TRIANGLES,Ot.disabled,new Zt({func:s.ALWAYS,mask:0},t,255,s.KEEP,s.KEEP,s.REPLACE),Ft.disabled,i?jt.disabled:jt.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments);}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,o=this.useProgram("depth"),s=this.getDepthModeFor3D(),a=ue(r,{tileSize:r.tileSize});for(const n of a){const a=this.style.map.terrain&&this.style.map.terrain.getTerrainData(n),l=i.getMeshFromTileID(this.context,n.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(e,t.TRIANGLES,s,Zt.disabled,Ft.disabled,jt.backCCW,null,a,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Zt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Zt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(this.clearStencil(),o>1){const e={},s={};for(let i=0;i0};for(const e in n){const t=n[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse();}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.b4.black:t.b4.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,o=((e,t,i)=>{const r=Math.cos(t.rollInRadians),o=Math.sin(t.rollInRadians),s=yt(t),a=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return {u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-s*o)*i,(t.height/2+s*r)*i],u_horizon_normal:[-o,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:a}})(t,e.style.map.transform,e.pixelRatio),s=new Ot(r.LEQUAL,Ot.ReadWrite,[0,1]),a=Zt.disabled,n=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=xo(i,t);l.draw(i,r.TRIANGLES,s,a,n,jt.disabled,o,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments);}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[s[this.currentLayer]],t=n[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,u);}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:o}))(c,u,[p[0],p[1],p[2]],d,_),f=xo(o,i);a.draw(o,s.TRIANGLES,n,Zt.disabled,Ft.alphaBlended,jt.disabled,m,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments);}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[])),o=r.filter((e=>"vector"===e.getSource().type)),s=r.filter((e=>"vector"!==e.getSource().type)),a=e=>{(!i||i.getSource().maxzooma(e))),i||s.forEach((e=>a(e))),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;ru.getElevation(s,e,t):null;Wr(a,d,_,c,h,f,i,p,g,t.au(h,e,n,l),s.toUnwrapped(),r);}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),s),0!==r.paint.get("icon-opacity").constantOr(1)&&$r(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,n),0!==r.paint.get("text-opacity").constantOr(1)&&$r(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,n),i.map.showCollisionBoxes&&(Ur(e,i,r,o,!0),Ur(e,i,r,o,!1));}(e,i,r,o,this.style.placement.variableOffsets,s):t.bZ(r)?function(e,i,r,o,s){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:a}=s,n=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===n.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,_=e.transform,p=e.getDepthModeForSublayer(0,Ot.ReadOnly),m=Zt.disabled,f=e.colorModeForRenderPass(),g=[],v=_.getCircleRadiusCorrection();for(let s=0;se.sortKey-t.sortKey));for(const t of g){const{programConfiguration:i,program:o,layoutVertexBuffer:s,indexBuffer:a,uniformValues:n,terrainData:l,projectionData:c}=t.state;o.draw(u,d.TRIANGLES,p,m,f,jt.backCCW,n,l,c,r.id,s,a,t.segments,r.paint,e.transform.zoom,i);}}(e,i,r,o,s):t.b_(r)?function(e,i,r,o,s){if(0===r.paint.get("heatmap-opacity"))return;const a=e.context,{isRenderingToTexture:n,isRenderingGlobe:l}=s;if(e.style.map.terrain){for(const t of o){const o=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?Yr(e,o,r,t,l):"translucent"===e.renderPass&&Jr(e,r,t,n,l));}a.viewport.set([0,0,e.width,e.height]);}else "offscreen"===e.renderPass?function(e,i,r,o){const s=e.context,a=s.gl,n=e.transform,l=Zt.disabled,c=new Ft([a.ONE,a.ONE],t.b4.transparent,[!0,!0,!0,!0]);((function(e,i,r){const o=e.gl;e.activeTexture.set(o.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let s=r.heatmapFbos.get(t.bP);s?(o.bindTexture(o.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)):(s=Qr(e,i.width/4,i.height/4),r.heatmapFbos.set(t.bP,s));}))(s,e,r),s.clear({color:t.b4.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return !1;if(!e.from||!e.to)return !0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return !t||!i}useProgram(e,t,i=!1){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,s=e+(t?t.cacheKey:"")+`/${i?gt:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"");return this.cache[s]||(this.cache[s]=new Ti(this.context,dt[e],t,Qi[e],this._showOverdrawInspector,r,i?dt.projectionMercator:o.shaderPreludeCode,i?ft:o.shaderDefine)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new v(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function yo(e,t){let i,r=!1,o=null,s=null;const a=()=>{o=null,r&&(e.apply(s,i),o=setTimeout(a,t),r=!1);};return (...e)=>(r=!0,s=this,i=e,o||a(),o)}class wo{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return !1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e);},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let o=window.location.href.replace(/(#.+)?$/,r);o=o.replace("&&","&"),window.history.replaceState(window.history.state,null,o);},this._updateHash=yo(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e);}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),s=Math.round(t.lng*o)/o,a=Math.round(t.lat*o)/o,n=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${s}/${a}/${i}`:`${i}/${a}/${s}`,(n||l)&&(c+="/"+Math.round(10*n)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return `#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return !1;try{new t.N(+e[2],+e[1]);}catch(e){return !1}const i=+e[0],r=+(e[3]||0),o=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=0&&r<=180&&o>=this._map.getMinPitch()&&o<=this._map.getMaxPitch()}}const To={linearity:.3,easing:t.c6(0,0,.3,1)},Po=t.e({deceleration:2500,maxSpeed:1400},To),Co=t.e({deceleration:20,maxSpeed:1400},To),Io=t.e({deceleration:1e3,maxSpeed:360},To),Eo=t.e({deceleration:1e3,maxSpeed:90},To),Mo=t.e({deceleration:1e3,maxSpeed:360},To);class So{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=a.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const s=Do(i.pan.mag(),r,t.e({},Po,e||{})),a=i.pan.mult(s.amount/i.pan.mag()),n=this._map.cameraHelper.handlePanInertia(a,this._map.transform);o.center=n.easingCenter,o.offset=n.easingOffset,Ro(o,s);}if(i.zoom){const e=Do(i.zoom,r,Co);o.zoom=this._map.transform.zoom+e.amount,Ro(o,e);}if(i.bearing){const e=Do(i.bearing,r,Io);o.bearing=this._map.transform.bearing+t.ab(e.amount,-179,179),Ro(o,e);}if(i.pitch){const e=Do(i.pitch,r,Eo);o.pitch=this._map.transform.pitch+e.amount,Ro(o,e);}if(i.roll){const e=Do(i.roll,r,Mo);o.roll=this._map.transform.roll+t.ab(e.amount,-179,179),Ro(o,e);}if(o.zoom||o.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;o.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),t.e(o,{noMoveStart:!0})}}function Ro(e,t){(!e.duration||e.durationi.unproject(e))),l=s.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:s,point:l,lngLats:a,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1;}}class Lo extends t.k{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class ko{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){delete this._mousedownPos;}wheel(e){return this._firePreventable(new Lo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new zo(e.type,this._map,e))}mouseup(e){this._map.fire(new zo(e.type,this._map,e));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new zo(e.type,this._map,e));}dblclick(e){return this._firePreventable(new zo(e.type,this._map,e))}mouseover(e){this._map.fire(new zo(e.type,this._map,e));}mouseout(e){this._map.fire(new zo(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Ao(e.type,this._map,e))}touchmove(e){this._map.fire(new Ao(e.type,this._map,e));}touchend(e){this._map.fire(new Ao(e.type,this._map,e));}touchcancel(e){this._map.fire(new Ao(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Fo{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(e){this._map.fire(new zo(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new zo("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new zo(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Bo{constructor(e){this._map=e;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class jo{constructor(e,t){this._map=e,this._tr=new Bo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(r,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.k(e,{originalEvent:i}))}}function Oo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=Oo(r,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=Oo(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Zo{constructor(e){this.singleTap=new No(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Go{constructor(e){this._tr=new Bo(e),this._zoomIn=new Zo({numTouches:1,numTaps:2}),this._zoomOut=new Zo({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),o=this._zoomOut.touchend(e,t,i),s=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:s.zoom+1,around:s.unproject(r)},{originalEvent:e})}):o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:s.zoom-1,around:s.unproject(o)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Uo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset();}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e);}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return !this._moved&&r.dist(i)!0}),t=new Ho){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t;}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)));}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)));}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Xo=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault();};};class $o{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0);}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const o=Oo(r,i),s=new t.P(0,0),a=new t.P(0,0);let n=0;for(const e in o){const t=o[e],i=this._touches[e];i&&(s._add(t),a._add(t.sub(i)),n++,o[e]=t);}if(this._touches=o,this._shouldBePrevented(n)||!a.mag())return;const l=a.div(n);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class rs extends Ko{constructor(e){super(),this._currentTouchCount=0,this._map=e;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length;}_start(e){this._lastPoints=e,is(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),o=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,o=t.mag()>=2;if(!r&&!o)return;if(!r||!o)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=e.y>0==t.y>0;return is(e)&&is(t)&&s}}const os={panStep:100,bearingStep:15,pitchStep:10};class ss{constructor(e){this._tr=new Bo(e);const t=os;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,o=0,s=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),o=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),o=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),s=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const n=this._tr;a.easeTo({duration:300,easeId:"keyboardHandler",easing:as,zoom:t?Math.round(n.zoom)+t*(e.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+r*this._pitchStep,offset:[-o*this._panStep,-s*this._panStep],center:n.center},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function as(e){return e*(2-e)}const ns=4.000244140625;class ls{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);},this._map=e,this._tr=new Bo(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(e){return !!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=a.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%ns==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=n.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.N.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t);}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>ns?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const o="number"!=typeof this._targetZoom?e.scale:t.aG(this._targetZoom);this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,t.a8(o*r))),"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,o=this._easing;let s,n=!1;if("wheel"===this._type&&r&&o){const e=a.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=o(l);s=t.y.number(r,i,c),l<1?this._frameId||(this._frameId=!0):n=!0;}else s=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout;}),200)),this._lastExpectedZoom=s,{noInertia:!0,needsRenderFrame:!n,zoomDelta:s-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.c8;if(this._prevEase){const e=this._prevEase,r=(a.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),s=.27/Math.sqrt(o*o+1e-4)*.01,n=Math.sqrt(.0729-s*s);i=t.c6(s,n,.25,1);}return this._prevEase={start:a.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class cs{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class hs{constructor(e){this._tr=new Bo(e),this.reset();}reset(){this._active=!1;}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class us{constructor(){this._tap=new Zo({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],o=e.timeStamp-this._tapTime<500,s=this._tapPoint.dist(r)<30;o&&s?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(e,t,i);}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ds{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class _s{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class ps{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class ms{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=n.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const o=document.createElement("div");o.className="maplibregl-mobile-message",o.textContent=i,this._container.appendChild(o),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(n.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.k("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const fs=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class gs extends t.k{}function vs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class xs{constructor(e,t){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`);},this.handleEvent=(e,t)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},o={},s={},a=e.touches,l=a?this._getMapTouches(a):void 0,c=l?n.touchPos(this._map.getCanvas(),l):n.mousePos(this._map.getCanvas(),e);for(const{handlerName:a,handler:n,allowed:h}of this._handlers){if(!n.isEnabled())continue;let u;this._blockedByActive(s,h,a)?n.reset():n[t||e.type]&&(u=n[t||e.type](e,c,l),this.mergeHandlerResult(r,o,u,a,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||n.isActive())&&(s[a]=n);}const h={};for(const e in this._previousActiveHandlers)s[e]||(h[e]=i);this._previousActiveHandlers=s,(Object.keys(h).length||vs(r))&&(this._changes.push([r,o,h]),this._triggerRenderFrame()),(Object.keys(s).length||vs(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map));},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new So(e),this._bearingSnap=t.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(t);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)n.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[e,t,i]of this._listeners)n.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new ko(i,e));const o=i.boxZoom=new jo(i,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const s=i.cooperativeGestures=new ms(i,e.cooperativeGestures);this._add("cooperativeGestures",s),e.cooperativeGestures&&s.enable();const a=new Go(i),l=new hs(i);i.doubleClickZoom=new cs(l,a),this._add("tapZoom",a),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new us;this._add("tapDragZoom",c);const h=i.touchPitch=new rs(i);this._add("touchPitch",h),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:o=100,rotateDegreesPerPixelMoved:s=.8},a){const l=new qo({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Uo({clickTolerance:i,move:(e,i)=>{const n=a();if(r&&Math.abs(n.y-e.y)>o)return {bearingDelta:t.c7(new t.P(e.x,i.y),i,n)};let l=(i.x-e.x)*s;return r&&i.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Uo({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:Xo})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const o=new qo({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Uo({clickTolerance:t,move:(e,t)=>{const o=r();let s=(t.x-e.x)*i;return t.y0===n.mouseButton(e)&&!e.ctrlKey});return new Uo({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Xo})}(e),f=new $o(e,i);i.dragPan=new ds(r,m,f),this._add("mousePan",m),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new ts,v=new Qo;i.touchZoomRotate=new ps(r,v,g,c),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",v,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const x=i.scrollZoom=new ls(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const b=i.keyboard=new ss(i);this._add("keyboard",b),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Fo(i));}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[];}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(fs(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,o,s){if(!r)return;t.e(e,r);const a={handlerName:o,originalEvent:r.originalEvent||s};void 0!==r.zoomDelta&&(i.zoom=a),void 0!==r.panDelta&&(i.drag=a),void 0!==r.rollDelta&&(i.roll=a),void 0!==r.pitchDelta&&(i.pitch=a),void 0!==r.bearingDelta&&(i.rotate=a);}_applyChanges(){const e={},i={},r={};for(const[o,s,a]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(e.rollDelta=(e.rollDelta||0)+o.rollDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.e(i,s),t.e(r,a);this._updateMapTransform(e,i,r),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,o=r._getTransformForUpdate(),s=r.terrain;if(!(vs(e)||s&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:a,zoomDelta:n,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u=u||r.transform.centerPoint,s&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const _={panDelta:a,zoomDelta:n,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const p=u.distSqr(o.centerPoint)<.01?o.center:o.screenPointToLocation(a?u.sub(a):u);s?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?o.setCenter(o.screenPointToLocation(o.centerPoint.sub(a))):this._map.cameraHelper.handleMapControlsPan(_,o,p):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(_,o,p))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._map.cameraHelper.handleMapControlsPan(_,o,p)),r._applyUpdatedTransform(o),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,i,r){const o=fs(this._eventsInProgress),s=fs(e),n={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(n[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!o&&s&&this._fireEvent("movestart",s.originalEvent);for(const e in n)this._fireEvent(e,n[e]);s&&this._fireEvent("move",s.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||r,l[`${e}end`]=c);}for(const e in l)this._fireEvent(e,l[e]);const h=fs(this._eventsInProgress),u=(o||s)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e);}if(r&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new gs("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class bs extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((a.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState;}));}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t;}getCenter(){return new t.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e;}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.k("movestart",i)).fire(new t.k("move",i)).fire(new t.k("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){f.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.k("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.k("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.k("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.k("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.k("rollstart",e));}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.setElevation(t.y.number(this._elevationStart,this._elevationTarget,e));}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return {};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:o,roll:s,pitch:a,bearing:n,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==o&&t.setZoom(o),void 0!==s&&t.setRoll(s),void 0!==a&&t.setPitch(a),void 0!==n&&t.setBearing(n),i.apply(t);}this.transform.apply(i);}_fireMoveEvents(e){this.fire(new t.k("move",e)),this._zooming&&this.fire(new t.k("zoom",e)),this._rotating&&this.fire(new t.k("rotate",e)),this._pitching&&this.fire(new t.k("pitch",e)),this._rolling&&this.fire(new t.k("roll",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,o=this._rotating,s=this._pitching,a=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.k("zoomend",e)),o&&this.fire(new t.k("rotateend",e)),s&&this.fire(new t.k("pitchend",e)),a&&this.fire(new t.k("rollend",e)),this.fire(new t.k("moveend",e));}flyTo(e,i){if(!e.essential&&a.prefersReducedMotion){const r=t.M(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.c8},e);const r=this._getTransformForUpdate(),o=r.bearing,s=r.pitch,n=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:s,u="roll"in e?this._normalizeBearing(e.roll,n):n,d="padding"in e?e.padding:r.padding,_=t.P.convert(e.offset);let p=r.centerPoint.add(_);const m=r.screenPointToLocation(p),f=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:_,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let g=e.curve;const v=Math.max(r.width,r.height),x=v/f.scaleOfZoom,b=f.pixelPathLength;"number"==typeof f.scaleOfMinZoom&&(g=Math.sqrt(v/f.scaleOfMinZoom/b*2));const y=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*y*y*b*b)/(2*(e?x:v)*y*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const C=w(!1);let I=function(e){return P(C)/P(C+g*e)},E=function(e){return v*((P(C)*(T(t=C+g*e)/P(t))-T(C))/y)/b;var t;},M=(w(!0)-C)/g;if(Math.abs(b)<2e-6||!isFinite(M)){if(Math.abs(v-x)<1e-6)return this.easeTo(e,i);const t=x0,I=e=>Math.exp(t*g*e);}return e.duration="duration"in e?+e.duration:1e3*M/("screenSpeed"in e?+e.screenSpeed/g:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==s,this._rolling=u!==n,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease((a=>{const m=a*M,g=1/I(m),v=E(m);this._rotating&&r.setBearing(t.y.number(o,c,a)),this._pitching&&r.setPitch(t.y.number(s,h,a)),this._rolling&&r.setRoll(t.y.number(n,u,a)),this._padding&&(r.interpolatePadding(l,d,a),p=r.centerPoint.add(_)),f.easeFunc(a,g,v,p),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t);}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=a.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.aI(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class ws{constructor(e=ys){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=e;}getDefaultPosition(){return "bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._sanitizedAttributionHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style.sourceCaches;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return !1;return !0}));const i=e.join(" | ");i!==this._sanitizedAttributionHTML&&(this._sanitizedAttributionHTML=n.sanitize(i),e.length?(this._innerContainer.innerHTML=this._sanitizedAttributionHTML,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class Ts{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact");}},this.options=e;}getDefaultPosition(){return "bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=n.create("div","maplibregl-ctrl");const t=n.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class Ps{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var Cs=t.aA([{name:"a_pos3d",type:"Int16",components:3}]);class Is extends t.E{constructor(e){super(),this._lastTilesetChange=a.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const r={};for(const o of ue(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float64Array(16),t.bL(o.terrainRttPosMatrix32f,0,t.X,t.X,0,0,1),this._tiles[o.key]=new se(o,this.tileSize),this._lastTilesetChange=a.now());for(const e in this._tiles)r[e]||delete this._tiles[e];}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e){const i={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID,s=e.clone(),a=t.a$();if(o.canonical.equals(e.canonical))t.bL(a,0,t.X,t.X,0,0,1);else if(o.canonical.isChildOf(e.canonical)){const i=o.canonical.z-e.canonical.z,r=o.canonical.x-(o.canonical.x>>i<>i<>i;t.bL(a,0,n,n,0,0,1),t.J(a,a,[-r*n,-s*n,0]);}else {if(!e.canonical.isChildOf(o.canonical))continue;{const i=e.canonical.z-o.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bL(a,0,t.X,t.X,0,0,1),t.J(a,a,[r*n,s*n,0]),t.K(a,a,[1/2**i,1/2**i,0]);}}s.terrainRttPosMatrix32f=new Float32Array(a),i[r]=s;}return i}getSourceTile(e,t){const i=this.sourceCache._source;let r=e.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!o||!o.dem);)o=this.sourceCache.getTileByID(e.scaledTo(r--).key);return o}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}}class Es{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Is(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(e,i,r,o=t.X){var s;if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?o=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const s=e.canonical.x-(e.canonical.x>>o<>o<>8<<4|e>>8,i[t+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),o=new v(e,r,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,o=r.gl,s=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),a=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(s,n-a-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,_=(1<0,o=r&&0===e.canonical.y,s=r&&e.canonical.y===(1<e.id!==t)),this._recentlyUsed.push(e.id);}stampObject(e){e.stamp=++this._stamp;}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1;}freeAllObjects(){for(const e of this._objects)this.freeObject(e);}isFull(){return !(this._objects.length!e.inUse))}}const Ss={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Rs{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Ms(e.context,30,t.sourceCache.tileSize*t.qualityFactor);}destruct(){this.pool.destruct();}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates();for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e]);}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],r=i.source;if(Ss[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join();}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[]);}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return !1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),o=e.type,s=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Ss[o]&&(this._prevType&&Ss[this._prevType]||this._stacks.push([]),this._prevType=o,this._stacks[this._stacks.length-1].push(e.id),!a))return !0;if(Ss[this._prevType]||Ss[o]&&a){this._prevType=o;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const o of this._renderableTiles){if(this.pool.isFull()&&(vo(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(o),o.rtt[e]){const t=this.pool.getObjectForId(o.rtt[e].id);if(t.stamp===o.rtt[e].stamp){this.pool.useObject(t);continue}}const a=this.pool.getOrCreateFreeObject();this.pool.useObject(a),this.pool.stampObject(a),o.rtt[e]={id:a.id,stamp:a.stamp},s.context.bindFramebuffer.set(a.fbo.framebuffer),s.context.clear({color:t.b4.transparent,stencil:0}),s.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=e=>{this.move(e,n.mousePos(this.element,e));},this.mouseup=e=>{this._rotatePitchHanlder.dragEnd(e),this.offTemp();},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend));},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos));},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10,this.element=i;const o=new Wo;this._rotatePitchHanlder=new Uo({clickTolerance:3,move:(e,o)=>{const s=i.getBoundingClientRect(),a=new t.P((s.bottom-s.top)/2,(s.right-s.left)/2);return {bearingDelta:t.c7(new t.P(e.x,o.y),o,a),pitchDelta:r?-.5*(o.y-e.y):void 0}},moveStateManager:o,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(i,"mousedown",this.mousedown),n.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(i,"touchcancel",this.reset);}startMove(e,t){this._rotatePitchHanlder.dragStart(e,t),n.disableDrag();}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:o}=this._rotatePitchHanlder.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),o&&i.setPitch(i.getPitch()+o);}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp();}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend);}}let Fs;function Bs(e,i,r){const o=new t.N(e.lng,e.lat);if(e=new t.N(e.lng,e.lat),i){const o=new t.N(e.lng-360,e.lat),s=new t.N(e.lng+360,e.lat),a=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(o).distSqr(i)180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360;}return e.lng!==o.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:o}const js={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Os(e,t,i){const r=e.classList;for(const e in js)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`);}class Ns extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();},this._update=e=>{var t;if(!this._map)return;const i=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!i)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Bs(this._lngLat,this._flatPos,this._map.transform):null===(t=this._lngLat)||void 0===t?void 0:t.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?r=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let o="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?o="rotateX(0deg)":"map"===this._pitchAlignment&&(o=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${js[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${o} ${r}`),a.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type);})).catch((()=>{}));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.k("dragstart"))),this.fire(new t.k("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.k("dragend")),this._state="inactive";},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=n.create("div");const i=n.createNS("http://www.w3.org/2000/svg","svg"),r=41,o=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${o}px`),i.setAttributeNS(null,"viewBox",`0 0 ${o} ${r}`);const s=n.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"stroke","none"),s.setAttributeNS(null,"stroke-width","1"),s.setAttributeNS(null,"fill","none"),s.setAttributeNS(null,"fill-rule","evenodd");const a=n.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"fill-rule","nonzero");const l=n.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=n.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t);}const h=n.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=n.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=n.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=n.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=n.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=n.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=n.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),a.appendChild(l),a.appendChild(h),a.appendChild(d),a.appendChild(p),a.appendChild(m),i.appendChild(a),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();})),Os(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.N.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;if(!(null===(i=this._map)||void 0===i?void 0:i.terrain)){const e=this._map.transform.isLocationOccluded(this._lngLat)?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const o=this._map,s=o.terrain.depthAtPoint(this._pos),a=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,a)-s<.006)return void(this._element.style.opacity=this._opacity);const n=-this._offset.y/o.transform.pixelsPerMeter,l=Math.sin(o.getPitch()*Math.PI/180)*n,c=o.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),h=o.transform.lngLatToCameraDepth(this._lngLat,a+l)-c>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity;}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e);}removeClassName(e){this._element.classList.remove(e);}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return void 0===e&&void 0===t&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Zs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Gs=0,Us=!1;const Vs={maxWidth:100,unit:"metric"};function qs(e,t,i){const r=i&&i.maxWidth||100,o=e._container.clientHeight/2,s=e._container.clientWidth/2,a=e.unproject([s-r/2,o]),n=e.unproject([s+r/2,o]),l=Math.round(e.project(n).x-e.project(a).x),c=Math.min(r,l,e._container.clientWidth),h=a.distanceTo(n);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Hs(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Hs(t,c,i,e._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?Hs(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Hs(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):Hs(t,c,h,e._getUIString("ScaleControl.Meters"));}function Hs(e,t,i,r){const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(o/i)+"px",e.innerHTML=`${o} ${r}`;}const Ws={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Xs=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function $s(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return $s(new t.P(0,0))}const Ks=i;e.AJAXError=t.cg,e.Event=t.k,e.Evented=t.E,e.LngLat=t.N,e.MercatorCoordinate=t.Y,e.Point=t.P,e.addProtocol=t.ch,e.config=t.a,e.removeProtocol=t.ci,e.AttributionControl=ws,e.BoxZoomHandler=jo,e.CanvasSource=J,e.CooperativeGesturesHandler=ms,e.DoubleClickZoomHandler=cs,e.DragPanHandler=ds,e.DragRotateHandler=_s,e.EdgeInsets=Pt,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},e.GeoJSONSource=$,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.k("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.N(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),s=t.e({bearing:o},this.options.fitBoundsOptions),a=V.fromLngLat(i,r);this._map.fitBounds(a,s,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&Us)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.k("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ns({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ns({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.k("trackuserlocationend")),this.fire(new t.k("userlocationlostfocus")));}));}},this.options=t.e({},Zs,e);}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(void 0!==Fs&&!e)return Fs;if(void 0===window.navigator.permissions)return Fs=!!window.navigator.geolocation,Fs;try{const e=yield window.navigator.permissions.query({name:"geolocation"});Fs="denied"!==e.state;}catch(e){Fs=!!window.navigator.geolocation;}return Fs}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Gs=0,Us=!1;}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),r=t.distanceTo(i),o=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Gs--,Us=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.k("trackuserlocationstart")),this.fire(new t.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Gs++,Gs>1?(e={maximumAge:6e5,timeout:0},Us=!0):(e=this.options.positionOptions,Us=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon();},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"));};}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0;}},e.Hash=wo,e.ImageSource=K,e.KeyboardHandler=ss,e.LngLatBounds=V,e.LogoControl=Ts,e.Map=class extends bs{constructor(e){var i,r;t.cd.mark(t.ce.create);const o=Object.assign(Object.assign(Object.assign({},As),e),{canvasContextAttributes:Object.assign(Object.assign({},As.canvasContextAttributes),e.canvasContextAttributes)});if(null!=o.minZoom&&null!=o.maxZoom&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=o.minPitch&&null!=o.maxPitch&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=o.minPitch&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=o.maxPitch&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const s=new Dt,a=new kt;if(void 0!==o.minZoom&&s.setMinZoom(o.minZoom),void 0!==o.maxZoom&&s.setMaxZoom(o.maxZoom),void 0!==o.minPitch&&s.setMinPitch(o.minPitch),void 0!==o.maxPitch&&s.setMaxPitch(o.maxPitch),void 0!==o.renderWorldCopies&&s.setRenderWorldCopies(o.renderWorldCopies),super(s,a,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ps,this._controls=[],this._mapId=t.a1(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.k("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.k("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=!0===o.trackResize,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=!0===o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=!0===o.crossSourceCollisions,this._collectResourceTiming=!0===o.collectResourceTiming,this._locale=Object.assign(Object.assign({},Ds),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this.transformCameraUpdate=o.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===o.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=p.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(o.transformRequest),"string"==typeof o.container){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else {if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container;}if(o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})),this.once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=yo((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw());}),50);this._resizeObserver=new ResizeObserver((i=>{e?t(i):e=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new xs(this,o),this._hash=o.hash&&new wo("string"==typeof o.hash&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,t.e({},o.fitBoundsOptions,{duration:0}))));const n="string"==typeof o.style||!("globe"===(null===(r=null===(i=o.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,n),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new ws("boolean"==typeof o.attributionControl?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Ts,o.logoPosition),this.on("style.load",(()=>{if(n||this._resizeTransform(),this.transform.unmodified){const e=t.M(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e);}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.k(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.k(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.k("sourcedataabort",e));}));}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return -1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){const[r,o]=this._containerDimensions(),s=this._getClampedPixelRatio(r,o);if(this._resizeCanvas(r,o,s),this.painter.resize(r,o,s),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(r,o);this._resizeCanvas(r,o,t),this.painter.resize(r,o,t);}this._resizeTransform(i);const a=!this._moving;return a&&(this.stop(),this.fire(new t.k("movestart",e)).fire(new t.k("move",e))),this.fire(new t.k("resize",e)),a&&this.fire(new t.k("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e);}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,o=this.getPixelRatio(),s=e*o,a=t*o;return Math.min(s>i?i/s:1,a>r?r/a:1)*o}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(V.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.N.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const o=o=>{const s=t.filter((e=>this.getLayer(e))),a=0!==s.length?this.queryRenderedFeatures(o.point,{layers:s}):[];a.length?r||(r=!0,i.call(this,new zo(e,this,o.originalEvent,{features:a}))):r=!1;};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=o=>{const s=t.filter((e=>this.getLayer(e)));(0!==s.length?this.queryRenderedFeatures(o.point,{layers:s}):[]).length?r=!0:r&&(r=!1,i.call(this,new zo(e,this,o.originalEvent)));},s=t=>{r&&(r=!1,i.call(this,new zo(e,this,t.originalEvent)));};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:s}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),o=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];o.length&&(e.features=o,i.call(this,e),delete e.features);};return {layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t);}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let e=0;et.includes(e)))){for(const e in o.delegates)this.off(e,o.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,o);for(const e in o.delegates)this.on(e,o.delegates[e]);return {unsubscribe:()=>{this._removeDelegatedListener(e,r,i);}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);for(const t in o.delegates){const s=o.delegates[t];o.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),s(...t);};}this._saveDelegatedListener(e,o);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return [];let r;const o=e instanceof t.P||Array.isArray(e),s=o?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(o?{}:e)||{},s instanceof t.P||"number"==typeof s[0])r=[t.P.convert(s)];else {const e=t.P.convert(s[0]),i=t.P.convert(s[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e];}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return !1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new gi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new gi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,"Style");t.h(r,new AbortController).then((e=>{this._updateDiff(e.data,i);})).catch((e=>{e&&this.fire(new t.j(e));}));}else "object"==typeof e&&this._updateDiff(e,i);}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.j(new Error(`There is no source with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new Es(this.painter,i,e),this.painter.renderToTexture=new Rs(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),this.terrain.sourceCache.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.k("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(e,i,r={}){const{pixelRatio:o=1,sdf:s=!1,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:a,data:d}=i,_=i;return this.style.addImage(e,{data:new t.R({width:r,height:a},new Uint8Array(d)),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:s,version:0,userImage:_}),_.onAdd&&_.onAdd(this,e),this}}{const{width:r,height:d,data:_}=a.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},_),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:s,version:0});}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||t.b(i)?a.getImageData(i):i,{width:s,height:n,data:l}=o;if(void 0===s||void 0===n)return this.fire(new t.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(s!==r.data.width||n!==r.data.height)return this.fire(new t.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.j(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e){return p.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,(e=>{e||this._update(!0);})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0);})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const o=this._controlContainer=n.create("div","maplibregl-control-container",e),s=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{s[e]=n.create("div",`maplibregl-ctrl-${e} `,o);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type);}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new bo(i,this.transform),l.testSupport(i);}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.k("projectiontransition",{newProjection:this.style.projection.name}));}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_render(e){var i,r,o,s,n;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=a.now();this.style.zoomHistory.update(e,i);const r=new t.z(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=r.crossFadingFactor();1===o&&o===this._crossFadingFactor||(h=!0,this._crossFadingFactor=o),this.style.update(r);}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(o=this.style.projection)||void 0===o||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState,null===(n=this.style.projection)||void 0===n?void 0:n.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cd.mark(t.ce.load),this.fire(new t.k("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.k("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cd.mark(t.ce.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),p.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cd.clearMetrics(),this._removed=!0,this.fire(new t.k("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then((e=>{t.cd.frame(e),this._frameRequest=null,this._render(e);})).catch((e=>{if(!t.cf(e)&&!function(e){return e.message===Or}(e))throw e})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get version(){return zs}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=zo,e.MapTouchEvent=Ao,e.MapWheelEvent=Lo,e.Marker=Ns,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`;},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i);},this.options=t.e({},Ls,e),this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e});})),this._compassIcon=n.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ks(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(e,t){const i=n.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this.remove=()=>(this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.k("close"))),this),this._onMouseUp=e=>{this._update(e.point);},this._onMouseMove=e=>{this._update(e.point);},this._onDrag=e=>{this._update(e.point);},this._update=e=>{var t;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?Bs(this._lngLat,this._flatPos,this._map.transform):null===(t=this._lngLat)||void 0===t?void 0:t.wrap(),this._trackPointer&&!e)return;const i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor;const o=$s(this.options.offset);if(!r){const e=this._container.offsetWidth,t=this._container.offsetHeight;let s;s=i.y+o.bottom.ythis._map.transform.height-t?["bottom"]:[],i.xthis._map.transform.width-e/2&&s.push("right"),r=0===s.length?"bottom":s.join("-");}let s=i.add(o[r]);this.options.subpixelPositioning||(s=s.round()),n.setTransform(this._container,`${js[r]} translate(${s.x}px,${s.y}px)`),Os(this._container,r,"popup");},this._onClose=()=>{this.remove();},this.options=t.e(Object.create(Ws),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.k("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.N.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Xs);e&&e.focus();}},e.RasterDEMTileSource=X,e.RasterTileSource=W,e.ScaleControl=class{constructor(e){this._onMove=()=>{qs(this._map,this._container,this.options);},this.setUnit=e=>{this.options.unit=e,qs(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},Vs),e);}getDefaultPosition(){return "bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},e.ScrollZoomHandler=ls,e.Style=gi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=e;}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},e.TwoFingersTouchPitchHandler=rs,e.TwoFingersTouchRotateHandler=ts,e.TwoFingersTouchZoomHandler=Qo,e.TwoFingersTouchZoomRotateHandler=ps,e.VectorTileSource=H,e.VideoSource=Y,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,(function*(){if(ee(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{Q[e]=t;})(e,i);})),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(D),L=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},e.createTileMesh=Ht,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return oe().getRTLTextPluginStatus()},e.getVersion=function(){return Ks},e.getWorkerCount=function(){return z.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return j().broadcast("IS",e)},e.prewarm=function(){F().acquire(D);},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e;},e.setRTLTextPlugin=function(e,t){return oe().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){z.workerCount=e;},e.setWorkerUrl=function(e){t.a.WORKER_URL=e;};})); + +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + + +var maplibregl$1 = maplibregl; + +return maplibregl$1; + +})); +//# sourceMappingURL=maplibre-gl.js.map diff --git a/docs/articles/getting-started_files/maplibre-gl-5.3.0/LICENSE.txt b/docs/articles/getting-started_files/maplibre-gl-5.3.0/LICENSE.txt new file mode 100644 index 00000000..1e8acbb5 --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.3.0/LICENSE.txt @@ -0,0 +1,116 @@ +Copyright (c) 2023, MapLibre contributors + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of MapLibre GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from mapbox-gl-js v1.13 and earlier + +Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license + +Copyright (c) 2020, Mapbox +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Mapbox GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from glfx.js + +Copyright (C) 2011 by Evan Wallace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +Contains a portion of d3-color https://github.com/d3/d3-color + +Copyright 2010-2016 Mike Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/articles/getting-started_files/maplibre-gl-5.3.0/maplibre-gl.css b/docs/articles/getting-started_files/maplibre-gl-5.3.0/maplibre-gl.css new file mode 100644 index 00000000..aa4f4650 --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.3.0/maplibre-gl.css @@ -0,0 +1 @@ +.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file diff --git a/docs/articles/getting-started_files/maplibre-gl-5.3.0/maplibre-gl.js b/docs/articles/getting-started_files/maplibre-gl-5.3.0/maplibre-gl.js new file mode 100644 index 00000000..61db6d9b --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.3.0/maplibre-gl.js @@ -0,0 +1,59 @@ +/** + * MapLibre GL JS + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.3.0/LICENSE.txt + */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); +})(this, (function () { 'use strict'; + +/* eslint-disable */ + +var maplibregl = {}; +var modules = {}; +function define(moduleName, _dependencies, moduleFactory) { + modules[moduleName] = moduleFactory; + + // to get the list of modules see generated dist/maplibre-gl-dev.js file (look for `define(` calls) + if (moduleName !== 'index') { + return; + } + + // we assume that when an index module is initializing then other modules are loaded already + var workerBundleString = 'var sharedModule = {}; (' + modules.shared + ')(sharedModule); (' + modules.worker + ')(sharedModule);' + + var sharedModule = {}; + // the order of arguments of a module factory depends on rollup (it decides who is whose dependency) + // to check the correct order, see dist/maplibre-gl-dev.js file (look for `define(` calls) + // we assume that for our 3 chunks it will generate 3 modules and their order is predefined like the following + modules.shared(sharedModule); + modules.index(maplibregl, sharedModule); + + if (typeof window !== 'undefined') { + maplibregl.setWorkerUrl(window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }))); + } + + return maplibregl; +}; + + + +define("shared",["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t));}catch(t){s(t);}}function o(t){try{l(n.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(a,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n,i;function s(){if(i)return n;function t(t,e){this.x=t,this.y=e;}return i=1,n=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},n}"function"==typeof SuppressedError&&SuppressedError;var a,o,l=r(s()),u=function(){if(o)return a;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return o=1,a=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},a}(),c=r(u);let h,p;function f(){return null==h&&(h="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),h}function d(){if(null==p&&(p=!1,f())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function B(t,e,r,n){const i=new c(t,e,r,n);return t=>i.solve(t)}const V=B(.25,.1,.25,1);function E(t,e,r){return Math.min(r,Math.max(e,t))}function T(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function F(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let $=1;function L(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function O(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function D(t){return Array.isArray(t)?t.map(D):"object"==typeof t&&t?L(t,D):t}const R={};function j(t){R[t]||("undefined"!=typeof console&&console.warn(t),R[t]=!0);}function N(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function U(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let q=null;function G(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const Z="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,r,n,i){const s=4*Math.max(1,0),a=(Math.max(0,r)-r)*n*4+s,o=4*n,l=Math.max(0,e),u=Math.max(0,r);return {rect:{x:l,y:u,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-u},layout:[{offset:a,stride:o}]}}(t,r,n,i,s)),o)for(let t=0;t{t.removeEventListener(e,r,n);}}}function J(t){return t/Math.PI*180}const W={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Q={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},tt="AbortError";function et(){return new Error(tt)}const rt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function nt(t){return rt.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const it="global-dispatcher";class st extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n;}}const at=()=>U(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ot=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=nt(t.url);if(e)return e(t,r);if(U(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:it},r)}if(!(/^file:/.test(n=t.url)||/^file:/.test(at())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:at(),signal:r.signal});let n,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e);}catch(e){throw new st(0,e.message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new st(n.status,n.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw et();return {data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(U(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:it},r)}var n;return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new st(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),n(et());})),s.send(t.body);}))}(t,r)};function lt(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function ut(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function ct(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class ht{constructor(t,e={}){F(this,e),this.type=t;}}class pt extends ht{constructor(t,e={}){super("error",F({error:t},e));}}class ft{on(t,e){return this._listeners=this._listeners||{},ut(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e);}}}off(t,e){return ct(t,e,this._listeners),ct(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},ut(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new ht(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)ct(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(F(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof pt&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var dt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const yt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function mt(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return yt.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function gt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Gt=[Ct,Bt,Vt,Et,Tt,Ft,Dt,$t,Ut(Lt),Rt,jt,Nt];function Zt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Zt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Gt)if(!Zt(t,e))return null}return `Expected ${qt(t)} but found ${qt(e)} instead.`}function Kt(t,e){return e.some((e=>e.kind===t.kind))}function Xt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function Ht(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Yt=.96422,Jt=.82521,Wt=4/29,Qt=6/29,te=3*Qt*Qt,ee=Qt*Qt*Qt,re=Math.PI/180,ne=180/Math.PI;function ie(t){return (t%=360)<0&&(t+=360),t}function se([t,e,r,n]){let i,s;const a=oe((.2225045*(t=ae(t))+.7168786*(e=ae(e))+.0606169*(r=ae(r)))/1);t===e&&e===r?i=s=a:(i=oe((.4360747*t+.3850649*e+.1430804*r)/Yt),s=oe((.0139322*t+.0971045*e+.7141733*r)/Jt));const o=116*a-16;return [o<0?0:o,500*(i-a),200*(a-s),n]}function ae(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function oe(t){return t>ee?Math.pow(t,1/3):t/te+Wt}function le([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*ce(i),s=Yt*ce(s),a=Jt*ce(a),[ue(3.1338561*s-1.6168667*i-.4906146*a),ue(-.9787684*s+1.9161415*i+.033454*a),ue(.0719453*s-.2289914*i+1.4052427*a),n]}function ue(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ce(t){return t>Qt?t*t*t:te*(t-Wt)}function he(t){return parseInt(t.padEnd(2,t),16)/255}function pe(t,e){return fe(e?t/100:t,0,1)}function fe(t,e,r){return Math.min(Math.max(e,t),r)}function de(t){return !t.some(Number.isNaN)}const ye={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function me(t,e,r){return t+r*(e-t)}function ge(t,e,r){return t.map(((t,n)=>me(t,e[n],r)))}class xe{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof xe)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=ye[t];if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [he(t.slice(r,r+=e)),he(t.slice(r,r+=e)),he(t.slice(r,r+=e)),he(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[fe(+r/e,0,1),fe(+s/e,0,1),fe(+l/e,0,1),h?pe(+h,p):1];if(de(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,fe(+i,0,100),fe(+a,0,100),l?pe(+l,u):1];if(de(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=ie(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new xe(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=se(t),s=Math.sqrt(r*r+n*n);return [Math.round(1e4*s)?ie(Math.atan2(n,r)*ne):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",se(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}static interpolate(t,e,r,n="rgb"){switch(n){case "rgb":{const[n,i,s,a]=ge(t.rgb,e.rgb,r);return new xe(n,i,s,a,!1)}case "hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*re,le([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:me(i,l,r),me(s,u,r),me(a,c,r)]);return new xe(f,d,y,m,!1)}case "lab":{const[n,i,s,a]=le(ge(t.lab,e.lab,r));return new xe(n,i,s,a,!1)}}}}xe.black=new xe(0,0,0,1),xe.white=new xe(1,1,1,1),xe.transparent=new xe(0,0,0,0),xe.red=new xe(1,0,0,1);class ve{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const be=["bottom","center","top"];class we{constructor(t,e,r,n,i,s){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i,this.verticalAlign=s;}}class _e{constructor(t){this.sections=t;}static fromString(t){return new _e([new we(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof _e?t:_e.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Se{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Se)return t;if("number"==typeof t)return new Se([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new Se(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new Se(ge(t.values,e.values,r))}}class Ae{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}}const ke=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Me{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Me)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ce(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof ze||t instanceof xe||t instanceof ve||t instanceof _e||t instanceof Se||t instanceof Me||t instanceof Ie)return !0;if(Array.isArray(t)){for(const e of t)if(!Ce(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!Ce(t[e]))return !1;return !0}return !1}function Be(t){if(null===t)return Ct;if("string"==typeof t)return Vt;if("boolean"==typeof t)return Et;if("number"==typeof t)return Bt;if(t instanceof xe)return Tt;if(t instanceof ze)return Ft;if(t instanceof ve)return Ot;if(t instanceof _e)return Dt;if(t instanceof Se)return Rt;if(t instanceof Me)return Nt;if(t instanceof Ie)return jt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=Be(e);if(r){if(r===t)continue;r=Lt;break}r=t;}return Ut(r||Lt,e)}return $t}function Ve(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof xe||t instanceof ze||t instanceof _e||t instanceof Se||t instanceof Me||t instanceof Ie?t.toString():JSON.stringify(t)}class Ee{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ce(t[1]))return e.error("invalid value");const r=t[1];let n=Be(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Ee(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}const Te={string:Vt,number:Bt,boolean:Et,object:$t};class Fe{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in Te)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Te[r],n++;}else i=Lt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=Ut(i,s);}else {if(!Te[i])throw new Error(`Types doesn't contain name = ${i}`);r=Te[i];}const s=[];for(;nt.outputDefined()))}}const $e={"to-boolean":Et,"to-color":Tt,"to-number":Bt,"to-string":Vt};class Le{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!$e[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=$e[r],i=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Pe(e[0],e[1],e[2],e[3]),!r))return new xe(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ae(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=Se.parse(e);if(n)return n}throw new Ae(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=Me.parse(e);if(n)return n}throw new Ae(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new Ae(`Could not convert ${JSON.stringify(e)} to number.`)}case "formatted":return _e.fromString(Ve(this.args[0].evaluate(t)));case "resolvedImage":return Ie.fromString(Ve(this.args[0].evaluate(t)));case "projectionDefinition":return this.args[0].evaluate(t);default:return Ve(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Oe=["Unknown","Point","LineString","Polygon"];class De{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null;}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Oe[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=xe.parse(t)),e}}class Re{constructor(t,e,r=[],n,i=new Pt,s=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new Fe(e,[t]):"coerce"===r?new Le(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("projectionDefinition"!==t.kind||"string"!==i.kind&&"array"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind)if("padding"!==t.kind||"value"!==i.kind&&"number"!==i.kind&&"array"!==i.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==i.kind&&"array"!==i.kind){if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof Ee)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new De;try{n=new Ee(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new Re(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new zt(r,t));}checkSubtype(t,e){const r=Zt(t,e);return r&&this.error(r),r}}class je{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new Ae(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new Ae(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class qe{constructor(t,e){this.type=Et,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Lt),n=e.parse(t[2],2,Lt);return r&&n?Kt(r.type,[Et,Vt,Bt,Ct,Lt])?new qe(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${qt(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!Xt(e,["boolean","string","number","null"]))throw new Ae(`Expected first argument to be of type boolean, string, number or null, but found ${qt(Be(e))} instead.`);if(!Xt(r,["string","array"]))throw new Ae(`Expected second argument to be of type array or string, but found ${qt(Be(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class Ge{constructor(t,e,r){this.type=Bt,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Lt),n=e.parse(t[2],2,Lt);if(!r||!n)return null;if(!Kt(r.type,[Et,Vt,Bt,Ct,Lt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${qt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Bt);return i?new Ge(r,n,i):null}return new Ge(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Xt(e,["boolean","string","number","null"]))throw new Ae(`Expected first argument to be of type boolean, string, number or null, but found ${qt(Be(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),Xt(r,["string"])){const t=r.indexOf(e,n);return -1===t?-1:[...r.slice(0,t)].length}if(Xt(r,["array"]))return r.indexOf(e,n);throw new Ae(`Expected second argument to be of type array or string, but found ${qt(Be(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class Ze{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,Be(t)))return null}else r=Be(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,Lt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new Ze(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (Be(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class Ke{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class Xe{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Lt),n=e.parse(t[2],2,Bt);if(!r||!n)return null;if(!Kt(r.type,[Ut(Lt),Vt,Lt]))return e.error(`Expected first argument to be of type array or string, but found ${qt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Bt);return i?new Xe(r.type,r,n,i):null}return new Xe(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),Xt(e,["string"]))return [...e].slice(r,n).join("");if(Xt(e,["array"]))return e.slice(r,n);throw new Ae(`Expected first argument to be of type array or string, but found ${qt(Be(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function He(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new Ae("Input is not a number.");a=o-1;}return 0}class Ye{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,Bt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Ye(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[He(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Je(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var We,Qe,tr=function(){if(Qe)return We;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return Qe=1,We=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},We}(),er=Je(tr);class rr{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=nr(e,t.base,r,n);else if("linear"===t.name)i=nr(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new er(s[0],s[1],s[2],s[3]).solve(nr(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Bt),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Tt:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return Ht(o,Bt)||Ht(o,Ft)||Ht(o,Tt)||Ht(o,Rt)||Ht(o,Nt)||Ht(o,Ut(Bt))?new rr(o,r,n,i,a):e.error(`Type ${qt(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=He(e,n),a=rr.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case "interpolate":switch(this.type.kind){case "number":return me(o,l,a);case "color":return xe.interpolate(o,l,a);case "padding":return Se.interpolate(o,l,a);case "variableAnchorOffsetCollection":return Me.interpolate(o,l,a);case "array":return ge(o,l,a);case "projectionDefinition":return ze.interpolate(o,l,a)}case "interpolate-hcl":return xe.interpolate(o,l,a,"hcl");case "interpolate-lab":return xe.interpolate(o,l,a,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function nr(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}const ir={color:xe.interpolate,number:me,padding:Se.interpolate,variableAnchorOffsetCollection:Me.interpolate,array:ge};class sr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const s=n&&i.some((t=>Zt(n,t.type)));return new sr(s?Lt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof Ie&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function ar(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function or(t,e,r,n){return 0===n.compare(e,r)}function lr(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=Et,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,Lt);if(!s)return null;if(!ar(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${qt(s.type)}'.`);let a=e.parse(t[2],2,Lt);if(!a)return null;if(!ar(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${qt(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${qt(s.type)}' and '${qt(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new Fe(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new Fe(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ot),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=Be(s),r=Be(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ae(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=Be(s),r=Be(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const ur=lr("==",(function(t,e,r){return e===r}),or),cr=lr("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !or(0,e,r,n)})),hr=lr("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),fr=lr("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),dr=lr(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class yr{constructor(t,e,r){this.type=Ot,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,Et);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Et);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,Vt),!s)?null:new yr(n,i,s)}evaluate(t){return new ve(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class mr{constructor(t,e,r,n,i){this.type=Vt,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Bt);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,Vt),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Vt),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Bt),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,Bt),!o)?null:new mr(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class gr{constructor(t){this.type=Dt,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Bt),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,Ut(Vt)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,Tt),!a))return null;let o=null;if(s["vertical-align"]){if("string"==typeof s["vertical-align"]&&!be.includes(s["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(o=e.parse(s["vertical-align"],1,Vt),!o)return null}const l=n[n.length-1];l.scale=t,l.font=r,l.textColor=a,l.verticalAlign=o;}else {const s=e.parse(t[r],1,Lt);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null});}}return new gr(n)}evaluate(t){return new _e(this.sections.map((e=>{const r=e.content.evaluate(t);return Be(r)===jt?new we("",r,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new we(Ve(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign);}outputDefined(){return !1}}class xr{constructor(t){this.type=jt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Vt);return r?new xr(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=Ie.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class vr{constructor(t){this.type=Bt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${qt(r.type)} instead.`):new vr(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new Ae(`Expected value to be of type string or array, but found ${qt(Be(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const br=8192;function wr(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*br),Math.round(n*i*br)]}function _r(t,e){const r=Math.pow(2,e.z);return [(i=(t[0]/br+e.x)/r,360*i-180),(n=(t[1]/br+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i;}function Sr(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function Ar(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function kr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Mr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Vr(t,e,r,n)||!Vr(r,n,t,e));var i,s;}function Ir(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(a=o[e+1])[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}var i,s,a;return n}function Pr(t,e){for(const r of e)if(zr(t,r))return !0;return !1}function Cr(t,e){for(const r of t)if(!zr(r,e))return !1;for(let r=0;r0&&o<0||a<0&&o>0}function Er(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Sr(e,t);}function $r(t,e,r,n){const i=Math.pow(2,n.z)*br,s=[n.x*br,n.y*br],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Fr(n,e,r,i),a.push(n);}return a}function Lr(t,e,r,n){const i=Math.pow(2,n.z)*br,s=[n.x*br,n.y*br],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Sr(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)Fr(n,e,r,i);}var o;return a}class Or{constructor(t,e){this.type=Et,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ce(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n);}if(t.length)return new Or(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Or(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Or(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Er(e.coordinates,n,i),a=$r(t.geometry(),r,n,i);if(!Ar(r,n))return !1;for(const t of a)if(!zr(t,s))return !1}if("MultiPolygon"===e.type){const s=Tr(e.coordinates,n,i),a=$r(t.geometry(),r,n,i);if(!Ar(r,n))return !1;for(const t of a)if(!Pr(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Er(e.coordinates,n,i),a=Lr(t.geometry(),r,n,i);if(!Ar(r,n))return !1;for(const t of a)if(!Cr(t,s))return !1}if("MultiPolygon"===e.type){const s=Tr(e.coordinates,n,i),a=Lr(t.geometry(),r,n,i);if(!Ar(r,n))return !1;for(const t of a)if(!Br(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let Dr=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}};function Rr(t,e,r=0,n=t.length-1,i=Nr){for(;n>r;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Rr(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(jr(t,r,e),i(t[n],s)>0&&jr(t,r,n);a0;)o--;}0===i(t[r],s)?jr(t,r,o):(o++,jr(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function jr(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Nr(t,e){return te?1:0}function Ur(t,e){if(t.length<=1)return [t];const r=[];let n,i;for(const e of t){const t=Gr(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e));}if(n&&r.push(n),e>1)for(let t=0;t1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function Yr(t,e){return e[0]-t[0]}function Jr(t){return t[1]-t[0]+1}function Wr(t,e){return t[1]>=t[0]&&t[1]t[1])return [null,null];const r=Jr(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return [t,null];const n=Math.floor(r/2)-1;return [[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function tn(t,e){if(!Wr(e,t.length))return [1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)Sr(r,t[n]);return r}function en(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)Sr(e,t);return e}function rn(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function nn(t,e,r){if(!rn(t)||!rn(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Ar(i,s)){if(hn(t,e))return 0}else if(hn(e,t))return 0;let a=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=a.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(Jr(l)<=u){if(!Wr(l,t.length))return NaN;if(e){const e=cn(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=un(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else {const r=Qr(l,e);fn(a,s,n,t,o,r[0]),fn(a,s,n,t,o,r[1]);}}return s}function mn(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new Dr([[0,[0,t.length-1],[0,r.length-1]]],Yr);for(;o.length>0;){const s=o.pop();if(s[0]>=a)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(Jr(l)<=c&&Jr(u)<=h){if(!Wr(l,t.length)&&Wr(u,r.length))return NaN;let s;if(e&&n)s=on(t,l,r,u,i),a=Math.min(a,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=sn(r[t],e,i),a=Math.min(a,s),0===a)return a}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=sn(t[r],e,i),a=Math.min(a,s),0===a)return a}else s=ln(t,l,r,u,i),a=Math.min(a,s);}else {const s=Qr(l,e),c=Qr(u,n);dn(o,a,i,t,r,s[0],c[0]),dn(o,a,i,t,r,s[0],c[1]),dn(o,a,i,t,r,s[1],c[0]),dn(o,a,i,t,r,s[1],c[1]);}}return a}function gn(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class xn{constructor(t,e){this.type=Bt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ce(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new xn(e,e.features.map((t=>gn(t.geometry))).flat());if("Feature"===e.type)return new xn(e,gn(e.geometry));if("type"in e&&"coordinates"in e)return new xn(e,gn(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>_r([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Hr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,mn(n,!1,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,mn(n,!1,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,yn(n,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>_r([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Hr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,mn(n,!0,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,mn(n,!0,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,yn(n,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Ur(r,0).map((e=>e.map((e=>e.map((e=>_r([e.x,e.y],t.canonical))))))),i=new Hr(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case "Point":s=Math.min(s,yn([t.coordinates],!1,e,i,s));break;case "LineString":s=Math.min(s,yn(t.coordinates,!0,e,i,s));break;case "Polygon":s=Math.min(s,pn(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}const vn={"==":ur,"!=":cr,">":pr,"<":hr,">=":dr,"<=":fr,array:Fe,at:Ue,boolean:Fe,case:Ke,coalesce:sr,collator:yr,format:gr,image:xr,in:qe,"index-of":Ge,interpolate:rr,"interpolate-hcl":rr,"interpolate-lab":rr,length:vr,let:je,literal:Ee,match:Ze,number:Fe,"number-format":mr,object:Fe,slice:Xe,step:Ye,string:Fe,"to-boolean":Le,"to-color":Le,"to-number":Le,"to-string":Le,var:Ne,within:Or,distance:xn};class bn{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const r=t[0],n=bn.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new Re(e.registry,kn,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(qt).join(", ")})`:`(${qt(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&kn(t):r&&t instanceof Ee;})),!!r&&Mn(t)&&zn(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Mn(t){if(t instanceof bn){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Or)return !1;if(t instanceof xn)return !1;let e=!0;return t.eachChild((t=>{e&&!Mn(t)&&(e=!1);})),e}function In(t){if(t instanceof bn&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!In(t)&&(e=!1);})),e}function zn(t,e){if(t instanceof bn&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!zn(t,e)&&(r=!1);})),r}function Pn(t){return {result:"success",value:t}}function Cn(t){return {result:"error",value:t}}function Bn(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Vn(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function En(t){return !!t.expression&&t.expression.interpolated}function Tn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Fn(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function $n(t){return t}function Ln(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(En(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?xe.parse:Se.parse;(t=It({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default);}if(t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;let o,l,u;if("exponential"===s)o=jn;else if("interval"===s)o=Rn;else if("categorical"===s){o=Dn,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=Nn;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>jn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:rr.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?On(t.default,e.default):o(t,e,i,l,u)}}}function On(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Dn(t,e,r,n,i){return On(typeof r===i?n[r]:void 0,t.default,e.default)}function Rn(t,e,r){if("number"!==Tn(r))return On(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=He(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function jn(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Tn(r))return On(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=He(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=ir[e.type]||$n;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function Nn(t,e,r){switch(e.type){case "color":r=xe.parse(r);break;case "formatted":r=_e.fromString(r.toString());break;case "resolvedImage":r=Ie.fromString(r.toString());break;case "padding":r=Se.parse(r);break;default:Tn(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return On(r,t.default,e.default)}bn.register(vn,{error:[{kind:"error"},[Vt],(t,[e])=>{throw new Ae(e.evaluate(t))}],typeof:[Vt,[Lt],(t,[e])=>qt(Be(e.evaluate(t)))],"to-rgba":[Ut(Bt,4),[Tt],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return [255*r,255*n,255*i,s]}],rgb:[Tt,[Bt,Bt,Bt],wn],rgba:[Tt,[Bt,Bt,Bt,Bt],wn],has:{type:Et,overloads:[[[Vt],(t,[e])=>_n(e.evaluate(t),t.properties())],[[Vt,$t],(t,[e,r])=>_n(e.evaluate(t),r.evaluate(t))]]},get:{type:Lt,overloads:[[[Vt],(t,[e])=>Sn(e.evaluate(t),t.properties())],[[Vt,$t],(t,[e,r])=>Sn(e.evaluate(t),r.evaluate(t))]]},"feature-state":[Lt,[Vt],(t,[e])=>Sn(e.evaluate(t),t.featureState||{})],properties:[$t,[],t=>t.properties()],"geometry-type":[Vt,[],t=>t.geometryType()],id:[Lt,[],t=>t.id()],zoom:[Bt,[],t=>t.globals.zoom],"heatmap-density":[Bt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Bt,[],t=>t.globals.lineProgress||0],accumulated:[Lt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Bt,An(Bt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[Bt,An(Bt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:Bt,overloads:[[[Bt,Bt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Bt],(t,[e])=>-e.evaluate(t)]]},"/":[Bt,[Bt,Bt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Bt,[Bt,Bt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Bt,[],()=>Math.LN2],pi:[Bt,[],()=>Math.PI],e:[Bt,[],()=>Math.E],"^":[Bt,[Bt,Bt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Bt,[Bt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Bt,[Bt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Bt,[Bt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Bt,[Bt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Bt,[Bt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Bt,[Bt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Bt,[Bt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Bt,[Bt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Bt,[Bt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Bt,[Bt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Bt,An(Bt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Bt,An(Bt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Bt,[Bt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Bt,[Bt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Bt,[Bt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Bt,[Bt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Et,[Vt,Lt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[Et,[Lt],(t,[e])=>t.id()===e.value],"filter-type-==":[Et,[Vt],(t,[e])=>t.geometryType()===e.value],"filter-<":[Et,[Vt,Lt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[Et,[Vt,Lt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Et,[Lt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Et,[Vt,Lt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Et,[Lt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Et,[Vt,Lt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Et,[Lt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Et,[Lt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Et,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Et,[Ut(Vt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Et,[Ut(Lt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Et,[Vt,Ut(Lt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Et,[Vt,Ut(Lt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Et,overloads:[[[Et,Et],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[An(Et),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:Et,overloads:[[[Et,Et],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[An(Et),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[Et,[Et],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Et,[Vt],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Vt,[Vt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Vt,[Vt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Vt,An(Lt),(t,e)=>e.map((e=>Ve(e.evaluate(t)))).join("")],"resolved-locale":[Vt,[Ot],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Un{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new De,this._defaultValue=e?"color"===(r=e).type&&Fn(r.default)?new xe(0,0,0,0):"color"===r.type?xe.parse(r.default)||null:"padding"===r.type?Se.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?Me.parse(r.default)||null:"projectionDefinition"===r.type?ze.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ae(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function qn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in vn}function Gn(t,e){const r=new Re(vn,kn,[],e?function(t){const e={color:Tt,string:Vt,number:Bt,enum:Vt,boolean:Et,formatted:Dt,padding:Rt,projectionDefinition:Ft,resolvedImage:jt,variableAnchorOffsetCollection:Nt};return "array"===t.type?Ut(e[t.value]||Lt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Pn(new Un(n,e)):Cn(r.errors)}class Zn{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!In(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class Kn{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!In(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?rr.interpolationFactor(this.interpolationType,t,e,r):0}}function Xn(t,e){const r=Gn(t,e);if("error"===r.result)return r;const n=r.value.expression,i=Mn(n);if(!i&&!Bn(e))return Cn([new zt("","data expressions not supported")]);const s=zn(n,["zoom"]);if(!s&&!Vn(e))return Cn([new zt("","zoom expressions not supported")]);const a=Yn(n);return a||s?a instanceof zt?Cn([a]):a instanceof rr&&!En(e)?Cn([new zt("",'"interpolate" expressions cannot be used with this property')]):Pn(a?new Kn(i?"camera":"composite",r.value,a.labels,a instanceof rr?a.interpolation:void 0):new Zn(i?"constant":"source",r.value)):Cn([new zt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Hn{constructor(t,e){this._parameters=t,this._specification=e,It(this,Ln(this._parameters,this._specification));}static deserialize(t){return new Hn(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function Yn(t){let e=null;if(t instanceof je)e=Yn(t.result);else if(t instanceof sr){for(const r of t.args)if(e=Yn(r),e)break}else (t instanceof Ye||t instanceof rr)&&t.input instanceof bn&&"zoom"===t.input.name&&(e=t);return e instanceof zt||t.eachChild((t=>{const r=Yn(t);r instanceof zt?e=r:!e&&r?e=new zt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new zt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function Jn(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case "has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case "in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case "any":case "all":for(const e of t.slice(1))if(!Jn(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const Wn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Qn(t){if(null==t)return {filter:()=>!0,needGeometry:!1};Jn(t)||(t=ri(t));const e=Gn(t,Wn);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:ei(t)}}function ti(t,e){return te?1:0}function ei(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?ni(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(ri))):"all"===e?["all"].concat(t.slice(1).map(ri)):"none"===e?["all"].concat(t.slice(1).map(ri).map(ai)):"in"===e?ii(t[1],t.slice(2)):"!in"===e?ai(ii(t[1],t.slice(2))):"has"===e?si(t[1]):"!has"!==e||ai(si(t[1]));var r;}function ni(t,e,r){switch(t){case "$type":return [`filter-type-${r}`,e];case "$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function ii(t,e){if(0===e.length)return !1;switch(t){case "$type":return ["filter-type-in",["literal",e]];case "$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ti)]]:["filter-in-small",t,["literal",e]]}}function si(t){switch(t){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",t]}}function ai(t){return ["!",t]}function oi(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${oi(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new Mt(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function yi(t){const e=t.valueSpec,r=ci(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===Tn(t.value.stops)&&"array"===Tn(t.value.stops[0])&&"object"===Tn(t.value.stops[0][0]),c=pi({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new Mt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(fi({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Tn(n)&&0===n.length&&e.push(new Mt(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new Mt(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new Mt(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!En(t.valueSpec)&&c.push(new Mt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Bn(t.valueSpec)?c.push(new Mt(t.key,t.value,"property functions not supported")):o&&!Vn(t.valueSpec)&&c.push(new Mt(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new Mt(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==Tn(n))return [new Mt(o,n,`array expected, ${Tn(n)} found`)];if(2!==n.length)return [new Mt(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==Tn(n[0]))return [new Mt(o,n,`object expected, ${Tn(n[0])} found`)];if(void 0===n[0].zoom)return [new Mt(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new Mt(o,n,"object stop key must have value")];if(s&&s>ci(n[0].zoom))return [new Mt(o,n[0].zoom,"stop zoom values must appear in ascending order")];ci(n[0].zoom)!==s&&(s=ci(n[0].zoom),i=void 0,a={}),r=r.concat(pi({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:di,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return qn(hi(n[1]))?r.concat([new Mt(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=Tn(t.value),l=ci(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return [new Mt(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new Mt(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return Bn(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Mt(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew Mt(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new Mt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!In(r))return [new Mt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!In(r))return [new Mt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!zn(r,["zoom","feature-state"]))return [new Mt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Mn(r))return [new Mt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function gi(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(ci(r))&&i.push(new Mt(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(ci(r))&&i.push(new Mt(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function xi(t){return Jn(hi(t.value))?mi(It({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):vi(t)}function vi(t){const e=t.value,r=t.key;if("array"!==Tn(e))return [new Mt(r,e,`array expected, ${Tn(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return [new Mt(r,e,"filter array must have at least 1 element")];switch(s=s.concat(gi({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),ci(e[0])){case "<":case "<=":case ">":case ">=":e.length>=2&&"$type"===ci(e[1])&&s.push(new Mt(r,e,`"$type" cannot be use with operator "${e[0]}"`));case "==":case "!=":3!==e.length&&s.push(new Mt(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case "in":case "!in":e.length>=2&&(i=Tn(e[1]),"string"!==i&&s.push(new Mt(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new Mt(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{ci(e.id)===o&&(t=e);})),t?t.ref?e.push(new Mt(n,r.ref,"ref cannot reference another ref layer")):a=ci(t.type):e.push(new Mt(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&ci(t.type);t?"vector"===s&&"raster"===a?e.push(new Mt(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new Mt(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new Mt(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new Mt(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new Mt(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Mt(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Mt(n,r.source,`source "${r.source}" not found`));}else e.push(new Mt(n,r,'missing required property "source"'));return e=e.concat(pi({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:xi,layout:t=>pi({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>_i(It({layerType:a},t))}}),paint:t=>pi({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>wi(It({layerType:a},t))}})}})),e}function Ai(t){const e=t.value,r=t.key,n=Tn(e);return "string"!==n?[new Mt(r,e,`string expected, ${n} found`)]:[]}const ki={promoteId:function({key:t,value:e}){if("string"===Tn(e))return Ai({key:t,value:e});{const r=[];for(const n in e)r.push(...Ai({key:`${t}.${n}`,value:e[n]}));return r}}};function Mi(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new Mt(r,e,'"type" is required')];const a=ci(e.type);let o;switch(a){case "vector":case "raster":return o=pi({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:ki,validateSpec:s}),o;case "raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=Tn(n);if(void 0===n)return o;if("object"!==l)return o.push(new Mt("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===ci(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new Mt(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new Mt(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case "geojson":if(o=pi({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:ki}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],s="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...mi({key:`${r}.${t}.map`,value:i,expressionContext:"cluster-map"})),o.push(...mi({key:`${r}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}));}return o;case "video":return pi({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case "image":return pi({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case "canvas":return [new Mt(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return gi({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Ii(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=Tn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Mt("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Mt(a,e[a],`unknown property "${a}"`)]);}return s}function zi(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=Tn(e);if(void 0===e)return [];if("object"!==s)return [new Mt("sky",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Mt(s,e[s],`unknown property "${s}"`)]);return a}function Pi(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=Tn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Mt("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Mt(a,e[a],`unknown property "${a}"`)]);return s}function Ci(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new Mt(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new Mt(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(pi({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Ai({key:n,value:r})}const Bi={"*":()=>[],array:fi,boolean:function(t){const e=t.value,r=t.key,n=Tn(e);return "boolean"!==n?[new Mt(r,e,`boolean expected, ${n} found`)]:[]},number:di,color:function(t){const e=t.key,r=t.value,n=Tn(r);return "string"!==n?[new Mt(e,r,`color expected, ${n} found`)]:xe.parse(String(r))?[]:[new Mt(e,r,`color expected, "${r}" found`)]},constants:ui,enum:gi,filter:xi,function:yi,layer:Si,object:pi,source:Mi,light:Ii,sky:zi,terrain:Pi,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=Tn(e);if(void 0===e)return [];if("object"!==s)return [new Mt("projection",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Mt(s,e[s],`unknown property "${s}"`)]);return a},projectionDefinition:function(t){const e=t.key;let r=t.value;r=r instanceof String?r.valueOf():r;const n=Tn(r);return "array"!==n||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(r)||function(t){return !!["interpolate","step","literal"].includes(t[0])}(r)?["array","string"].includes(n)?[]:[new Mt(e,r,`projection expected, invalid type "${n}" found`)]:[new Mt(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:Ai,formatted:function(t){return 0===Ai(t).length?[]:mi(t)},resolvedImage:function(t){return 0===Ai(t).length?[]:mi(t)},padding:function(t){const e=t.key,r=t.value;if("array"===Tn(r)){if(r.length<1||r.length>4)return [new Mt(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(ui({key:"constants",value:t.constants}))),$i(r)}function Fi(t){return function(e){return t({...e,validateSpec:Vi})}}function $i(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function Li(t){return function(...e){return $i(t.apply(this,e))}}Ti.source=Li(Fi(Mi)),Ti.sprite=Li(Fi(Ci)),Ti.glyphs=Li(Fi(Ei)),Ti.light=Li(Fi(Ii)),Ti.sky=Li(Fi(zi)),Ti.terrain=Li(Fi(Pi)),Ti.layer=Li(Fi(Si)),Ti.filter=Li(Fi(xi)),Ti.paintProperty=Li(Fi(wi)),Ti.layoutProperty=Li(Fi(_i));const Oi=Ti,Di=Oi.light,Ri=Oi.sky,ji=Oi.paintProperty,Ni=Oi.layoutProperty;function Ui(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new pt(new Error(n.message))),r=!0;return r}class qi{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1;}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const s=t[n];i[n]=Gi[r].shallow.indexOf(n)>=0?s:Yi(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(i.$name=r),i}function Ji(t){if(Hi(t))return t;if(Array.isArray(t))return t.map(Ji);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=Xi(t)||"Object";if(!Gi[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Gi[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=Gi[e].shallow.indexOf(r)>=0?i:Ji(i);}return n}class Wi{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Hangul Syllables":t=>t>=44032&&t<=55215,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function ts(t){for(const e of t)if(as(e.charCodeAt(0)))return !0;return !1}function es(t){for(const e of t)if(!is(e.charCodeAt(0)))return !1;return !0}function rs(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const ns=rs(["Arab","Dupl","Mong","Ougr","Syrc"]);function is(t){return !ns.test(String.fromCodePoint(t))}const ss=rs(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function as(t){return !(746!==t&&747!==t&&(t<4352||!(Qi["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Qi["CJK Compatibility"](t)||Qi["CJK Strokes"](t)||!(!Qi["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Qi["Enclosed CJK Letters and Months"](t)||Qi["Ideographic Description Characters"](t)||Qi.Kanbun(t)||Qi.Katakana(t)&&12540!==t||!(!Qi["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Qi["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Qi["Vertical Forms"](t)||Qi["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||ss.test(String.fromCodePoint(t)))))}function os(t){return !(as(t)||function(t){return !!(Qi["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Qi["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||Qi["Letterlike Symbols"](t)||Qi["Number Forms"](t)||Qi["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||Qi["Control Pictures"](t)&&9251!==t||Qi["Optical Character Recognition"](t)||Qi["Enclosed Alphanumerics"](t)||Qi["Geometric Shapes"](t)||Qi["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Qi["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Qi["CJK Symbols and Punctuation"](t)||Qi.Katakana(t)||Qi["Private Use Area"](t)||Qi["CJK Compatibility Forms"](t)||Qi["Small Form Variants"](t)||Qi["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const ls=rs(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function us(t){return ls.test(String.fromCodePoint(t))}function cs(t,e){return !(!e&&us(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Qi.Khmer(t))}function hs(t){for(const e of t)if(us(e.charCodeAt(0)))return !0;return !1}const ps=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{};}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(ps.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve();}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,r){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((t=>{this.loadScriptResolve=t;}));r(e);const i=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([n,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class fs{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Wi,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!cs(r.charCodeAt(0),e))return !1;return !0}(t,"loaded"===ps.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class ds{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Fn(t))return new Hn(t,e);if(qn(t)){const r=Xn(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=xe.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?r=Me.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(r=ze.parse(t)):r=Se.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class ys{constructor(t){this.property=t,this.value=new ds(t,void 0);}transitioned(t,e){return new gs(this.property,this.value,e,F({},t.transition,this.transition),t.now)}untransitioned(){return new gs(this.property,this.value,null,{},0)}}class ms{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return D(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ys(this._values[t].property)),this._values[t].value=new ds(this._values[t].property,null===e?void 0:D(e));}getTransition(t){return D(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ys(this._values[t].property)),this._values[t].transition=D(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new xs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new xs(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class gs{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(nn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class ks{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new fs(Math.floor(e.zoom-1),e)),t.expression.evaluate(new fs(Math.floor(e.zoom),e)),t.expression.evaluate(new fs(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Ms{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class Is{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new ds(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new ys(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}Zi("DataDrivenProperty",Ss),Zi("DataConstantProperty",_s),Zi("CrossFadedDataDrivenProperty",As),Zi("CrossFadedProperty",ks),Zi("ColorRampProperty",Ms);const zs="-transition";class Ps extends ft{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new vs(e.layout)),e.paint)){this._transitionablePaint=new ms(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ws(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(Ni,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(zs)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(ji,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(zs))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),O(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&Ui(this,t.call(Oi,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:dt,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof bs&&Bn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const Cs={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Bs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class Vs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Es(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=Cs[t.type].BYTES_PER_ELEMENT,s=r=Ts(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Ts(r,Math.max(n,e)),alignment:e}}function Ts(t,e){return Math.ceil(t/e)*e}class Fs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Fs.prototype.bytesPerElement=4,Zi("StructArrayLayout2i4",Fs);class $s extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}$s.prototype.bytesPerElement=6,Zi("StructArrayLayout3i6",$s);class Ls extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Ls.prototype.bytesPerElement=8,Zi("StructArrayLayout4i8",Ls);class Os extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Os.prototype.bytesPerElement=12,Zi("StructArrayLayout2i4i12",Os);class Ds extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}Ds.prototype.bytesPerElement=8,Zi("StructArrayLayout2i4ub8",Ds);class Rs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Rs.prototype.bytesPerElement=8,Zi("StructArrayLayout2f8",Rs);class js extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}js.prototype.bytesPerElement=20,Zi("StructArrayLayout10ui20",js);class Ns extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}Ns.prototype.bytesPerElement=24,Zi("StructArrayLayout4i4ui4i24",Ns);class Us extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Us.prototype.bytesPerElement=12,Zi("StructArrayLayout3f12",Us);class qs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}qs.prototype.bytesPerElement=4,Zi("StructArrayLayout1ul4",qs);class Gs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}Gs.prototype.bytesPerElement=20,Zi("StructArrayLayout6i1ul2ui20",Gs);class Zs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Zs.prototype.bytesPerElement=12,Zi("StructArrayLayout2i2i2i12",Zs);class Ks extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}Ks.prototype.bytesPerElement=16,Zi("StructArrayLayout2f1f2i16",Ks);class Xs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=16*t,l=4*t,u=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=a,t}}Xs.prototype.bytesPerElement=16,Zi("StructArrayLayout2ub2f2i16",Xs);class Hs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Hs.prototype.bytesPerElement=6,Zi("StructArrayLayout3ui6",Hs);class Ys extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}Ys.prototype.bytesPerElement=48,Zi("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Ys);class Js extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=S,this.uint32[C+12]=A,this.float32[C+13]=k,this.float32[C+14]=M,this.uint16[P+30]=I,this.uint16[P+31]=z,t}}Js.prototype.bytesPerElement=64,Zi("StructArrayLayout8i15ui1ul2f2ui64",Js);class Ws extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Ws.prototype.bytesPerElement=4,Zi("StructArrayLayout1f4",Ws);class Qs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Qs.prototype.bytesPerElement=12,Zi("StructArrayLayout1ui2f12",Qs);class ta extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}ta.prototype.bytesPerElement=8,Zi("StructArrayLayout1ul2ui8",ta);class ea extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}ea.prototype.bytesPerElement=4,Zi("StructArrayLayout2ui4",ea);class ra extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}ra.prototype.bytesPerElement=2,Zi("StructArrayLayout1ui2",ra);class na extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}na.prototype.bytesPerElement=16,Zi("StructArrayLayout4f16",na);class ia extends Bs{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}ia.prototype.size=20;class sa extends Gs{get(t){return new ia(this,t)}}Zi("CollisionBoxArray",sa);class aa extends Bs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}aa.prototype.size=48;class oa extends Ys{get(t){return new aa(this,t)}}Zi("PlacedSymbolArray",oa);class la extends Bs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}la.prototype.size=64;class ua extends Js{get(t){return new la(this,t)}}Zi("SymbolInstanceArray",ua);class ca extends Ws{getoffsetX(t){return this.float32[1*t+0]}}Zi("GlyphOffsetArray",ca);class ha extends $s{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Zi("SymbolLineVertexArray",ha);class pa extends Bs{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}pa.prototype.size=12;class fa extends Qs{get(t){return new pa(this,t)}}Zi("TextAnchorOffsetArray",fa);class da extends Bs{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}da.prototype.size=8;class ya extends ta{get(t){return new da(this,t)}}Zi("FeatureIndexArray",ya);class ma extends Fs{}class ga extends Fs{}class xa extends Fs{}class va extends Os{}class ba extends Ds{}class wa extends Rs{}class _a extends js{}class Sa extends Ns{}class Aa extends Us{}class ka extends qs{}class Ma extends Zs{}class Ia extends Xs{}class za extends Hs{}class Pa extends ea{}const Ca=Es([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ba}=Ca;class Va{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t;}prepareSegment(t,e,r,n){const i=this.segments[this.segments.length-1];return t>Va.MAX_VERTEX_ARRAY_LENGTH&&j(`Max vertices per segment is ${Va.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Va.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+t>Va.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n?this.createNewSegment(e,r,n):i}createNewSegment(t,e,r){const n={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==r&&(n.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(t,e,r){return this.prepareSegment(0,t,e,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0;}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new Va([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ea(t,e){return 256*(t=E(Math.floor(t),0,255))+E(Math.floor(e),0,255)}Va.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Zi("SegmentVector",Va);const Ta=Es([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Fa,$a,La,Oa={exports:{}},Da={exports:{}},Ra={exports:{}},ja=function(){if(La)return Oa.exports;La=1;var t=(Fa||(Fa=1,Da.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Da.exports),e=($a||($a=1,Ra.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),Ra.exports);return Oa.exports=t,Oa.exports.murmur3=t,Oa.exports.murmur2=e,Oa.exports}(),Na=r(ja);class Ua{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(qa(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=qa(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Ga(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new Ua;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function qa(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Na(String(t))}function Ga(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;Za(t,s,a),Za(e,3*s,3*a),Za(e,3*s+1,3*a+1),Za(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new Ya(t,e):new Xa(t,e)}}class to{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new Ha(t,e):new Xa(t,e)}}class eo{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new fs(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=Wa(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new fs(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new fs(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Wa(r),s=Wa(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof eo||r instanceof ro)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new io(n,e,r);this.needsUpload=!1,this._featureMap=new Ua,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function ao(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function oo(t,e,r){const n={color:{source:Rs,composite:na},number:{source:Ws,composite:Rs}},i=function(t){return {"line-pattern":{source:_a,composite:_a},"fill-pattern":{source:_a,composite:_a},"fill-extrusion-pattern":{source:_a,composite:_a}}[t]}(t);return i&&i[r]||n[e][r]}Zi("ConstantBinder",Qa),Zi("CrossFadedConstantBinder",to),Zi("SourceExpressionBinder",eo),Zi("CrossFadedCompositeBinder",no),Zi("CompositeExpressionBinder",ro),Zi("ProgramConfiguration",io,{omit:["_buffers"]}),Zi("ProgramConfigurationSet",so);const lo=Math.pow(2,14)-1,uo=-lo-1;function co(t){const e=M/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&j("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function ho(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?co(t):[]}}const po=-32768;function fo(t,e,r,n,i){t.emplaceBack(po+8*e+n,po+8*r+i);}class yo{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ga,this.indexArray=new za,this.segments=new Va,this.programConfigurations=new so(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1,o="heatmap"===n.type;if("circle"===n.type){const t=n;s=t.layout.get("circle-sort-key"),a=!s.isConstant(),o=o||"map"===t.paint.get("circle-pitch-alignment");}const l=o?e.subdivisionGranularity.circle:1;for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ho(e,t);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:co(e),patterns:{},sortKey:c};i.push(h);}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r,l),e.featureIndex.insert(o,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ba),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const a=s.length;for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=M||n<0||n>=M)continue;const i=this.segments.prepareSegment(a*a,this.layoutVertexArray,this.indexArray,t.sortKey),o=i.vertexLength;for(let t=0;t1){if(bo(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function Ao(t,e){for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function Mo(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=N(t,e,r[0]);return s!==N(t,e,r[1])||s!==N(t,e,r[2])||s!==N(t,e,r[3])}function Io(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function zo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Po(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=l.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let e=0;eTo(t,e,r,n)))}(l,i,a,o),p=c?u*s:u;for(const t of n)for(const e of t){const t=c?e:To(e,i,a,o);let r=p;const n=i.projectTileCoordinates(e.x,e.y,a,o).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n/i.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=i.cameraToCenterDistance/n),go(h,t,r))return !0}return !1}}function To(t,e,r,n){const i=e.projectTileCoordinates(t.x,t.y,r,n).point;return new l((.5*i.x+.5)*e.width,(.5*-i.y+.5)*e.height)}class Fo extends yo{}let $o;Zi("HeatmapBucket",Fo,{omit:["layers"]});var Lo={get paint(){return $o=$o||new Is({"heatmap-radius":new Ss(dt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ss(dt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new _s(dt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ms(dt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new _s(dt.paint_heatmap["heatmap-opacity"])})}};function Oo(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function Do(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Oo({},{width:e,height:r},n);Ro(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function Ro(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a);};if(t.clips)for(let e=0,i=0;e0)for(let i=e;i=e;i-=n)s=wl(i/n|0,t[i],t[i+1],s);return s&&yl(s,s.next)&&(_l(s),s=s.next),s}function tl(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!yl(n,n.next)&&0!==dl(n.prev,n,n.next))n=n.next;else {if(_l(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function el(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=ul(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?nl(t,n,i,s):rl(t))e.push(l.i,t.i,u.i),_l(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?el(t=il(tl(t),e),e,r,n,i,s,2):2===a&&sl(t,e,r,n,i,s):el(tl(t),e,r,n,i,s,1);break}}}function rl(t){const e=t.prev,r=t,n=t.next;if(dl(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),p=Math.max(i,s,a),f=Math.max(o,l,u);let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&pl(i,o,s,l,a,u,d.x,d.y)&&dl(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function nl(t,e,r,n){const i=t.prev,s=t,a=t.next;if(dl(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=Math.min(o,l,u),d=Math.min(c,h,p),y=Math.max(o,l,u),m=Math.max(c,h,p),g=ul(f,d,e,r,n),x=ul(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&pl(o,c,l,h,u,p,v.x,v.y)&&dl(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&pl(o,c,l,h,u,p,b.x,b.y)&&dl(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&pl(o,c,l,h,u,p,v.x,v.y)&&dl(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&pl(o,c,l,h,u,p,b.x,b.y)&&dl(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function il(t,e){let r=t;do{const n=r.prev,i=r.next.next;!yl(n,i)&&ml(n,r,r.next,i)&&vl(n,i)&&vl(i,n)&&(e.push(n.i,r.i,i.i),_l(r),_l(r.next),r=t=i),r=r.next;}while(r!==t);return tl(r)}function sl(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&fl(a,t)){let o=bl(a,t);return a=tl(a,a.next),o=tl(o,o.next),el(a,e,r,n,i,s,0),void el(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function al(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function ol(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;if(yl(t,r))return r;do{if(yl(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&hl(is.x||r.x===s.x&&ll(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=bl(r,t);return tl(n,n.next),tl(r,r.next)}function ll(t,e){return dl(t.prev,t,e.prev)<0&&dl(e.next,t,t.next)<0}function ul(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function cl(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function pl(t,e,r,n,i,s,a,o){return !(t===a&&e===o)&&hl(t,e,r,n,i,s,a,o)}function fl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&ml(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(vl(t,e)&&vl(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(dl(t.prev,t,e.prev)||dl(t,e.prev,e))||yl(t,e)&&dl(t.prev,t,t.next)>0&&dl(e.prev,e,e.next)>0)}function dl(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function yl(t,e){return t.x===e.x&&t.y===e.y}function ml(t,e,r,n){const i=xl(dl(t,e,r)),s=xl(dl(t,e,n)),a=xl(dl(r,n,t)),o=xl(dl(r,n,e));return i!==s&&a!==o||!(0!==i||!gl(t,r,e))||!(0!==s||!gl(t,n,e))||!(0!==a||!gl(r,t,n))||!(0!==o||!gl(r,e,n))}function gl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function xl(t){return t>0?1:t<0?-1:0}function vl(t,e){return dl(t.prev,t,t.next)<0?dl(t,e,t.next)>=0&&dl(t,t.prev,e)>=0:dl(t,e,t.prev)<0||dl(t,t.next,e)<0}function bl(t,e){const r=Sl(t.i,t.x,t.y),n=Sl(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function wl(t,e,r,n){const i=Sl(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function _l(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Sl(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Al{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e;}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const r=0|Math.round(t),n=0|Math.round(e),i=this._getKey(r,n);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(r,n),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const r=[];for(let n=0;n0?(r.push(i),r.push(a),r.push(s)):(r.push(i),r.push(s),r.push(a));}return r}(this._vertexBuffer,t);const e=[],r=t.length;for(let n=0;n=1||v<=0)||y&&(oi)){u>=n&&u<=i&&s.push(r[(t+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(a+p*x,o+f*x));const b=a+p*Math.max(x,0),w=a+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,a,o,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(a+p*v,o+f*v)),(y||u>=n&&u<=i)&&s.push(r[(t+1)%3]),!y&&(u<=n||u>=i)&&this._generateInterEdgeVertices(s,a,o,l,u,c,h,w,n,i);}return s}_generateIntraEdgeVertices(t,e,r,n,i,s,a){const o=n-e,l=i-r,u=0===l,c=u?Math.min(e,n):Math.min(s,a),h=u?Math.max(e,n):Math.max(s,a),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?e=p;n--){const i=n*this._granularityCellSize;t.push(this._vertexToIndex(i,r+l*(i-e)/o));}}_generateInterEdgeVertices(t,e,r,n,i,s,a,o,l,u){const c=i-r,h=s-n,p=a-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=n+h*y;let x=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,b=o=1||m<=0){const t=r-a,n=s+(e-s)*Math.min((l-a)/t,(u-a)/t);x=Math.floor(Math.min(n,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,o)/this._granularityCellSize)-1,b=o0?u:l;if(b)for(let e=x;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,_));else for(let e=v;e>=x;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,_));}_generateOutline(t){const e=[];for(const r of t){const t=Cl(r,this._granularity,!0),n=this._pointArrayToIndices(t),i=[];for(let t=1;ti!=(s===Ml)?(t.push(e),t.push(r),t.push(this._vertexToIndex(n,s)),t.push(r),t.push(this._vertexToIndex(i,s)),t.push(this._vertexToIndex(n,s))):(t.push(r),t.push(e),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(i,s)),t.push(r),t.push(this._vertexToIndex(n,s)));}_fillPoles(t,e,r){const n=this._vertexBuffer,i=M,s=t.length;for(let a=2;a80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return el(s,a,r,o,l,u,0),a}(r,n),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e);}catch(t){console.error(t);}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(t,e){const r=[];for(let n=0;n0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,e=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(x-t),n=Math.abs(v-e),i=Math.abs(x-c),s=Math.abs(v-h),u=p?r/m:Number.POSITIVE_INFINITY,b=f?n/g:Number.POSITIVE_INFINITY;if((i<=r||!p)&&(s<=n||!f))break;if(u=0?a-1:s-1,i=(o+1)%s,l=t[2*e[n]],u=t[2*e[i]],c=t[2*e[a]],h=t[2*e[a]+1],p=t[2*e[o]+1];let f=!1;if(lu)f=!1;else {const r=p-h,s=-(t[2*e[o]]-c),a=h((u-c)*r+(t[2*e[i]+1]-h)*s)*a&&(f=!0);}if(f){const t=e[n],i=e[a],l=e[o];t!==i&&t!==l&&i!==l&&r.push(l,i,t),a--,a<0&&(a=s-1);}else {const t=e[i],n=e[a],l=e[o];t!==n&&t!==l&&n!==l&&r.push(l,n,t),o++,o>=s&&(o=0);}if(n===i)break}}function Vl(t,e,r,n,i,s,a,o,l){const u=i.length/2,c=a&&o&&l;if(uVa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,g=!0,c=0);const x=El(a,n,s,o,p,y,u),v=El(a,n,s,o,f,m,u),b=El(a,n,s,o,d,g,u);r.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++;}}(e,r,n,i,s,t),c&&function(t,e,r,n,i,s){const a=[];for(let t=0;tVa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,d=!0,y=!0,c=0);const m=El(a,n,s,o,i,d,u),g=El(a,n,s,o,h,y,u);r.emplaceBack(c+m-l,c+g-l),u.primitiveLength++;}}}(a,r,o,i,l,t),e.forceNewSegmentOnNextPrepare(),null==a||a.forceNewSegmentOnNextPrepare();}function El(t,e,r,n,i,s,a){if(s){const s=n.count;return r(e[2*i],e[2*i+1]),t[i]=n.count,n.count++,a.vertexLength++,s}return t[i]}class Tl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new xa,this.indexArray=new za,this.indexArray2=new Pa,this.programConfigurations=new so(t.layers,t.zoom),this.segments=new Va,this.segments2=new Va,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Jo("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ho(a,t);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:co(a),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Wo("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Yo),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s){for(const t of Ur(e,500)){const e=Pl(t,n,s.fill.getGranularityForZoomLevel(n.z)),r=this.layoutVertexArray;Vl(((t,e)=>{r.emplaceBack(t,e);}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}}let Fl,$l;Zi("FillBucket",Tl,{omit:["layers","patternFeatures"]});var Ll={get paint(){return $l=$l||new Is({"fill-antialias":new _s(dt.paint_fill["fill-antialias"]),"fill-opacity":new Ss(dt.paint_fill["fill-opacity"]),"fill-color":new Ss(dt.paint_fill["fill-color"]),"fill-outline-color":new Ss(dt.paint_fill["fill-outline-color"]),"fill-translate":new _s(dt.paint_fill["fill-translate"]),"fill-translate-anchor":new _s(dt.paint_fill["fill-translate-anchor"]),"fill-pattern":new As(dt.paint_fill["fill-pattern"])})},get layout(){return Fl=Fl||new Is({"fill-sort-key":new Ss(dt.layout_fill["fill-sort-key"])})}};class Ol extends Ps{constructor(t){super(t,Ll);}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Tl(t)}queryRadius(){return zo(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:r,pixelsToTileUnits:n}){return xo(Po(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,n),e)}isTileClipped(){return !0}}const Dl=Es([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Rl=Es([{name:"a_centroid",components:2,type:"Int16"}],4),{members:jl}=Dl;var Nl,Ul,ql,Gl,Zl,Kl,Xl,Hl={};function Yl(){if(Ul)return Nl;Ul=1;var t=s();function e(t,e,n,i,s){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=s,t.readFields(r,this,e);}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){for(var r=t.readVarint()+t.pos;t.pos>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(a,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var s,a,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return ql=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},ql}function Wl(){return Xl||(Xl=1,Hl.VectorTile=function(){if(Kl)return Zl;Kl=1;var t=Jl();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return Zl=function(t,r){this.layers=t.readFields(e,{},r);},Zl}(),Hl.VectorTileFeature=Yl(),Hl.VectorTileLayer=Jl()),Hl}var Ql=r(Wl());const tu=Ql.VectorTileFeature.types,eu=Math.pow(2,13);function ru(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*eu)+a,i*eu*2,s*eu*2,Math.round(o));}class nu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new va,this.centroidVertexArray=new ma,this.indexArray=new za,this.programConfigurations=new so(t.layers,t.zoom),this.segments=new Va,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=Jo("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=ho(n,t);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:co(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Wo("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{},e.subdivisionGranularity),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0);}}addFeatures(t,e,r){for(const n of this.features){const{geometry:i}=n;this.addFeature(n,i,n.index,e,r,t.subdivisionGranularity);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,jl),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Rl.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i,s){for(const r of Ur(e,500)){const e={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(e,n,t,r,s);const a=this.layoutVertexArray.length-i,o=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t{ru(u,t,e,0,0,1,1,0);}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles);}_generateSideFaces(t,e){let r=0;for(let n=1;nVa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const a=i.sub(s)._perp()._unit(),o=s.dist(i);r+o>32768&&(r=0),ru(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,0,r),ru(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,1,r),r+=o,ru(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,0,r),ru(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,1,r);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2;}}}function iu(t,e){for(let r=0;rM)||t.y===e.y&&(t.y<0||t.y>M)}function au(t){return t.every((t=>t.x<0))||t.every((t=>t.x>M))||t.every((t=>t.y<0))||t.every((t=>t.y>M))}let ou;Zi("FillExtrusionBucket",nu,{omit:["layers","features"]});var lu={get paint(){return ou=ou||new Is({"fill-extrusion-opacity":new _s(dt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ss(dt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new _s(dt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new _s(dt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new As(dt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ss(dt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ss(dt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new _s(dt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class uu extends Ps{constructor(t){super(t,lu);}createBucket(t){return new nu(t)}queryRadius(){return zo(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s,pixelPosMatrix:a}){const o=Po(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-i.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(e,r),c=this.paint.get("fill-extrusion-base").evaluate(e,r),h=function(t,e,r){const n=[];for(const r of t){const t=[r.x,r.y,0,1];_(t,t,e),n.push(new l(t[0]/t[3],t[1]/t[3]));}return n}(o,a),p=function(t,e,r,n){const i=[],s=[],a=n[8]*e,o=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,s=i.y,y=n[0]*e+n[4]*s+n[12],m=n[1]*e+n[5]*s+n[13],g=n[2]*e+n[6]*s+n[14],x=n[3]*e+n[7]*s+n[15],v=g+u,b=x+c,w=y+h,_=m+p,S=g+f,A=x+d,k=new l((y+a)/b,(m+o)/b);k.z=v/b,t.push(k);const M=new l(w/A,_/A);M.z=S/A,r.push(M);}i.push(t),s.push(r);}return [i,s]}(n,c,u,a);return function(t,e,r){let n=1/0;xo(r,e)&&(n=hu(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new ba,this.layoutVertexArray2=new wa,this.indexArray=new za,this.programConfigurations=new so(t.layers,t.zoom),this.segments=new Va,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Jo("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ho(e,t);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:co(e),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Wo("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,yu)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,fu),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),l=a.get("line-cap"),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,s,a,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Cl(t,a?o.line.getGranularityForZoomLevel(a.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c0;if(w&&e>c){const t=f.dist(d);if(t>2*h){const e=f.sub(f.sub(d)._mult(h/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,m,0,0,p),d=e;}}const S=d&&y;let A=S?r:l?"butt":n;if(S&&"round"===A&&(vi&&(A="bevel"),"bevel"===A&&(v>2&&(A="flipbevel"),v100)a=g.mult(-1);else {const t=v*m.add(g).mag()/m.sub(g).mag();a._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(f,a,0,0,p),this.addCurrentVertex(f,a.mult(-1),0,0,p);}else if("bevel"===A||"fakeround"===A){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(d&&this.addCurrentVertex(f,m,e,r,p),"fakeround"===A){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*h){const e=f.add(y.sub(f)._mult(h/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,p),f=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>xu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s));}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(xu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let bu,wu;Zi("LineBucket",vu,{omit:["layers","patternFeatures"]});var _u={get paint(){return wu=wu||new Is({"line-opacity":new Ss(dt.paint_line["line-opacity"]),"line-color":new Ss(dt.paint_line["line-color"]),"line-translate":new _s(dt.paint_line["line-translate"]),"line-translate-anchor":new _s(dt.paint_line["line-translate-anchor"]),"line-width":new Ss(dt.paint_line["line-width"]),"line-gap-width":new Ss(dt.paint_line["line-gap-width"]),"line-offset":new Ss(dt.paint_line["line-offset"]),"line-blur":new Ss(dt.paint_line["line-blur"]),"line-dasharray":new ks(dt.paint_line["line-dasharray"]),"line-pattern":new As(dt.paint_line["line-pattern"]),"line-gradient":new Ms(dt.paint_line["line-gradient"])})},get layout(){return bu=bu||new Is({"line-cap":new _s(dt.layout_line["line-cap"]),"line-join":new Ss(dt.layout_line["line-join"]),"line-miter-limit":new _s(dt.layout_line["line-miter-limit"]),"line-round-limit":new _s(dt.layout_line["line-round-limit"]),"line-sort-key":new Ss(dt.layout_line["line-sort-key"])})}};class Su extends Ss{possiblyEvaluate(t,e){return e=new fs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=F({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let Au;class ku extends Ps{constructor(t){super(t,_u),this.gradientVersion=0,Au||(Au=new Su(_u.paint.properties["line-width"].specification),Au.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Ye,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Au.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new vu(t)}queryRadius(t){const e=t,r=Mu(Io("line-width",this,e),Io("line-gap-width",this,e)),n=Io("line-offset",this,e);return r/2+Math.abs(n)+zo(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s}){const a=Po(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-i.bearingInRadians,s),o=s/2*Mu(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Iu=Es([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),zu=Es([{name:"a_projected_pos",components:3,type:"Float32"}],4);Es([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Pu=Es([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Es([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cu=Es([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Bu=Es([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Vu(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),ps.applyArabicShaping&&(t=ps.applyArabicShaping(t)),t}(t.text,e,r);})),t}Es([{name:"triangle",components:3,type:"Uint16"}]),Es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Es([{type:"Float32",name:"offsetX"}]),Es([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Es([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Eu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Tu,Fu,$u,Lu=24,Ou={};function Du(){return Tu||(Tu=1,Ou.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},Ou.write=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;}),Ou}function Ru(){if($u)return Fu;$u=1,Fu=e;var t=Du();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function v(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return a(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=s(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},Fu}var ju=r(Ru());const Nu=3;function Uu(t,e,r){1===t&&r.readMessage(qu,e);}function qu(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(Gu,{});e.push({id:t,bitmap:new jo({width:i+2*Nu,height:s+2*Nu},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}}function Gu(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const Zu=Nu;function Ku(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&rc[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new tc;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}getMaxImageSize(t){let e=0,r=0;for(let n=0;n=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ec(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=tc.fromFeature(e,s);let g;p===t.ah.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=ps;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),cc(m,c,a,r,i,d));for(const e of t){const t=new tc;t.text=e,t.sections=m.sections;for(let r=0;r=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/a,a=t;}return {x1:n,y1:i,x2:n+s,y2:i+a}}function bc(t,e,r,n,i,s){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-a.displaySize[1])/2,p=c+a.displaySize[1]),{image:a,top:c,right:h,bottom:p,left:f,collisionPadding:o}}const wc=255,_c=128,Sc=wc*_c;function Ac(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new fs(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ac(this.zoom,r["text-size"]),this.iconSizeData=Ac(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap="never"!==kc(n,"text-overlap","text-allow-overlap")||"never"!==kc(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ah[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Bc(new so(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Bc(new so(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new ca,this.lineVertexArray=new ha,this.symbolInstances=new ua,this.textAnchorOffsets=new fa;}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new fs(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=ho(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=co(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=_e.factory(t),r=this.hasRTLText=this.hasRTLText||Cc(e);(!r||"unavailable"===ps.getRTLTextPluginStatus()||r&&ps.isParsed())&&(x=Vu(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof Ie?t:Ie.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:Mc[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=a.evaluate(g,{},n).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ah.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=ts(x.toString()),i=t.fontStack||e,s=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,s,r,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Tc,Fc;Zi("SymbolBucket",Ec,{omit:["layers","collisionBoxArray","features","compareText"]}),Ec.MAX_GLYPHS=65535,Ec.addDynamicAttributes=Pc;var $c={get paint(){return Fc=Fc||new Is({"icon-opacity":new Ss(dt.paint_symbol["icon-opacity"]),"icon-color":new Ss(dt.paint_symbol["icon-color"]),"icon-halo-color":new Ss(dt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ss(dt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ss(dt.paint_symbol["icon-halo-blur"]),"icon-translate":new _s(dt.paint_symbol["icon-translate"]),"icon-translate-anchor":new _s(dt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ss(dt.paint_symbol["text-opacity"]),"text-color":new Ss(dt.paint_symbol["text-color"],{runtimeType:Tt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Ss(dt.paint_symbol["text-halo-color"]),"text-halo-width":new Ss(dt.paint_symbol["text-halo-width"]),"text-halo-blur":new Ss(dt.paint_symbol["text-halo-blur"]),"text-translate":new _s(dt.paint_symbol["text-translate"]),"text-translate-anchor":new _s(dt.paint_symbol["text-translate-anchor"])})},get layout(){return Tc=Tc||new Is({"symbol-placement":new _s(dt.layout_symbol["symbol-placement"]),"symbol-spacing":new _s(dt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new _s(dt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ss(dt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new _s(dt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new _s(dt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new _s(dt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new _s(dt.layout_symbol["icon-ignore-placement"]),"icon-optional":new _s(dt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new _s(dt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ss(dt.layout_symbol["icon-size"]),"icon-text-fit":new _s(dt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new _s(dt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ss(dt.layout_symbol["icon-image"]),"icon-rotate":new Ss(dt.layout_symbol["icon-rotate"]),"icon-padding":new Ss(dt.layout_symbol["icon-padding"]),"icon-keep-upright":new _s(dt.layout_symbol["icon-keep-upright"]),"icon-offset":new Ss(dt.layout_symbol["icon-offset"]),"icon-anchor":new Ss(dt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new _s(dt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new _s(dt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new _s(dt.layout_symbol["text-rotation-alignment"]),"text-field":new Ss(dt.layout_symbol["text-field"]),"text-font":new Ss(dt.layout_symbol["text-font"]),"text-size":new Ss(dt.layout_symbol["text-size"]),"text-max-width":new Ss(dt.layout_symbol["text-max-width"]),"text-line-height":new _s(dt.layout_symbol["text-line-height"]),"text-letter-spacing":new Ss(dt.layout_symbol["text-letter-spacing"]),"text-justify":new Ss(dt.layout_symbol["text-justify"]),"text-radial-offset":new Ss(dt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new _s(dt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ss(dt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ss(dt.layout_symbol["text-anchor"]),"text-max-angle":new _s(dt.layout_symbol["text-max-angle"]),"text-writing-mode":new _s(dt.layout_symbol["text-writing-mode"]),"text-rotate":new Ss(dt.layout_symbol["text-rotate"]),"text-padding":new _s(dt.layout_symbol["text-padding"]),"text-keep-upright":new _s(dt.layout_symbol["text-keep-upright"]),"text-transform":new Ss(dt.layout_symbol["text-transform"]),"text-offset":new Ss(dt.layout_symbol["text-offset"]),"text-allow-overlap":new _s(dt.layout_symbol["text-allow-overlap"]),"text-overlap":new _s(dt.layout_symbol["text-overlap"]),"text-ignore-placement":new _s(dt.layout_symbol["text-ignore-placement"]),"text-optional":new _s(dt.layout_symbol["text-optional"])})}};class Lc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Ct,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Zi("FormatSectionOverride",Lc,{omit:["defaultValue"]});class Oc extends Ps{constructor(t){super(t,$c);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||qn(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Ec(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of $c.paint.overridableProperties){if(!Oc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Lc(e),n=new Un(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Zn("source",n):new Kn("composite",n,e.value.zoomStops),this.paint._values[t]=new bs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&Oc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=$c.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof _e)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof Ee&&Be(e.value)===Dt?s(e.value.sections):e instanceof gr?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Dc;var Rc={get paint(){return Dc=Dc||new Is({"background-color":new _s(dt.paint_background["background-color"]),"background-pattern":new ks(dt.paint_background["background-pattern"]),"background-opacity":new _s(dt.paint_background["background-opacity"])})}};class jc extends Ps{constructor(t){super(t,Rc);}}let Nc;var Uc={get paint(){return Nc=Nc||new Is({"raster-opacity":new _s(dt.paint_raster["raster-opacity"]),"raster-hue-rotate":new _s(dt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new _s(dt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new _s(dt.paint_raster["raster-brightness-max"]),"raster-saturation":new _s(dt.paint_raster["raster-saturation"]),"raster-contrast":new _s(dt.paint_raster["raster-contrast"]),"raster-resampling":new _s(dt.paint_raster["raster-resampling"]),"raster-fade-duration":new _s(dt.paint_raster["raster-fade-duration"])})}};class qc extends Ps{constructor(t){super(t,Uc);}}class Gc extends Ps{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Zc{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle();}),0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const Kc={once:!0},Xc=6371008.8;class Hc{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Hc(T(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Xc*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof Hc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Hc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Hc(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Yc=2*Math.PI*Xc;function Jc(t){return Yc*Math.cos(t*Math.PI/180)}function Wc(t){return (180+t)/360}function Qc(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function th(t,e){return t/Jc(e)}function eh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function rh(t,e){return t*Jc(eh(e))}class nh{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=Hc.convert(t);return new nh(Wc(r.lng),Qc(r.lat),th(e,r.lat))}toLngLat(){return new Hc(360*this.x-180,eh(this.y))}toAltitude(){return rh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Yc*(t=eh(this.y),1/Math.cos(t*Math.PI/180));var t;}}function ih(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class sh{constructor(t,e,r){if(!function(t,e,r){return !(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=lh(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=ih(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=ih(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*M,(t.y*e-this.y)*M)}toString(){return `${this.z}/${this.x}/${this.y}`}}class ah{constructor(t,e){this.wrap=t,this.canonical=e,this.key=lh(t,e.z,e.z,e.x,e.y);}}class oh{constructor(t,e,r,n,i){if(this.terrainRttPosMatrix32f=null,t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new sh(r,+n,+i),this.key=lh(e,t,r,n,i);}clone(){return new oh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new oh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new oh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?lh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):lh(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new oh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new oh(e,this.wrap,e,r,n),new oh(e,this.wrap,e,r+1,n),new oh(e,this.wrap,e,r,n+1),new oh(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new No({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class hh{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class ph{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new qi(M,16,0),this.grid3D=new qi(M,16,0),this.featureIndexArray=new ya,this.promoteId=e;}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ql.VectorTile(new ju(this.rawTileData)).layers,this.sourceLayerCoder=new ch(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params,s=M/t.tileSize/t.scale,a=Qn(i.filter),o=t.queryGeometry,u=t.queryPadding*s,c=dh(o),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=dh(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new l(e,r),new l(e,i),new l(n,i),new l(n,r)];if(t.length>2)for(const e of s)if(ko(t,e))return !0;for(let e=0;e(p||(p=co(e)),r.queryIntersectsFeature({queryGeometry:o,feature:e,featureState:n,geometry:p,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))));}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!h.some((t=>s.has(t))))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=ho(f,!0);if(!i.filter(new fs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new fs(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const a=e instanceof ws?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function dh(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {minX:e,minY:r,maxX:n,maxY:i}}function yh(t,e){return e-t}function mh(t,e,r,n,i){const s=[];for(let a=0;a=n&&c.x>=n||(a.x>=n?a=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=n&&(c=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=i&&c.y>=i||(a.y>=i?a=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y>=i&&(c=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),u&&a.equals(u[u.length-1])||(u=[a],s.push(u)),u.push(c)))));}}return s}Zi("FeatureIndex",ph,{omit:["rawTileData","sourceLayerCoder"]});class gh extends l{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new gh(this.x,this.y,this.angle,this.segment)}}function xh(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function vh(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=ir.number(n.x,i.x,c),p=ir.number(n.y,i.y,c),f=new gh(h,p,i.angleTo(n),r);return f._round(),!a||xh(t,f,o,a,e)?f:void 0}l+=s;}}function Sh(t,e,r,n,i,s,a,o,l){const u=bh(n,s,a),c=wh(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new gh(g,x,y,e);r._round(),n&&!xh(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=Ah(t,h/2,r,n,i,s,a,!0,l)),f}Zi("Anchor",gh);const kh=Xu;function Mh(t,e,r,n){const i=[],s=t.image,a=s.pixelRatio,o=s.paddedRect.w-2*kh,u=s.paddedRect.h-2*kh;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=s.stretchX||[[0,o]],p=s.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=o-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,S=m,A=0,k=g;if(s.content&&n){const e=s.content,r=e[2]-e[0],n=e[3]-e[1];(s.textFitWidth||s.textFitHeight)&&(c=vc(t)),x=Ih(h,0,e[0]),b=Ih(p,0,e[1]),v=Ih(h,e[0],e[2]),w=Ih(p,e[1],e[3]),_=e[0]-x,A=e[1]-b,S=r-v,k=n-w;}const M=c.x1,I=c.y1,z=c.x2-M,P=c.y2-I,C=(t,n,i,o)=>{const u=Ph(t.stretch-x,v,z,M),c=Ch(t.fixed-_,S,t.stretch,d),h=Ph(n.stretch-b,w,P,I),p=Ch(n.fixed-A,k,n.stretch,y),f=Ph(i.stretch-x,v,z,M),m=Ch(i.fixed-_,S,i.stretch,d),g=Ph(o.stretch-b,w,P,I),C=Ch(o.fixed-A,k,o.stretch,y),B=new l(u,h),V=new l(f,h),E=new l(f,g),T=new l(u,g),F=new l(c/a,p/a),$=new l(m/a,C/a),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),r=[e,-t,t,e];B._matMult(r),V._matMult(r),T._matMult(r),E._matMult(r);}const O=t.stretch+t.fixed,D=n.stretch+n.fixed;return {tl:B,tr:V,bl:T,br:E,tex:{x:s.paddedRect.x+kh+O,y:s.paddedRect.y+kh+D,w:i.stretch+i.fixed-O,h:o.stretch+o.fixed-D},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:$,minFontScaleX:S/a/z,minFontScaleY:k/a/P,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=zh(h,m,d),e=zh(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {const u=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?vc(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};u.y1=u.y1*a-o[0],u.y2=u.y2*a+o[2],u.x1=u.x1*a-o[3],u.x2=u.x2*a+o[1];const p=s.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const t=new l(u.x1,u.y1),e=new l(u.x2,u.y1),r=new l(u.x1,u.y2),n=new l(u.x2,u.y2),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,i);}this.boxEndIndex=t.length;}}class Vh{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}function Eh(t,e=1,r=!1){let n=1/0,i=1/0,s=-1/0,a=-1/0;const o=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const u=Math.min(s-n,a-i);let c=u/2;const h=new Vh([],Th);if(0===u)return new l(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Fh(n.p.x-c,n.p.y-c,c,t)),h.push(new Fh(n.p.x+c,n.p.y-c,c,t)),h.push(new Fh(n.p.x-c,n.p.y+c,c,t)),h.push(new Fh(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Th(t,e){return e.max-t.max}function Fh(t,e,r,n){this.p=new l(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,So(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var $h;t.ay=void 0,($h=t.ay||(t.ay={}))[$h.center=1]="center",$h[$h.left=2]="left",$h[$h.right=3]="right",$h[$h.top=4]="top",$h[$h.bottom=5]="bottom",$h[$h["top-left"]=6]="top-left",$h[$h["top-right"]=7]="top-right",$h[$h["bottom-left"]=8]="bottom-left",$h[$h["bottom-right"]=9]="bottom-right";const Lh=7,Oh=Number.POSITIVE_INFINITY;function Dh(t,e){return e[1]!==Oh?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case "top-right":case "top-left":case "top":i=r-Lh;break;case "bottom-right":case "bottom-left":case "bottom":i=-r+Lh;}switch(t){case "top-right":case "bottom-right":case "right":n=-e;break;case "top-left":case "bottom-left":case "left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case "top-right":case "top-left":n=i-Lh;break;case "bottom-right":case "bottom-left":n=-i+Lh;break;case "bottom":n=-e+Lh;break;case "top":n=e-Lh;}switch(t){case "top-right":case "bottom-right":r=-i;break;case "top-left":case "bottom-left":r=i;break;case "left":r=e;break;case "right":r=-e;}return [r,n]}(t,e[0])}function Rh(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*Lu));n.startsWith("top")?i[1]-=Lh:n.startsWith("bottom")&&(i[1]+=Lh),e[r+1]=i;}return new Me(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Lu,Oh]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Lu));const s=[];for(const t of a)s.push(t,Dh(t,n));return new Me(s)}return null}function jh(t){switch(t){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function Nh(e,r,n,i,s,a,o,l,u,c,h,p){let f=a.textMaxSize.evaluate(r,{});void 0===f&&(f=o);const d=e.layers[0].layout,y=d.get("icon-offset").evaluate(r,{},h),m=qh(n.horizontal),g=o/24,x=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*d.get("symbol-spacing"),_=d.get("text-padding")*e.tilePixelRatio,S=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),s=i&&i.values;return [s[0]*n,s[1]*n,s[2]*n,s[3]*n]}(d,r,h,e.tilePixelRatio),A=d.get("text-max-angle")/180*Math.PI,k="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),I="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),z=d.get("symbol-placement"),P=w/2,C=d.get("icon-text-fit");let B;i&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(B=bc(i,n.vertical,C,d.get("icon-text-fit-padding"),y,g)),m&&(i=bc(i,m,C,d.get("icon-text-fit-padding"),y,g)));const V=h?p.line.getGranularityForZoomLevel(h.z):1,E=(l,p)=>{p.x<0||p.x>=M||p.y<0||p.y>=M||function(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k){const M=e.addToLineVertexArray(r,n);let I,z,P,C,B=0,V=0,E=0,T=0,F=-1,$=-1;const L={};let O=Na("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},A)+90;P=new Bh(u,r,c,h,p,i.vertical,f,d,y,t),o&&(C=new Bh(u,r,c,h,p,o,g,x,y,t));}if(s){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),a=Mh(s,n,S,i),f=o?Mh(o,n,S,i):void 0;z=new Bh(u,r,c,h,p,s,g,x,!1,n),B=4*a.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[_c*l.layout.get("icon-size").evaluate(w,{})],y[0]>Sc&&j(`${e.layerIds[0]}: Value for "icon-size" is >= ${wc}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[_c*_.compositeIconSizes[0].evaluate(w,{},A),_c*_.compositeIconSizes[1].evaluate(w,{},A)],(y[0]>Sc||y[1]>Sc)&&j(`${e.layerIds[0]}: Value for "icon-size" is >= ${wc}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,y,b,v,w,t.ah.none,r,M.lineStartIndex,M.lineLength,-1,A),F=e.icon.placedSymbolArray.length-1,f&&(V=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.ah.vertical,r,M.lineStartIndex,M.lineLength,-1,A),$=e.icon.placedSymbolArray.length-1);}const D=Object.keys(i.horizontal);for(const n of D){const s=i.horizontal[n];if(!I){O=Na(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},A);I=new Bh(u,r,c,h,p,s,f,d,y,t);}const o=1===s.positionedLines.length;if(E+=Uh(e,r,s,a,l,y,w,m,M,i.vertical?t.ah.horizontal:t.ah.horizontalOnly,o?D:[n],L,F,_,A),o)break}i.vertical&&(T+=Uh(e,r,i.vertical,a,l,y,w,m,M,t.ah.vertical,["vertical"],L,$,_,A));const R=I?I.boxStartIndex:e.collisionBoxArray.length,N=I?I.boxEndIndex:e.collisionBoxArray.length,U=P?P.boxStartIndex:e.collisionBoxArray.length,q=P?P.boxEndIndex:e.collisionBoxArray.length,G=z?z.boxStartIndex:e.collisionBoxArray.length,Z=z?z.boxEndIndex:e.collisionBoxArray.length,K=C?C.boxStartIndex:e.collisionBoxArray.length,X=C?C.boxEndIndex:e.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(I,H),H=Y(P,H),H=Y(z,H),H=Y(C,H);const J=H>-1?1:0;J&&(H*=k/Lu),e.glyphOffsetArray.length>=Ec.MAX_GLYPHS&&j("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=Rh(l,w,A),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,F,$,O,R,N,U,q,G,Z,K,X,c,E,T,B,V,J,0,f,H,Q,tt);}(e,p,l,n,i,s,B,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,x,[_,_,_,_],k,u,b,S,I,y,r,a,c,h,o);};if("line"===z)for(const t of mh(r.geometry,0,0,M,M)){const r=Cl(t,V),s=Sh(r,w,A,n.vertical||m,i,24,v,e.overscaling,M);for(const t of s)m&&Gh(e,m.text,P,t)||E(r,t);}else if("line-center"===z){for(const t of r.geometry)if(t.length>1){const e=Cl(t,V),r=_h(e,A,n.vertical||m,i,24,v);r&&E(e,r);}}else if("Polygon"===r.type)for(const t of Ur(r.geometry,0)){const e=Eh(t,16);E(Cl(t[0],V,!0),new gh(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry){const e=Cl(t,V);E(e,new gh(e[0].x,e[0].y,0));}else if("Point"===r.type)for(const t of r.geometry)for(const e of t)E([e],new gh(e.x,e.y,0));}function Uh(t,e,r,n,i,s,a,o,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,s,a,o){const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=Zu+1,p=!0,f=1,d=0;const y=(i||o)&&n.vertical,m=n.metrics.advance*n.scale/2;if(o&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Lu-n.metrics.width*n.scale)/2:(n.scale-1)*Lu)),n.imageName){const t=a[n.imageName];p=t.sdf,f=t.pixelRatio,h=Xu/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],S=w+s.w/b*n.scale/f,A=_+s.h/b*n.scale/f,k=new l(w,_),M=new l(S,_),I=new l(w,A),z=new l(S,A);if(y){const t=new l(-m,m-Wu),e=-Math.PI/2,r=Lu/2-m,i=new l(5-Wu-r,-(n.imageName?r:0)),s=new l(...v);k._rotateAround(e,t)._add(i)._add(s),M._rotateAround(e,t)._add(i)._add(s),I._rotateAround(e,t)._add(i)._add(s),z._rotateAround(e,t)._add(i)._add(s);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),M._matMult(r),I._matMult(r),z._matMult(r);}const P=new l(0,0),C=new l(0,0);c.push({tl:k,tr:M,bl:I,br:z,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,o,i,s,a,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[_c*i.layout.get("text-size").evaluate(a,{})],x[0]>Sc&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${wc}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[_c*d.compositeTextSizes[0].evaluate(a,{},y),_c*d.compositeTextSizes[1].evaluate(a,{},y)],(x[0]>Sc||x[1]>Sc)&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${wc}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,o,s,a,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function qh(t){for(const e in t)return t[e];return null}function Gh(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=Zh[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Kh(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Zh.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)Wh(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Wh(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function Xh(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;Hh(t,e,a,n,i,s),Xh(t,e,r,n,a-1,1-s),Xh(t,e,r,a+1,i,1-s);}function Hh(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);Hh(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(Yh(t,e,n,r),e[2*i+s]>a&&Yh(t,e,n,i);oa;)l--;}e[2*n+s]===a?Yh(t,e,n,l):(l++,Yh(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function Yh(t,e,r,n){Jh(t,r,n),Jh(e,2*r,2*n),Jh(e,2*r+1,2*n+1);}function Jh(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Wh(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}var Qh;t.ck=void 0,(Qh=t.ck||(t.ck={})).create="create",Qh.load="load",Qh.fullLoad="fullLoad";let tp=null,ep=[];const rp=1e3/60,np="loadTime",ip="fullLoadTime",sp={mark(t){performance.mark(t);},frame(t){const e=t;null!=tp&&ep.push(e-tp),tp=e;},clearMetrics(){tp=null,ep=[],performance.clearMeasures(np),performance.clearMeasures(ip);for(const e in t.ck)performance.clearMarks(t.ck[e]);},getPerformanceMetrics(){performance.measure(np,t.ck.create,t.ck.load),performance.measure(ip,t.ck.create,t.ck.fullLoad);const e=performance.getEntriesByName(np)[0].duration,r=performance.getEntriesByName(ip)[0].duration,n=ep.length,i=1/(ep.reduce(((t,e)=>t+e),0)/n/1e3),s=ep.filter((t=>t>rp)).reduce(((t,e)=>t+(e-rp)/rp),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:s/(n+s)*100,totalFrames:n}}};t.$=nh,t.A=g,t.B=ir,t.C=fs,t.D=_s,t.E=ft,t.F=Ri,t.G=function(t){if(null==q){const e=t.navigator?t.navigator.userAgent:null;q=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return q},t.H=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Zc((()=>this.process())),this.subscription=Y(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=U(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=e?Y(e.signal,"abort",(()=>{null==s||s.unsubscribe(),delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),Kc):null;this.resolveRejects[i]={resolve:t=>{null==s||s.unsubscribe(),r(t);},reject:t=>{null==s||s.unsubscribe(),n(t);}};const a=[],o=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:Yi(t.data,a)});this.target.postMessage(o,{transfer:a});}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(U(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(Ji(r.error)):e.resolve(Ji(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=Ji(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i);}catch(e){this.completeTask(t,e);}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?Yi(e):null,data:Yi(r,n)};this.target.postMessage(i,{transfer:n});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.I=Hu,t.J=it,t.K=function(){var t=new g(16);return g!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.L=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=a*y+c*m+d*g+e[15]),t},t.M=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.N=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*o+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*s+b*u+w*f+_*g,t[3]=v*a+b*c+w*d+_*x,t[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*s+b*u+w*f+_*g,t[7]=v*a+b*c+w*d+_*x,t[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*s+b*u+w*f+_*g,t[11]=v*a+b*c+w*d+_*x,t[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*s+b*u+w*f+_*g,t[15]=v*a+b*c+w*d+_*x,t},t.O=function(t,e){const r={};for(let n=0;n{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e);};for(const r of t){const t=window.document.createElement("source");lt(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t);}}))},t.a3=Mt,t.a4=function(){return $++},t.a5=sa,t.a6=Ec,t.a7=Qn,t.a8=ho,t.a9=hh,t.aA=jh,t.aB=hc,t.aC=Kh,t.aD=Es,t.aE=kl,t.aF=ma,t.aG=Va,t.aH=za,t.aI=function(t){return Math.pow(2,t)},t.aJ=85.051129,t.aK=th,t.aL=T,t.aM=J,t.aN=rh,t.aO=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},t.aP=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},t.aQ=function(t){var e=new g(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aR=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},t.aS=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},t.aT=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.aU=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},t.aV=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aW=ah,t.aX=lh,t.aY=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.aZ=function(t){var e=new g(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.a_=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.aa=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.ab=function(t){return Math.log(t)/Math.LN2},t.ac=function(t){var e=t[0],r=t[1];return e*e+r*r},t.ad=function(t){return t*Math.PI/180},t.ae=E,t.af=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ag=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:a}=t,o=i?E(rr.interpolationFactor(i,e,s,a),0,1):0;"camera"===t.kind?n=ir.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.ai=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/_c:"composite"===t.kind?ir.number(n/_c,i/_c,r):e},t.aj=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,S=i*u-s*l,A=c*y-h*d,k=c*m-p*d,M=c*g-f*d,I=h*m-p*y,z=h*g-f*y,P=p*g-f*m,C=x*P-v*z+b*I+w*M-_*k+S*A;return C?(t[0]=(o*P-l*z+u*I)*(C=1/C),t[1]=(i*z-n*P-s*I)*C,t[2]=(y*S-m*_+g*w)*C,t[3]=(p*_-h*S-f*w)*C,t[4]=(l*M-a*P-u*k)*C,t[5]=(r*P-i*M+s*k)*C,t[6]=(m*b-d*S-g*v)*C,t[7]=(c*S-p*b+f*v)*C,t[8]=(a*z-o*M+u*A)*C,t[9]=(n*M-r*z-s*A)*C,t[10]=(d*_-y*b+g*x)*C,t[11]=(h*b-c*_-f*x)*C,t[12]=(o*k-a*I-l*A)*C,t[13]=(r*I-n*k+i*A)*C,t[14]=(y*v-d*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null},t.ak=A,t.al=function(t){return Math.hypot(t[0],t[1])},t.am=function(t){return t[0]=0,t[1]=0,t},t.an=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},t.ao=Pc,t.ap=_,t.aq=function(t,e,r,n){const i=e.y-t.y,s=e.x-t.x,a=n.y-r.y,o=n.x-r.x,u=a*s-o*i;if(0===u)return null;const c=(o*(t.y-r.y)-a*(t.x-r.x))/u;return new l(t.x+c*s,t.y+c*i)},t.ar=mh,t.as=mo,t.at=v,t.au=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return [e,r,n,i]},t.av=Lu,t.aw=I,t.ax=function(t,e,r,n,i=!1){if(!r[0]&&!r[1])return [0,0];const s=i?"map"===n?-t.bearingInRadians:0:"viewport"===n?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e];}return [i?r[0]:I(e,r[0],t.zoom),i?r[1]:I(e,r[1],t.zoom)]},t.az=kc,t.b=G,t.b$=t=>"symbol"===t.type,t.b0=function(){const t=new Float32Array(16);return v(t),t},t.b1=function(){const t=new Float64Array(16);return v(t),t},t.b2=function(){return new Float64Array(16)},t.b3=function(t,e,r){const n=new Float64Array(4);return function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u;}(n,t,e-90,r),n},t.b4=function(t,e,r,n){var i,s,a,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],y=r[2],g=r[3];return (s=u*f+c*d+h*y+p*g)<0&&(s=-s,f=-f,d=-d,y=-y,g=-g),1-s>m?(i=Math.acos(s),a=Math.sin(i),o=Math.sin((1-n)*i)/a,l=Math.sin(n*i)/a):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*y,t[3]=o*p+l*g,t},t.b5=function(t){const e=new Float64Array(9);var r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v;h=(i=(n=t)[0])*(l=i+i),p=(s=n[1])*l,d=(a=n[2])*l,y=a*(u=s+s),g=(o=n[3])*l,x=o*u,v=o*(c=a+a),(r=e)[0]=1-(f=s*u)-(m=a*c),r[3]=p-v,r[6]=d+x,r[1]=p+v,r[4]=1-h-m,r[7]=y-g,r[2]=d-x,r[5]=y+g,r[8]=1-h-f;const b=J(-Math.asin(E(e[2],-1,1)));let w,_;return Math.hypot(e[5],e[8])<.001?(w=0,_=-J(Math.atan2(e[3],e[4]))):(w=J(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),_=J(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:w,pitch:b+90,bearing:_}},t.b6=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b7=xe,t.b8=Xa,t.b9=Ml,t.bA=function(t,e){if(!t)return [{command:"setStyle",args:[e]}];let r=[];try{if(!gt(t.version,e.version))return [{command:"setStyle",args:[e]}];gt(t.center,e.center)||r.push({command:"setCenter",args:[e.center]}),gt(t.centerAltitude,e.centerAltitude)||r.push({command:"setCenterAltitude",args:[e.centerAltitude]}),gt(t.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),gt(t.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),gt(t.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),gt(t.roll,e.roll)||r.push({command:"setRoll",args:[e.roll]}),gt(t.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),gt(t.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),gt(t.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),gt(t.light,e.light)||r.push({command:"setLight",args:[e.light]}),gt(t.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),gt(t.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),gt(t.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const n={},i=[];!function(t,e,r,n){let i;for(i in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)||bt(i,r,n));for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)?gt(t[i],e[i])||("geojson"===t[i].type&&"geojson"===e[i].type&&_t(t,e,i)?xt(r,{command:"setGeoJSONSourceData",args:[i,e[i].data]}):wt(i,e,r,n)):vt(i,e,r));}(t.sources,e.sources,i,n);const s=[];t.layers&&t.layers.forEach((t=>{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):s.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(At),i=e.map(At),s=t.reduce(kt,{}),a=e.reduce(kt,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;tr?i-360:i+360;return Math.abs(i)0?a:-a},t.bq=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.br=Xc,t.bs=function(t,e){const r=z(t,2*Math.PI),n=z(e,2*Math.PI);return Math.min(Math.abs(r-n),Math.abs(r-n+2*Math.PI),Math.abs(r-n-2*Math.PI))},t.bt=function(t){return Math.hypot(t[0],t[1],t[2])},t.bu=function(){const t={},e=dt.$version;for(const r in dt.$root){const n=dt.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.bv=Wi,t.bw=at,t.bx=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r"circle"===t.type,t.c1=t=>"heatmap"===t.type,t.c2=t=>"line"===t.type,t.c3=t=>"fill"===t.type,t.c4=t=>"fill-extrusion"===t.type,t.c5=t=>"hillshade"===t.type,t.c6=t=>"raster"===t.type,t.c7=t=>"background"===t.type,t.c8=t=>"custom"===t.type,t.c9=B,t.cA=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start);}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.cB=function(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if(d())try{return yield K(t,r,n,i,s)}catch(t){}return function(t,e,r,n,i){const s=t.width,a=t.height;X&&H||(X=new OffscreenCanvas(s,a),H=X.getContext("2d",{willReadFrequently:!0})),X.width=s,X.height=a,H.drawImage(t,0,0,s,a);const o=H.getImageData(e,r,n,i);return H.clearRect(0,0,s,a),o.data}(t,r,n,i,s)}))},t.cC=uh,t.cD=r,t.cE=s,t.cF=Wl,t.cG=Ru,t.cH=Gn,t.cI=ps,t.ca=function(t,e,r){const n=k(e.x-r.x,e.y-r.y),i=k(t.x-r.x,t.y-r.y);var s,a;return J(Math.atan2(n[0]*i[1]-n[1]*i[0],(s=n)[0]*(a=i)[0]+s[1]*a[1]))},t.cb=V,t.cc=function(t,e){return Q[e]&&(t instanceof MouseEvent||t instanceof WheelEvent)},t.cd=function(t,e){return W[e]&&"touches"in t},t.ce=function(t){return W[t]||Q[t]},t.cf=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},t.cg=function(t,e){const{x:r,y:n}=nh.fromLngLat(e);return !(t<0||t>25||n<0||n>=1||r<0||r>=1)},t.ch=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.ci=class extends $s{},t.cj=sp,t.cl=function(t){return t.message===tt},t.cm=st,t.cn=function(t,e){rt.REGISTERED_PROTOCOLS[t]=e;},t.co=function(t){delete rt.REGISTERED_PROTOCOLS[t];},t.cp=function(t,e){const r={};for(let n=0;nt*Lu));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(i,{},e.canonical)*Lu:1/0,w=()=>{e.bucket.allowVerticalPlacement&&ts(s)&&(d.vertical=ec(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,b,a,m,"left",f,g,t.ah.vertical,!0,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.g=nt,t.h=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=Z;}));},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):Z;})),t.i=U,t.j=(t,e)=>ot(F(t,{type:"json"}),e),t.k=pt,t.l=ht,t.m=ot,t.n=(t,e)=>ot(F(t,{type:"arrayBuffer"}),e),t.o=function(t){return new ju(t).readFields(Uu,[])},t.p=Ku,t.q=jo,t.r=Is,t.s=Y,t.t=Di,t.u=Qi,t.v=dt,t.w=j,t.x=Ui,t.y=Oi,t.z=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}};})); + +define("worker",["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const o of t){this._layerConfigs[o.id]=o;const t=this._layers[o.id]=e.by(o);t._featureFilter=e.a7(t.filter),this.keyCache[o.id]&&delete this.keyCache[o.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=e.cp(Object.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let r=this.familiesBySource[i];r||(r=this.familiesBySource[i]={});const s=o.sourceLayer||"_geojsonTileLayer";let n=r[s];n||(n=r[s]=[]),n.push(t);}}}class o{constructor(t){const o={},i=[];for(const e in t){const r=t[e],s=o[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};i.push(o),s[e]={rect:o,metrics:t.metrics};}}const{w:r,h:s}=e.p(i),n=new e.q({width:r||1,height:s||1});for(const i in t){const r=t[i];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=o[i][t].rect;e.q.copy(s.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap);}}this.image=n,this.positions=o;}}e.cq("GlyphAtlas",o);class i{constructor(t){this.tileID=new e.Y(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,i,s,n,a){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a5;const l=new e.cr(Object.keys(t.layers).sort()),c=new e.cs(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:s,subdivisionGranularity:a},d=i.familiesBySource[this.source];for(const o in d){const i=t.layers[o];if(!i)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(o),a=[];for(let e=0;e=o.maxzoom||"none"!==o.visibility&&(r(t,this.zoom,s),(u[o.id]=o.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}const f=e.bD(h.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let g=Promise.resolve({});if(Object.keys(f).length){const e=new AbortController;this.inFlightDependencies.push(e),g=n.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const p=Object.keys(h.iconDependencies);let m=Promise.resolve({});if(p.length){const e=new AbortController;this.inFlightDependencies.push(e),m=n.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},e);}const y=Object.keys(h.patternDependencies);let v=Promise.resolve({});if(y.length){const e=new AbortController;this.inFlightDependencies.push(e),v=n.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const[w,x,_]=yield Promise.all([g,m,v]),b=new o(w),M=new e.ct(x,_);for(const t in u){const o=u[t];o instanceof e.a6?(r(o.layers,this.zoom,s),e.cu({bucket:o,glyphMap:w,glyphPositions:b.positions,imageMap:x,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):o.hasPattern&&(o instanceof e.cv||o instanceof e.cw||o instanceof e.cx)&&(r(o.layers,this.zoom,s),o.addFeatures(h,this.tileID.canonical,M.patternPositions));}return this.status="done",{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:M,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function r(t,o,i){const r=new e.C(o);for(const e of t)e.recalculate(r,i);}class s{constructor(e,t,o){this.actor=e,this.layerIndex=t,this.availableImages=o,this.fetching={},this.loading={},this.loaded={};}loadVectorTile(t,o){return e._(this,void 0,void 0,(function*(){const i=yield e.n(t.request,o);try{return {vectorTile:new e.cy.VectorTile(new e.cz(i.data)),rawData:i.data,cacheControl:i.cacheControl,expires:i.expires}}catch(e){const o=new Uint8Array(i.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cA(t.request),s=new i(t);this.loading[o]=s;const n=new AbortController;s.abort=n;try{const i=yield this.loadVectorTile(t,n);if(delete this.loading[o],!i)return null;const a=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}s.vectorTile=i.vectorTile;const u=s.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[o]=s,this.fetching[o]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[o];}}catch(e){throw delete this.loading[o],s.status="done",this.loaded[o]=s,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid;if(!this.loaded||!this.loaded[o])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const i=this.loaded[o];if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=yield i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let s;if(this.fetching[o]){const{rawTileData:t,cacheControl:i,resourceTiming:n}=this.fetching[o];delete this.fetching[o],s=e.e({rawTileData:t.slice(0)},r,i,n);}else s=r;return s}if("done"===i.status&&i.vectorTile)return i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){const e=this.loading,o=t.uid;e&&e[o]&&e[o].abort&&(e[o].abort.abort(),delete e[o]);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid];}))}}class n{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:i,rawImageData:r,redFactor:s,greenFactor:n,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cB(r,-1,-1,c,u)):r,d=new e.cC(o,h,i,s,n,a,l);return this.loaded=this.loaded||{},this.loaded[o]=d,d}))}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}var a,l,c=function(){if(l)return a;function e(e,o){if(0!==e.length){t(e[0],o);for(var i=1;i=Math.abs(a)?o-l+a:a-l+o,o=l;}o+i>=0!=!!t&&e.reverse();}return l=1,a=function t(o,i){var r,s=o&&o.type;if("FeatureCollection"===s)for(r=0;r>31}function c(e,t){for(var o=e.loadGeometry(),i=e.type,r=0,s=0,n=o.length,c=0;ce},_=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;const M=3,S=5,I=6;class P{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const s=[];for(let t=0;t=o;e--){const o=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,r=180;else if(o>r){const e=this.getClusters([o,i,180,s],t),n=this.getClusters([-180,i,r,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(D(o),C(s),D(r),C(i)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+S]>1?k(l,t,this.clusterProps):this.points[l[t+M]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(i);const s=r.data;if(t*this.stride>=s.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const o=t*this.stride;s[o+4]===e&&l.push(s[o+S]>1?k(s,o,this.clusterProps):this.points[s[o+M]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(o-a)/r,c=(o+1+a)/r,u={features:[]};return this._addTileFeatures(i.range((t-a)/r,l,(t+1+a)/r,c),i.data,t,o,r,u),0===t&&this._addTileFeatures(i.range(1-a/r,l,1,c),i.data,r,o,r,u),t===r-1&&this._addTileFeatures(i.range(0,l,a/r,c),i.data,-1,o,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=i?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,o,i,r):r1;let l,c,u;if(a)l=T(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+M]];l=o.properties;const[i,r]=o.geometry.coordinates;c=D(i),u=C(r);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-o)),Math.round(this.options.extent*(u*r-i))]],tags:l};let d;d=a||this.options.generateId?t[e+M]:this.points[t[e+M]].id,void 0!==d&&(h.id=d),s.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:r,minPoints:s}=this.options,n=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+S]);}if(f>d&&f>=s){let e,s=i*d,n=u*d,g=-1;const p=((o/c|0)<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+S];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=p,r&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)));}a[o+4]=p,l.push(s/f,n/f,1/0,p,-1,f),r&&l.push(g);}else {for(let e=0;e1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+S]>1){const i=this.clusterProps[e[t+I]];return o?Object.assign({},i):i}const i=this.points[e[t+M]].properties,r=this.options.map(i);return o&&r===i?Object.assign({},r):r}}function k(e,t,o){return {type:"Feature",id:e[t+M],properties:T(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),O(e[t+1])]}};var i;}function T(e,t,o){const i=e[t+S],r=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,s=e[t+I],n=-1===s?{}:Object.assign({},o[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+M],point_count:i,point_count_abbreviated:r})}function D(e){return e/360+.5}function C(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function O(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function L(e,t,o,i){let r=i;const s=t+(o-t>>1);let n,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;ir)n=i,r=t;else if(t===r){const e=Math.abs(i-s);ei&&(n-t>3&&L(e,t,n,i),e[n+2]=r,o-n>3&&L(e,n,o,i));}function F(e,t,o,i,r,s){let n=r-o,a=s-i;if(0!==n||0!==a){const l=((e-o)*n+(t-i)*a)/(n*n+a*a);l>1?(o=r,i=s):l>0&&(o+=n*l,i+=a*l);}return n=e-o,a=t-i,n*n+a*a}function G(e,t,o,i){const r={id:null==e?null:e,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)z(r,o);else if("Polygon"===t)z(r,o[0]);else if("MultiLineString"===t)for(const e of o)z(r,e);else if("MultiPolygon"===t)for(const e of o)z(r,e[0]);return r}function z(e,t){for(let o=0;o0&&(n+=i?(r*l-a*s)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-s,2))),r=a,s=l;}const a=t.length-3;t[2]=1,L(t,0,a,o),t[a+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function Z(e,t,o,i){for(let r=0;r1?1:o}function W(e,t,o,i,r,s,n,a){if(i/=t,s>=(o/=t)&&n=i)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const n=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(n>=o&&c=i)continue;let u=[];if("Point"===s||"MultiPoint"===s)R(e,u,o,i,r);else if("LineString"===s)Y(e,u,o,i,r,!1,a.lineMetrics);else if("MultiLineString"===s)H(e,u,o,i,r,!1);else if("Polygon"===s)H(e,u,o,i,r,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];H(t,e,o,i,r,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(G(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(G(t.id,s,u,t.tags));}}return l.length?l:null}function R(e,t,o,i,r){for(let s=0;s=o&&n<=i&&V(t,e[s],e[s+1],e[s+2]);}}function Y(e,t,o,i,r,s,n){let a=q(e);const l=0===r?X:B;let c,u,h=e.start;for(let d=0;do&&(u=l(a,f,g,m,y,o),n&&(a.start=h+c*u)):v>i?w=o&&(u=l(a,f,g,m,y,o),x=!0),w>i&&v<=i&&(u=l(a,f,g,m,y,i),x=!0),!s&&x&&(n&&(a.end=h+c*u),t.push(a),a=q(e)),n&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===r?f:g;p>=o&&p<=i&&V(a,f,g,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&V(a,a[0],a[1],a[2]),a.length&&t.push(a);}function q(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function H(e,t,o,i,r,s){for(const n of e)Y(n,t,o,i,r,s,!1);}function V(e,t,o,i){e.push(t,o,i);}function X(e,t,o,i,r,s){const n=(s-t)/(i-t);return V(e,s,o+(r-o)*n,1),n}function B(e,t,o,i,r,s){const n=(s-o)/(r-o);return V(e,t+(i-t)*n,s,1),n}function $(e,t){const o=[];for(let i=0;i0&&t.size<(r?n:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;en)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;r&&function(e,t){let o=0;for(let t=0,i=e.length,r=i-2;t0===t)for(let t=0,o=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=ee(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(o!==s>>e||i!==n>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,v=null,w=null,x=null,_=W(e,u,o-f,o+p,0,d.minX,d.maxX,l),b=W(e,u,o+g,o+m,0,d.minX,d.maxX,l);e=null,_&&(y=W(_,u,i-f,i+p,1,d.minY,d.maxY,l),v=W(_,u,i+g,i+m,1,d.minY,d.maxY,l),_=null),b&&(w=W(b,u,i-f,i+p,1,d.minY,d.maxY,l),x=W(b,u,i+g,i+m,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(v||[],t+1,2*o,2*i+1),a.push(w||[],t+1,2*o+1,2*i),a.push(x||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:r,debug:s}=i;if(e<0||e>24)return null;const n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[se(c,u,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),s>1&&console.timeEnd("drilling down"),this.tiles[a]?K(this.tiles[a],r):null):null}}function se(e,t,o){return 32*((1<{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,n);},t}(t)).load((yield this._pendingData).features):(r=yield this._pendingData,new re(r,t.geojsonVtOptions)),this.loaded={};const o={};if(i){const e=i.finish();e&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}return o}catch(t){if(delete this._pendingRequest,e.cl(t))return {abandoned:!0};throw t}var r;}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){let i=yield this.loadGeoJSON(t,o);if(delete this._pendingRequest,"object"!=typeof i)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(i,!0),t.filter){const o=e.cH(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const r=i.features.filter((e=>o.value.evaluate({zoom:0},e)));i={type:"FeatureCollection",features:r};}return i}))}loadGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){const{promoteId:i}=t;if(t.request){const r=yield e.j(t.request,o);return this._dataUpdateable=ae(r.data,i)?le(r.data,i):void 0,r.data}if("string"==typeof t.data)try{const e=JSON.parse(t.data);return this._dataUpdateable=ae(e,i)?le(e,i):void 0,e}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return function(e,t,o){var i,r,s,n;if(t.removeAll&&e.clear(),t.remove)for(const o of t.remove)e.delete(o);if(t.add)for(const i of t.add){const t=ne(i,o);null!=t&&e.set(t,i);}if(t.update)for(const o of t.update){let t=e.get(o.id);if(null==t)continue;const a=!o.removeAllProperties&&((null===(i=o.removeProperties)||void 0===i?void 0:i.length)>0||(null===(r=o.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((o.newGeometry||o.removeAllProperties||a)&&(t=Object.assign({},t),e.set(o.id,t),a&&(t.properties=Object.assign({},t.properties))),o.newGeometry&&(t.geometry=o.newGeometry),o.removeAllProperties)t.properties={};else if((null===(s=o.removeProperties)||void 0===s?void 0:s.length)>0)for(const e of o.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:i}of o.addOrUpdateProperties)t.properties[e]=i;}}(this._dataUpdateable,t.dataDiff,i),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class ue{constructor(t){this.self=t,this.actor=new e.H(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.cn,this.self.removeProtocol=e.co,this.self.registerRTLTextPlugin=t=>{e.cI.setMethods(t);},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,o)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,o.source).removeTile(o);})))),this.actor.registerMessageHandler("GCEZ",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterExpansionZoom(o)})))),this.actor.registerMessageHandler("GCC",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterChildren(o)})))),this.actor.registerMessageHandler("GCL",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterLeaves(o)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,o)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][o.type]||!this.workerSources[t][o.type][o.source])return;const e=this.workerSources[t][o.type][o.source];delete this.workerSources[t][o.type][o.source],void 0!==e.removeSource&&e.removeSource(o);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t];})))),this.actor.registerMessageHandler("SR",((t,o)=>e._(this,void 0,void 0,(function*(){this.referrer=o;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,o)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(o);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(o.layers,o.removedIds);})))),this.actor.registerMessageHandler("SL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(o);}))));}_setImages(t,o){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=o;for(const e in this.workerSources[t]){const i=this.workerSources[t][e];for(const e in i)i[e].availableImages=o;}}))}_syncRTLPluginState(t,o){return e._(this,void 0,void 0,(function*(){return yield e.cI.syncState(o,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let o=this.layerIndexes[e];return o||(o=this.layerIndexes[e]=new t),o}_getWorkerSource(e,t,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][o]){const i={sendAsync:(t,o)=>(t.targetMapId=e,this.actor.sendAsync(t,o))};switch(t){case "vector":this.workerSources[e][t][o]=new s(i,this._getLayerIndex(e),this._getAvailableImages(e));break;case "geojson":this.workerSources[e][t][o]=new ce(i,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][o]=new this.externalWorkerSourceTypes[t](i,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][o]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue})); + +define("index",["exports","./shared"],(function(e,t){"use strict";var i="5.3.0";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let o,a;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,i,r){const o=requestAnimationFrame((e=>{a(),i(e);})),{unsubscribe:a}=t.s(e.signal,"abort",(()=>{a(),cancelAnimationFrame(o),r(t.c());}),!1);},frameAsync(e){return new Promise(((t,i)=>{this.frame(e,t,i);}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(o||(o=document.createElement("a")),o.href=e,o.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==a&&(a=matchMedia("(prefers-reduced-motion: reduce)")),a.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",n.suppressClickInternal,!0);}),0);}static getScale(e){const t=e.getBoundingClientRect();return {x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const o=i.boundingClientRect;return new t.P((r.clientX-o.left)/i.x-e.clientLeft,(r.clientY-o.top)/i.y-e.clientTop)}static mousePos(e,t){const i=n.getScale(e);return n.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=n.getScale(e);for(let o=0;o{c&&_(c),c=null,d=!0;},h.onerror=()=>{u=!0,c=null;},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,r,o,a;e.resetRequestQueue=()=>{i=[],r=0,o=0,a={};},e.addThrottleControl=e=>{const t=o++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],n();},e.getImage=(e,r,o=!0)=>new Promise(((a,s)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:o,state:"queued",onError:e=>{s(e);},onSuccess:e=>{a(e);}}),n();}));const s=e=>t._(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:i,supportImageRefresh:o,onError:a,onSuccess:s,abortController:l}=e,h=!1===o&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((e,t)=>e&&"accept"===t),!0));r++;const u=h?c(i,l):t.m(i,l);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(t){delete e.abortController,a(t);}finally{r--,n();}var d;})),n=()=>{const e=(()=>{for(const e of Object.keys(a))if(a[e]())return !0;return !1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e);}},c=(e,i)=>new Promise(((r,o)=>{const a=new Image,s=e.url,n=e.credentials;n&&"include"===n?a.crossOrigin="use-credentials":(n&&"same-origin"===n||!t.d(s))&&(a.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{a.src="",o(t.c());})),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,r({data:a});},a.onerror=()=>{a.onerror=a.onload=null,i.signal.aborted||o(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},a.src=s;}));}(p||(p={})),p.resetRequestQueue();class m{constructor(e){this._transformRequestFn=e;}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e;}}function f(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:o}of e){const e=`${r}${o}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:o}));}}return t}function g(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}class v{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:o,height:a}=e,s=!(this.size&&this.size[0]===o&&this.size[1]===a||r),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),s)this.size=[o,a],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,o,a,0,this.format,l.UNSIGNED_BYTE,e.data);else {const{x:i,y:s}=r||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,s,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,s,o,a,l.RGBA,l.UNSIGNED_BYTE,e.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D);}bind(e,t,i){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),i!==o.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=o.LINEAR),e!==this.filter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,t),this.wrap=t);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t);}_validate(e,i){let r=!0;const o=i.data||i.spriteData;return this._validateStretch(i.stretchX,o&&o.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,o&&o.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return !0;let i=0;for(const r of e){if(r[0]{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t});}))}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.l("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return {width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else {const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},o=new t.I(i,r);this.patterns[e]={bin:i,position:o};}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new v(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE);}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),o=this.atlasImage;o.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,a=i.y+1,s=this.getImage(e).data,n=s.width,l=s.height;t.R.copy(s,o,{x:0,y:0},{x:r,y:a},{width:n,height:l}),t.R.copy(s,o,{x:0,y:l-1},{x:r,y:a-1},{width:n,height:1}),t.R.copy(s,o,{x:0,y:0},{x:r,y:a+l},{width:n,height:1}),t.R.copy(s,o,{x:n-1,y:0},{x:r-1,y:a},{width:1,height:l}),t.R.copy(s,o,{x:0,y:0},{x:r+n,y:a},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e);}}}const y=1e20;function w(e,t,i,r,o,a,s,n,l){for(let c=t;c-1);l++,a[l]=n,s[l]=c,s[l+1]=y;}for(let n=0,l=0;n65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[o])return {stack:e,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[o]){const i=P.loadGlyphRange(e,o,this.url,this.requestManager);t.requests[o]=i;}const a=yield t.requests[o];for(const e in a)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=a[+e]);return t.ranges[o]=!0,{stack:e,id:i,glyph:a[i]||null}}))}_doesCharSupportLocalGlyph(e){return !!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||t.u["CJK Unified Ideographs"](e)||t.u["Hangul Syllables"](e)||t.u.Hiragana(e)||t.u.Katakana(e)||t.u["CJK Symbols and Punctuation"](e)||t.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,i,r){const o=this.localIdeographFontFamily;if(!o)return;if(!this._doesCharSupportLocalGlyph(r))return;let a=e.tinySDF;if(!a){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),a=e.tinySDF=new P.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:t});}const s=a.draw(String.fromCharCode(r));return {id:r,bitmap:new t.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}P.loadGlyphRange=function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=256*i,s=a+255,n=o.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${a}-${s}`),"Glyphs"),l=yield t.n(n,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${a}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c}))},P.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:a="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const n=this.size=e+4*t,l=this._createCanvas(n),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${a} ${e}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:a}=this.ctx.measureText(e),s=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-o))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=n+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),_={data:d,width:c,height:h,glyphWidth:n,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(e,m,m+s);const v=p.getImageData(m,m,n,l);g.fill(y,0,u),f.fill(0,0,u);for(let e=0;e0?e*e:0,f[r]=e<0?e*e:0;}}w(g,0,0,c,h,c,this.f,this.v,this.z),w(f,m,m,n,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++a]);const l=Math.abs(n-s.left),c=Math.abs(n-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.data[o+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let o=0,a=e[o];for(let t=0;t1&&(a=e[++o]);const i=Math.abs(t-a.left),s=Math.abs(t-a.right),n=Math.min(i,s);this.data[r+t]=Math.max(0,Math.min(255,(a.isDash?n:-n)+128));}}addDash(e,i){const r=i?7:0,o=2*r+1;if(this.nextRow+o>this.height)return t.w("LineAtlas out of space"),null;let a=0;for(let t=0;t{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[D]}numActive(){return Object.keys(this.active).length}}const A=Math.floor(s.hardwareConcurrency/2);let L,k;function F(){return L||(L=new z),L}z.workerCount=t.G(globalThis)?Math.max(Math.min(A,3),1):1;class B{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let e=0;e{e.remove();})),this.actors=[],e&&this.workerPool.release(this.id);}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t);}}function O(){return k||(k=new B(F(),t.J),k.registerMessageHandler("GR",((e,i,r)=>t.m(i,r)))),k}function j(e,i){const r=t.K();return t.L(r,r,[1,1,0]),t.M(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.N(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function Z(e,t,i,r,o,a,s){var n;const l=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return !0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return !0}return !1}(null!==(n=null==o?void 0:o.layers)&&void 0!==n?n:null,t,e.id),c=a.maxPitchScaleFactor(),h=e.tilesIn(r,c,l);h.sort(N);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,o,a,c,j(e.transform,r.tileID),s?(e,t)=>s(r.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const r of e[i])G(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,o=r.wrappedTileID,a=i[o]=i[o]||{};for(const i in e){const r=e[i],o=a[i]=a[i]||{},s=t[i]=t[i]||[];for(const e of r)o[e.featureIndex]||(o[e.featureIndex]=!0,s.push(e));}}return t}(u),e)}function N(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function G(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r;}function U(e,i,r){return t._(this,void 0,void 0,(function*(){let o=e;if(e.url?o=(yield t.j(i.transformRequest(e.url,"Source"),r)).data:yield s.frameAsync(r),!o)return null;const a=t.O(t.e(o,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in o&&o.vector_layers&&(a.vectorLayerIds=o.vector_layers.map((e=>e.id))),a}))}class V{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])));}setNorthEast(e){return this._ne=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}extend(e){const i=this._sw,r=this._ne;let o,a;if(e instanceof t.Q)o=e,a=e;else {if(!(e instanceof V))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(V.convert(e)):this.extend(t.Q.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.Q.convert(e)):this;if(o=e._sw,a=e._ne,!o||!a)return this}return i||r?(i.lng=Math.min(o.lng,i.lng),i.lat=Math.min(o.lat,i.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)):(this._sw=new t.Q(o.lng,o.lat),this._ne=new t.Q(a.lng,a.lat)),this}getCenter(){return new t.Q((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.Q(this.getWest(),this.getNorth())}getSouthEast(){return new t.Q(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:r}=t.Q.convert(e);let o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&o}static convert(e){return e instanceof V?e:e?new V(e):e}static fromLngLat(e,i=0){const r=360*i/40075017,o=r/Math.cos(Math.PI/180*e.lat);return new V(new t.Q(e.lng-o,e.lat-r),new t.Q(e.lng+o,e.lat+r))}adjustAntiMeridian(){const e=new t.Q(this._sw.lng,this._sw.lat),i=new t.Q(this._ne.lng,this._ne.lat);return new V(e,e.lng>i.lng?new t.Q(i.lng+360,i.lat):i)}}class q{constructor(e,t,i){this.bounds=V.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.U(this.bounds.getWest())*i),o=Math.floor(t.S(this.bounds.getNorth())*i),a=Math.ceil(t.U(this.bounds.getEast())*i),s=Math.ceil(t.S(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((t,i)=>{e.reloadPromise={resolve:t,reject:i};}))}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null);}}))}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject);}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class $ extends t.E{constructor(e,i,r,o){super(),this.id=e,this.dispatcher=r,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.O(i,["url","scheme","tileSize"]));}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield U(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e));}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}serialize(){return t.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const i=yield p.getImage(this.map._requestManager.transformRequest(t,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const t=this.map.painter.context,r=t.gl,o=i.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new v(t,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController);}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture);}))}hasTransition(){return !1}}class H extends ${constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield p.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const o=t.b(r)&&t.V()?r:yield this.readImageNow(r),a={type:this.type,uid:e.uid,source:this.id,rawImageData:o,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:a});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded";}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.W()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.X(e,-1,-1,i,r))}catch(e){}}return s.getImageData(e,1)}))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,a=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,n=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.Y(e.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.Y(e.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return t._(this,void 0,void 0,(function*(){const e=new V,t=yield this.getData();let i;switch(t.type){case "FeatureCollection":i=t.features.map((e=>this.getCoordinatesFromGeometry(e.geometry))).flat(1/0);break;case "Feature":i=this.getCoordinatesFromGeometry(t.geometry);break;default:i=this.getCoordinatesFromGeometry(t);}if(0==i.length)return e;for(let t=0;t0&&t.e(o,{resourceTiming:r}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content"})));}catch(e){if(this._pendingLoads--,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e));}}))}loaded(){return 0===this._pendingLoads}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t);}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0;}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}}class X extends t.E{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t;}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield p.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading());}catch(e){this._request=null,this._loaded=!0,this.fire(new t.k(e));}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.$.fromLngLat);var r;return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s=Math.max(o-i,a-r),n=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,n);return new t.a1(n,Math.floor((i+o)/2*l),Math.floor((r+a)/2*l))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new v(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}_getOverlappingTileRanges(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s={};for(let e=0;e<=t.a0;e++){const t=Math.pow(2,e),n=Math.floor(i*t),l=Math.floor(r*t),c=Math.floor(o*t),h=Math.floor(a*t);s[e]={minTileX:n,minTileY:l,maxTileX:c,maxTileY:h};}return s}}class Q extends X{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a2(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading();}catch(e){this.fire(new t.k(e));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.a3(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new v(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Y extends X{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.a3(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new v(i,this.canvas,r.RGBA,{premultiply:!0});let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}}const J={},ee=e=>{switch(e){case "geojson":return K;case "image":return X;case "raster":return $;case "raster-dem":return H;case "vector":return W;case "video":return Q;case "canvas":return Y}return J[e]},te="RTLPluginLoaded";class ie extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=O();}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(te));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let re=null;function oe(){return re||(re=new ie),re}class ae{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a4(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r;}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6&&i.hasRTLText){this.hasRTLText=!0,oe().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage);}else this.collisionBoxArray=new t.a5;}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new v(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new v(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null);}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture);}queryRenderedFeatures(e,t,i,r,o,a,s,n,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:o,scale:a,tileSize:this.tileSize,pixelPosMatrix:c,transform:n,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const o=r.loadVTLayers(),a=i&&i.sourceLayer?i.sourceLayer:"",s=o._geojsonTileLayer||o[a];if(!s)return;const n=t.a7(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,o);}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class ne{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,i,r){const o=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},t.e(this.stateChanges[e][o],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null);}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,i){const r=String(i),o=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete o[e];}return o}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,i){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}r[e]=r[e]||{},t.e(r[e],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i);}}function le(e,t,i){const r=t.intersectsFrustum(e);if(!i)return r;const o=t.intersectsPlane(i);return 0===r||0===o?0:2===r&&2===o?2:1}function ce(e,i,r,o,a){let s=e;const n=Math.atan(i/r),l=Math.hypot(i,r);return s=e+t.ab(o/l/Math.max(.5,Math.cos(t.ad(a/2)))),s+=1*t.ab(Math.cos(n))/2,s+=t.ae(e-s,-0,0),s}function he(e,i){const r=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ab(e.tileSize/i.tileSize));return Math.max(0,r)}function ue(e,i){const r=e.getCameraFrustum(),o=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.$.fromLngLat(e.center,e.elevation);a.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const n=e.getCoveringTilesDetailsProvider(),l=n.allowVariableZoom(e,i),c=he(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),_=Math.pow(2,d),p=[_*a.x,_*a.y,0],m=[_*s.x,_*s.y,0],f=Math.hypot(s.x-a.x,s.y-a.y),g=Math.abs(s.z-a.z),v=Math.hypot(f,g),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],y=[];if(e.renderWorldCopies&&n.allowWorldCopies())for(let e=1;e<=3;e++)b.push(x(-e)),b.push(x(e));for(b.push(x(0));b.length>0;){const _=b.pop(),f=_.x,x=_.y;let w=_.fullyVisible;const T={x:f,y:x,z:_.zoom},P=n.getTileAABB(T,_.wrap,e.elevation,i);if(!w){const e=le(r,P,o);if(0===e)continue;w=2===e;}const C=n.distanceToTile2d(a.x,a.y,T,P);let I=c;l&&(I=(i.calculateTileZoom||ce)(e.zoom+t.ab(e.tileSize/i.tileSize),C,g,v,e.fov)),I=(i.roundZoom?Math.round:Math.floor)(I),I=Math.max(0,I);const M=Math.min(I,u);if(_.wrap=n.getWrap(s,T,_.wrap),_.zoom>=M){if(_.zoom>1),wrap:_.wrap,fullyVisible:w});}return y.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}class de extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((e,t,i,r)=>{const o=new(ee(t.type))(e,t,i,r);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return o})(e,t,i,this),this._tiles={},this._cache=new se(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ne,this._didEmitContent=!1,this._updated=!1;}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e);}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(e,i,r){return t._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,r);}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain);}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e);}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(_e).map((e=>e.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,o=i.tileID,a=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(o.canonical.x,o.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-o.overscaledZ||s.y-a.y||s.x-a.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(_e).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)(e||"errored"!==this._tiles[t].state)&&this._reloadTile(t,"reloading");}}_reloadTile(e,i){return t._(this,void 0,void 0,(function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i));}))}_tileLoaded(e,i,r){e.timeAdded=s.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[a]&&(e.neighboringTiles[a].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const o in this._tiles){let a=this._tiles[o];if(r[o]||!a.hasData()||a.tileID.overscaledZ<=t||a.tileID.overscaledZ>i)continue;let s=a.tileID;for(;a&&a.tileID.overscaledZ>t+1;){const e=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[e.key],a&&a.hasData()&&(s=e);}let n=s;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]||e[n.canonical.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e]);}}_updateCoveredAndRetainedTiles(e,t,i,r,o,a){const n={},l={},c=Object.keys(e),h=s.now();for(const i of c){const r=e[i],o=this._tiles[i];if(!o||0!==o.fadeEndTime&&o.fadeEndTime<=h)continue;const a=this.findLoadedParent(r,t),s=this.findLoadedSibling(r),c=a||s||null;c&&(this._addTile(c.tileID),n[c.tileID.key]=c.tileID),l[i]=r;}this._retainLoadedChildren(l,r,i,e);for(const t in n)e[t]||(this._coveredTiles[t]=!0,e[t]=n[t]);if(a){const t={},i={};for(const e of o)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const r in i){const o=i[r].children(this._source.maxzoom);this._tiles[o[0].key]&&this._tiles[o[1].key]&&this._tiles[o[2].key]&&this._tiles[o[3].key]&&(t[o[0].key]=e[o[0].key]=o[0],t[o[1].key]=e[o[1].key]=o[1],t[o[2].key]=e[o[2].key]=o[2],t[o[3].key]=e[o[3].key]=o[3],delete i[r]);}for(const r in i){const o=i[r],a=this.findLoadedParent(o,this._source.minzoom),s=this.findLoadedSibling(o),n=a||s||null;if(n){t[n.tileID.key]=e[n.tileID.key]=n.tileID;for(const e in t)t[e].isChildOf(n.tileID)&&delete t[e];}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0);}}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.Y(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=ue(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const o=he(e,this._source),a=Math.max(o-de.maxOverzooming,this._source.minzoom),s=Math.max(o+de.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of r)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const r=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[r.key]=r;}r=r.concat(Object.values(e));}const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,o);pe(this._source.type)&&this._updateCoveredAndRetainedTiles(l,a,s,o,r,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.af(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e);}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e);}_updateRetainedTiles(e,t){var i;const r={},o={},a=Math.max(t-de.maxOverzooming,this._source.minzoom),s=Math.max(t+de.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);r[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=s.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){r[e.key]=e;continue}}else {const e=s.children(this._source.maxzoom);if(r[e[0].key]&&r[e[1].key]&&r[e[2].key]&&r[e[3].key])continue}let n=e.wasRequested();for(let t=s.overscaledZ-1;t>=a;--t){const a=s.scaledTo(t);if(o[a.key])break;if(o[a.key]=!0,e=this.getTile(a),!e&&n&&(e=this._addTile(a)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=e.wasRequested(),t)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i;}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new ae(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset();}tilesIn(e,i,r){const o=[],a=this.transform;if(!a)return o;const s=r?a.getCameraQueryGeometry(e):e,n=e.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),l=s.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),c=this.getIds();let h=1/0,u=1/0,d=-1/0,_=-1/0;for(const e of l)h=Math.min(h,e.x),u=Math.min(u,e.y),d=Math.max(d,e.x),_=Math.max(_,e.y);for(let e=0;e=0&&f[1].y+m>=0){const e=n.map((e=>s.getTilePoint(e))),t=l.map((e=>s.getTilePoint(e)));o.push({tile:r,tileID:s,queryGeometry:e,cameraQueryGeometry:t,scale:p});}}return o}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return !0;if(pe(this._source.type)){const e=s.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}}function _e(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function pe(e){return "raster"===e||"image"===e||"video"===e}de.maxOverzooming=10,de.maxUnderzooming=3;class me{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(o-s)/n:0;return this.points[a].mult(1-l).add(this.points[i].mult(l))}}function fe(e,t){let i=!0;return "always"===e||"never"!==e&&"never"!==t||(i=!1),i}class ge{constructor(e,t,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return [];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(o)return [{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e0}hitTestCircle(e,t,i,r,o){const a=e-i,s=e+i,n=t-i,l=t+i;if(s<0||a>this.width||l<0||n>this.height)return !1;const c=[];return this._forEachCell(a,n,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},o),c.length>0}_queryCell(e,t,i,r,o,a,s,n){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const o=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,d=this.boxKeys[s];if(e<=o[u+2]&&t<=o[u+3]&&i>=o[u+0]&&r>=o[u+1]&&(!n||n(d))&&(!c||!fe(h,d.overlapMode))&&(a.push({key:d,x1:o[u],y1:o[u+1],x2:o[u+2],y2:o[u+3]}),c))return !0}}const d=this.circleCells[o];if(null!==d){const o=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],e,t,i,r)&&(!n||n(d))&&(!c||!fe(h,d.overlapMode))){const e=o[u],t=o[u+1],i=o[u+2];if(a.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return !0}}}return !1}_queryCellCircle(e,t,i,r,o,a,s,n){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(r))&&!fe(h,r.overlapMode))return a.push(!0),!0}}const d=this.circleCells[o];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!n||n(r))&&!fe(h,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,i,r,o,a,s,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(o.call(this,e,t,i,r,this.xCellCount*l+d,a,s,n))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,o,a){const s=r-e,n=o-t,l=i+a;return l*l>s*s+n*n}_circleAndRectCollide(e,t,i,r,o,a,s){const n=(a-r)/2,l=Math.abs(e-(r+n));if(l>n+i)return !1;const c=(s-o)/2,h=Math.abs(t-(o+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}function ve(e,i,o){const a=t.K();if(!e){const{vecSouth:e,vecEast:t}=be(i),o=r();o[0]=t[0],o[1]=t[1],o[2]=e[0],o[3]=e[1],s=o,(d=(l=(n=o)[0])*(u=n[3])-(h=n[2])*(c=n[1]))&&(s[0]=u*(d=1/d),s[1]=-c*d,s[2]=-h*d,s[3]=l*d),a[0]=o[0],a[1]=o[1],a[4]=o[2],a[5]=o[3];}var s,n,l,c,h,u,d;return t.M(a,a,[1/o,1/o,1]),a}function xe(e,i,r,o){if(e){const e=t.K();if(!i){const{vecSouth:t,vecEast:i}=be(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1];}return t.M(e,e,[o,o,1]),e}return r.pixelsToClipSpaceMatrix}function be(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),o=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),n=t.ak();n[0]=-a*o*r-s*i,n[1]=-s*o*r+a*i;const l=t.al(n);l<1e-9?t.am(n):t.an(n,n,1/l);const c=t.ak();c[0]=a*o*i-s*r,c[1]=s*o*i+a*r;const h=t.al(c);return h<1e-9?t.am(c):t.an(c,c,1/h),{vecEast:c,vecSouth:n}}function ye(e,i,r,o){let a;o?(a=[e,i,o(e,i),1],t.ap(a,a,r)):(a=[e,i,0,1],Oe(a,a,r));const s=a[3];return {point:new t.P(a[0]/s,a[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function we(e,t){return .5+e/t*.5}function Te(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Pe(e,i,r,o,a,s,n,l,c,h,u,d,_){const p=r?e.textSizeData:e.iconSizeData,m=t.ag(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const v=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let y=!1;for(let r=0;rMath.abs(r.x-i.x)*o?{useVertical:!0}:(e===t.ah.vertical?i.yr.x)?{needsFlipping:!0}:null}function Me(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:o,fontSize:a,flip:s,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=a/24,_=o.lineOffsetX*d,p=o.lineOffsetY*d;let m;if(o.numGlyphs>1){const e=o.glyphStartIndex+o.numGlyphs,t=o.lineStartIndex,a=o.lineStartIndex+o.lineLength,c=Ce(d,l,_,p,s,o,u,i);if(!c)return {notEnoughRoom:!0};const f=De(c.first.point.x,c.first.point.y,i,r),g=De(c.last.point.x,c.last.point.y,i,r);if(n&&!s){const e=Ie(o.writingMode,f,g,h);if(e)return e}m=[c.first];for(let r=o.glyphStartIndex+1;r0?n.point:Ee(i.tileAnchorPoint,s,e,1,i),c=De(e.x,e.y,i,r),u=De(l.x,l.y,i,r),d=Ie(o.writingMode,c,u,h);if(d)return d}const e=ke(d*l.getoffsetX(o.glyphStartIndex),_,p,s,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[e];}for(const e of m)t.ao(c,e.point,e.angle);return {}}function Ee(e,t,i,r,o){const a=e.add(e.sub(t)._unit()),s=Re(a.x,a.y,o).point,n=i.sub(s);return i.add(n._mult(r/n.mag()))}function Se(e,i,r){const o=i.projectionCache;if(o.projections[e])return o.projections[e];const a=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Re(a.x,a.y,i);if(s.signedDistanceFromCamera>0)return o.projections[e]=s.point,o.anyProjectionOccluded=o.anyProjectionOccluded||s.isOccluded,s.point;const n=e-r.direction;return Ee(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),a,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Re(e,t,i){const r=e+i.translation[0],o=t+i.translation[1];let a;return i.pitchWithMap?(a=ye(r,o,i.pitchedLabelPlaneMatrix,i.getElevation),a.isOccluded=!1):(a=i.transform.projectTileCoordinates(r,o,i.unwrappedTileID,i.getElevation),a.point.x=(.5*a.point.x+.5)*i.width,a.point.y=(.5*-a.point.y+.5)*i.height),a}function De(e,i,r,o){if(r.pitchWithMap){const a=[e,i,0,1];return t.ap(a,a,o),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}return {x:e/r.width*2-1,y:i/r.height*2-1}}function ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ae(e,t,i){return e._unit()._perp()._mult(t*i)}function Le(e,i,r,o,a,s,n,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=r.add(i);if(e+c.direction=a)return l.projectionCache.offsets[e]=h,h;const u=Se(e+c.direction,l,c),d=Ae(u.sub(r),n,c.direction),_=r.add(d),p=u.add(d);return l.projectionCache.offsets[e]=t.aq(s,h,_,p)||h,l.projectionCache.offsets[e]}function ke(e,t,i,r,o,a,s,n,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,_=h>0?a+o:a+o+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=Re(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const b=Math.abs(c),y=[];let w;for(;v+x<=b;){if(_+=h,_=s)return null;v+=x,g=f,m=p;const e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:g};if(f=Se(_,n,e),0===i)y.push(g),w=f.sub(g);else {let t;const r=f.sub(g);t=0===r.mag()?Ae(Se(_+h,n,e).sub(f),i,h):Ae(r,i,h),m||(m=g.add(t)),p=Le(_,t,f,a,s,m,i,n,e),y.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((b-v)/x)._add(m||g),P=u+Math.atan2(f.y-g.y,f.x-g.x);return y.push(T),{point:T,angle:l?P:0,path:y}}const Fe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Be(e,t){for(let i=0;i=1;e--)_.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let f=[];if(_.length>0){const e=_[0].clone(),i=_[0].clone();for(let t=1;t<_.length;t++)e.x=Math.min(e.x,_[t].x),e.y=Math.min(e.y,_[t].y),i.x=Math.max(i.x,_[t].x),i.y=Math.max(i.y,_[t].y);f=e.x>=r.x&&i.x<=o.x&&e.y>=r.y&&i.y<=o.y?[_]:i.xo.x||i.yo.y?[]:t.ar([_],r.x,r.y,o.x,o.y);}for(const t of f){a.reset(t,.25*i);let r=0;r=a.length<=.5*i?1:Math.ceil(a.paddedLength/p)+1;for(let t=0;t{const t=ye(e.x,e.y,r,i.getElevation),o=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height,o}))}(e,i);return function(e){let t=0,i=0,r=0,o=0;for(let a=0;ai&&(i=o,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let r=1/0,o=1/0,a=-1/0,s=-1/0;for(const n of e){const e=new t.P(n.x+je,n.y+je);r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y),i.push(e);}const n=this.grid.query(r,o,a,s).concat(this.ignoredGrid.query(r,o,a,s)),l={},c={};for(const e of n){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const o=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.as(i,o)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex));}return c}insertCollisionBox(e,t,i,r,o,a){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,r,o,a){const s=i?this.ignoredGrid:this.grid,n={bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t};for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,o,c,u)));S=e.some((e=>!e.isOccluded)),E=e.map((e=>new t.P(e.x,e.y)));}else S=!0;return {box:t.au(E),allPointsOccluded:!S}}}class Ne{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Ge{constructor(e,t,i,r,o){this.text=new Ne(e?e.text:null,t,i,o),this.icon=new Ne(e?e.icon:null,t,r,o);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ue{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i;}}class Ve{constructor(e,t,i,r,o){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=o;}}class qe{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function We(e,i,r,o,a){const{horizontalAlign:s,verticalAlign:n}=t.aB(e);return new t.P(-(s-.5)*i+o[0]*a,-(n-.5)*r+o[1]*a)}class $e{constructor(e,t,i,r,o){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Ze(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new qe(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,o){const a=r.getBucket(i),s=r.latestFeatureIndex;if(!a||!s||i.id!==a.layerIds[0])return;const n=r.collisionBoxArray,l=a.layers[0].layout,c=a.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.Z,d=r.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=t.aw(r,1,this.transform.zoom),m=t.ax(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),f=t.ax(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),g=ve(_,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new Ve(a.bucketInstanceId,s,a.sourceLayerIndex,a.index,r.tileID);const v={bucket:a,layout:l,translationText:m,translationIcon:f,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.ag(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(o)for(const t of a.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:v});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v});}attemptAnchorPlacement(e,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v,x,b){const y=t.ay[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=We(y,r,o,w,a),P=this.collisionIndex.placeCollisionBox(i,d,l,c,h,n,s,f,u.predicate,x,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,c,h,n,s,g,u.predicate,x,T,b).placeable)&&P.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID].text&&(e=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:w,width:r,height:o,anchor:y,textBoxScale:a,prevAnchor:e},this.markUsedJustification(p,y,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:T,placedGlyphBoxes:P}}}placeLayerBucketPart(e,i,r){const{bucket:o,layout:a,translationText:s,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=e.parameters,m=a.get("text-optional"),f=a.get("icon-optional"),g=t.az(a,"text-overlap","text-allow-overlap"),v="always"===g,x=t.az(a,"icon-overlap","icon-allow-overlap"),b="always"===x,y="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),T="none"!==a.get("icon-text-fit"),P="viewport-y"===a.get("symbol-z-order"),C=v&&(b||!o.hasIconData()||f),I=b&&(v||!o.hasTextData()||m);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d);const M=this.retainedQueryData[o.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(M),S=this.transform.getFastPathSimpleProjectionMatrix(M),R=(e,d,b)=>{var P,R;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new Ue(!1,!1,!1));let D=!1,z=!1,A=!0,L=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,j=null,Z=0,N=0,G=0;d.textFeatureIndex?Z=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(Z=e.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const U=d.textBox;if(U){const i=i=>{let r=t.ah.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(o,r,e));}return r},a=(i,r)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===t.ah.vertical?(k=r(),F=k):k=i(),k&&k.placeable)break}else k=i();},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,h,M,l,w,y,s,p.predicate,E,void 0,S);return r&&r.placeable&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),r};a((()=>r(U,t.ah.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.ah.vertical):{box:null,offscreen:null}})),i(k&&k.placeable);}else {let _=t.ay[null===(R=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[e.crossTileID])||void 0===R?void 0:R.anchor];const m=(t,i,a)=>{const d=t.x2-t.x1,m=t.y2-t.y1,f=e.textBoxScale,v=T&&"never"===x?i:null;let b=null,P="never"===g?1:2,C="never";_&&P++;for(let i=0;im(U,d.iconBox,t.ah.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ah.vertical):{box:null,occluded:!0,offscreen:null}})),k&&(D=k.placeable,A=k.offscreen);const f=i(k&&k.placeable);if(!D&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,f));}}}if(B=k,D=B&&B.placeable,A=B&&B.offscreen,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),n=t.ai(o.textSizeData,_,i),h=a.get("text-padding");O=this.collisionIndex.placeCollisionCircles(g,i,o.lineVertexArray,o.glyphOffsetArray,n,l,c,r,w,p.predicate,e.collisionCircleDiameter,h,s,E),O.circles.length&&O.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),D=v||O.circles.length>0&&!O.collisionDetected,A=A&&O.offscreen;}if(d.iconFeatureIndex&&(G=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,M,l,w,y,n,p.predicate,E,T&&L?L:void 0,S);F&&F.placeable&&d.verticalIconBox?(j=e(d.verticalIconBox),z=j.placeable):(j=e(d.iconBox),z=j.placeable),A=A&&j.offscreen;}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,q=f||0===e.numIconVertices;V||q?q?V||(z=z&&D):D=z&&D:z=D=z&&D;const W=z&&j.placeable;if(D&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,a.get("text-ignore-placement"),o.bucketInstanceId,F&&F.placeable&&N?N:Z,p.ID),W&&this.collisionIndex.insertCollisionBox(j.box,x,a.get("icon-ignore-placement"),o.bucketInstanceId,G,p.ID),O&&D&&this.collisionIndex.insertCollisionCircles(O.circles,g,a.get("text-ignore-placement"),o.bucketInstanceId,Z,p.ID),r&&this.storeCollisionData(o.bucketInstanceId,b,d,B,j,O),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===o.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Ue((D||C)&&!(null==B?void 0:B.occluded),(z||I)&&!(null==j?void 0:j.occluded),A||o.justReloaded),i[e.crossTileID]=!0;};if(P){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=o.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];R(o.symbolInstances.get(i),o.collisionArrays[i],i);}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID);}markUsedOrientation(e,i,r){const o=i===t.ah.horizontal||i===t.ah.horizontalOnly?i:0,a=i===t.ah.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,o=t?t.opacities:{},a=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],a=o[e];a?(this.opacities[e]=new Ge(a,r,t.text,t.icon),i=i||t.text!==a.text.placed||t.icon!==a.icon.placed):(this.opacities[e]=new Ge(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon);}for(const e in o){const t=o[e];if(!this.opacities[e]){const o=new Ge(t,r,!1,!1);o.isHidden()||(this.opacities[e]=o,i=i||t.text.placed||t.icon.placed);}}for(const e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray);}}updateBucketOpacities(e,i,r,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const a=e.layers[0],s=a.layout,n=new Ge(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),_="none"!==s.get("icon-text-fit"),p=new Ge(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const m=(e,t,i)=>{for(let r=0;r0,v=this.placedOrientations[o.crossTileID],x=v===t.ah.vertical,b=v===t.ah.horizontal||v===t.ah.horizontalOnly;if(a>0||s>0){const t=it(c.text);m(e.text,a,x?rt:t),m(e.text,s,b?rt:t);const i=c.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||x?1:0);})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||b?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o));}if(g){const t=it(c.icon),i=!(_&&o.verticalPlacedIconSymbolIndex&&x);o.placedIconSymbolIndex>=0&&(m(e.icon,o.numIconVertices,i?t:rt),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=c.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,o.numVerticalIconVertices,i?rt:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden());}const y=f&&f.has(i)?f.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const r=e.collisionArrays[i];if(r){let i=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(i=We(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1;}if(r.textBox||r.verticalTextBox){let o;r.textBox&&(o=x),r.verticalTextBox&&(o=b),He(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||o,y.text,i.x,i.y);}}if(r.iconBox||r.verticalIconBox){const t=Boolean(!b&&r.verticalIconBox);let o;r.iconBox&&(o=t),r.verticalIconBox&&(o=!t),He(e.iconCollisionBox.collisionVertexArray,c.icon.placed,o,y.icon,_?i.x:0,_?i.y:0);}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId]);}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function He(e,t,i,r,o,a){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-je,n=r[1]-je,l=r[2]-je,c=r[3]-je;e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,c),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,c);}const Ke=Math.pow(2,25),Xe=Math.pow(2,24),Qe=Math.pow(2,17),Ye=Math.pow(2,16),Je=Math.pow(2,9),et=Math.pow(2,8),tt=Math.pow(2,1);function it(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Ke+t*Xe+i*Qe+t*Ye+i*Je+t*et+i*tt+t}const rt=0;class ot{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,r,o){const a=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex!this._forceFullPlacement&&s.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=a)&&(!r.maxzoom||r.maxzoom>a)){if(this._inProgressLayer||(this._inProgressLayer=new ot(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const st=512/t.Z/2;class nt{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const o=new Map;for(let e=0;e({x:Math.floor(e.anchorX*st),y:Math.floor(e.anchorY*st)}))),crossTileIDs:i.map((e=>e.crossTileID))};if(r.positions.length>128){const e=new t.aC(r.positions.length,16,Uint16Array);for(const{x:t,y:i}of r.positions)e.add(t,i);e.finish(),delete r.positions,r.index=e;}this._symbolsByKey[e]=r;}}getScaledCoordinates(e,i){const{x:r,y:o,z:a}=this.tileID.canonical,{x:s,y:n,z:l}=i.canonical,c=st/Math.pow(2,l-a),h=(n*t.Z+e.anchorY)*c,u=o*t.Z*st;return {x:Math.floor((s*t.Z+e.anchorX)*c-r*t.Z*st),y:Math.floor(h-u)}}findMatches(e,t,i){const r=this.tileID.canonical.ze))}}class lt{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class ct{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const o=i[e];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),r[o.tileID.key]=o;}this.indexes[e]=r;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in o){const a=o[i];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,r);}else {const a=o[e.scaledTo(Number(i)).key];a&&a.findMatches(t.symbolInstances,e,r);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var ut="void main() {fragColor=vec4(1.0);}";const dt={prelude:_t("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:_t("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:_t("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:_t("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:_t("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:_t("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:_t(ut,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:_t("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:_t("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:_t("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:_t("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:_t("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:_t(ut,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:_t("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:_t("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:_t("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:_t("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:_t("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));fragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:_t("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:_t("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:_t("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:_t("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:_t("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:_t("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:_t("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:_t("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:_t("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:_t("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:_t("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:_t("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:_t("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:_t("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function _t(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=a?a.concat(o):o,n={};return {fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\nout ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,staticUniforms:s}}class pt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}var mt=t.aD([{name:"a_pos",type:"Int16",components:2}]);const ft="#define PROJECTION_MERCATOR",gt="mercator";class vt{constructor(){this._cachedMesh=null;}get name(){return "mercator"}get useSubdivision(){return !1}get shaderVariantName(){return gt}get shaderDefine(){return ft}get shaderPreludeCode(){return dt.projectionMercator}get vertexShaderPreludeCode(){return dt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aE.noSubdivision}get useGlobeControls(){return !1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,o,a){if(this._cachedMesh)return this._cachedMesh;const s=new t.aF;s.emplaceBack(0,0),s.emplaceBack(t.Z,0),s.emplaceBack(0,t.Z),s.emplaceBack(t.Z,t.Z);const n=e.createVertexBuffer(s,mt.members),l=t.aG.simpleSegment(0,0,4,2),c=new t.aH;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new pt(n,h,l),this._cachedMesh}recalculate(){}hasTransition(){return !1}setErrorQueryLatitudeDegrees(e){}}function xt(e,i){const r=t.ae(i.lat,-85.051129,t.aJ);return new t.P(t.U(i.lng)*e,t.S(r)*e)}function bt(e,i){return new t.$(i.x/e,i.y/e).toLngLat()}function yt(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.ad(90-e.pitch)),Math.tan(t.ad(89.25-e.pitch)))}function wt(e,i){const r=e.canonical,o=i/t.aI(r.z),a=r.x+Math.pow(2,r.z)*e.wrap,s=t.at(new Float64Array(16));return t.L(s,s,[a*o,r.y*o,0]),t.M(s,s,[o/t.Z,o/t.Z,1]),s}function Tt(e,i,r,o,a){const s=t.$.fromLngLat(e,i),n=a*t.aK(1,e.lat),l=n*Math.cos(t.ad(r)),c=Math.sqrt(n*n-l*l),h=c*Math.sin(t.ad(-o)),u=c*Math.cos(t.ad(-o));return new t.$(s.x+h,s.y+u,s.z+l)}class Pt{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r;}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.B.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.B.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.B.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.B.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.ae((this.left+e-this.right)/2,0,e),o=t.ae((this.top+i-this.bottom)/2,0,i);return new t.P(r,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Pt(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ct(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0;}function It(e){return Math.max(0,Math.floor(e))}class Mt{constructor(e,i,r,o,a,s){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==o?0:o,this._maxPitch=null==a?60:a,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.Q(0,0),this._elevation=0,this._zoom=0,this._tileZoom=It(this._zoom),this._scale=t.aI(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Pt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0;}apply(e,i,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=It(this._zoom),this._scale=t.aI(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Pt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices();}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e;}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)));}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)));}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aL(e,-180,180)*Math.PI/180;var o,a,s,n,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),o=this._rotationMatrix,s=-this._bearingInRadians,n=(a=this._rotationMatrix)[0],l=a[1],c=a[2],h=a[3],u=Math.sin(s),d=Math.cos(s),o[0]=n*d+c*u,o[1]=l*d+h*u,o[2]=n*-u+c*d,o[3]=l*-u+h*d);}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ae(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices());}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices());}get fovInRadians(){return this._fovInRadians}get fov(){return t.aM(this._fovInRadians)}setFov(e){e=t.ae(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ad(e),this._calcMatrices());}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.aI(i),this._constrain(),this._calcMatrices());}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices();}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices();}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices();}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new V([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-85.051129,t.aJ]);}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return [i[0],e];{let r=e.x,o=e.y,a=e.x,s=e.y;for(const e of i)r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y);return [new t.P(r,o),new t.P(a,o),new t.P(a,s),new t.P(r,s),new t.P(r,o)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1;}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.at(new Float64Array(16));t.M(e,e,[this._width/2,-this._height/2,1]),t.L(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.at(new Float64Array(16)),t.M(e,e,[1,-1,1]),t.L(e,e,[-1,-1,0]),t.M(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height;}this._callbacks.calcMatrices();}calculateCenterFromCameraLngLatAlt(e,i,r,o){const a=void 0!==r?r:this.bearing,s=o=void 0!==o?o:this.pitch,n=t.$.fromLngLat(e,i),l=-Math.cos(t.ad(s)),c=Math.sin(t.ad(s)),h=c*Math.sin(t.ad(a)),u=-c*Math.cos(t.ad(a));let d=this.elevation;const _=i-d;let p;l*_>=0||Math.abs(l)<.1?(p=1e4,d=i+p*l):p=-_/l;let m,f,g=t.aN(1,n.y),v=0;do{if(v+=1,v>10)break;f=p/g,m=new t.$(n.x+h*f,n.y+u*f),g=1/m.meterInMercatorCoordinateUnits();}while(Math.abs(p-f*g)>1e-12);return {center:m.toLngLat(),elevation:d,zoom:t.ab(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.aK(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,o=t.$.fromLngLat(this.center,this.elevation),a=Tt(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(a.toLngLat(),t.aN(a.z,o.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom);}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.aK(1,this.center.lat)*this.worldSize;return Tt(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return [0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class St{distanceToTile2d(e,t,i,r){const o=r.distanceX([e,t]),a=r.distanceY([e,t]);return Math.hypot(o,a)}getWrap(e,t,i){return i}getTileAABB(e,i,r,o){var a,s;let n=r,l=r;if(o.terrain){const c=new t.Y(e.z,i,e.z,e.x,e.y),h=o.terrain.getMinMaxElevation(c);n=null!==(a=h.minElevation)&&void 0!==a?a:r,l=null!==(s=h.maxElevation)&&void 0!==s?s:r;}const c=1<o}allowWorldCopies(){return !0}recalculateCache(){}}class Rt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i;}static fromInvProjectionMatrix(e,i=1,r=0){const o=Math.pow(2,r),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const a=1/(r=t.ap([],r,e))[3]/i*o;return t.aR(r,r,[a,a,1/r[3],a])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.aS([],a[e[0]],a[e[1]]),r=t.aS([],a[e[2]],a[e[1]]),o=t.aT([],t.aU([],i,r)),s=-t.aV(o,a[e[1]]);return o.concat(s)})),n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of a)for(let t=0;t<3;t++)n[t]=Math.min(n[t],e[t]),l[t]=Math.max(l[t],e[t]);return new Rt(a,s,new Et(n,l))}}class Dt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,r,o){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Mt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,r,o),this._coveringTilesDetailsProvider=new St;}clone(){const e=new Dt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i);}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.aW(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),n=Math.floor(Math.min(r.x,o.x,a.x,s.x)),l=Math.floor(Math.max(r.x,o.x,a.x,s.x)),c=1;for(let r=n-c;r<=l+c;r++)0!==r&&i.push(new t.aW(r,e));}return i}getCameraFrustum(){return Rt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i);}setLocationAtPoint(e,i){const r=t.aK(this.elevation,this.center.lat),o=this.screenPointToMercatorCoordinateAtZ(i,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),s=t.$.fromLngLat(e),n=new t.$(s.x-(o.x-a.x),s.y-(o.y-a.y));this.setCenter(null==n?void 0:n.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap());}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.$.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.$.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,o=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.ap(o,o,this._pixelMatrixInverse),t.ap(a,a,this._pixelMatrixInverse);const s=o[3],n=a[3],l=o[1]/s,c=a[1]/n,h=o[2]/s,u=a[2]/n,d=h===u?0:(r-h)/(u-h);return new t.$(t.B.number(o[0]/s,a[0]/n,d)/this.worldSize,t.B.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.ap(o,o,r),new t.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this._helper._height/2-yt(this));return (new V).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-yt(this)}calculatePosMatrix(e,i=!1,r){var o;const a=null!==(o=e.key)&&void 0!==o?o:t.aX(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(a)){const e=s.get(a);return r?e.f32:e.f64}const n=wt(e,this.worldSize);t.N(n,i?this._alignedProjMatrix:this._viewProjMatrix,n);const l={f64:n,f32:new Float32Array(n)};return s.set(a,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const o=wt(e,this.worldSize);return t.N(o,this._fogMatrix,o),r.set(i,new Float32Array(o)),r.get(i)}getConstrained(e,i){i=t.ae(+i,this.minZoom,this.maxZoom);const r={center:new t.Q(e.lng,e.lat),zoom:i};let o=this._helper._lngRange;this._helper._renderWorldCopies||null!==o||(o=[-179.9999999999,180-1e-10]);const a=this.tileSize*t.aI(r.zoom);let s=0,n=a,l=0,c=a,h=0,u=0;const{x:d,y:_}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.S(e[1])*a,n=t.S(e[0])*a,n-s<_&&(h=_/(n-s));}o&&(l=t.aL(t.U(o[0])*a,0,a),c=t.aL(t.U(o[1])*a,0,a),cn&&(g=n-e);}if(o){const e=(l+c)/2;let i=p;this._helper._renderWorldCopies&&(i=t.aL(p,e-a/2,e+a/2));const r=d/2;i-rc&&(f=c-r);}if(void 0!==f||void 0!==g){const e=new t.P(null!=f?f:p,null!=g?g:m);r.center=bt(a,e).wrap();}return r}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const o=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-o*this._helper._pixelPerMeter/Math.cos(i),s=o<0?a:e,n=Math.PI/2+this.pitchInRadians,l=t.ad(this.fov)*(Math.abs(Math.cos(t.ad(this.roll)))*this.height+Math.abs(Math.sin(t.ad(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*s/Math.sin(t.ae(Math.PI-n-l,.01,Math.PI-.01)),h=yt(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.ad(.75),_=u>d?2*u*(.5+r.y/(2*h)):d,p=Math.sin(_)*s/Math.sin(t.ae(Math.PI-n-_,.01,Math.PI-.01)),m=Math.min(c,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50;}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=xt(this.worldSize,this.center),r=i.x,o=i.y;this._helper._pixelPerMeter=t.aK(1,this.center.lat)*this.worldSize;const a=t.ad(Math.min(this.pitch,89.25)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a));let n;this._calculateNearFarZIfNeeded(s,a,e),n=new Float64Array(16),t.aY(n,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.aj(this._invProjMatrix,n),n[8]=2*-e.x/this._helper._width,n[9]=2*e.y/this._helper._height,this._projectionMatrix=t.aZ(n),t.M(n,n,[1,-1,1]),t.L(n,n,[0,0,-this._helper.cameraToCenterDistance]),t.a_(n,n,-this.rollInRadians),t.a$(n,n,this.pitchInRadians),t.a_(n,n,-this.bearingInRadians),t.L(n,n,[-r,-o,0]),this._mercatorMatrix=t.M([],n,[this.worldSize,this.worldSize,this.worldSize]),t.M(n,n,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n),t.L(n,n,[0,0,-this.elevation]),this._viewProjMatrix=n,this._invViewProjMatrix=t.aj([],n);const l=[0,0,-1,1];t.ap(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.aY(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.M(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.a_(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.a$(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.a_(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.L(this._fogMatrix,this._fogMatrix,[-r,-o,0]),t.M(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),_=r-Math.round(r)+u*c+d*h,p=o-Math.round(o)+u*h+d*c,m=new Float64Array(n);if(t.L(m,m,[_>.5?_-1:_,p>.5?p-1:p,0]),this._alignedProjMatrix=m,n=t.aj(new Float64Array(16),this._pixelMatrix),!n)throw new Error("failed to invert matrix");this._pixelMatrixInverse=n,this._clearMatrixCaches();}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear();}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.ap(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.aK(1,this.center.lat)*this.worldSize;return Tt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.$.fromLngLat(e),o=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.ap(o,o,this._viewProjMatrix),o[2]/o[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:o}=e,a=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;let n;return n=i&&i.terrainRttPosMatrix32f&&o?i.terrainRttPosMatrix32f:s||t.b0(),{mainMatrix:n,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n}}isLocationOccluded(e){return !1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aQ(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,o){const a=this.calculatePosMatrix(r);let s;o?(s=[e,i,o(e,i),1],t.ap(s,s,a)):(s=[e,i,0,1],Oe(s,s,a));const n=s[3];return {point:new t.P(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t);}getMatrixForModel(e,i){const r=t.$.fromLngLat(e,i),o=r.meterInMercatorCoordinateUnits(),a=t.b1();return t.L(a,a,[r.x,r.y,r.z]),t.a_(a,a,Math.PI),t.a$(a,a,Math.PI/2),t.M(a,a,[-o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=new t.Y(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),o=wt(i,this.worldSize);t.N(o,this._viewProjMatrix,o),r.tileMercatorCoords=[0,0,1,1];const a=[t.Z,t.Z,this.worldSize/this._helper.pixelsPerMeter],s=t.b2();return t.M(s,o,a),r.fallbackMatrix=s,r.mainMatrix=s,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function zt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");}function At(e){if(e.useSlerp)if(e.k<1){const i=t.b3(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.b3(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),o=new Float64Array(4);t.b4(o,i,r,e.k);const a=t.b5(o);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing);}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.B.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.B.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.B.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k));}function Lt(e,i,r,o,a){const s=a.padding,n=xt(a.worldSize,r.getNorthWest()),l=xt(a.worldSize,r.getNorthEast()),c=xt(a.worldSize,r.getSouthEast()),h=xt(a.worldSize,r.getSouthWest()),u=t.ad(-o),d=n.rotate(u),_=l.rotate(u),p=c.rotate(u),m=h.rotate(u),f=new t.P(Math.max(d.x,_.x,m.x,p.x),Math.max(d.y,_.y,m.y,p.y)),g=new t.P(Math.min(d.x,_.x,m.x,p.x),Math.min(d.y,_.y,m.y,p.y)),v=f.sub(g),x=(a.width-(s.left+s.right+i.left+i.right))/v.x,b=(a.height-(s.top+s.bottom+i.top+i.bottom))/v.y;if(b<0||x<0)return void zt();const y=Math.min(t.ab(a.scale*Math.min(x,b)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ad(o)),P=w.add(T).mult(a.scale/t.aI(y));return {center:bt(a.worldSize,n.add(c).div(2).sub(P)),zoom:y,bearing:o}}class kt{get useGlobeControls(){return !1}handlePanInertia(e,t){return {easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around);}cameraForBoxAndBearing(e,t,i,r,o){return Lt(e,t,i,r,o)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.Q.convert(i.center));}handleEaseTo(e,i){const r=e.zoom,o=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},n=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=n?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:_,zoom:p}=e.getConstrained(t.Q.convert(i.center||d),null!=h?h:r);Ct(e,_);const m=xt(e.worldSize,d),f=xt(e.worldSize,_).sub(m),g=t.aI(p-r);return c=p!==r,{easeFunc:n=>{if(c&&e.setZoom(t.B.number(r,p,n)),t.b6(a,s)||At({startEulerAngles:a,endEulerAngles:s,tr:e,k:n,useSlerp:a.roll!=s.roll}),l&&(e.interpolatePadding(o,i.padding,n),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else {const i=t.aI(e.zoom-r),o=p>r?Math.min(2,g):Math.max(.5,g),a=Math.pow(o,1-n),s=bt(e.worldSize,m.add(f.mult(n*a)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,u);}},isZooming:c,elevationCenter:_}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.zoom,a=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),r?+i.zoom:o),s=a.center,n=a.zoom;Ct(e,s);const l=xt(e.worldSize,i.locationAtOffset),c=xt(e.worldSize,s).sub(l),h=c.mag(),u=t.aI(n-o);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,o,n),a=e.getConstrained(s,r).zoom;d=t.aI(a-o);}return {easeFunc:(i,r,a,h)=>{e.setZoom(1===i?n:o+t.ab(r));const u=1===i?s:bt(e.worldSize,l.add(c.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h);},scaleOfZoom:u,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:h}}}class Ft{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i;}}Ft.Replace=[1,0],Ft.disabled=new Ft(Ft.Replace,t.b7.transparent,[!1,!1,!1,!1]),Ft.unblended=new Ft(Ft.Replace,t.b7.transparent,[!0,!0,!0,!0]),Ft.alphaBlended=new Ft([1,771],t.b7.transparent,[!0,!0,!0,!0]);const Bt=2305;class Ot{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Ot.disabled=new Ot(!1,1029,Bt),Ot.backCCW=new Ot(!0,1029,Bt),Ot.frontCCW=new Ot(!0,1028,Bt);class jt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}jt.ReadOnly=!1,jt.ReadWrite=!0,jt.disabled=new jt(519,jt.ReadOnly,[0,1]);const Zt=7680;class Nt{constructor(e,t,i,r,o,a){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=o,this.pass=a;}}Nt.disabled=new Nt({func:519,mask:0},0,0,Zt,Zt,Zt);const Gt=new WeakMap;function Ut(e){var t;if(Gt.has(e))return Gt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Gt.set(e,i),i}}class Vt{get awaitingQuery(){return !!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const o=new t.aF;o.emplaceBack(-1,-1),o.emplaceBack(2,-1),o.emplaceBack(-1,2);const a=new t.aH;a.emplaceBack(0,1,2),this._fullscreenTriangle=new pt(i.createVertexBuffer(o,mt.members),i.createIndexBuffer(a),t.aG.simpleSegment(0,0,o.length,a.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Ut(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null));}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null;}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer);}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,o=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.b7.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,o.TRIANGLES,jt.disabled,Nt.disabled,Ft.unblended,Ot.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Ut(o)){o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.readBuffer(o.COLOR_ATTACHMENT0),o.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const e=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);o.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e};}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null};}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Ut(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Vt._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount;}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const qt=t.Z/128;function Wt(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,o=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=o+1,n=a+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=r+(e.generateBorders?1:0),u=r+(e.generateBorders||e.extendToSouthPole?1:0),d=s*n,_=o*a*6,p=s*n>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,f=new Int16Array(2*d);let g=0;for(let i=c;i<=u;i++)for(let o=l;o<=h;o++){let a=o/r*t.Z;-1===o&&(a=-64),o===r+1&&(a=t.Z+qt);let s=i/r*t.Z;-1===i&&(s=e.extendToNorthPole?t.b9:-64),i===r+1&&(s=e.extendToSouthPole?t.ba:t.Z+qt),f[g++]=a,f[g++]=s;}const v=m?new Uint32Array(_):new Uint16Array(_);let x=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return "globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy();}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e);}getMeshFromTileID(e,t,i,r,o){return this.currentProjection.getMeshFromTileID(e,t,i,r,o)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator");}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e);}}function Qt(e){const t=ei(e.worldSize,e.center.lat);return 2*Math.PI*t}function Yt(e,i,r,o,a){const s=1/(1<1e-6){const o=e[0]/r,a=Math.acos(e[2]/r),s=(o>0?a:-a)/Math.PI*180;return new t.Q(t.aL(s,-180,180),i)}return new t.Q(0,i)}function ii(e){return Math.cos(e*Math.PI/180)}function ri(e,i){const r=ii(e),o=ii(i);return t.ab(o/r)}function oi(e,i){const r=e.rotate(i.bearingInRadians),o=i.zoom+ri(i.center.lat,0),a=t.bc(1/ii(i.center.lat),1/ii(Math.min(Math.abs(i.center.lat),60)),t.bf(o,7,3,0,1)),s=360/Qt({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.Q(i.center.lng-r.x*s*a,t.ae(i.center.lat+r.y*s,-85.051129,t.aJ))}function ai(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function si(e,i,r,o){const a=e.lat+r*o;if(Math.abs(r)>1){const s=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,n=Math.abs(e.lat+r)*Math.PI/180,l=ai(s+o*(n-s)),c=ai(s),h=ai(n);return new t.Q(e.lng+i*((l-c)/(h-c)),a)}return new t.Q(e.lng+i*o,a)}class ni{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=e;}recalculateCache(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1;}getTileAABB(e,t,i,r){const o=`${e.z}_${e.x}_${e.y}`,a=this._cache.get(o);if(a)return a;const s=this._cachePrevious.get(o);if(s)return this._cache.set(o,s),s;const n=this._aabbFactory(e,t,i,r);return this._cache.set(o,n),this._hadAnyChanges=!0,n}}function li(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function ci(e,t,i,r,o){const a=e-i;let s;return s=a<0?Math.min(-a,1+a-o):a>1?Math.min(Math.max(a-o,0),1-a):0,Math.max(s,li(t,r,o))}class hi{constructor(){this._aabbCache=new ni(this._computeTileAABB);}recalculateCache(){this._aabbCache.recalculateCache();}distanceToTile2d(e,t,i,r){const o=1<4}allowWorldCopies(){return !1}getTileAABB(e,t,i,r){return this._aabbCache.getTileAABB(e,t,i,r)}_computeTileAABB(e,i,r,o){if(e.z<=0)return new Et([-1,-1,-1],[1,1,1]);if(1===e.z)return new Et([0===e.x?-1:0,0===e.y?0:-1,-1],[0===e.x?0:1,0===e.y?1:0,1]);{const i=[Yt(0,0,e.x,e.y,e.z),Yt(t.Z,0,e.x,e.y,e.z),Yt(t.Z,t.Z,e.x,e.y,e.z),Yt(0,t.Z,e.x,e.y,e.z)],r=[1,1,1],o=[-1,-1,-1];for(const e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);if(0===e.y||e.y===(1<{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new hi;}clone(){const e=new ui;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e);}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bi();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return {mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,o=Math.sin(i)*r,a=Math.cos(i)*r+1,s=1/Math.sqrt(o*o+a*a)*1;let n=-o,l=a;const c=Math.sqrt(n*n+l*l);n/=c,l/=c;const h=[0,n,l];return t.bj(h,h,[0,0,0],-this.bearingInRadians),t.bk(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bl(h,h,[0,0,0],this.center.lng*Math.PI/180),t.aO(h,h,.25),[...h,.25*-s]}isLocationOccluded(e){return !this.isSurfacePointVisible(Jt(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,o=Math.cos(r),a=[Math.sin(i)*o,Math.sin(r),Math.cos(i)*o],s=[a[2],0,-a[0]],n=[0,0,0];t.aU(n,s,a),t.aT(s,s),t.aT(n,n);const l=[0,0,0];return t.aT(l,[s[0]*e[0]+n[0]*e[1]+a[0]*e[2],s[1]*e[0]+n[1]*e[1]+a[1]*e[2],s[2]*e[0]+n[2]*e[1]+a[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const o=function(e,i,r){const o=1/(1<a&&(a=i),rn&&(n=r);}const h=[c.lng+s,c.lat+l,c.lng+a,c.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new V(h)}getConstrained(e,i){const r=t.ae(e.lat,-85.051129,t.aJ),o=t.ae(+i,this.minZoom+ri(0,r),this.maxZoom);return {center:new t.Q(e.lng,r),zoom:o}}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=Jt(this.unprojectScreenPoint(i)),o=Jt(e),a=t.bi();t.bo(a);const s=t.bi();t.bl(s,r,a,-this.center.lng*Math.PI/180),t.bk(s,s,a,this.center.lat*Math.PI/180);const n=o[0]*o[0]+o[2]*o[2],l=s[0]*s[0];if(n=-g&&p<=g,x=f>=-g&&f<=g;let b,y;if(v&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bs(u,e)+t.bs(p,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return !1;const i=t.bh();return t.ap(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.aV(e,i),o=t.bi(),a=t.bi();t.aO(a,i,r),t.aS(o,e,a);const s=1-t.aV(o,o);if(s<0)return null;const n=t.aV(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(s),c=n/l,h=l;return {tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),o=this.rayPlanetIntersection(i,r);if(o){const e=t.bi();t.aP(e,i,[r[0]*o.tMin,r[1]*o.tMin,r[2]*o.tMin]);const a=t.bi();return t.aT(a,e),ti(a)}const a=this._cachedClippingPlane[0]*r[0]+this._cachedClippingPlane[1]*r[1]+this._cachedClippingPlane[2]*r[2],s=-t.bq(this._cachedClippingPlane,i)/a,n=t.bi();if(s>0)t.aP(n,i,[r[0]*s,r[1]*s,r[2]*s]);else {const e=t.bi();t.aP(e,i,[2*r[0],2*r[1],2*r[2]]);const o=t.bq(this._cachedClippingPlane,e);t.aS(n,e,[this._cachedClippingPlane[0]*o,this._cachedClippingPlane[1]*o,this._cachedClippingPlane[2]*o]);}const l=t.bi();return t.aT(l,n),ti(l)}getMatrixForModel(e,i){const r=t.Q.convert(e),o=1/t.br,a=t.b1();return t.bm(a,a,r.lng/180*Math.PI),t.a$(a,a,-r.lat/180*Math.PI),t.L(a,a,[0,0,1+i/t.br]),t.a$(a,a,.5*Math.PI),t.M(a,a,[o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.Y(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class di{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache();}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Mt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Dt,this._verticalPerspectiveTransform=new ui;}clone(){const e=new di;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians);}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return {mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bc(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bc(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const o=this._mercatorTransform.getPitchedTextCorrection(e,i,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.bc(o,a,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ);}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e);}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e);}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform);}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class _i{get useGlobeControls(){return !0}handlePanInertia(e,i){const r=oi(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,o=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const a=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-a;if(0===s)return;const n=t.bn(i.center.lng,o.lng),l=n/(Math.abs(n/180)+1),c=t.bn(i.center.lat,o.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*t.aV(u,h),_=t.bi();t.aP(_,u,[h[0]*d,h[1]*d,h[2]*d]);const p=t.bt(_)-1,m=Math.exp(.5*-Math.max(p-.3,0)),f=ei(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=t.bf(f,.9,.5,1,.25),v=(1-t.aI(-s))*Math.min(m,g),x=i.center.lat,b=i.zoom,y=new t.Q(i.center.lng+l*v,t.ae(i.center.lat+c*v,-85.051129,t.aJ));i.setLocationAtPoint(o,r);const w=i.center,T=t.bf(Math.abs(n),45,85,0,1),P=t.bf(f,.75,.35,0,1),C=Math.pow(Math.max(T,P),.25),I=t.bn(w.lng,y.lng),M=t.bn(w.lat,y.lat);i.setCenter(new t.Q(w.lng+I*C,w.lat+M*C).wrap()),i.setZoom(b+ri(x,i.center.lat));}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,o=t.zoom;t.setCenter(oi(e.panDelta,t).wrap()),t.setZoom(o+ri(r,t.center.lat));}cameraForBoxAndBearing(e,i,r,o,a){const s=Lt(e,i,r,o,a),n=i.left/a.width*2-1,l=(a.width-i.right)/a.width*2-1,c=i.top/a.height*-2+1,h=(a.height-i.bottom)/a.height*-2+1,u=t.bn(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),_=u?r.getWest():r.getEast(),p=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),f=d+.5*t.bn(d,_),g=p+.5*t.bn(p,m),v=a.clone();v.setCenter(s.center),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);const x=v.modelViewProjectionMatrix,b=[Jt(r.getNorthWest()),Jt(r.getNorthEast()),Jt(r.getSouthWest()),Jt(r.getSouthEast()),Jt(new t.Q(_,g)),Jt(new t.Q(d,g)),Jt(new t.Q(f,p)),Jt(new t.Q(f,m))],y=Jt(s.center);let w=Number.POSITIVE_INFINITY;for(const e of b)n<0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"x",n))),l>0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"x",l))),c>0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"y",c))),h<0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"y",h)));if(Number.isFinite(w)&&0!==w)return s.zoom=v.zoom+t.ab(w),s;zt();}handleJumpToCenterZoom(e,i){const r=e.center.lat,o=e.getConstrained(i.center?t.Q.convert(i.center):e.center,e.zoom).center;e.setCenter(o.wrap());const a=void 0!==i.zoom?+i.zoom:e.zoom+ri(r,o.lat);e.zoom!==a&&e.setZoom(a);}handleEaseTo(e,i){const r=e.zoom,o=e.center,a=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.Q.convert(i.center):o,d=e.getConstrained(u,r).center;Ct(e,d);const _=e.clone();_.setCenter(d),_.setZoom(l?+i.zoom:r+ri(o.lat,u.lat)),_.setBearing(i.bearing);const p=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));_.setLocationAtPoint(d,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,f=l?+i.zoom:r+ri(o.lat,m.lat),g=r+ri(o.lat,0),v=f+ri(m.lat,0),x=t.bn(o.lng,m.lng),b=t.bn(o.lat,m.lat),y=t.aI(v-g);return h=f!==r,{easeFunc:r=>{if(t.b6(s,n)||At({startEulerAngles:s,endEulerAngles:n,tr:e,k:r,useSlerp:s.roll!=n.roll}),c&&e.interpolatePadding(a,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else {const t=v>g?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-r),a=si(o,x,b,r*i);e.setCenter(a.wrap());}if(h){const i=t.B.number(g,v,r)+ri(0,e.center.lat);e.setZoom(i);}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.center,a=e.zoom,s=e.padding,n=!e.isPaddingEqual(i.padding),l=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),a).center,c=r?+i.zoom:e.zoom+ri(e.center.lat,l.lat),h=e.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(l,u);const d=h.center;Ct(e,d);const _=function(e,i,r){const o=Jt(i),a=Jt(r),s=t.aV(o,a),n=Math.acos(s),l=Qt(e);return n/(2*Math.PI)*l}(e,o,d),p=a+ri(o.lat,0),m=c+ri(d.lat,0),f=t.aI(m-p);let g;if("number"==typeof i.minZoom){const r=+i.minZoom+ri(d.lat,0),o=Math.min(r,p,m)+ri(0,d.lat),a=e.getConstrained(d,o).zoom+ri(d.lat,0);g=t.aI(a-p);}const v=t.bn(o.lng,d.lng),x=t.bn(o.lat,d.lat);return {easeFunc:(r,a,l,h)=>{const u=si(o,v,x,l);n&&e.interpolatePadding(s,i.padding,r);const _=1===r?d:u;e.setCenter(_.wrap());const m=p+t.ab(a);e.setZoom(1===r?c:m+ri(0,_.lat));},scaleOfZoom:f,targetCenter:d,scaleOfMinZoom:g,pixelPathLength:_}}static solveVectorScale(e,t,i,r,o){const a="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],n=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],h=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+o*l===n+o*h||s[3]*(n-c)+a[3]*(h-l)+n*h==c*l?null:(c+a[3]-o*h-o*s[3])/(c-n-o*h+o*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.x(e,i&&i.filter((e=>"source.canvas"!==e.identifier))),fi=t.bu();class gi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload();}},this.map=e,this.dispatcher=new B(F(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler("GI",((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new P(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new R(256,512),this.crossTileSymbolIndex=new ht,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bv,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",t.bw()),oe().on(te,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t);}}));}loadURL(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const a=this._loadStyleRequest;t.j(o,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,i,r);})).catch((e=>{this._loadStyleRequest=null,e&&!a.signal.aborted&&this.fire(new t.k(e));}));}loadJSON(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r);})).catch((()=>{}));}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(fi,{validate:!1});}_load(e,i,r){var o,a;const s=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!mi(this,t.y(s))){this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new M(this.stylesheet.light),this._setProjectionInternal((null===(o=this.stylesheet.projection)||void 0===o?void 0:o.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(a=this.stylesheet.terrain)&&void 0!==a?a:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"));}}_createLayers(){const e=t.bx(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.by(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e;}}_loadSprite(e,i=!1,r=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=f(e),n=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of a){const a=i.transformRequest(g(r,n,".json"),"SpriteJSON");l[e]=t.j(a,o);const s=i.transformRequest(g(r,n,".png"),"SpriteImage");c[e]=p.getImage(s,o);}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,(function*(){const t={};for(const r in e){t[r]={};const o=s.getImageCanvasContext((yield i[r]).data),a=(yield e[r]).data;for(const e in a){const{width:i,height:s,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=a[e];t[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:s,x:n,y:l,context:o}};}}return t}))}(l,c)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[t]){const o="default"===t?r:`${t}:${r}`;this._spritesImagesIds[t].push(o),o in this.imageManager.images?this.imageManager.updateImage(o,e[t][r],!1):this.imageManager.addImage(o,e[t][r]),i&&(this._changedImages[o]=!0);}}})).catch((e=>{this._spriteRequest=null,o=e,this.fire(new t.k(o));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),r&&r(o);}));}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const o=i.getSource();("geojson"===o.type||o.vectorLayerIds&&-1===o.vectorLayerIds.indexOf(r))&&this.fire(new t.k(new Error(`Source layer "${r}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bz(r):r);const o=[];for(const a of e)if(r[a]){const e=i?t.bz(r[a]):r[a];o.push(e);}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize());}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return !0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return !0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return !0;for(const e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else {if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates();}const r={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const e in r){const i=this.sourceCaches[e];!!r[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){var r;this._checkLoaded();const o=this.serialize();if(e=i.transformStyle?i.transformStyle(o,e):e,(null===(r=i.validate)||void 0===r||r)&&mi(this,t.y(e)))return !1;(e=t.bz(e)).layers=t.bx(e.layers);const a=t.bA(o,e),s=this._getOperationsToPerform(a);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return !1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case "setCenter":case "setZoom":case "setBearing":case "setPitch":case "setRoll":continue;case "addLayer":t.push((()=>this.addLayer.apply(this,r.args)));break;case "removeLayer":t.push((()=>this.removeLayer.apply(this,r.args)));break;case "setPaintProperty":t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case "setLayoutProperty":t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case "setFilter":t.push((()=>this.setFilter.apply(this,r.args)));break;case "addSource":t.push((()=>this.addSource.apply(this,r.args)));break;case "removeSource":t.push((()=>this.removeSource.apply(this,r.args)));break;case "setLayerZoomRange":t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case "setLight":t.push((()=>this.setLight.apply(this,r.args)));break;case "setGeoJSONSourceData":t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case "setGlyphs":t.push((()=>this.setGlyphs.apply(this,r.args)));break;case "setSprite":t.push((()=>this.setSprite.apply(this,r.args)));break;case "setTerrain":t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case "setSky":t.push((()=>this.setSky.apply(this,r.args)));break;case "setProjection":this.setProjection.apply(this,r.args);break;case "setTransition":t.push((()=>{}));break;default:i.push(r.command);}return {operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(e,t){this.imageManager.updateImage(e,t);}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.y.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=this.sourceCaches[e]=new de(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,(()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e}))),o.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0;}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.k(new Error(`Layer "${o}" already exists on this map.`)));let a;if("custom"===e.type){if(mi(this,t.bB(e)))return;a=t.by(e);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(o,e.source),e=t.bz(e),e=t.e(e,{source:o})),this._validate(t.y.layer,`layers.${o}`,e,{arrayIndex:-1},r))return;a=t.by(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:o}});}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));else {if(this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=a,this._removedLayers[o]&&a.source&&"custom"!==a.type){const e=this._removedLayers[o];delete this._removedLayers[o],e.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause());}this._updateLayer(a),a.onAdd&&a.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(e){return this._layers[e]}getLayersOrder(){return [...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!t.bC(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.y.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.bz(i),this._updateLayer(o)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.bz(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bC(a.getLayoutProperty(i),r)||(a.setLayoutProperty(i,r,o),this._updateLayer(a)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bC(a.getPaintProperty(i),r)||(a.setPaintProperty(i,r,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,a=this.sourceCaches[r];if(void 0===a)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=a.getSource().type;"geojson"===s&&o?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||o?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),a.setFeatureState(o,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.getSource().type,s="vector"===a?e.sourceLayer:void 0;"vector"!==a||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.sourceCaches[i];if(void 0!==o)return "vector"!==o.getSource().type||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.getFeatureState(r,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bD(this.sourceCaches,(e=>e.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,o=this.stylesheet;return t.bE({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,projection:o.projection,sources:e,layers:i,terrain:r},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a)){i[a]=o;for(const t of e){const e=t[a];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let a=this._order.length-1;a>=0;a--){const s=this._order[a];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&a.push(function(e,t,i,r,o,a,s){const n={},l=a.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(N);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,o.filter,o.layers,o.availableImages,e);for(const e in r){const t=n[e]=n[e]||[],o=r[e];o.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of o)t.push(e);}}return function(e,t,i){for(const r in e)for(const o of e[r])G(o,i[t[r].source]);return e}(n,e,i)}(this._layers,s,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.y.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],o={};for(let e=0;ee.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);a=a||r;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),e.zoom))&&(this.pauseablePlacement=new at(e,this.map.terrain,this._order,o,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.now()),n=!0),a&&this.pauseablePlacement.placement.setStale()),n||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles();}getImages(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e}))}getGlyphs(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.y.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}addSprite(e,i,r={},o){this._checkLoaded();const a=[{id:e,url:i}],s=[...f(this.stylesheet.sprite),...a];this._validate(t.y.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(a,!0,o));}removeSprite(e){this._checkLoaded();const i=f(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return f(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.y.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)));}}var vi=t.aD([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class xi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(e,t,i,r,o,a,s,n,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.b7.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(o):0,u_horizon_color:r?r.properties.get("horizon-color"):t.b7.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:a?1:0}),yi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function wi(e){const t=[];for(let i=0;i({u_depth:new t.bF(e,i.u_depth),u_terrain:new t.bF(e,i.u_terrain),u_terrain_dim:new t.b8(e,i.u_terrain_dim),u_terrain_matrix:new t.bH(e,i.u_terrain_matrix),u_terrain_unpack:new t.bI(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.b8(e,i.u_terrain_exaggeration)}))(e,P),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bH(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bI(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bI(e,i.u_projection_clipping_plane),u_projection_transition:new t.b8(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bH(e,i.u_projection_fallback_matrix)}))(e,P),this.binderUniforms=r?r.getUniforms(e,P):[];}draw(e,t,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v){const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(o),e.setCullFace(a),n){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,n.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,n.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(n[e]);}if(l)for(const e in l)this.projectionUniforms[yi[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,_,{zoom:p});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1;}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new xi)).bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,f,g,v),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2);}}}function Pi(e,i,r){const o=1/t.aw(r,1,i.transform.tileZoom),a=Math.pow(2,r.tileID.overscaledZ),s=r.tileSize*Math.pow(2,i.transform.tileZoom)/a,n=s*(r.tileID.canonical.x+r.tileID.wrap*a),l=s*r.tileID.canonical.y;return {u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[o,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}const Ci=(e,i,r,o)=>{const a=e.style.light,s=a.properties.get("position"),n=[s.x,s.y,s.z],l=t.bL();"viewport"===a.properties.get("anchor")&&t.bM(l,e.transform.bearingInRadians),t.bN(n,n,l);const c=e.transform.transformLightDirection(n),h=a.properties.get("color");return {u_lightpos:n,u_lightpos_globe:c,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:o}},Ii=(e,i,r,o,a,s,n)=>t.e(Ci(e,i,r,o),Pi(s,e,n),{u_height_factor:-Math.pow(2,a.overscaledZ)/n.tileSize/8}),Mi=(e,i,r,o)=>t.e(Pi(i,e,r),{u_fill_translate:o}),Ei=(e,t)=>({u_world:e,u_fill_translate:t}),Si=(e,i,r,o,a)=>t.e(Mi(e,i,r,a),{u_world:o}),Ri=(e,i,r,o,a)=>{const s=e.transform;let n,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.aw(i,1,s.zoom);n=!0,l=[e,e],c=e/(t.Z*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*a;}else n=!1,l=s.pixelsToGLUnits;return {u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:o}},Di=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),zi=e=>({u_viewport_size:[e.width,e.height]}),Ai=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Li=(e,i,r,o)=>{const a=t.aw(e,1,i)/(t.Z*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*o;return {u_extrude_scale:t.aw(e,1,i),u_intensity:r,u_globe_extrude_scale:a}},ki=(e,i,r,o)=>{const a=t.K();t.bO(a,0,e.width,e.height,0,0,1);const s=e.context.gl;return {u_matrix:a,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:r,u_color_ramp:o,u_opacity:i.paint.get("heatmap-opacity")}},Fi=(e,t,i)=>{const r=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let s=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);return "viewport"===i.paint.get("hillshade-illumination-anchor")&&(s+=e.transform.bearingInRadians),{u_image:0,u_latrange:Oi(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),s],u_shadow:r,u_highlight:o,u_accent:a}},Bi=(e,i)=>{const r=i.stride,o=t.K();return t.bO(o,0,t.Z,-8192,0,0,1),t.L(o,o,[0,-8192,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Oi(e,i){const r=Math.pow(2,i.canonical.z),o=i.canonical.y;return [new t.$(0,o/r).toLngLat().lat,new t.$(0,(o+1)/r).toLngLat().lat]}const ji=(e,i,r,o)=>{const a=e.transform;return {u_translation:Vi(e,i,r),u_ratio:o/t.aw(i,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Zi=(e,i,r,o,a)=>t.e(ji(e,i,r,o),{u_image:0,u_image_height:a}),Ni=(e,i,r,o,a)=>{const s=e.transform,n=Ui(i,s);return {u_translation:Vi(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:o/t.aw(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[n,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Gi=(e,i,r,o,a,s)=>{const n=e.lineAtlas,l=Ui(i,e.transform),c="round"===r.layout.get("line-cap"),h=n.getDash(a.from,c),u=n.getDash(a.to,c),d=h.width*s.fromScale,_=u.width*s.toScale;return t.e(ji(e,i,r,o),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:s.t})};function Ui(e,i){return 1/t.aw(e,1,i.tileZoom)}function Vi(e,i,r){return t.ax(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const qi=(e,t,i,r,o)=>{return {u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=r.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Wi(r.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]};var a,s;};function Wi(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const $i=(e,t,i,r,o,a,s,n,l,c,h,u,d)=>{const _=s.transform;return {u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_pitch:_.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:o,u_is_variable_anchor:a,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},Hi=(e,i,r,o,a,s,n,l,c,h,u,d,_,p)=>{const m=n.transform;return t.e($i(e,i,r,o,a,s,n,l,c,h,u,d,p),{u_gamma_scale:o?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:1})},Ki=(e,i,r,o,a,s,n,l,c,h,u,d,_)=>t.e(Hi(e,i,r,o,a,s,n,l,c,h,!0,u,0,_),{u_texsize_icon:d,u_texture_icon:1}),Xi=(e,t)=>({u_opacity:e,u_color:t}),Qi=(e,i,r,o,a)=>t.e(function(e,i,r,o){const a=r.imageManager.getPattern(e.from.toString()),s=r.imageManager.getPattern(e.to.toString()),{width:n,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(o.tileID.canonical.x+o.tileID.wrap*c),d=h*o.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aw(o,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,a,i,o),{u_opacity:e}),Yi=(e,t)=>{},Ji={fillExtrusion:(e,i)=>({u_lightpos:new t.bJ(e,i.u_lightpos),u_lightpos_globe:new t.bJ(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bJ(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bK(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bJ(e,i.u_lightpos),u_lightpos_globe:new t.bJ(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bJ(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_height_factor:new t.b8(e,i.u_height_factor),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bK(e,i.u_fill_translate),u_image:new t.bF(e,i.u_image),u_texsize:new t.bK(e,i.u_texsize),u_pixel_coord_upper:new t.bK(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bK(e,i.u_pixel_coord_lower),u_scale:new t.bJ(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bK(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bF(e,i.u_image),u_texsize:new t.bK(e,i.u_texsize),u_pixel_coord_upper:new t.bK(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bK(e,i.u_pixel_coord_lower),u_scale:new t.bJ(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bK(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bK(e,i.u_world),u_fill_translate:new t.bK(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bK(e,i.u_world),u_image:new t.bF(e,i.u_image),u_texsize:new t.bK(e,i.u_texsize),u_pixel_coord_upper:new t.bK(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bK(e,i.u_pixel_coord_lower),u_scale:new t.bJ(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bK(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bF(e,i.u_scale_with_map),u_pitch_with_map:new t.bF(e,i.u_pitch_with_map),u_extrude_scale:new t.bK(e,i.u_extrude_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale),u_translate:new t.bK(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bK(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bK(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bG(e,i.u_color),u_overlay:new t.bF(e,i.u_overlay),u_overlay_scale:new t.b8(e,i.u_overlay_scale)}),depth:Yi,clippingMask:Yi,heatmap:(e,i)=>({u_extrude_scale:new t.b8(e,i.u_extrude_scale),u_intensity:new t.b8(e,i.u_intensity),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bH(e,i.u_matrix),u_world:new t.bK(e,i.u_world),u_image:new t.bF(e,i.u_image),u_color_ramp:new t.bF(e,i.u_color_ramp),u_opacity:new t.b8(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bF(e,i.u_image),u_latrange:new t.bK(e,i.u_latrange),u_light:new t.bK(e,i.u_light),u_shadow:new t.bG(e,i.u_shadow),u_highlight:new t.bG(e,i.u_highlight),u_accent:new t.bG(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bH(e,i.u_matrix),u_image:new t.bF(e,i.u_image),u_dimension:new t.bK(e,i.u_dimension),u_zoom:new t.b8(e,i.u_zoom),u_unpack:new t.bI(e,i.u_unpack)}),line:(e,i)=>({u_translation:new t.bK(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bK(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bK(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bK(e,i.u_units_to_pixels),u_image:new t.bF(e,i.u_image),u_image_height:new t.b8(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bK(e,i.u_translation),u_texsize:new t.bK(e,i.u_texsize),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_image:new t.bF(e,i.u_image),u_units_to_pixels:new t.bK(e,i.u_units_to_pixels),u_scale:new t.bJ(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bK(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bK(e,i.u_units_to_pixels),u_patternscale_a:new t.bK(e,i.u_patternscale_a),u_patternscale_b:new t.bK(e,i.u_patternscale_b),u_sdfgamma:new t.b8(e,i.u_sdfgamma),u_image:new t.bF(e,i.u_image),u_tex_y_a:new t.b8(e,i.u_tex_y_a),u_tex_y_b:new t.b8(e,i.u_tex_y_b),u_mix:new t.b8(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bK(e,i.u_tl_parent),u_scale_parent:new t.b8(e,i.u_scale_parent),u_buffer_scale:new t.b8(e,i.u_buffer_scale),u_fade_t:new t.b8(e,i.u_fade_t),u_opacity:new t.b8(e,i.u_opacity),u_image0:new t.bF(e,i.u_image0),u_image1:new t.bF(e,i.u_image1),u_brightness_low:new t.b8(e,i.u_brightness_low),u_brightness_high:new t.b8(e,i.u_brightness_high),u_saturation_factor:new t.b8(e,i.u_saturation_factor),u_contrast_factor:new t.b8(e,i.u_contrast_factor),u_spin_weights:new t.bJ(e,i.u_spin_weights),u_coords_top:new t.bI(e,i.u_coords_top),u_coords_bottom:new t.bI(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bF(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bF(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bF(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bH(e,i.u_label_plane_matrix),u_coord_matrix:new t.bH(e,i.u_coord_matrix),u_is_text:new t.bF(e,i.u_is_text),u_pitch_with_map:new t.bF(e,i.u_pitch_with_map),u_is_along_line:new t.bF(e,i.u_is_along_line),u_is_variable_anchor:new t.bF(e,i.u_is_variable_anchor),u_texsize:new t.bK(e,i.u_texsize),u_texture:new t.bF(e,i.u_texture),u_translation:new t.bK(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bF(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bF(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bF(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bH(e,i.u_label_plane_matrix),u_coord_matrix:new t.bH(e,i.u_coord_matrix),u_is_text:new t.bF(e,i.u_is_text),u_pitch_with_map:new t.bF(e,i.u_pitch_with_map),u_is_along_line:new t.bF(e,i.u_is_along_line),u_is_variable_anchor:new t.bF(e,i.u_is_variable_anchor),u_texsize:new t.bK(e,i.u_texsize),u_texture:new t.bF(e,i.u_texture),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bF(e,i.u_is_halo),u_translation:new t.bK(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bF(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bF(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bF(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bH(e,i.u_label_plane_matrix),u_coord_matrix:new t.bH(e,i.u_coord_matrix),u_is_text:new t.bF(e,i.u_is_text),u_pitch_with_map:new t.bF(e,i.u_pitch_with_map),u_is_along_line:new t.bF(e,i.u_is_along_line),u_is_variable_anchor:new t.bF(e,i.u_is_variable_anchor),u_texsize:new t.bK(e,i.u_texsize),u_texsize_icon:new t.bK(e,i.u_texsize_icon),u_texture:new t.bF(e,i.u_texture),u_texture_icon:new t.bF(e,i.u_texture_icon),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bF(e,i.u_is_halo),u_translation:new t.bK(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_color:new t.bG(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_image:new t.bF(e,i.u_image),u_pattern_tl_a:new t.bK(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bK(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bK(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bK(e,i.u_pattern_br_b),u_texsize:new t.bK(e,i.u_texsize),u_mix:new t.b8(e,i.u_mix),u_pattern_size_a:new t.bK(e,i.u_pattern_size_a),u_pattern_size_b:new t.bK(e,i.u_pattern_size_b),u_scale_a:new t.b8(e,i.u_scale_a),u_scale_b:new t.b8(e,i.u_scale_b),u_pixel_coord_upper:new t.bK(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bK(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.b8(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bF(e,i.u_texture),u_ele_delta:new t.b8(e,i.u_ele_delta),u_fog_matrix:new t.bH(e,i.u_fog_matrix),u_fog_color:new t.bG(e,i.u_fog_color),u_fog_ground_blend:new t.b8(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.b8(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bG(e,i.u_horizon_color),u_horizon_fog_blend:new t.b8(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.b8(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.b8(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bF(e,i.u_texture),u_terrain_coords_id:new t.b8(e,i.u_terrain_coords_id),u_ele_delta:new t.b8(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.b8(e,i.u_input),u_output_expected:new t.b8(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bJ(e,i.u_sun_pos),u_atmosphere_blend:new t.b8(e,i.u_atmosphere_blend),u_globe_position:new t.bJ(e,i.u_globe_position),u_globe_radius:new t.b8(e,i.u_globe_radius),u_inv_proj_matrix:new t.bH(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bG(e,i.u_sky_color),u_horizon_color:new t.bG(e,i.u_horizon_color),u_horizon:new t.bK(e,i.u_horizon),u_horizon_normal:new t.bK(e,i.u_horizon_normal),u_sky_horizon_blend:new t.b8(e,i.u_sky_horizon_blend),u_sky_blend:new t.b8(e,i.u_sky_blend)})};class er{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const tr={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ir{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const o=e.gl;this.buffer=o.createBuffer(),e.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&(h.push({circleArray:f,circleOffset:d,coord:_}),u+=f.length/4,d=u),m&&c.draw(s,l.LINES,jt.disabled,Nt.disabled,e.colorModeForRenderPass(),Ot.disabled,Di(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(_),n.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer);}if(!a||!h.length)return;const _=e.useProgram("collisionCircle"),p=new t.bP;p.resize(4*u),p._trim();let m=0;for(const e of h)for(let t=0;t=0&&(f[g.associatedIconIndex]={shiftedAnchor:E,angle:S});}else Be(g.numGlyphs,p);}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");Pe(c,e,a,O,j,v,h,i,l.toUnwrapped(),f.width,f.height,N,t);}const q=a&&P||V,W=x||q?Vr:v?O:e.transform.clipSpaceToPixelsMatrix,$=p&&0!==r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let H;H=p?c.iconsInText?Ki(T.kind,S,b,v,x,q,e,W,Z,N,D,k,I):Hi(T.kind,S,b,v,x,q,e,W,Z,N,a,D,0,I):$i(T.kind,S,b,v,x,q,e,W,Z,N,a,D,I);const K={program:E,buffers:u,uniformValues:H,projectionData:G,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:A,atlasInterpolationIcon:L,isSDF:p,hasHalo:$};if(y&&c.canOverlap){w=!0;const e=u.segments.get();for(const i of e)C.push({segments:new t.aG([i]),sortKey:i.sortKey,state:K,terrainData:R});}else C.push({segments:u.segments,sortKey:0,state:K,terrainData:R});}w&&C.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of C){const i=t.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,Xr(i.buffers,t.segments,r,e,i.program,T,u,d,o,i.projectionData,t.terrainData)),o.u_is_halo=0;}Xr(i.buffers,t.segments,r,e,i.program,T,u,d,i.uniformValues,i.projectionData,t.terrainData);}}function Xr(e,t,i,r,o,a,s,n,l,c,h){const u=r.context;o.draw(u,u.gl.TRIANGLES,a,s,n,Ot.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer);}function Qr(e,i,r,o,a){const s=e.context,n=s.gl,l=Nt.disabled,c=new Ft([n.ONE,n.ONE],t.b7.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=o.key;let d=r.heatmapFbos.get(u);d||(d=Jr(s,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.b7.transparent});const _=h.programConfigurations.get(r.id),p=e.useProgram("heatmap",_,!a),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),f=e.style.map.terrain.getTerrainData(o);p.draw(s,n.TRIANGLES,jt.disabled,l,c,Ot.disabled,Li(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),f,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,_);}function Yr(e,t,i,r,o){const a=e.context,s=a.gl,n=e.transform;a.setColorMode(e.colorModeForRenderPass());const l=eo(a,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),a.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=n.getProjectionData({overscaledTileID:i,applyTerrainMatrix:o,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(a,s.TRIANGLES,jt.disabled,Nt.disabled,e.colorModeForRenderPass(),Ot.disabled,ki(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,n.zoom),h.destroy(),t.heatmapFbos.delete(c);}function Jr(e,t,i){var r,o;const a=e.gl,s=a.createTexture();a.bindTexture(a.TEXTURE_2D,s),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);const n=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:a.UNSIGNED_BYTE,l=null!==(o=e.RGBA16F)&&void 0!==o?o:a.RGBA;a.texImage2D(a.TEXTURE_2D,0,l,t,i,0,a.RGBA,n,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function eo(e,t){return t.colorRampTexture||(t.colorRampTexture=new v(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function to(e,t,i,r,o){if(!i||!r||!r.imageAtlas)return;const a=r.imageAtlas.patternPositions;let s=a[i.to.toString()],n=a[i.from.toString()];if(!s&&n&&(s=n),!n&&s&&(n=s),!s||!n){const e=o.getPaintProperty(t);s=a[e],n=a[e];}s&&n&&e.setConstantPatternPositions(s,n);}function io(e,i,r,o,a,s,n,l){const c=e.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),_=r.getCrossfadeParameters();let p,m,f,g,v;const x=e.transform,b=r.paint.get("fill-translate"),y=r.paint.get("fill-translate-anchor");n?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=c.LINES):(m=d?"fillPattern":"fill",p=c.TRIANGLES);const w=u.constantOr(null);for(const u of o){const T=i.getTile(u);if(d&&!T.patternsLoaded())continue;const P=T.getBucket(r);if(!P)continue;const C=P.programConfigurations.get(r.id),I=e.useProgram(m,C),M=e.style.map.terrain&&e.style.map.terrain.getTerrainData(u);d&&(e.context.activeTexture.set(c.TEXTURE0),T.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),C.updatePaintBuffers(_)),to(C,h,w,T,r);const E=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),S=t.ax(x,T,b,y);if(n){g=P.indexBuffer2,v=P.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];f="fillOutlinePattern"===m&&d?Si(e,_,T,t,S):Ei(t,S);}else g=P.indexBuffer,v=P.segments,f=d?Mi(e,_,T,S):{u_fill_translate:S};let R;if("translucent"===e.renderPass&&l){const[t]=e.getStencilConfigForOverlapAndUpdateStencilID(o);R=t[u.overscaledZ];}else R=e.stencilModeForClipping(u);I.draw(e.context,p,a,R,s,Ot.backCCW,f,M,E,r.id,P.layoutVertexBuffer,g,v,r.paint,e.transform.zoom,C);}}function ro(e,i,r,o,a,s,n,l){const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),_=d.constantOr(1),p=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),f=d.constantOr(null),g=e.transform;for(const d of o){const o=i.getTile(d),v=o.getBucket(r);if(!v)continue;const x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),b=v.programConfigurations.get(r.id),y=e.useProgram(_?"fillExtrusionPattern":"fillExtrusion",b);_&&(e.context.activeTexture.set(h.TEXTURE0),o.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const w=g.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});to(b,u,f,o,r);const T=t.ax(g,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),C=_?Ii(e,P,m,T,d,p,o):Ci(e,P,m,T);y.draw(c,c.gl.TRIANGLES,a,s,n,Ot.backCCW,C,x,w,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer);}}function oo(e,t,i,r,o,a,s,n,l){var c;const h=e.style.projection,u=e.context,d=e.transform,_=u.gl,p=e.useProgram("hillshade"),m=!e.options.moving;for(const f of r){const r=t.getTile(f),g=r.fbo;if(!g)continue;const v=h.getMeshFromTileID(u,f.canonical,n,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);u.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,g.colorAttachment.get());const b=d.getProjectionData({overscaledTileID:f,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(u,_.TRIANGLES,a,o[f.overscaledZ],s,Ot.backCCW,Fi(e,r,i),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments);}}const ao=[new t.P(0,0),new t.P(t.Z,0),new t.P(t.Z,t.Z),new t.P(0,t.Z)];function so(e,t,i,r,o,a,s,n,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=e.context,d=u.gl,_=e.useProgram("raster"),p=e.transform,m=e.style.projection,f=e.colorModeForRenderPass(),g=!e.options.moving;for(const v of r){const r=e.getDepthModeForSublayer(v.overscaledZ-h,1===i.paint.get("raster-opacity")?jt.ReadWrite:jt.ReadOnly,d.LESS),x=t.getTile(v);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const b=t.findLoadedParent(v,0),y=t.findLoadedSibling(v),w=no(x,b||y||null,t,i,e.transform,e.style.map.terrain);let T,P;const C="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),b?(b.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,b.tileID.overscaledZ-x.tileID.overscaledZ),P=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),M=p.getProjectionData({overscaledTileID:v,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),E=qi(P||[0,0],T||1,w,i,n),S=m.getMeshFromTileID(u,v.canonical,a,s,"raster");_.draw(u,d.TRIANGLES,r,o?o[v.overscaledZ]:Nt.disabled,f,l?Ot.frontCCW:Ot.backCCW,E,I,M,i.id,S.vertexBuffer,S.indexBuffer,S.segments);}}function no(e,i,r,o,a,n){const l=o.paint.get("raster-fade-duration");if(!n&&l>0){const o=s.now(),n=(o-e.timeAdded)/l,c=i?(o-i.timeAdded)/l:-1,h=r.getSource(),u=he(a,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),_=d&&e.refreshedUponExpiration?1:t.ae(d?n:1-c,0,1);return e.refreshedUponExpiration&&n>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-_}:{opacity:_,mix:0}}return {opacity:1,mix:0}}const lo=new t.b7(1,0,0,1),co=new t.b7(0,1,0,1),ho=new t.b7(0,0,1,1),uo=new t.b7(1,0,1,1),_o=new t.b7(0,1,1,1);function po(e,t,i,r){fo(e,0,t+i/2,e.transform.width,i,r);}function mo(e,t,i,r){fo(e,t-i/2,0,i,e.transform.height,r);}function fo(e,t,i,r,o,a){const s=e.context,n=s.gl;n.enable(n.SCISSOR_TEST),n.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,o*e.pixelRatio),s.clear({color:a}),n.disable(n.SCISSOR_TEST);}function go(e,i,r){const o=e.context,a=o.gl,s=e.useProgram("debug"),n=jt.disabled,l=Nt.disabled,c=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);o.activeTexture.set(a.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,_=Math.floor((d&&d.byteLength||0)/1024),p=i.getTile(r).tileSize,m=512/Math.min(p,512)*(r.overscaledZ/e.transform.zoom)*.5;let f=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(f+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,o=e.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(t,5,5),o.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,`${f} ${_}kB`);const g=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(o,a.TRIANGLES,n,l,Ft.alphaBlended,Ot.disabled,Ai(t.b7.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(o,a.LINE_STRIP,n,l,c,Ot.disabled,Ai(t.b7.red),u,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function vo(e,t,i,r){const{isRenderingGlobe:o}=r,a=e.context,s=a.gl,n=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),u=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const _=t.getMeshFrameDelta(n.zoom),p=n.calculateFogMatrix(r.tileID.toUnwrapped()),m=bi(_,p,e.style.sky,n.pitch,o),f=n.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(a,s.TRIANGLES,c,Nt.disabled,l,Ot.backCCW,m,d,f,"terrain",i.vertexBuffer,i.indexBuffer,i.segments);}}function xo(e,i){if(!i.mesh){const r=new t.aF;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const o=new t.aH;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),i.mesh=new pt(e.createVertexBuffer(r,mt.members),e.createIndexBuffer(o),t.aG.simpleSegment(0,0,r.length,o.length));}return i.mesh}class bo{constructor(e,i){this.context=new Nr(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.at(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=de.maxUnderzooming+de.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ht;}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize();}setup(){const e=this.context,i=new t.aF;i.emplaceBack(0,0),i.emplaceBack(t.Z,0),i.emplaceBack(0,t.Z),i.emplaceBack(t.Z,t.Z),this.tileExtentBuffer=e.createVertexBuffer(i,mt.members),this.tileExtentSegments=t.aG.simpleSegment(0,0,4,2);const r=new t.aF;r.emplaceBack(0,0),r.emplaceBack(t.Z,0),r.emplaceBack(0,t.Z),r.emplaceBack(t.Z,t.Z),this.debugBuffer=e.createVertexBuffer(r,mt.members),this.debugSegments=t.aG.simpleSegment(0,0,4,5);const o=new t.bW;o.emplaceBack(0,0,0,0),o.emplaceBack(t.Z,0,t.Z,0),o.emplaceBack(0,t.Z,0,t.Z),o.emplaceBack(t.Z,t.Z,t.Z,t.Z),this.rasterBoundsBuffer=e.createVertexBuffer(o,vi.members),this.rasterBoundsSegments=t.aG.simpleSegment(0,0,4,2);const a=new t.aF;a.emplaceBack(0,0),a.emplaceBack(t.Z,0),a.emplaceBack(0,t.Z),a.emplaceBack(t.Z,t.Z),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,mt.members),this.rasterBoundsSegmentsPosOnly=t.aG.simpleSegment(0,0,4,5);const s=new t.aF;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,mt.members),this.viewportSegments=t.aG.simpleSegment(0,0,4,2);const n=new t.bX;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);const l=new t.aH;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Nt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new pt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.K();t.bO(r,0,this.width,this.height,0,0,1),t.M(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const o={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,jt.disabled,this.stencilClearMode,Ft.disabled,Ot.disabled,null,null,o,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Ft.disabled),r.setDepthMode(jt.disabled);const o={};for(const e of t)o[e.key]=this.nextStencilID++;this._renderTileMasks(o,t,i,!0),this._renderTileMasks(o,t,i,!1),this._tileClippingMaskIDs=o;}_renderTileMasks(e,t,i,r){const o=this.context,a=o.gl,s=this.style.projection,n=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=s.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=n.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});l.draw(o,a.TRIANGLES,jt.disabled,new Nt({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),Ft.disabled,i?Ot.disabled:Ot.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments);}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,o=this.useProgram("depth"),a=this.getDepthModeFor3D(),s=ue(r,{tileSize:r.tileSize});for(const n of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(n),l=i.getMeshFromTileID(this.context,n.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(e,t.TRIANGLES,a,Nt.disabled,Ft.disabled,Ot.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Nt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Nt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(this.clearStencil(),o>1){const e={},a={};for(let i=0;i0};for(const e in n){const t=n[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse();}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.b7.black:t.b7.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,o=((e,t,i)=>{const r=Math.cos(t.rollInRadians),o=Math.sin(t.rollInRadians),a=yt(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return {u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-a*o)*i,(t.height/2+a*r)*i],u_horizon_normal:[-o,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),a=new jt(r.LEQUAL,jt.ReadWrite,[0,1]),s=Nt.disabled,n=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=xo(i,t);l.draw(i,r.TRIANGLES,a,s,n,Ot.disabled,o,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments);}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[a[this.currentLayer]],t=n[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,u);}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:o}))(c,u,[p[0],p[1],p[2]],d,_),f=xo(o,i);s.draw(o,a.TRIANGLES,n,Nt.disabled,Ft.alphaBlended,Ot.disabled,m,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments);}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[])),o=r.filter((e=>"vector"===e.getSource().type)),a=r.filter((e=>"vector"!==e.getSource().type)),s=e=>{(!i||i.getSource().maxzooms(e))),i||a.forEach((e=>s(e))),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;ru.getElevation(a,e,t):null;$r(s,d,_,c,h,f,i,p,g,t.ax(h,e,n,l),a.toUnwrapped(),r);}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),a),0!==r.paint.get("icon-opacity").constantOr(1)&&Kr(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,n),0!==r.paint.get("text-opacity").constantOr(1)&&Kr(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,n),i.map.showCollisionBoxes&&(Ur(e,i,r,o,!0),Ur(e,i,r,o,!1));}(e,i,r,o,this.style.placement.variableOffsets,a):t.c0(r)?function(e,i,r,o,a){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=a,n=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===n.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,_=e.transform,p=e.getDepthModeForSublayer(0,jt.ReadOnly),m=Nt.disabled,f=e.colorModeForRenderPass(),g=[],v=_.getCircleRadiusCorrection();for(let a=0;ae.sortKey-t.sortKey));for(const t of g){const{programConfiguration:i,program:o,layoutVertexBuffer:a,indexBuffer:s,uniformValues:n,terrainData:l,projectionData:c}=t.state;o.draw(u,d.TRIANGLES,p,m,f,Ot.backCCW,n,l,c,r.id,a,s,t.segments,r.paint,e.transform.zoom,i);}}(e,i,r,o,a):t.c1(r)?function(e,i,r,o,a){if(0===r.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:n,isRenderingGlobe:l}=a;if(e.style.map.terrain){for(const t of o){const o=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?Qr(e,o,r,t,l):"translucent"===e.renderPass&&Yr(e,r,t,n,l));}s.viewport.set([0,0,e.width,e.height]);}else "offscreen"===e.renderPass?function(e,i,r,o){const a=e.context,s=a.gl,n=e.transform,l=Nt.disabled,c=new Ft([s.ONE,s.ONE],t.b7.transparent,[!0,!0,!0,!0]);((function(e,i,r){const o=e.gl;e.activeTexture.set(o.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let a=r.heatmapFbos.get(t.bS);a?(o.bindTexture(o.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=Jr(e,i.width/4,i.height/4),r.heatmapFbos.set(t.bS,a));}))(a,e,r),a.clear({color:t.b7.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return !1;if(!e.from||!e.to)return !0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return !t||!i}useProgram(e,t,i=!1){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,a=e+(t?t.cacheKey:"")+`/${i?gt:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"");return this.cache[a]||(this.cache[a]=new Ti(this.context,dt[e],t,Ji[e],this._showOverdrawInspector,r,i?dt.projectionMercator:o.shaderPreludeCode,i?ft:o.shaderDefine)),this.cache[a]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new v(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function yo(e,t){let i,r=!1,o=null,a=null;const s=()=>{o=null,r&&(e.apply(a,i),o=setTimeout(s,t),r=!1);};return (...e)=>(r=!0,a=this,i=e,o||s(),o)}class wo{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return !1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e);},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let o=window.location.href.replace(/(#.+)?$/,r);o=o.replace("&&","&"),window.history.replaceState(window.history.state,null,o);},this._updateHash=yo(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e);}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),a=Math.round(t.lng*o)/o,s=Math.round(t.lat*o)/o,n=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${a}/${s}/${i}`:`${i}/${s}/${a}`,(n||l)&&(c+="/"+Math.round(10*n)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return `#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return !1;try{new t.Q(+e[2],+e[1]);}catch(e){return !1}const i=+e[0],r=+(e[3]||0),o=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&o>=this._map.getMinPitch()&&o<=this._map.getMaxPitch()}}const To={linearity:.3,easing:t.c9(0,0,.3,1)},Po=t.e({deceleration:2500,maxSpeed:1400},To),Co=t.e({deceleration:20,maxSpeed:1400},To),Io=t.e({deceleration:1e3,maxSpeed:360},To),Mo=t.e({deceleration:1e3,maxSpeed:90},To),Eo=t.e({deceleration:1e3,maxSpeed:360},To);class So{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=s.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const a=Do(i.pan.mag(),r,t.e({},Po,e||{})),s=i.pan.mult(a.amount/i.pan.mag()),n=this._map.cameraHelper.handlePanInertia(s,this._map.transform);o.center=n.easingCenter,o.offset=n.easingOffset,Ro(o,a);}if(i.zoom){const e=Do(i.zoom,r,Co);o.zoom=this._map.transform.zoom+e.amount,Ro(o,e);}if(i.bearing){const e=Do(i.bearing,r,Io);o.bearing=this._map.transform.bearing+t.ae(e.amount,-179,179),Ro(o,e);}if(i.pitch){const e=Do(i.pitch,r,Mo);o.pitch=this._map.transform.pitch+e.amount,Ro(o,e);}if(i.roll){const e=Do(i.roll,r,Eo);o.roll=this._map.transform.roll+t.ae(e.amount,-179,179),Ro(o,e);}if(o.zoom||o.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;o.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),t.e(o,{noMoveStart:!0})}}function Ro(e,t){(!e.duration||e.durationi.unproject(e))),l=a.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1;}}class Lo extends t.l{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class ko{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){delete this._mousedownPos;}wheel(e){return this._firePreventable(new Lo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new zo(e.type,this._map,e))}mouseup(e){this._map.fire(new zo(e.type,this._map,e));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new zo(e.type,this._map,e));}dblclick(e){return this._firePreventable(new zo(e.type,this._map,e))}mouseover(e){this._map.fire(new zo(e.type,this._map,e));}mouseout(e){this._map.fire(new zo(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Ao(e.type,this._map,e))}touchmove(e){this._map.fire(new Ao(e.type,this._map,e));}touchend(e){this._map.fire(new Ao(e.type,this._map,e));}touchcancel(e){this._map.fire(new Ao(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Fo{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(e){this._map.fire(new zo(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new zo("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new zo(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Bo{constructor(e){this._map=e;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class Oo{constructor(e,t){this._map=e,this._tr=new Bo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(r,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function jo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=jo(r,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=jo(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class No{constructor(e){this.singleTap=new Zo(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Go{constructor(e){this._tr=new Bo(e),this._zoomIn=new No({numTouches:1,numTaps:2}),this._zoomOut=new No({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),o=this._zoomOut.touchend(e,t,i),a=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(r)},{originalEvent:e})}):o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(o)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Uo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset();}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e);}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return !this._moved&&r.dist(i)!0}),t=new Wo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t;}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)));}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)));}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Ho=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault();};};class Ko{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0);}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const o=jo(r,i),a=new t.P(0,0),s=new t.P(0,0);let n=0;for(const e in o){const t=o[e],i=this._touches[e];i&&(a._add(t),s._add(t.sub(i)),n++,o[e]=t);}if(this._touches=o,this._shouldBePrevented(n)||!s.mag())return;const l=s.div(n);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class ra extends Xo{constructor(e){super(),this._currentTouchCount=0,this._map=e;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length;}_start(e){this._lastPoints=e,ia(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),o=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,o=t.mag()>=2;if(!r&&!o)return;if(!r||!o)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const a=e.y>0==t.y>0;return ia(e)&&ia(t)&&a}}const oa={panStep:100,bearingStep:15,pitchStep:10};class aa{constructor(e){this._tr=new Bo(e);const t=oa;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,o=0,a=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),o=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),o=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const n=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:sa,zoom:t?Math.round(n.zoom)+t*(e.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+r*this._pitchStep,offset:[-o*this._panStep,-a*this._panStep],center:n.center},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function sa(e){return e*(2-e)}const na=4.000244140625;class la{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);},this._map=e,this._tr=new Bo(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(e){return !!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=s.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%na==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=n.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.Q.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t);}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>na?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const o="number"!=typeof this._targetZoom?e.scale:t.aI(this._targetZoom);this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,t.ab(o*r))),"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,o=this._easing;let a,n=!1;if("wheel"===this._type&&r&&o){const e=s.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=o(l);a=t.B.number(r,i,c),l<1?this._frameId||(this._frameId=!0):n=!0;}else a=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout;}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!n,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cb;if(this._prevEase){const e=this._prevEase,r=(s.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(o*o+1e-4)*.01,n=Math.sqrt(.0729-a*a);i=t.c9(a,n,.25,1);}return this._prevEase={start:s.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class ca{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class ha{constructor(e){this._tr=new Bo(e),this.reset();}reset(){this._active=!1;}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ua{constructor(){this._tap=new No({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],o=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;o&&a?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(e,t,i);}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class da{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class _a{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class pa{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class ma{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=n.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const o=document.createElement("div");o.className="maplibregl-mobile-message",o.textContent=i,this._container.appendChild(o),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(n.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const fa=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class ga extends t.l{}function va(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class xa{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`);},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===e.type?void 0:e,o={needsRenderFrame:!1},a={},s={};for(const{handlerName:l,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(s,h,l))c.reset();else if(c[i||e.type]){if(t.cc(e,i||e.type)){const t=n.mousePos(this._map.getCanvas(),e);u=c[i||e.type](e,t);}else if(t.cd(e,i||e.type)){const t=this._getMapTouches(e.touches),r=n.touchPos(this._map.getCanvas(),t);u=c[i||e.type](e,r,t);}else t.ce(i||e.type)||(u=c[i||e.type](e));this.mergeHandlerResult(o,a,u,l,r),u&&u.needsRenderFrame&&this._triggerRenderFrame();}(u||c.isActive())&&(s[l]=c);}const l={};for(const e in this._previousActiveHandlers)s[e]||(l[e]=r);this._previousActiveHandlers=s,(Object.keys(l).length||va(o))&&(this._changes.push([o,a,l]),this._triggerRenderFrame()),(Object.keys(s).length||va(o))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=o;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map));},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new So(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)n.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[e,t,i]of this._listeners)n.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new ko(i,e));const o=i.boxZoom=new Oo(i,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const a=i.cooperativeGestures=new ma(i,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();const s=new Go(i),l=new ha(i);i.doubleClickZoom=new ca(l,s),this._add("tapZoom",s),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new ua;this._add("tapDragZoom",c);const h=i.touchPitch=new ra(i);this._add("touchPitch",h),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:o=100,rotateDegreesPerPixelMoved:a=.8},s){const l=new qo({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Uo({clickTolerance:i,move:(e,i)=>{const n=s();if(r&&Math.abs(n.y-e.y)>o)return {bearingDelta:t.ca(new t.P(e.x,i.y),i,n)};let l=(i.x-e.x)*a;return r&&i.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Uo({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:Ho})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const o=new qo({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Uo({clickTolerance:t,move:(e,t)=>{const o=r();let a=(t.x-e.x)*i;return t.y0===n.mouseButton(e)&&!e.ctrlKey});return new Uo({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Ho})}(e),f=new Ko(e,i);i.dragPan=new da(r,m,f),this._add("mousePan",m),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new ta,v=new Jo;i.touchZoomRotate=new pa(r,v,g,c),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",v,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const x=i.scrollZoom=new la(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const b=i.keyboard=new aa(i);this._add("keyboard",b),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Fo(i));}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[];}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(fa(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,o,a){if(!r)return;t.e(e,r);const s={handlerName:o,originalEvent:r.originalEvent||a};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s);}_applyChanges(){const e={},i={},r={};for(const[o,a,s]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(e.rollDelta=(e.rollDelta||0)+o.rollDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.e(i,a),t.e(r,s);this._updateMapTransform(e,i,r),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,o=r._getTransformForUpdate(),a=r.terrain;if(!(va(e)||a&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:n,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u=u||r.transform.centerPoint,a&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const _={panDelta:s,zoomDelta:n,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const p=u.distSqr(o.centerPoint)<.01?o.center:o.screenPointToLocation(s?u.sub(s):u);a?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?o.setCenter(o.screenPointToLocation(o.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(_,o,p):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(_,o,p))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._map.cameraHelper.handleMapControlsPan(_,o,p)),r._applyUpdatedTransform(o),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,i,r){const o=fa(this._eventsInProgress),a=fa(e),n={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(n[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!o&&a&&this._fireEvent("movestart",a.originalEvent);for(const e in n)this._fireEvent(e,n[e]);a&&this._fireEvent("move",a.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||r,l[`${e}end`]=c);}for(const e in l)this._fireEvent(e,l[e]);const h=fa(this._eventsInProgress),u=(o||a)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e);}if(r&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ga("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class ba extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState;}));}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t;}getCenter(){return new t.Q(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e;}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){f.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.l("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.l("rollstart",e));}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.setElevation(t.B.number(this._elevationStart,this._elevationTarget,e));}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return {};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:o,roll:a,pitch:s,bearing:n,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==o&&t.setZoom(o),void 0!==a&&t.setRoll(a),void 0!==s&&t.setPitch(s),void 0!==n&&t.setBearing(n),i.apply(t);}this.transform.apply(i);}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,o=this._rotating,a=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l("zoomend",e)),o&&this.fire(new t.l("rotateend",e)),a&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e));}flyTo(e,i){if(!e.essential&&s.prefersReducedMotion){const r=t.O(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cb},e);const r=this._getTransformForUpdate(),o=r.bearing,a=r.pitch,n=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:a,u="roll"in e?this._normalizeBearing(e.roll,n):n,d="padding"in e?e.padding:r.padding,_=t.P.convert(e.offset);let p=r.centerPoint.add(_);const m=r.screenPointToLocation(p),f=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:_,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let g=e.curve;const v=Math.max(r.width,r.height),x=v/f.scaleOfZoom,b=f.pixelPathLength;"number"==typeof f.scaleOfMinZoom&&(g=Math.sqrt(v/f.scaleOfMinZoom/b*2));const y=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*y*y*b*b)/(2*(e?x:v)*y*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const C=w(!1);let I=function(e){return P(C)/P(C+g*e)},M=function(e){return v*((P(C)*(T(t=C+g*e)/P(t))-T(C))/y)/b;var t;},E=(w(!0)-C)/g;if(Math.abs(b)<2e-6||!isFinite(E)){if(Math.abs(v-x)<1e-6)return this.easeTo(e,i);const t=x0,I=e=>Math.exp(t*g*e);}return e.duration="duration"in e?+e.duration:1e3*E/("screenSpeed"in e?+e.screenSpeed/g:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==a,this._rolling=u!==n,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease((s=>{const m=s*E,g=1/I(m),v=M(m);this._rotating&&r.setBearing(t.B.number(o,c,s)),this._pitching&&r.setPitch(t.B.number(a,h,s)),this._rolling&&r.setRoll(t.B.number(n,u,s)),this._padding&&(r.interpolatePadding(l,d,s),p=r.centerPoint.add(_)),f.easeFunc(s,g,v,p),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t);}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.aL(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class wa{constructor(e=ya){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=e;}getDefaultPosition(){return "bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style.sourceCaches;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return !1;return !0}));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=n.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class Ta{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact");}},this.options=e;}getDefaultPosition(){return "bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=n.create("div","maplibregl-ctrl");const t=n.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class Pa{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var Ca=t.aD([{name:"a_pos3d",type:"Int16",components:3}]);class Ia extends t.E{constructor(e){super(),this._lastTilesetChange=s.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const r={};for(const o of ue(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float64Array(16),t.bO(o.terrainRttPosMatrix32f,0,t.Z,t.Z,0,0,1),this._tiles[o.key]=new ae(o,this.tileSize),this._lastTilesetChange=s.now());for(const e in this._tiles)r[e]||delete this._tiles[e];}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID,a=e.clone(),s=t.b2();if(o.canonical.equals(e.canonical))t.bO(s,0,t.Z,t.Z,0,0,1);else if(o.canonical.isChildOf(e.canonical)){const i=o.canonical.z-e.canonical.z,r=o.canonical.x-(o.canonical.x>>i<>i<>i;t.bO(s,0,n,n,0,0,1),t.L(s,s,[-r*n,-a*n,0]);}else {if(!e.canonical.isChildOf(o.canonical))continue;{const i=e.canonical.z-o.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bO(s,0,t.Z,t.Z,0,0,1),t.L(s,s,[r*n,a*n,0]),t.M(s,s,[1/2**i,1/2**i,0]);}}a.terrainRttPosMatrix32f=new Float32Array(s),i[r]=a;}return i}_getTerrainCoordsForTileRanges(e,i){const r={};for(const o of this._renderableTilesKeys){const a=this._tiles[o].tileID;if(!this._isWithinTileRanges(a,i))continue;const s=e.clone(),n=t.b2();if(a.canonical.z===e.canonical.z){const i=e.canonical.x-a.canonical.x,r=e.canonical.y-a.canonical.y;t.bO(n,0,t.Z,t.Z,0,0,1),t.L(n,n,[i*t.Z,r*t.Z,0]);}else if(a.canonical.z>e.canonical.z){const i=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>i<>i<>i),l=e.canonical.y-(a.canonical.y>>i),c=t.Z>>i;t.bO(n,0,c,c,0,0,1),t.L(n,n,[-r*c+s*t.Z,-o*c+l*t.Z,0]);}else {const i=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i)-a.canonical.x,l=(e.canonical.y>>i)-a.canonical.y,c=t.Z<i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!o||!o.dem);)o=this.sourceCache.getTileByID(e.scaledTo(r--).key);return o}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Ma{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Ia(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(e,i,r,o=t.Z){var a;if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?o=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=e.canonical.x-(e.canonical.x>>o<>o<>8<<4|e>>8,i[t+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),o=new v(e,r,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,o=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(a,n-s-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,_=(1<0,o=r&&0===e.canonical.y,a=r&&e.canonical.y===(1<e.id!==t)),this._recentlyUsed.push(e.id);}stampObject(e){e.stamp=++this._stamp;}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1;}freeAllObjects(){for(const e of this._objects)this.freeObject(e);}isFull(){return !(this._objects.length!e.inUse))}}const Sa={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ra{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Ea(e.context,30,t.sourceCache.tileSize*t.qualityFactor);}destruct(){this.pool.destruct();}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates(),r=e.sourceCaches[t].getSource(),o=r instanceof X?r.terrainTileRanges:null;for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e,o);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e]);}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],r=i.source;if(Sa[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join();}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[]);}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return !1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),o=e.type,a=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Sa[o]&&(this._prevType&&Sa[this._prevType]||this._stacks.push([]),this._prevType=o,this._stacks[this._stacks.length-1].push(e.id),!s))return !0;if(Sa[this._prevType]||Sa[o]&&s){this._prevType=o;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const o of this._renderableTiles){if(this.pool.isFull()&&(vo(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(o),o.rtt[e]){const t=this.pool.getObjectForId(o.rtt[e].id);if(t.stamp===o.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),o.rtt[e]={id:s.id,stamp:s.stamp},a.context.bindFramebuffer.set(s.fbo.framebuffer),a.context.clear({color:t.b7.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=e=>{this.move(e,n.mousePos(this.element,e));},this.mouseup=e=>{this._rotatePitchHanlder.dragEnd(e),this.offTemp();},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend));},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos));},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10,this.element=i;const o=new $o;this._rotatePitchHanlder=new Uo({clickTolerance:3,move:(e,o)=>{const a=i.getBoundingClientRect(),s=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return {bearingDelta:t.ca(new t.P(e.x,o.y),o,s),pitchDelta:r?-.5*(o.y-e.y):void 0}},moveStateManager:o,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(i,"mousedown",this.mousedown),n.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(i,"touchcancel",this.reset);}startMove(e,t){this._rotatePitchHanlder.dragStart(e,t),n.disableDrag();}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:o}=this._rotatePitchHanlder.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),o&&i.setPitch(i.getPitch()+o);}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp();}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend);}}let Fa;function Ba(e,i,r){const o=new t.Q(e.lng,e.lat);if(e=new t.Q(e.lng,e.lat),i){const o=new t.Q(e.lng-360,e.lat),a=new t.Q(e.lng+360,e.lat),s=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(o).distSqr(i)180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360;}return e.lng!==o.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:o}const Oa={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function ja(e,t,i){const r=e.classList;for(const e in Oa)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`);}class Za extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();},this._update=e=>{var t;if(!this._map)return;const i=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!i)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Ba(this._lngLat,this._flatPos,this._map.transform):null===(t=this._lngLat)||void 0===t?void 0:t.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?r=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let o="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?o="rotateX(0deg)":"map"===this._pitchAlignment&&(o=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${Oa[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${o} ${r}`),s.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type);})).catch((()=>{}));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive";},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=n.create("div");const i=n.createNS("http://www.w3.org/2000/svg","svg"),r=41,o=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${o}px`),i.setAttributeNS(null,"viewBox",`0 0 ${o} ${r}`);const a=n.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");const s=n.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=n.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=n.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t);}const h=n.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=n.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=n.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=n.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=n.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=n.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=n.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),s.appendChild(l),s.appendChild(h),s.appendChild(d),s.appendChild(p),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();})),ja(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-13.5,-1*(t-i)]}:this._offset;}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;if(!(null===(i=this._map)||void 0===i?void 0:i.terrain)){const e=this._map.transform.isLocationOccluded(this._lngLat)?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const o=this._map,a=o.terrain.depthAtPoint(this._pos),s=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,s)-a<.006)return void(this._element.style.opacity=this._opacity);const n=-this._offset.y/o.transform.pixelsPerMeter,l=Math.sin(o.getPitch()*Math.PI/180)*n,c=o.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),h=o.transform.lngLatToCameraDepth(this._lngLat,s+l)-c>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity;}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e);}removeClassName(e){this._element.classList.remove(e);}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return (void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Na={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Ga=0,Ua=!1;const Va={maxWidth:100,unit:"metric"};function qa(e,t,i){const r=i&&i.maxWidth||100,o=e._container.clientHeight/2,a=e._container.clientWidth/2,s=e.unproject([a-r/2,o]),n=e.unproject([a+r/2,o]),l=Math.round(e.project(n).x-e.project(s).x),c=Math.min(r,l,e._container.clientWidth),h=s.distanceTo(n);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Wa(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Wa(t,c,i,e._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?Wa(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Wa(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):Wa(t,c,h,e._getUIString("ScaleControl.Meters"));}function Wa(e,t,i,r){const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(o/i)+"px",e.innerHTML=`${o} ${r}`;}const $a={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Ha=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ka(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Ka(new t.P(0,0))}const Xa=i;e.AJAXError=t.cm,e.Event=t.l,e.Evented=t.E,e.LngLat=t.Q,e.MercatorCoordinate=t.$,e.Point=t.P,e.addProtocol=t.cn,e.config=t.a,e.removeProtocol=t.co,e.AttributionControl=wa,e.BoxZoomHandler=Oo,e.CanvasSource=Y,e.CooperativeGesturesHandler=ma,e.DoubleClickZoomHandler=ca,e.DragPanHandler=da,e.DragRotateHandler=_a,e.EdgeInsets=Pt,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},e.GeoJSONSource=K,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "BACKGROUND":case "BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.Q(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),a=t.e({bearing:o},this.options.fitBoundsOptions),s=V.fromLngLat(i,r);this._map.fitBounds(s,a,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.Q(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&Ua)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Za({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Za({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")));}));}},this.options=t.e({},Na,e);}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(void 0!==Fa&&!e)return Fa;if(void 0===window.navigator.permissions)return Fa=!!window.navigator.geolocation,Fa;try{const e=yield window.navigator.permissions.query({name:"geolocation"});Fa="denied"!==e.state;}catch(e){Fa=!!window.navigator.geolocation;}return Fa}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ga=0,Ua=!1;}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case "ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),r=t.distanceTo(i),o=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.l("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":Ga--,Ua=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case "BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case "WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ga++,Ga>1?(e={maximumAge:6e5,timeout:0},Ua=!0):(e=this.options.positionOptions,Ua=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon();},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"));};}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0;}},e.Hash=wo,e.ImageSource=X,e.KeyboardHandler=aa,e.LngLatBounds=V,e.LogoControl=Ta,e.Map=class extends ba{constructor(e){var i,r;t.cj.mark(t.ck.create);const o=Object.assign(Object.assign(Object.assign({},Aa),e),{canvasContextAttributes:Object.assign(Object.assign({},Aa.canvasContextAttributes),e.canvasContextAttributes)});if(null!=o.minZoom&&null!=o.maxZoom&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=o.minPitch&&null!=o.maxPitch&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=o.minPitch&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=o.maxPitch&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const a=new Dt,s=new kt;if(void 0!==o.minZoom&&a.setMinZoom(o.minZoom),void 0!==o.maxZoom&&a.setMaxZoom(o.maxZoom),void 0!==o.minPitch&&a.setMinPitch(o.minPitch),void 0!==o.maxPitch&&a.setMaxPitch(o.maxPitch),void 0!==o.renderWorldCopies&&a.setRenderWorldCopies(o.renderWorldCopies),super(a,s,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Pa,this._controls=[],this._mapId=t.a4(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.l("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=!0===o.trackResize,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=!0===o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=!0===o.crossSourceCollisions,this._collectResourceTiming=!0===o.collectResourceTiming,this._locale=Object.assign(Object.assign({},Da),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this.transformCameraUpdate=o.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===o.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=p.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(o.transformRequest),"string"==typeof o.container){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else {if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container;}if(o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})),this.once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=yo((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw());}),50);this._resizeObserver=new ResizeObserver((i=>{e?t(i):e=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new xa(this,o),this._hash=o.hash&&new wo("string"==typeof o.hash&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,t.e({},o.fitBoundsOptions,{duration:0}))));const n="string"==typeof o.style||!("globe"===(null===(r=null===(i=o.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,n),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new wa("boolean"==typeof o.attributionControl?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Ta,o.logoPosition),this.on("style.load",(()=>{if(n||this._resizeTransform(),this.transform.unmodified){const e=t.O(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e);}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.l(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.l("sourcedataabort",e));}));}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return -1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){const[r,o]=this._containerDimensions(),a=this._getClampedPixelRatio(r,o);if(this._resizeCanvas(r,o,a),this.painter.resize(r,o,a),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(r,o);this._resizeCanvas(r,o,t),this.painter.resize(r,o,t);}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e);}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,o=this.getPixelRatio(),a=e*o,s=t*o;return Math.min(a>i?i/a:1,s>r?r/s:1)*o}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(V.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.Q.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e))),s=0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[];s.length?r||(r=!0,i.call(this,new zo(e,this,o.originalEvent,{features:s}))):r=!1;};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e)));(0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[]).length?r=!0:r&&(r=!1,i.call(this,new zo(e,this,o.originalEvent)));},a=t=>{r&&(r=!1,i.call(this,new zo(e,this,t.originalEvent)));};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:a}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),o=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];o.length&&(e.features=o,i.call(this,e),delete e.features);};return {layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t);}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let e=0;et.includes(e)))){for(const e in o.delegates)this.off(e,o.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,o);for(const e in o.delegates)this.on(e,o.delegates[e]);return {unsubscribe:()=>{this._removeDelegatedListener(e,r,i);}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);for(const t in o.delegates){const a=o.delegates[t];o.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),a(...t);};}this._saveDelegatedListener(e,o);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return [];let r;const o=e instanceof t.P||Array.isArray(e),a=o?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(o?{}:e)||{},a instanceof t.P||"number"==typeof a[0])r=[t.P.convert(a)];else {const e=t.P.convert(a[0]),i=t.P.convert(a[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e];}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return !1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new gi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new gi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,"Style");t.j(r,new AbortController).then((e=>{this._updateDiff(e.data,i);})).catch((e=>{e&&this.fire(new t.k(e));}));}else "object"==typeof e&&this._updateDiff(e,i);}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no source with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new Ma(this.painter,i,e),this.painter.renderToTexture=new Ra(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(e,i,r={}){const{pixelRatio:o=1,sdf:a=!1,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:s,data:d}=i,_=i;return this.style.addImage(e,{data:new t.R({width:r,height:s},new Uint8Array(d)),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0,userImage:_}),_.onAdd&&_.onAdd(this,e),this}}{const{width:r,height:d,data:_}=s.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},_),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0});}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||t.b(i)?s.getImageData(i):i,{width:a,height:n,data:l}=o;if(void 0===a||void 0===n)return this.fire(new t.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(a!==r.data.width||n!==r.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e){return p.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,(e=>{e||this._update(!0);})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0);})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const o=this._controlContainer=n.create("div","maplibregl-control-container",e),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{a[e]=n.create("div",`maplibregl-ctrl-${e} `,o);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type);}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new bo(i,this.transform),l.testSupport(i);}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}));}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_render(e){var i,r,o,a,n;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=s.now();this.style.zoomHistory.update(e,i);const r=new t.C(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=r.crossFadingFactor();1===o&&o===this._crossFadingFactor||(h=!0,this._crossFadingFactor=o),this.style.update(r);}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(o=this.style.projection)||void 0===o||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(a=this.style.projection)||void 0===a?void 0:a.transitionState,null===(n=this.style.projection)||void 0===n?void 0:n.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cj.mark(t.ck.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cj.mark(t.ck.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),p.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cj.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(e=>{t.cj.frame(e),this._frameRequest=null;try{this._render(e);}catch(e){if(!t.cl(e)&&!function(e){return e.message===jr}(e))throw e}}),(()=>{})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get version(){return za}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=zo,e.MapTouchEvent=Ao,e.MapWheelEvent=Lo,e.Marker=Za,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`;},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i);},this.options=t.e({},La,e),this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e});})),this._compassIcon=n.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ka(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(e,t){const i=n.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:void 0);},this.remove=()=>(this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._closeButton&&this._closeButton.removeEventListener("click",this._onClose),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point);},this._onMouseMove=e=>{this._update(e.point);},this._onDrag=e=>{this._update(e.point);},this._update=e=>{var t;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?Ba(this._lngLat,this._flatPos,this._map.transform):null===(t=this._lngLat)||void 0===t?void 0:t.wrap(),this._trackPointer&&!e)return;const i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor;const o=Ka(this.options.offset);if(!r){const e=this._container.offsetWidth,t=this._container.offsetHeight;let a;a=i.y+o.bottom.ythis._map.transform.height-t?["bottom"]:[],i.xthis._map.transform.width-e/2&&a.push("right"),r=0===a.length?"bottom":a.join("-");}let a=i.add(o[r]);this.options.subpixelPositioning||(a=a.round()),n.setTransform(this._container,`${Oa[r]} translate(${a.x}px,${a.y}px)`),ja(this._container,r,"popup"),this._updateOpacity();},this._onClose=()=>{this.remove();},this.options=t.e(Object.create($a),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Ha);e&&e.focus();}},e.RasterDEMTileSource=H,e.RasterTileSource=$,e.ScaleControl=class{constructor(e){this._onMove=()=>{qa(this._map,this._container,this.options);},this.setUnit=e=>{this.options.unit=e,qa(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},Va),e);}getDefaultPosition(){return "bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},e.ScrollZoomHandler=la,e.Style=gi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=e;}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},e.TwoFingersTouchPitchHandler=ra,e.TwoFingersTouchRotateHandler=ta,e.TwoFingersTouchZoomHandler=Jo,e.TwoFingersTouchZoomRotateHandler=pa,e.VectorTileSource=W,e.VideoSource=Q,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,(function*(){if(ee(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{J[e]=t;})(e,i);})),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(D),L=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},e.createTileMesh=Wt,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return oe().getRTLTextPluginStatus()},e.getVersion=function(){return Xa},e.getWorkerCount=function(){return z.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return O().broadcast("IS",e)},e.prewarm=function(){F().acquire(D);},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e;},e.setRTLTextPlugin=function(e,t){return oe().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){z.workerCount=e;},e.setWorkerUrl=function(e){t.a.WORKER_URL=e;};})); + +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + + +var maplibregl$1 = maplibregl; + +return maplibregl$1; + +})); +//# sourceMappingURL=maplibre-gl.js.map diff --git a/docs/articles/getting-started_files/maplibre-gl-5.5.0/LICENSE.txt b/docs/articles/getting-started_files/maplibre-gl-5.5.0/LICENSE.txt new file mode 100644 index 00000000..1e8acbb5 --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.5.0/LICENSE.txt @@ -0,0 +1,116 @@ +Copyright (c) 2023, MapLibre contributors + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of MapLibre GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from mapbox-gl-js v1.13 and earlier + +Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license + +Copyright (c) 2020, Mapbox +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Mapbox GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from glfx.js + +Copyright (C) 2011 by Evan Wallace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +Contains a portion of d3-color https://github.com/d3/d3-color + +Copyright 2010-2016 Mike Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/articles/getting-started_files/maplibre-gl-5.5.0/maplibre-gl.css b/docs/articles/getting-started_files/maplibre-gl-5.5.0/maplibre-gl.css new file mode 100644 index 00000000..aa4f4650 --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.5.0/maplibre-gl.css @@ -0,0 +1 @@ +.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file diff --git a/docs/articles/getting-started_files/maplibre-gl-5.5.0/maplibre-gl.js b/docs/articles/getting-started_files/maplibre-gl-5.5.0/maplibre-gl.js new file mode 100644 index 00000000..fd0c3b11 --- /dev/null +++ b/docs/articles/getting-started_files/maplibre-gl-5.5.0/maplibre-gl.js @@ -0,0 +1,59 @@ +/** + * MapLibre GL JS + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.5.0/LICENSE.txt + */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); +})(this, (function () { 'use strict'; + +/* eslint-disable */ + +var maplibregl = {}; +var modules = {}; +function define(moduleName, _dependencies, moduleFactory) { + modules[moduleName] = moduleFactory; + + // to get the list of modules see generated dist/maplibre-gl-dev.js file (look for `define(` calls) + if (moduleName !== 'index') { + return; + } + + // we assume that when an index module is initializing then other modules are loaded already + var workerBundleString = 'var sharedModule = {}; (' + modules.shared + ')(sharedModule); (' + modules.worker + ')(sharedModule);' + + var sharedModule = {}; + // the order of arguments of a module factory depends on rollup (it decides who is whose dependency) + // to check the correct order, see dist/maplibre-gl-dev.js file (look for `define(` calls) + // we assume that for our 3 chunks it will generate 3 modules and their order is predefined like the following + modules.shared(sharedModule); + modules.index(maplibregl, sharedModule); + + if (typeof window !== 'undefined') { + maplibregl.setWorkerUrl(window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }))); + } + + return maplibregl; +}; + + + +define("shared",["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t));}catch(t){s(t);}}function o(t){try{l(n.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(a,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n,i;function s(){if(i)return n;function t(t,e){this.x=t,this.y=e;}return i=1,n=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},n}"function"==typeof SuppressedError&&SuppressedError;var a,o,l=r(s()),u=function(){if(o)return a;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return o=1,a=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},a}(),c=r(u);let h,p;function f(){return null==h&&(h="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),h}function d(){if(null==p&&(p=!1,f())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function E(t,e,r,n){const i=new c(t,e,r,n);return t=>i.solve(t)}const T=E(.25,.1,.25,1);function F(t,e,r){return Math.min(r,Math.max(e,t))}function $(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function L(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let O=1;function D(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function j(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function R(t){return Array.isArray(t)?t.map(R):"object"==typeof t&&t?D(t,R):t}const N={};function U(t){N[t]||("undefined"!=typeof console&&console.warn(t),N[t]=!0);}function q(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function G(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let Z=null;function K(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const X="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function H(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,r,n,i){const s=4*Math.max(1,0),a=(Math.max(0,r)-r)*n*4+s,o=4*n,l=Math.max(0,e),u=Math.max(0,r);return {rect:{x:l,y:u,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-u},layout:[{offset:a,stride:o}]}}(t,r,n,i,s)),o)for(let t=0;t{t.removeEventListener(e,r,n);}}}function Q(t){return t*Math.PI/180}function tt(t){return t/Math.PI*180}const et={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},rt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},nt="AbortError";function it(){return new Error(nt)}const st={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function at(t){return st.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const ot="global-dispatcher";class lt extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n;}}const ut=()=>G(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ct=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=at(t.url);if(e)return e(t,r);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:ot},r)}if(!(/^file:/.test(n=t.url)||/^file:/.test(ut())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:ut(),signal:r.signal});let n,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e);}catch(e){throw new lt(0,e.message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new lt(n.status,n.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw it();return {data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:ot},r)}var n;return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new lt(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),n(it());})),s.send(t.body);}))}(t,r)};function ht(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function pt(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function ft(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class dt{constructor(t,e={}){L(this,e),this.type=t;}}class yt extends dt{constructor(t,e={}){super("error",L({error:t},e));}}class mt{on(t,e){return this._listeners=this._listeners||{},pt(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e);}}}off(t,e){return ft(t,e,this._listeners),ft(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},pt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new dt(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)ft(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(L(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof yt&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var gt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const xt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function vt(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return xt.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function bt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Yt=[Et,Tt,Ft,$t,Lt,Ot,Nt,Dt,Xt(jt),Ut,Gt,qt,Zt,Kt];function Jt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Jt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Yt)if(!Jt(t,e))return null}return `Expected ${Ht(t)} but found ${Ht(e)} instead.`}function Wt(t,e){return e.some((e=>e.kind===t.kind))}function Qt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function te(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const ee=.96422,re=.82521,ne=4/29,ie=6/29,se=3*ie*ie,ae=ie*ie*ie,oe=Math.PI/180,le=180/Math.PI;function ue(t){return (t%=360)<0&&(t+=360),t}function ce([t,e,r,n]){let i,s;const a=pe((.2225045*(t=he(t))+.7168786*(e=he(e))+.0606169*(r=he(r)))/1);t===e&&e===r?i=s=a:(i=pe((.4360747*t+.3850649*e+.1430804*r)/ee),s=pe((.0139322*t+.0971045*e+.7141733*r)/re));const o=116*a-16;return [o<0?0:o,500*(i-a),200*(a-s),n]}function he(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pe(t){return t>ae?Math.pow(t,1/3):t/se+ne}function fe([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*ye(i),s=ee*ye(s),a=re*ye(a),[de(3.1338561*s-1.6168667*i-.4906146*a),de(-.9787684*s+1.9161415*i+.033454*a),de(.0719453*s-.2289914*i+1.4052427*a),n]}function de(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ye(t){return t>ie?t*t*t:se*(t-ne)}const me=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function ge(t,e){return me(t,e)?t[e]:void 0}function xe(t){return parseInt(t.padEnd(2,t),16)/255}function ve(t,e){return be(e?t/100:t,0,1)}function be(t,e,r){return Math.min(Math.max(e,t),r)}function we(t){return !t.some(Number.isNaN)}const _e={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Ae(t,e,r){return t+r*(e-t)}function Se(t,e,r){return t.map(((t,n)=>Ae(t,e[n],r)))}class ke{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof ke)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=ge(_e,t);if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [xe(t.slice(r,r+=e)),xe(t.slice(r,r+=e)),xe(t.slice(r,r+=e)),xe(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[be(+r/e,0,1),be(+s/e,0,1),be(+l/e,0,1),h?ve(+h,p):1];if(we(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,be(+i,0,100),be(+a,0,100),l?ve(+l,u):1];if(we(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=ue(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new ke(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=ce(t),s=Math.sqrt(r*r+n*n);return [Math.round(1e4*s)?ue(Math.atan2(n,r)*le):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ce(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}static interpolate(t,e,r,n="rgb"){switch(n){case "rgb":{const[n,i,s,a]=Se(t.rgb,e.rgb,r);return new ke(n,i,s,a,!1)}case "hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*oe,fe([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:Ae(i,l,r),Ae(s,u,r),Ae(a,c,r)]);return new ke(f,d,y,m,!1)}case "lab":{const[n,i,s,a]=fe(Se(t.lab,e.lab,r));return new ke(n,i,s,a,!1)}}}}ke.black=new ke(0,0,0,1),ke.white=new ke(1,1,1,1),ke.transparent=new ke(0,0,0,0),ke.red=new ke(1,0,0,1);class Me{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Ie=["bottom","center","top"];class ze{constructor(t,e,r,n,i,s){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i,this.verticalAlign=s;}}class Pe{constructor(t){this.sections=t;}static fromString(t){return new Pe([new ze(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Pe?t:Pe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Ce{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Ce)return t;if("number"==typeof t)return new Ce([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new Ce(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new Ce(Se(t.values,e.values,r))}}class Be{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Be)return t;if("number"==typeof t)return new Be([t]);if(Array.isArray(t)){for(const e of t)if("number"!=typeof e)return;return new Be(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new Be(Se(t.values,e.values,r))}}class Ve{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Ve)return t;if("string"==typeof t){const e=ke.parse(t);if(!e)return;return new Ve([e])}if(!Array.isArray(t))return;const e=[];for(const r of t){if("string"!=typeof r)return;const t=ke.parse(r);if(!t)return;e.push(t);}return new Ve(e)}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r,n="rgb"){const i=[];if(t.values.length!=e.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${e.values.length}), cannot interpolate.`);for(let s=0;s=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function De(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Le||t instanceof ke||t instanceof Me||t instanceof Pe||t instanceof Ce||t instanceof Be||t instanceof Ve||t instanceof Fe||t instanceof $e)return !0;if(Array.isArray(t)){for(const e of t)if(!De(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!De(t[e]))return !1;return !0}return !1}function je(t){if(null===t)return Et;if("string"==typeof t)return Ft;if("boolean"==typeof t)return $t;if("number"==typeof t)return Tt;if(t instanceof ke)return Lt;if(t instanceof Le)return Ot;if(t instanceof Me)return Rt;if(t instanceof Pe)return Nt;if(t instanceof Ce)return Ut;if(t instanceof Be)return Gt;if(t instanceof Ve)return qt;if(t instanceof Fe)return Kt;if(t instanceof $e)return Zt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=je(e);if(r){if(r===t)continue;r=jt;break}r=t;}return Xt(r||jt,e)}return Dt}function Re(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ke||t instanceof Le||t instanceof Pe||t instanceof Ce||t instanceof Be||t instanceof Ve||t instanceof Fe||t instanceof $e?t.toString():JSON.stringify(t)}class Ne{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!De(t[1]))return e.error("invalid value");const r=t[1];let n=je(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Ne(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}const Ue={string:Ft,number:Tt,boolean:$t,object:Dt};class qe{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in Ue)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Ue[r],n++;}else i=jt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=Xt(i,s);}else {if(!Ue[i])throw new Error(`Types doesn't contain name = ${i}`);r=Ue[i];}const s=[];for(;nt.outputDefined()))}}const Ge={"to-boolean":$t,"to-color":Lt,"to-number":Tt,"to-string":Ft};class Ze{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!Ge[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=Ge[r],i=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Oe(e[0],e[1],e[2],e[3]),!r))return new ke(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ee(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=Ce.parse(e);if(n)return n}throw new Ee(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "numberArray":{let e;for(const r of this.args){e=r.evaluate(t);const n=Be.parse(e);if(n)return n}throw new Ee(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "colorArray":{let e;for(const r of this.args){e=r.evaluate(t);const n=Ve.parse(e);if(n)return n}throw new Ee(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=Fe.parse(e);if(n)return n}throw new Ee(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new Ee(`Could not convert ${JSON.stringify(e)} to number.`)}case "formatted":return Pe.fromString(Re(this.args[0].evaluate(t)));case "resolvedImage":return $e.fromString(Re(this.args[0].evaluate(t)));case "projectionDefinition":return this.args[0].evaluate(t);default:return Re(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ke=["Unknown","Point","LineString","Polygon"];class Xe{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null;}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ke[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=ke.parse(t),this._parseColorCache.set(t,e)),e}}class He{constructor(t,e,r=[],n,i=new Vt,s=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new qe(e,[t]):"coerce"===r?new Ze(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(i.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(i.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(i.kind)||"colorArray"===t.kind&&["value","string","array"].includes(i.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(i.kind))n=r(n,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof Ne)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Xe;try{n=new Ne(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new He(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Bt(r,t));}checkSubtype(t,e){const r=Jt(t,e);return r&&this.error(r),r}}class Ye{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new Ee(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new Ee(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class Qe{constructor(t,e){this.type=$t,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,jt);return r&&n?Wt(r.type,[$t,Ft,Tt,Et,jt])?new Qe(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!Qt(e,["boolean","string","number","null"]))throw new Ee(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(je(e))} instead.`);if(!Qt(r,["string","array"]))throw new Ee(`Expected second argument to be of type array or string, but found ${Ht(je(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class tr{constructor(t,e,r){this.type=Tt,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,jt);if(!r||!n)return null;if(!Wt(r.type,[$t,Ft,Tt,Et,jt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Tt);return i?new tr(r,n,i):null}return new tr(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Qt(e,["boolean","string","number","null"]))throw new Ee(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(je(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),Qt(r,["string"])){const t=r.indexOf(e,n);return -1===t?-1:[...r.slice(0,t)].length}if(Qt(r,["array"]))return r.indexOf(e,n);throw new Ee(`Expected second argument to be of type array or string, but found ${Ht(je(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class er{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,je(t)))return null}else r=je(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,jt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new er(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (je(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class rr{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class nr{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,Tt);if(!r||!n)return null;if(!Wt(r.type,[Xt(jt),Ft,jt]))return e.error(`Expected first argument to be of type array or string, but found ${Ht(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Tt);return i?new nr(r.type,r,n,i):null}return new nr(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),Qt(e,["string"]))return [...e].slice(r,n).join("");if(Qt(e,["array"]))return e.slice(r,n);throw new Ee(`Expected first argument to be of type array or string, but found ${Ht(je(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function ir(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new Ee("Input is not a number.");a=o-1;}return 0}class sr{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,Tt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new sr(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[ir(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function ar(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var or,lr,ur=function(){if(lr)return or;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return lr=1,or=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},or}(),cr=ar(ur);class hr{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=pr(e,t.base,r,n);else if("linear"===t.name)i=pr(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new cr(s[0],s[1],s[2],s[3]).solve(pr(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Tt),!i)return null;const a=[];let o=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||e.expectedType==qt?e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType):o=Lt;for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return te(o,Tt)||te(o,Ot)||te(o,Lt)||te(o,Ut)||te(o,Gt)||te(o,qt)||te(o,Kt)||te(o,Xt(Tt))?new hr(o,r,n,i,a):e.error(`Type ${Ht(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=ir(e,n),a=hr.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case "interpolate":switch(this.type.kind){case "number":return Ae(o,l,a);case "color":return ke.interpolate(o,l,a);case "padding":return Ce.interpolate(o,l,a);case "colorArray":return Ve.interpolate(o,l,a);case "numberArray":return Be.interpolate(o,l,a);case "variableAnchorOffsetCollection":return Fe.interpolate(o,l,a);case "array":return Se(o,l,a);case "projectionDefinition":return Le.interpolate(o,l,a)}case "interpolate-hcl":switch(this.type.kind){case "color":return ke.interpolate(o,l,a,"hcl");case "colorArray":return Ve.interpolate(o,l,a,"hcl")}case "interpolate-lab":switch(this.type.kind){case "color":return ke.interpolate(o,l,a,"lab");case "colorArray":return Ve.interpolate(o,l,a,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function pr(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}const fr={color:ke.interpolate,number:Ae,padding:Ce.interpolate,numberArray:Be.interpolate,colorArray:Ve.interpolate,variableAnchorOffsetCollection:Fe.interpolate,array:Se};class dr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const s=n&&i.some((t=>Jt(n,t.type)));return new dr(s?jt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof $e&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function yr(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function mr(t,e,r,n){return 0===n.compare(e,r)}function gr(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=$t,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,jt);if(!s)return null;if(!yr(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${Ht(s.type)}'.`);let a=e.parse(t[2],2,jt);if(!a)return null;if(!yr(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${Ht(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Ht(s.type)}' and '${Ht(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new qe(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new qe(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Rt),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=je(s),r=je(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ee(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=je(s),r=je(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const xr=gr("==",(function(t,e,r){return e===r}),mr),vr=gr("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !mr(0,e,r,n)})),br=gr("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),_r=gr("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),Ar=gr(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class Sr{constructor(t,e,r){this.type=Rt,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,$t);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,$t);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,Ft),!s)?null:new Sr(n,i,s)}evaluate(t){return new Me(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class kr{constructor(t,e,r,n,i){this.type=Ft,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Tt);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,Ft),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Ft),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Tt),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,Tt),!o)?null:new kr(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class Mr{constructor(t){this.type=Nt,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Tt),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,Xt(Ft)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,Lt),!a))return null;let o=null;if(s["vertical-align"]){if("string"==typeof s["vertical-align"]&&!Ie.includes(s["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(o=e.parse(s["vertical-align"],1,Ft),!o)return null}const l=n[n.length-1];l.scale=t,l.font=r,l.textColor=a,l.verticalAlign=o;}else {const s=e.parse(t[r],1,jt);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null});}}return new Mr(n)}evaluate(t){return new Pe(this.sections.map((e=>{const r=e.content.evaluate(t);return je(r)===Zt?new ze("",r,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new ze(Re(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign);}outputDefined(){return !1}}class Ir{constructor(t){this.type=Zt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Ft);return r?new Ir(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=$e.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class zr{constructor(t){this.type=Tt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${Ht(r.type)} instead.`):new zr(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new Ee(`Expected value to be of type string or array, but found ${Ht(je(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const Pr=8192;function Cr(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*Pr),Math.round(n*i*Pr)]}function Br(t,e){const r=Math.pow(2,e.z);return [(i=(t[0]/Pr+e.x)/r,360*i-180),(n=(t[1]/Pr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i;}function Vr(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function Er(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Tr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Fr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Rr(t,e,r,n)||!Rr(r,n,t,e));var i,s;}function $r(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(a=o[e+1])[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}var i,s,a;return n}function Or(t,e){for(const r of e)if(Lr(t,r))return !0;return !1}function Dr(t,e){for(const r of t)if(!Lr(r,e))return !1;for(let r=0;r0&&o<0||a<0&&o>0}function Nr(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Vr(e,t);}function Gr(t,e,r,n){const i=Math.pow(2,n.z)*Pr,s=[n.x*Pr,n.y*Pr],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];qr(n,e,r,i),a.push(n);}return a}function Zr(t,e,r,n){const i=Math.pow(2,n.z)*Pr,s=[n.x*Pr,n.y*Pr],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Vr(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)qr(n,e,r,i);}var o;return a}class Kr{constructor(t,e){this.type=$t,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(De(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n);}if(t.length)return new Kr(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Kr(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Kr(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Nr(e.coordinates,n,i),a=Gr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Lr(t,s))return !1}if("MultiPolygon"===e.type){const s=Ur(e.coordinates,n,i),a=Gr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Or(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Nr(e.coordinates,n,i),a=Zr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Dr(t,s))return !1}if("MultiPolygon"===e.type){const s=Ur(e.coordinates,n,i),a=Zr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!jr(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let Xr=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}};function Hr(t,e,r=0,n=t.length-1,i=Jr){for(;n>r;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Hr(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(Yr(t,r,e),i(t[n],s)>0&&Yr(t,r,n);a0;)o--;}0===i(t[r],s)?Yr(t,r,o):(o++,Yr(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function Yr(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Jr(t,e){return te?1:0}function Wr(t,e){if(t.length<=1)return [t];const r=[];let n,i;for(const e of t){const t=tn(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e));}if(n&&r.push(n),e>1)for(let t=0;t1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function an(t,e){return e[0]-t[0]}function on(t){return t[1]-t[0]+1}function ln(t,e){return t[1]>=t[0]&&t[1]t[1])return [null,null];const r=on(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return [t,null];const n=Math.floor(r/2)-1;return [[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function cn(t,e){if(!ln(e,t.length))return [1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)Vr(r,t[n]);return r}function hn(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)Vr(e,t);return e}function pn(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function fn(t,e,r){if(!pn(t)||!pn(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Er(i,s)){if(bn(t,e))return 0}else if(bn(e,t))return 0;let a=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=a.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(on(l)<=u){if(!ln(l,t.length))return NaN;if(e){const e=vn(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=xn(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else {const r=un(l,e);_n(a,s,n,t,o,r[0]),_n(a,s,n,t,o,r[1]);}}return s}function kn(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new Xr([[0,[0,t.length-1],[0,r.length-1]]],an);for(;o.length>0;){const s=o.pop();if(s[0]>=a)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(on(l)<=c&&on(u)<=h){if(!ln(l,t.length)&&ln(u,r.length))return NaN;let s;if(e&&n)s=mn(t,l,r,u,i),a=Math.min(a,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=dn(r[t],e,i),a=Math.min(a,s),0===a)return a}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=dn(t[r],e,i),a=Math.min(a,s),0===a)return a}else s=gn(t,l,r,u,i),a=Math.min(a,s);}else {const s=un(l,e),c=un(u,n);An(o,a,i,t,r,s[0],c[0]),An(o,a,i,t,r,s[0],c[1]),An(o,a,i,t,r,s[1],c[0]),An(o,a,i,t,r,s[1],c[1]);}}return a}function Mn(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class In{constructor(t,e){this.type=Tt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(De(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new In(e,e.features.map((t=>Mn(t.geometry))).flat());if("Feature"===e.type)return new In(e,Mn(e.geometry));if("type"in e&&"coordinates"in e)return new In(e,Mn(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>Br([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new sn(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,kn(n,!1,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,kn(n,!1,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,Sn(n,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>Br([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new sn(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,kn(n,!0,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,kn(n,!0,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,Sn(n,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Wr(r,0).map((e=>e.map((e=>e.map((e=>Br([e.x,e.y],t.canonical))))))),i=new sn(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case "Point":s=Math.min(s,Sn([t.coordinates],!1,e,i,s));break;case "LineString":s=Math.min(s,Sn(t.coordinates,!0,e,i,s));break;case "Polygon":s=Math.min(s,wn(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}class zn{constructor(t){this.type=jt,this.key=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=t[1];return null==r?e.error("Global state property must be defined."):"string"!=typeof r?e.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new zn(r)}evaluate(t){var e;const r=null===(e=t.globals)||void 0===e?void 0:e.globalState;return r&&0!==Object.keys(r).length?ge(r,this.key):null}eachChild(){}outputDefined(){return !1}}const Pn={"==":xr,"!=":vr,">":wr,"<":br,">=":Ar,"<=":_r,array:qe,at:We,boolean:qe,case:rr,coalesce:dr,collator:Sr,format:Mr,image:Ir,in:Qe,"index-of":tr,interpolate:hr,"interpolate-hcl":hr,"interpolate-lab":hr,length:zr,let:Ye,literal:Ne,match:er,number:qe,"number-format":kr,object:qe,slice:nr,step:sr,string:qe,"to-boolean":Ze,"to-color":Ze,"to-number":Ze,"to-string":Ze,var:Je,within:Kr,distance:In,"global-state":zn};class Cn{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const r=t[0],n=Cn.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new He(e.registry,Fn,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(Ht).join(", ")})`:`(${Ht(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&Fn(t):r&&t instanceof Ne;})),!!r&&$n(t)&&On(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function $n(t){if(t instanceof Cn){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Kr)return !1;if(t instanceof In)return !1;let e=!0;return t.eachChild((t=>{e&&!$n(t)&&(e=!1);})),e}function Ln(t){if(t instanceof Cn&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!Ln(t)&&(e=!1);})),e}function On(t,e){if(t instanceof Cn&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!On(t,e)&&(r=!1);})),r}function Dn(t){return {result:"success",value:t}}function jn(t){return {result:"error",value:t}}function Rn(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Nn(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Un(t){return !!t.expression&&t.expression.interpolated}function qn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Gn(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)&&je(t)===Dt}function Zn(t){return t}function Kn(t,e){const r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),i=t.type||(Un(e)?"exponential":"interval"),s=function(t){switch(t.type){case "color":return ke.parse;case "padding":return Ce.parse;case "numberArray":return Be.parse;case "colorArray":return Ve.parse;default:return null}}(e);if(s&&((t=Ct({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],s(t[1])]))),t.default=s(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;const o=function(t){switch(t){case "exponential":return Jn;case "interval":return Yn;case "categorical":return Hn;case "identity":return Wn;default:throw new Error(`Unknown function type "${t}"`)}}(i);let l,u;if("categorical"===i){l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}if(r){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Jn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(n){const r="exponential"===i?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:hr.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Xn(t.default,e.default):o(t,e,i,l,u)}}}function Xn(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Hn(t,e,r,n,i){return Xn(typeof r===i?n[r]:void 0,t.default,e.default)}function Yn(t,e,r){if("number"!==qn(r))return Xn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=ir(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Jn(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==qn(r))return Xn(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=ir(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=fr[e.type]||Zn;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function Wn(t,e,r){switch(e.type){case "color":r=ke.parse(r);break;case "formatted":r=Pe.fromString(r.toString());break;case "resolvedImage":r=$e.fromString(r.toString());break;case "padding":r=Ce.parse(r);break;case "colorArray":r=Ve.parse(r);break;case "numberArray":r=Be.parse(r);break;default:qn(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return Xn(r,t.default,e.default)}Cn.register(Pn,{error:[{kind:"error"},[Ft],(t,[e])=>{throw new Ee(e.evaluate(t))}],typeof:[Ft,[jt],(t,[e])=>Ht(je(e.evaluate(t)))],"to-rgba":[Xt(Tt,4),[Lt],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return [255*r,255*n,255*i,s]}],rgb:[Lt,[Tt,Tt,Tt],Bn],rgba:[Lt,[Tt,Tt,Tt,Tt],Bn],has:{type:$t,overloads:[[[Ft],(t,[e])=>Vn(e.evaluate(t),t.properties())],[[Ft,Dt],(t,[e,r])=>Vn(e.evaluate(t),r.evaluate(t))]]},get:{type:jt,overloads:[[[Ft],(t,[e])=>En(e.evaluate(t),t.properties())],[[Ft,Dt],(t,[e,r])=>En(e.evaluate(t),r.evaluate(t))]]},"feature-state":[jt,[Ft],(t,[e])=>En(e.evaluate(t),t.featureState||{})],properties:[Dt,[],t=>t.properties()],"geometry-type":[Ft,[],t=>t.geometryType()],id:[jt,[],t=>t.id()],zoom:[Tt,[],t=>t.globals.zoom],"heatmap-density":[Tt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Tt,[],t=>t.globals.lineProgress||0],accumulated:[jt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Tt,Tn(Tt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[Tt,Tn(Tt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:Tt,overloads:[[[Tt,Tt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Tt],(t,[e])=>-e.evaluate(t)]]},"/":[Tt,[Tt,Tt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Tt,[Tt,Tt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Tt,[],()=>Math.LN2],pi:[Tt,[],()=>Math.PI],e:[Tt,[],()=>Math.E],"^":[Tt,[Tt,Tt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Tt,[Tt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Tt,[Tt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Tt,[Tt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Tt,[Tt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Tt,[Tt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Tt,[Tt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Tt,[Tt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Tt,Tn(Tt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Tt,Tn(Tt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Tt,[Tt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Tt,[Tt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Tt,[Tt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Tt,[Tt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[$t,[Ft,jt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[$t,[jt],(t,[e])=>t.id()===e.value],"filter-type-==":[$t,[Ft],(t,[e])=>t.geometryType()===e.value],"filter-<":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[$t,[jt],(t,[e])=>e.value in t.properties()],"filter-has-id":[$t,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[$t,[Xt(Ft)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[$t,[Xt(jt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[$t,[Ft,Xt(jt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[$t,[Ft,Xt(jt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:$t,overloads:[[[$t,$t],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Tn($t),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:$t,overloads:[[[$t,$t],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Tn($t),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[$t,[$t],(t,[e])=>!e.evaluate(t)],"is-supported-script":[$t,[Ft],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Ft,[Ft],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Ft,[Ft],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Ft,Tn(jt),(t,e)=>e.map((e=>Re(e.evaluate(t)))).join("")],"resolved-locale":[Ft,[Rt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Qn{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Xe,this._defaultValue=e?function(t){if("color"===t.type&&Gn(t.default))return new ke(0,0,0,0);switch(t.type){case "color":return ke.parse(t.default)||null;case "padding":return Ce.parse(t.default)||null;case "numberArray":return Be.parse(t.default)||null;case "colorArray":return Ve.parse(t.default)||null;case "variableAnchorOffsetCollection":return Fe.parse(t.default)||null;case "projectionDefinition":return Le.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ee(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ti(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Pn}function ei(t,e){const r=new He(Pn,Fn,[],e?function(t){const e={color:Lt,string:Ft,number:Tt,enum:Ft,boolean:$t,formatted:Nt,padding:Ut,numberArray:Gt,colorArray:qt,projectionDefinition:Ot,resolvedImage:Zt,variableAnchorOffsetCollection:Kt};return "array"===t.type?Xt(e[t.value]||jt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Dn(new Qn(n,e)):jn(r.errors)}class ri{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Ln(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class ni{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Ln(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?hr.interpolationFactor(this.interpolationType,t,e,r):0}}function ii(t,e){const r=ei(t,e);if("error"===r.result)return r;const n=r.value.expression,i=$n(n);if(!i&&!Rn(e))return jn([new Bt("","data expressions not supported")]);const s=On(n,["zoom"]);if(!s&&!Nn(e))return jn([new Bt("","zoom expressions not supported")]);const a=ai(n);return a||s?a instanceof Bt?jn([a]):a instanceof hr&&!Un(e)?jn([new Bt("",'"interpolate" expressions cannot be used with this property')]):Dn(a?new ni(i?"camera":"composite",r.value,a.labels,a instanceof hr?a.interpolation:void 0):new ri(i?"constant":"source",r.value)):jn([new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class si{constructor(t,e){this._parameters=t,this._specification=e,Ct(this,Kn(this._parameters,this._specification));}static deserialize(t){return new si(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function ai(t){let e=null;if(t instanceof Ye)e=ai(t.result);else if(t instanceof dr){for(const r of t.args)if(e=ai(r),e)break}else (t instanceof sr||t instanceof hr)&&t.input instanceof Cn&&"zoom"===t.input.name&&(e=t);return e instanceof Bt||t.eachChild((t=>{const r=ai(t);r instanceof Bt?e=r:!e&&r?e=new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new Bt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function oi(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case "has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case "in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case "any":case "all":for(const e of t.slice(1))if(!oi(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const li={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ui(t){if(null==t)return {filter:()=>!0,needGeometry:!1};oi(t)||(t=pi(t));const e=ei(t,li);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:hi(t)}}function ci(t,e){return te?1:0}function hi(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?fi(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(pi))):"all"===e?["all"].concat(t.slice(1).map(pi)):"none"===e?["all"].concat(t.slice(1).map(pi).map(mi)):"in"===e?di(t[1],t.slice(2)):"!in"===e?mi(di(t[1],t.slice(2))):"has"===e?yi(t[1]):"!has"!==e||mi(yi(t[1]));var r;}function fi(t,e,r){switch(t){case "$type":return [`filter-type-${r}`,e];case "$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function di(t,e){if(0===e.length)return !1;switch(t){case "$type":return ["filter-type-in",["literal",e]];case "$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ci)]]:["filter-in-small",t,["literal",e]]}}function yi(t){switch(t){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",t]}}function mi(t){return ["!",t]}function gi(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${gi(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new Pt(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function ki(t){const e=t.valueSpec,r=bi(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===qn(t.value.stops)&&"array"===qn(t.value.stops[0])&&"object"===qn(t.value.stops[0][0]),c=_i({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new Pt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(Ai({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===qn(n)&&0===n.length&&e.push(new Pt(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new Pt(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new Pt(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!Un(t.valueSpec)&&c.push(new Pt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Rn(t.valueSpec)?c.push(new Pt(t.key,t.value,"property functions not supported")):o&&!Nn(t.valueSpec)&&c.push(new Pt(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new Pt(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==qn(n))return [new Pt(o,n,`array expected, ${qn(n)} found`)];if(2!==n.length)return [new Pt(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==qn(n[0]))return [new Pt(o,n,`object expected, ${qn(n[0])} found`)];if(void 0===n[0].zoom)return [new Pt(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new Pt(o,n,"object stop key must have value")];if(s&&s>bi(n[0].zoom))return [new Pt(o,n[0].zoom,"stop zoom values must appear in ascending order")];bi(n[0].zoom)!==s&&(s=bi(n[0].zoom),i=void 0,a={}),r=r.concat(_i({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Si,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return ti(wi(n[1]))?r.concat([new Pt(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=qn(t.value),l=bi(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return [new Pt(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new Pt(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return Rn(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Pt(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew Pt(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new Pt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Ln(r))return [new Pt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Ln(r))return [new Pt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!On(r,["zoom","feature-state"]))return [new Pt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!$n(r))return [new Pt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function Ii(t){const e=t.key,r=t.value,n=qn(r);return "string"!==n?[new Pt(e,r,`color expected, ${n} found`)]:ke.parse(String(r))?[]:[new Pt(e,r,`color expected, "${r}" found`)]}function zi(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(bi(r))&&i.push(new Pt(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(bi(r))&&i.push(new Pt(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function Pi(t){return oi(wi(t.value))?Mi(Ct({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ci(t)}function Ci(t){const e=t.value,r=t.key;if("array"!==qn(e))return [new Pt(r,e,`array expected, ${qn(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return [new Pt(r,e,"filter array must have at least 1 element")];switch(s=s.concat(zi({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),bi(e[0])){case "<":case "<=":case ">":case ">=":e.length>=2&&"$type"===bi(e[1])&&s.push(new Pt(r,e,`"$type" cannot be use with operator "${e[0]}"`));case "==":case "!=":3!==e.length&&s.push(new Pt(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case "in":case "!in":e.length>=2&&(i=qn(e[1]),"string"!==i&&s.push(new Pt(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new Pt(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{bi(e.id)===o&&(t=e);})),t?t.ref?e.push(new Pt(n,r.ref,"ref cannot reference another ref layer")):a=bi(t.type):e.push(new Pt(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&bi(t.type);t?"vector"===s&&"raster"===a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new Pt(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new Pt(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Pt(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Pt(n,r.source,`source "${r.source}" not found`));}else e.push(new Pt(n,r,'missing required property "source"'));return e=e.concat(_i({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:Pi,layout:t=>_i({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Ei(Ct({layerType:a},t))}}),paint:t=>_i({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Vi(Ct({layerType:a},t))}})}})),e}function Fi(t){const e=t.value,r=t.key,n=qn(e);return "string"!==n?[new Pt(r,e,`string expected, ${n} found`)]:[]}const $i={promoteId:function({key:t,value:e}){if("string"===qn(e))return Fi({key:t,value:e});{const r=[];for(const n in e)r.push(...Fi({key:`${t}.${n}`,value:e[n]}));return r}}};function Li(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new Pt(r,e,'"type" is required')];const a=bi(e.type);let o;switch(a){case "vector":case "raster":return o=_i({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:$i,validateSpec:s}),o;case "raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=qn(n);if(void 0===n)return o;if("object"!==l)return o.push(new Pt("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===bi(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new Pt(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new Pt(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case "geojson":if(o=_i({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:$i}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],s="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...Mi({key:`${r}.${t}.map`,value:i,expressionContext:"cluster-map"})),o.push(...Mi({key:`${r}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}));}return o;case "video":return _i({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case "image":return _i({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case "canvas":return [new Pt(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return zi({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Oi(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=qn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Pt("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Pt(a,e[a],`unknown property "${a}"`)]);}return s}function Di(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=qn(e);if(void 0===e)return [];if("object"!==s)return [new Pt("sky",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Pt(s,e[s],`unknown property "${s}"`)]);return a}function ji(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=qn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Pt("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Pt(a,e[a],`unknown property "${a}"`)]);return s}function Ri(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new Pt(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new Pt(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(_i({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Fi({key:n,value:r})}function Ni(t){return e=t.value,Boolean(e)&&e.constructor===Object?[]:[new Pt(t.key,t.value,`object expected, ${qn(t.value)} found`)];var e;}const Ui={"*":()=>[],array:Ai,boolean:function(t){const e=t.value,r=t.key,n=qn(e);return "boolean"!==n?[new Pt(r,e,`boolean expected, ${n} found`)]:[]},number:Si,color:Ii,constants:vi,enum:zi,filter:Pi,function:ki,layer:Ti,object:_i,source:Li,light:Oi,sky:Di,terrain:ji,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=qn(e);if(void 0===e)return [];if("object"!==s)return [new Pt("projection",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Pt(s,e[s],`unknown property "${s}"`)]);return a},projectionDefinition:function(t){const e=t.key;let r=t.value;r=r instanceof String?r.valueOf():r;const n=qn(r);return "array"!==n||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(r)||function(t){return !!["interpolate","step","literal"].includes(t[0])}(r)?["array","string"].includes(n)?[]:[new Pt(e,r,`projection expected, invalid type "${n}" found`)]:[new Pt(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:Fi,formatted:function(t){return 0===Fi(t).length?[]:Mi(t)},resolvedImage:function(t){return 0===Fi(t).length?[]:Mi(t)},padding:function(t){const e=t.key,r=t.value;if("array"===qn(r)){if(r.length<1||r.length>4)return [new Pt(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(vi({key:"constants",value:t.constants}))),Xi(r)}function Ki(t){return function(e){return t({...e,validateSpec:qi})}}function Xi(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function Hi(t){return function(...e){return Xi(t.apply(this,e))}}Zi.source=Hi(Ki(Li)),Zi.sprite=Hi(Ki(Ri)),Zi.glyphs=Hi(Ki(Gi)),Zi.light=Hi(Ki(Oi)),Zi.sky=Hi(Ki(Di)),Zi.terrain=Hi(Ki(ji)),Zi.state=Hi(Ki(Ni)),Zi.layer=Hi(Ki(Ti)),Zi.filter=Hi(Ki(Pi)),Zi.paintProperty=Hi(Ki(Vi)),Zi.layoutProperty=Hi(Ki(Ei));const Yi=Zi,Ji=Yi.light,Wi=Yi.sky,Qi=Yi.paintProperty,ts=Yi.layoutProperty;function es(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new yt(new Error(n.message))),r=!0;return r}class rs{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1;}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const s=t[n];i[n]=ns[r].shallow.indexOf(n)>=0?s:ls(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(i.$name=r),i}function us(t){if(os(t))return t;if(Array.isArray(t))return t.map(us);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=as(t)||"Object";if(!ns[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=ns[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=ns[e].shallow.indexOf(r)>=0?i:us(i);}return n}class cs{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Hangul Syllables":t=>t>=44032&&t<=55215,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function ps(t){for(const e of t)if(xs(e.charCodeAt(0)))return !0;return !1}function fs(t){for(const e of t)if(!ms(e.charCodeAt(0)))return !1;return !0}function ds(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const ys=ds(["Arab","Dupl","Mong","Ougr","Syrc"]);function ms(t){return !ys.test(String.fromCodePoint(t))}const gs=ds(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function xs(t){return !(746!==t&&747!==t&&(t<4352||!(hs["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||hs["CJK Compatibility"](t)||hs["CJK Strokes"](t)||!(!hs["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||hs["Enclosed CJK Letters and Months"](t)||hs["Ideographic Description Characters"](t)||hs.Kanbun(t)||hs.Katakana(t)&&12540!==t||!(!hs["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!hs["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||hs["Vertical Forms"](t)||hs["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||gs.test(String.fromCodePoint(t)))))}function vs(t){return !(xs(t)||function(t){return !!(hs["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||hs["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||hs["Letterlike Symbols"](t)||hs["Number Forms"](t)||hs["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||hs["Control Pictures"](t)&&9251!==t||hs["Optical Character Recognition"](t)||hs["Enclosed Alphanumerics"](t)||hs["Geometric Shapes"](t)||hs["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||hs["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||hs["CJK Symbols and Punctuation"](t)||hs.Katakana(t)||hs["Private Use Area"](t)||hs["CJK Compatibility Forms"](t)||hs["Small Form Variants"](t)||hs["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const bs=ds(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function ws(t){return bs.test(String.fromCodePoint(t))}function _s(t,e){return !(!e&&ws(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||hs.Khmer(t))}function As(t){for(const e of t)if(ws(e.charCodeAt(0)))return !0;return !1}const Ss=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{};}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(Ss.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve();}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,r){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((t=>{this.loadScriptResolve=t;}));r(e);const i=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([n,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class ks{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new cs,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!_s(r.charCodeAt(0),e))return !1;return !0}(t,"loaded"===Ss.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class Ms{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Gn(t))return new si(t,e);if(ti(t)){const r=ii(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=ke.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"numberArray"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"colorArray"!==e.type||"string"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?r=Fe.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(r=Le.parse(t)):r=Ve.parse(t):r=Be.parse(t):r=Ce.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class Is{constructor(t){this.property=t,this.value=new Ms(t,void 0);}transitioned(t,e){return new Ps(this.property,this.value,e,L({},t.transition,this.transition),t.now)}untransitioned(){return new Ps(this.property,this.value,null,{},0)}}class zs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return R(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].value=new Ms(this._values[t].property,null===e?void 0:R(e));}getTransition(t){return R(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].transition=R(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new Cs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new Cs(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ps{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(nn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Ls{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new ks(Math.floor(e.zoom-1),e)),t.expression.evaluate(new ks(Math.floor(e.zoom),e)),t.expression.evaluate(new ks(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Os{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class Ds{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new Ms(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Is(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}is("DataDrivenProperty",Fs),is("DataConstantProperty",Ts),is("CrossFadedDataDrivenProperty",$s),is("CrossFadedProperty",Ls),is("ColorRampProperty",Os);const js="-transition";class Rs extends mt{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Bs(e.layout)),e.paint)){this._transitionablePaint=new zs(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Es(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(ts,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(js)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(Qi,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(js))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),j(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&es(this,t.call(Yi,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:gt,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Vs&&Rn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const Ns={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Us{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class qs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Gs(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=Ns[t.type].BYTES_PER_ELEMENT,s=r=Zs(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Zs(r,Math.max(n,e)),alignment:e}}function Zs(t,e){return Math.ceil(t/e)*e}class Ks extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Ks.prototype.bytesPerElement=4,is("StructArrayLayout2i4",Ks);class Xs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}Xs.prototype.bytesPerElement=6,is("StructArrayLayout3i6",Xs);class Hs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Hs.prototype.bytesPerElement=8,is("StructArrayLayout4i8",Hs);class Ys extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Ys.prototype.bytesPerElement=12,is("StructArrayLayout2i4i12",Ys);class Js extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}Js.prototype.bytesPerElement=8,is("StructArrayLayout2i4ub8",Js);class Ws extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Ws.prototype.bytesPerElement=8,is("StructArrayLayout2f8",Ws);class Qs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}Qs.prototype.bytesPerElement=20,is("StructArrayLayout10ui20",Qs);class ta extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}ta.prototype.bytesPerElement=24,is("StructArrayLayout4i4ui4i24",ta);class ea extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}ea.prototype.bytesPerElement=12,is("StructArrayLayout3f12",ea);class ra extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ra.prototype.bytesPerElement=4,is("StructArrayLayout1ul4",ra);class na extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}na.prototype.bytesPerElement=20,is("StructArrayLayout6i1ul2ui20",na);class ia extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}ia.prototype.bytesPerElement=12,is("StructArrayLayout2i2i2i12",ia);class sa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}sa.prototype.bytesPerElement=16,is("StructArrayLayout2f1f2i16",sa);class aa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=16*t,l=4*t,u=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=a,t}}aa.prototype.bytesPerElement=16,is("StructArrayLayout2ub2f2i16",aa);class oa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}oa.prototype.bytesPerElement=6,is("StructArrayLayout3ui6",oa);class la extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}la.prototype.bytesPerElement=48,is("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",la);class ua extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=A,this.uint32[C+12]=S,this.float32[C+13]=k,this.float32[C+14]=M,this.uint16[P+30]=I,this.uint16[P+31]=z,t}}ua.prototype.bytesPerElement=64,is("StructArrayLayout8i15ui1ul2f2ui64",ua);class ca extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}ca.prototype.bytesPerElement=4,is("StructArrayLayout1f4",ca);class ha extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}ha.prototype.bytesPerElement=12,is("StructArrayLayout1ui2f12",ha);class pa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}pa.prototype.bytesPerElement=8,is("StructArrayLayout1ul2ui8",pa);class fa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}fa.prototype.bytesPerElement=4,is("StructArrayLayout2ui4",fa);class da extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}da.prototype.bytesPerElement=2,is("StructArrayLayout1ui2",da);class ya extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}ya.prototype.bytesPerElement=16,is("StructArrayLayout4f16",ya);class ma extends Us{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}ma.prototype.size=20;class ga extends na{get(t){return new ma(this,t)}}is("CollisionBoxArray",ga);class xa extends Us{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}xa.prototype.size=48;class va extends la{get(t){return new xa(this,t)}}is("PlacedSymbolArray",va);class ba extends Us{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}ba.prototype.size=64;class wa extends ua{get(t){return new ba(this,t)}}is("SymbolInstanceArray",wa);class _a extends ca{getoffsetX(t){return this.float32[1*t+0]}}is("GlyphOffsetArray",_a);class Aa extends Xs{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}is("SymbolLineVertexArray",Aa);class Sa extends Us{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Sa.prototype.size=12;class ka extends ha{get(t){return new Sa(this,t)}}is("TextAnchorOffsetArray",ka);class Ma extends Us{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}Ma.prototype.size=8;class Ia extends pa{get(t){return new Ma(this,t)}}is("FeatureIndexArray",Ia);class za extends Ks{}class Pa extends Ks{}class Ca extends Ks{}class Ba extends Ys{}class Va extends Js{}class Ea extends Ws{}class Ta extends Qs{}class Fa extends ta{}class $a extends ea{}class La extends ra{}class Oa extends ia{}class Da extends aa{}class ja extends oa{}class Ra extends fa{}const Na=Gs([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ua}=Na;class qa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t;}prepareSegment(t,e,r,n){const i=this.segments[this.segments.length-1];return t>qa.MAX_VERTEX_ARRAY_LENGTH&&U(`Max vertices per segment is ${qa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${qa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+t>qa.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n?this.createNewSegment(e,r,n):i}createNewSegment(t,e,r){const n={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==r&&(n.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(t,e,r){return this.prepareSegment(0,t,e,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0;}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new qa([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ga(t,e){return 256*(t=F(Math.floor(t),0,255))+F(Math.floor(e),0,255)}qa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,is("SegmentVector",qa);const Za=Gs([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Ka,Xa,Ha,Ya={exports:{}},Ja={exports:{}},Wa={exports:{}},Qa=function(){if(Ha)return Ya.exports;Ha=1;var t=(Ka||(Ka=1,Ja.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Ja.exports),e=(Xa||(Xa=1,Wa.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),Wa.exports);return Ya.exports=t,Ya.exports.murmur3=t,Ya.exports.murmur2=e,Ya.exports}(),to=r(Qa);class eo{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(ro(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=ro(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return no(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new eo;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function ro(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:to(String(t))}function no(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;io(t,s,a),io(e,3*s,3*a),io(e,3*s+1,3*a+1),io(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new lo(t,e):new ao(t,e)}}class po{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new oo(t,e):new ao(t,e)}}class fo{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new ks(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=co(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new ks(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new ks(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=co(r),s=co(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof fo||r instanceof yo)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new go(n,e,r);this.needsUpload=!1,this._featureMap=new eo,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function vo(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function bo(t,e,r){const n={color:{source:Ws,composite:ya},number:{source:ca,composite:Ws}},i=function(t){return {"line-pattern":{source:Ta,composite:Ta},"fill-pattern":{source:Ta,composite:Ta},"fill-extrusion-pattern":{source:Ta,composite:Ta}}[t]}(t);return i&&i[r]||n[e][r]}is("ConstantBinder",ho),is("CrossFadedConstantBinder",po),is("SourceExpressionBinder",fo),is("CrossFadedCompositeBinder",mo),is("CompositeExpressionBinder",yo),is("ProgramConfiguration",go,{omit:["_buffers"]}),is("ProgramConfigurationSet",xo);const wo=Math.pow(2,14)-1,_o=-wo-1;function Ao(t){const e=z/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&U("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function So(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?Ao(t):[]}}const ko=-32768;function Mo(t,e,r,n,i){t.emplaceBack(ko+8*e+n,ko+8*r+i);}class Io{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Pa,this.indexArray=new ja,this.segments=new qa,this.programConfigurations=new xo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1,o="heatmap"===n.type;if("circle"===n.type){const t=n;s=t.layout.get("circle-sort-key"),a=!s.isConstant(),o=o||"map"===t.paint.get("circle-pitch-alignment");}const l=o?e.subdivisionGranularity.circle:1;for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=So(e,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Ao(e),patterns:{},sortKey:c};i.push(h);}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r,l),e.featureIndex.insert(o,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ua),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const a=s.length;for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=z||n<0||n>=z)continue;const i=this.segments.prepareSegment(a*a,this.layoutVertexArray,this.indexArray,t.sortKey),o=i.vertexLength;for(let t=0;t1){if(Vo(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function $o(t,e){for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function Oo(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=q(t,e,r[0]);return s!==q(t,e,r[1])||s!==q(t,e,r[2])||s!==q(t,e,r[3])}function Do(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function jo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ro(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=l.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let e=0;eZo(t,e,r,n)))}(l,i,a,o),p=c?u*s:u;for(const t of n)for(const e of t){const t=c?e:Zo(e,i,a,o);let r=p;const n=i.projectTileCoordinates(e.x,e.y,a,o).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n/i.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=i.cameraToCenterDistance/n),Po(h,t,r))return !0}return !1}}function Zo(t,e,r,n){const i=e.projectTileCoordinates(t.x,t.y,r,n).point;return new l((.5*i.x+.5)*e.width,(.5*-i.y+.5)*e.height)}class Ko extends Io{}let Xo;is("HeatmapBucket",Ko,{omit:["layers"]});var Ho={get paint(){return Xo=Xo||new Ds({"heatmap-radius":new Fs(gt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Fs(gt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ts(gt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Os(gt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ts(gt.paint_heatmap["heatmap-opacity"])})}};function Yo(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function Jo(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Yo({},{width:e,height:r},n);Wo(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function Wo(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a);};if(t.clips)for(let e=0,i=0;e0)for(let i=e;i=e;i-=n)s=El(i/n|0,t[i],t[i+1],s);return s&&Il(s,s.next)&&(Tl(s),s=s.next),s}function pl(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Il(n,n.next)&&0!==Ml(n.prev,n,n.next))n=n.next;else {if(Tl(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function fl(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=wl(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?yl(t,n,i,s):dl(t))e.push(l.i,t.i,u.i),Tl(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?fl(t=ml(pl(t),e),e,r,n,i,s,2):2===a&&gl(t,e,r,n,i,s):fl(pl(t),e,r,n,i,s,1);break}}}function dl(t){const e=t.prev,r=t,n=t.next;if(Ml(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),p=Math.max(i,s,a),f=Math.max(o,l,u);let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&Sl(i,o,s,l,a,u,d.x,d.y)&&Ml(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function yl(t,e,r,n){const i=t.prev,s=t,a=t.next;if(Ml(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=Math.min(o,l,u),d=Math.min(c,h,p),y=Math.max(o,l,u),m=Math.max(c,h,p),g=wl(f,d,e,r,n),x=wl(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Sl(o,c,l,h,u,p,v.x,v.y)&&Ml(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Sl(o,c,l,h,u,p,b.x,b.y)&&Ml(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Sl(o,c,l,h,u,p,v.x,v.y)&&Ml(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Sl(o,c,l,h,u,p,b.x,b.y)&&Ml(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function ml(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Il(n,i)&&zl(n,r,r.next,i)&&Bl(n,i)&&Bl(i,n)&&(e.push(n.i,r.i,i.i),Tl(r),Tl(r.next),r=t=i),r=r.next;}while(r!==t);return pl(r)}function gl(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&kl(a,t)){let o=Vl(a,t);return a=pl(a,a.next),o=pl(o,o.next),fl(a,e,r,n,i,s,0),void fl(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function xl(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function vl(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;if(Il(t,r))return r;do{if(Il(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&Al(is.x||r.x===s.x&&bl(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=Vl(r,t);return pl(n,n.next),pl(r,r.next)}function bl(t,e){return Ml(t.prev,t,e.prev)<0&&Ml(e.next,t,t.next)<0}function wl(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function _l(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function Sl(t,e,r,n,i,s,a,o){return !(t===a&&e===o)&&Al(t,e,r,n,i,s,a,o)}function kl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&zl(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(Bl(t,e)&&Bl(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Ml(t.prev,t,e.prev)||Ml(t,e.prev,e))||Il(t,e)&&Ml(t.prev,t,t.next)>0&&Ml(e.prev,e,e.next)>0)}function Ml(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Il(t,e){return t.x===e.x&&t.y===e.y}function zl(t,e,r,n){const i=Cl(Ml(t,e,r)),s=Cl(Ml(t,e,n)),a=Cl(Ml(r,n,t)),o=Cl(Ml(r,n,e));return i!==s&&a!==o||!(0!==i||!Pl(t,r,e))||!(0!==s||!Pl(t,n,e))||!(0!==a||!Pl(r,t,n))||!(0!==o||!Pl(r,e,n))}function Pl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Cl(t){return t>0?1:t<0?-1:0}function Bl(t,e){return Ml(t.prev,t,t.next)<0?Ml(t,e,t.next)>=0&&Ml(t,t.prev,e)>=0:Ml(t,e,t.prev)<0||Ml(t,t.next,e)<0}function Vl(t,e){const r=Fl(t.i,t.x,t.y),n=Fl(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function El(t,e,r,n){const i=Fl(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Tl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Fl(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class $l{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e;}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const r=0|Math.round(t),n=0|Math.round(e),i=this._getKey(r,n);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(r,n),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const r=[];for(let n=0;n0?(r.push(i),r.push(a),r.push(s)):(r.push(i),r.push(s),r.push(a));}return r}(this._vertexBuffer,t);const e=[],r=t.length;for(let n=0;n=1||v<=0)||y&&(oi)){u>=n&&u<=i&&s.push(r[(t+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(a+p*x,o+f*x));const b=a+p*Math.max(x,0),w=a+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,a,o,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(a+p*v,o+f*v)),(y||u>=n&&u<=i)&&s.push(r[(t+1)%3]),!y&&(u<=n||u>=i)&&this._generateInterEdgeVertices(s,a,o,l,u,c,h,w,n,i);}return s}_generateIntraEdgeVertices(t,e,r,n,i,s,a){const o=n-e,l=i-r,u=0===l,c=u?Math.min(e,n):Math.min(s,a),h=u?Math.max(e,n):Math.max(s,a),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?e=p;n--){const i=n*this._granularityCellSize;t.push(this._vertexToIndex(i,r+l*(i-e)/o));}}_generateInterEdgeVertices(t,e,r,n,i,s,a,o,l,u){const c=i-r,h=s-n,p=a-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=n+h*y;let x=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,b=o=1||m<=0){const t=r-a,n=s+(e-s)*Math.min((l-a)/t,(u-a)/t);x=Math.floor(Math.min(n,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,o)/this._granularityCellSize)-1,b=o0?u:l;if(b)for(let e=x;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,_));else for(let e=v;e>=x;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,_));}_generateOutline(t){const e=[];for(const r of t){const t=Nl(r,this._granularity,!0),n=this._pointArrayToIndices(t),i=[];for(let t=1;ti!=(s===Ol)?(t.push(e),t.push(r),t.push(this._vertexToIndex(n,s)),t.push(r),t.push(this._vertexToIndex(i,s)),t.push(this._vertexToIndex(n,s))):(t.push(r),t.push(e),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(i,s)),t.push(r),t.push(this._vertexToIndex(n,s)));}_fillPoles(t,e,r){const n=this._vertexBuffer,i=z,s=t.length;for(let a=2;a80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return fl(s,a,r,o,l,u,0),a}(r,n),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e);}catch(t){console.error(t);}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(t,e){const r=[];for(let n=0;n0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,e=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(x-t),n=Math.abs(v-e),i=Math.abs(x-c),s=Math.abs(v-h),u=p?r/m:Number.POSITIVE_INFINITY,b=f?n/g:Number.POSITIVE_INFINITY;if((i<=r||!p)&&(s<=n||!f))break;if(u=0?a-1:s-1,i=(o+1)%s,l=t[2*e[n]],u=t[2*e[i]],c=t[2*e[a]],h=t[2*e[a]+1],p=t[2*e[o]+1];let f=!1;if(lu)f=!1;else {const r=p-h,s=-(t[2*e[o]]-c),a=h((u-c)*r+(t[2*e[i]+1]-h)*s)*a&&(f=!0);}if(f){const t=e[n],i=e[a],l=e[o];t!==i&&t!==l&&i!==l&&r.push(l,i,t),a--,a<0&&(a=s-1);}else {const t=e[i],n=e[a],l=e[o];t!==n&&t!==l&&n!==l&&r.push(l,n,t),o++,o>=s&&(o=0);}if(n===i)break}}function ql(t,e,r,n,i,s,a,o,l){const u=i.length/2,c=a&&o&&l;if(uqa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,g=!0,c=0);const x=Gl(a,n,s,o,p,y,u),v=Gl(a,n,s,o,f,m,u),b=Gl(a,n,s,o,d,g,u);r.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++;}}(e,r,n,i,s,t),c&&function(t,e,r,n,i,s){const a=[];for(let t=0;tqa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,d=!0,y=!0,c=0);const m=Gl(a,n,s,o,i,d,u),g=Gl(a,n,s,o,h,y,u);r.emplaceBack(c+m-l,c+g-l),u.primitiveLength++;}}}(a,r,o,i,l,t),e.forceNewSegmentOnNextPrepare(),null==a||a.forceNewSegmentOnNextPrepare();}function Gl(t,e,r,n,i,s,a){if(s){const s=n.count;return r(e[2*i],e[2*i+1]),t[i]=n.count,n.count++,a.vertexLength++,s}return t[i]}class Zl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ca,this.indexArray=new ja,this.indexArray2=new Ra,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.segments2=new qa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=ul("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=So(a,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Ao(a),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=cl("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ll),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s){for(const t of Wr(e,500)){const e=Rl(t,n,s.fill.getGranularityForZoomLevel(n.z)),r=this.layoutVertexArray;ql(((t,e)=>{r.emplaceBack(t,e);}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}}let Kl,Xl;is("FillBucket",Zl,{omit:["layers","patternFeatures"]});var Hl={get paint(){return Xl=Xl||new Ds({"fill-antialias":new Ts(gt.paint_fill["fill-antialias"]),"fill-opacity":new Fs(gt.paint_fill["fill-opacity"]),"fill-color":new Fs(gt.paint_fill["fill-color"]),"fill-outline-color":new Fs(gt.paint_fill["fill-outline-color"]),"fill-translate":new Ts(gt.paint_fill["fill-translate"]),"fill-translate-anchor":new Ts(gt.paint_fill["fill-translate-anchor"]),"fill-pattern":new $s(gt.paint_fill["fill-pattern"])})},get layout(){return Kl=Kl||new Ds({"fill-sort-key":new Fs(gt.layout_fill["fill-sort-key"])})}};class Yl extends Rs{constructor(t){super(t,Hl);}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Zl(t)}queryRadius(){return jo(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:r,pixelsToTileUnits:n}){return Co(Ro(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,n),e)}isTileClipped(){return !0}}const Jl=Gs([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Wl=Gs([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Ql}=Jl;var tu,eu,ru,nu,iu,su,au,ou={};function lu(){if(eu)return tu;eu=1;var t=s();function e(t,e,n,i,s){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=s,t.readFields(r,this,e);}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){for(var r=t.readVarint()+t.pos;t.pos>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(a,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var s,a,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return ru=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},ru}function cu(){return au||(au=1,ou.VectorTile=function(){if(su)return iu;su=1;var t=uu();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return iu=function(t,r){this.layers=t.readFields(e,{},r);},iu}(),ou.VectorTileFeature=lu(),ou.VectorTileLayer=uu()),ou}var hu=r(cu());const pu=hu.VectorTileFeature.types,fu=Math.pow(2,13);function du(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*fu)+a,i*fu*2,s*fu*2,Math.round(o));}class yu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ba,this.centroidVertexArray=new za,this.indexArray=new ja,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=ul("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=So(n,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:Ao(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(cl("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{},e.subdivisionGranularity),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0);}}addFeatures(t,e,r){for(const n of this.features){const{geometry:i}=n;this.addFeature(n,i,n.index,e,r,t.subdivisionGranularity);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ql),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Wl.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i,s){for(const r of Wr(e,500)){const e={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(e,n,t,r,s);const a=this.layoutVertexArray.length-i,o=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t{du(u,t,e,0,0,1,1,0);}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles);}_generateSideFaces(t,e){let r=0;for(let n=1;nqa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const a=i.sub(s)._perp()._unit(),o=s.dist(i);r+o>32768&&(r=0),du(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,0,r),du(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,1,r),r+=o,du(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,0,r),du(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,1,r);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2;}}}function mu(t,e){for(let r=0;rz)||t.y===e.y&&(t.y<0||t.y>z)}function xu(t){return t.every((t=>t.x<0))||t.every((t=>t.x>z))||t.every((t=>t.y<0))||t.every((t=>t.y>z))}let vu;is("FillExtrusionBucket",yu,{omit:["layers","features"]});var bu={get paint(){return vu=vu||new Ds({"fill-extrusion-opacity":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new $s(gt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class wu extends Rs{constructor(t){super(t,bu);}createBucket(t){return new yu(t)}queryRadius(){return jo(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s,pixelPosMatrix:a}){const o=Ro(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-i.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(e,r),c=this.paint.get("fill-extrusion-base").evaluate(e,r),h=function(t,e,r){const n=[];for(const r of t){const t=[r.x,r.y,0,1];S(t,t,e),n.push(new l(t[0]/t[3],t[1]/t[3]));}return n}(o,a),p=function(t,e,r,n){const i=[],s=[],a=n[8]*e,o=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,s=i.y,y=n[0]*e+n[4]*s+n[12],m=n[1]*e+n[5]*s+n[13],g=n[2]*e+n[6]*s+n[14],x=n[3]*e+n[7]*s+n[15],v=g+u,b=x+c,w=y+h,_=m+p,A=g+f,S=x+d,k=new l((y+a)/b,(m+o)/b);k.z=v/b,t.push(k);const M=new l(w/S,_/S);M.z=A/S,r.push(M);}i.push(t),s.push(r);}return [i,s]}(n,c,u,a);return function(t,e,r){let n=1/0;Co(r,e)&&(n=Au(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new Va,this.layoutVertexArray2=new Ea,this.indexArray=new ja,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=ul("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=So(e,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Ao(e),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=cl("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Iu)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ku),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),l=a.get("line-cap"),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,s,a,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Nl(t,a?o.line.getGranularityForZoomLevel(a.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c0;if(w&&e>c){const t=f.dist(d);if(t>2*h){const e=f.sub(f.sub(d)._mult(h/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,m,0,0,p),d=e;}}const A=d&&y;let S=A?r:l?"butt":n;if(A&&"round"===S&&(vi&&(S="bevel"),"bevel"===S&&(v>2&&(S="flipbevel"),v100)a=g.mult(-1);else {const t=v*m.add(g).mag()/m.sub(g).mag();a._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(f,a,0,0,p),this.addCurrentVertex(f,a.mult(-1),0,0,p);}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(d&&this.addCurrentVertex(f,m,e,r,p),"fakeround"===S){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*h){const e=f.add(y.sub(f)._mult(h/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,p),f=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>Cu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s));}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(Cu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let Vu,Eu;is("LineBucket",Bu,{omit:["layers","patternFeatures"]});var Tu={get paint(){return Eu=Eu||new Ds({"line-opacity":new Fs(gt.paint_line["line-opacity"]),"line-color":new Fs(gt.paint_line["line-color"]),"line-translate":new Ts(gt.paint_line["line-translate"]),"line-translate-anchor":new Ts(gt.paint_line["line-translate-anchor"]),"line-width":new Fs(gt.paint_line["line-width"]),"line-gap-width":new Fs(gt.paint_line["line-gap-width"]),"line-offset":new Fs(gt.paint_line["line-offset"]),"line-blur":new Fs(gt.paint_line["line-blur"]),"line-dasharray":new Ls(gt.paint_line["line-dasharray"]),"line-pattern":new $s(gt.paint_line["line-pattern"]),"line-gradient":new Os(gt.paint_line["line-gradient"])})},get layout(){return Vu=Vu||new Ds({"line-cap":new Ts(gt.layout_line["line-cap"]),"line-join":new Fs(gt.layout_line["line-join"]),"line-miter-limit":new Ts(gt.layout_line["line-miter-limit"]),"line-round-limit":new Ts(gt.layout_line["line-round-limit"]),"line-sort-key":new Fs(gt.layout_line["line-sort-key"])})}};class Fu extends Fs{possiblyEvaluate(t,e){return e=new ks(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=L({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let $u;class Lu extends Rs{constructor(t){super(t,Tu),this.gradientVersion=0,$u||($u=new Fu(Tu.paint.properties["line-width"].specification),$u.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof sr,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=$u.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new Bu(t)}queryRadius(t){const e=t,r=Ou(Do("line-width",this,e),Do("line-gap-width",this,e)),n=Do("line-offset",this,e);return r/2+Math.abs(n)+jo(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s}){const a=Ro(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-i.bearingInRadians,s),o=s/2*Ou(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Du=Gs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ju=Gs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Gs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ru=Gs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Gs([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Nu=Gs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Uu=Gs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function qu(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ss.applyArabicShaping&&(t=Ss.applyArabicShaping(t)),t}(t.text,e,r);})),t}Gs([{name:"triangle",components:3,type:"Uint16"}]),Gs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Gs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Gs([{type:"Float32",name:"offsetX"}]),Gs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Gs([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Gu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Zu,Ku,Xu,Hu=24,Yu={};function Ju(){return Zu||(Zu=1,Yu.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},Yu.write=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;}),Yu}function Wu(){if(Xu)return Ku;Xu=1,Ku=e;var t=Ju();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function v(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return a(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=s(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},Ku}var Qu=r(Wu());const tc=3;function ec(t,e,r){1===t&&r.readMessage(rc,e);}function rc(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(nc,{});e.push({id:t,bitmap:new Qo({width:i+2*tc,height:s+2*tc},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}}function nc(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const ic=tc;function sc(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&dc[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new pc;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}getMaxImageSize(t){let e=0,r=0;for(let n=0;n=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function fc(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=pc.fromFeature(e,s);let g;p===t.al.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=Ss;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),_c(m,c,a,r,i,d));for(const e of t){const t=new pc;t.text=e,t.sections=m.sections;for(let r=0;r=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/a,a=t;}return {x1:n,y1:i,x2:n+s,y2:i+a}}function Vc(t,e,r,n,i,s){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-a.displaySize[1])/2,p=c+a.displaySize[1]),{image:a,top:c,right:h,bottom:p,left:f,collisionPadding:o}}const Ec=255,Tc=128,Fc=Ec*Tc;function $c(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new ks(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=$c(this.zoom,r["text-size"]),this.iconSizeData=$c(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap="never"!==Lc(n,"text-overlap","text-allow-overlap")||"never"!==Lc(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.al[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Uc(new xo(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Uc(new xo(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new _a,this.lineVertexArray=new Aa,this.symbolInstances=new wa,this.textAnchorOffsets=new ka;}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new ks(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=So(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=Ao(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=Pe.factory(t),r=this.hasRTLText=this.hasRTLText||Nc(e);(!r||"unavailable"===Ss.getRTLTextPluginStatus()||r&&Ss.isParsed())&&(x=qu(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof $e?t:$e.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:Oc[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=a.evaluate(g,{},n).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.al.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=ps(x.toString()),i=t.fontStack||e,s=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,s,r,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Zc,Kc;is("SymbolBucket",Gc,{omit:["layers","collisionBoxArray","features","compareText"]}),Gc.MAX_GLYPHS=65535,Gc.addDynamicAttributes=Rc;var Xc={get paint(){return Kc=Kc||new Ds({"icon-opacity":new Fs(gt.paint_symbol["icon-opacity"]),"icon-color":new Fs(gt.paint_symbol["icon-color"]),"icon-halo-color":new Fs(gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Fs(gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Fs(gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ts(gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ts(gt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Fs(gt.paint_symbol["text-opacity"]),"text-color":new Fs(gt.paint_symbol["text-color"],{runtimeType:Lt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Fs(gt.paint_symbol["text-halo-color"]),"text-halo-width":new Fs(gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Fs(gt.paint_symbol["text-halo-blur"]),"text-translate":new Ts(gt.paint_symbol["text-translate"]),"text-translate-anchor":new Ts(gt.paint_symbol["text-translate-anchor"])})},get layout(){return Zc=Zc||new Ds({"symbol-placement":new Ts(gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ts(gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ts(gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Fs(gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ts(gt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ts(gt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ts(gt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ts(gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ts(gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ts(gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Fs(gt.layout_symbol["icon-size"]),"icon-text-fit":new Ts(gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ts(gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Fs(gt.layout_symbol["icon-image"]),"icon-rotate":new Fs(gt.layout_symbol["icon-rotate"]),"icon-padding":new Fs(gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ts(gt.layout_symbol["icon-keep-upright"]),"icon-offset":new Fs(gt.layout_symbol["icon-offset"]),"icon-anchor":new Fs(gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ts(gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ts(gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ts(gt.layout_symbol["text-rotation-alignment"]),"text-field":new Fs(gt.layout_symbol["text-field"]),"text-font":new Fs(gt.layout_symbol["text-font"]),"text-size":new Fs(gt.layout_symbol["text-size"]),"text-max-width":new Fs(gt.layout_symbol["text-max-width"]),"text-line-height":new Ts(gt.layout_symbol["text-line-height"]),"text-letter-spacing":new Fs(gt.layout_symbol["text-letter-spacing"]),"text-justify":new Fs(gt.layout_symbol["text-justify"]),"text-radial-offset":new Fs(gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ts(gt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Fs(gt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Fs(gt.layout_symbol["text-anchor"]),"text-max-angle":new Ts(gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ts(gt.layout_symbol["text-writing-mode"]),"text-rotate":new Fs(gt.layout_symbol["text-rotate"]),"text-padding":new Ts(gt.layout_symbol["text-padding"]),"text-keep-upright":new Ts(gt.layout_symbol["text-keep-upright"]),"text-transform":new Fs(gt.layout_symbol["text-transform"]),"text-offset":new Fs(gt.layout_symbol["text-offset"]),"text-allow-overlap":new Ts(gt.layout_symbol["text-allow-overlap"]),"text-overlap":new Ts(gt.layout_symbol["text-overlap"]),"text-ignore-placement":new Ts(gt.layout_symbol["text-ignore-placement"]),"text-optional":new Ts(gt.layout_symbol["text-optional"])})}};class Hc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Et,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}is("FormatSectionOverride",Hc,{omit:["defaultValue"]});class Yc extends Rs{constructor(t){super(t,Xc);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||ti(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Gc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Xc.paint.overridableProperties){if(!Yc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Hc(e),n=new Qn(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new ri("source",n):new ni("composite",n,e.value.zoomStops),this.paint._values[t]=new Vs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&Yc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Xc.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Pe)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof Ne&&je(e.value)===Nt?s(e.value.sections):e instanceof Mr?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Jc;var Wc={get paint(){return Jc=Jc||new Ds({"background-color":new Ts(gt.paint_background["background-color"]),"background-pattern":new Ls(gt.paint_background["background-pattern"]),"background-opacity":new Ts(gt.paint_background["background-opacity"])})}};class Qc extends Rs{constructor(t){super(t,Wc);}}let th;var eh={get paint(){return th=th||new Ds({"raster-opacity":new Ts(gt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ts(gt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ts(gt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ts(gt.paint_raster["raster-brightness-max"]),"raster-saturation":new Ts(gt.paint_raster["raster-saturation"]),"raster-contrast":new Ts(gt.paint_raster["raster-contrast"]),"raster-resampling":new Ts(gt.paint_raster["raster-resampling"]),"raster-fade-duration":new Ts(gt.paint_raster["raster-fade-duration"])})}};class rh extends Rs{constructor(t){super(t,eh);}}class nh extends Rs{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class ih{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle();}),0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const sh={once:!0},ah=6371008.8;class oh{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new oh($(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return ah*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof oh)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new oh(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new oh(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const lh=2*Math.PI*ah;function uh(t){return lh*Math.cos(t*Math.PI/180)}function ch(t){return (180+t)/360}function hh(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function ph(t,e){return t/uh(e)}function fh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function dh(t,e){return t*uh(fh(e))}class yh{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=oh.convert(t);return new yh(ch(r.lng),hh(r.lat),ph(e,r.lat))}toLngLat(){return new oh(360*this.x-180,fh(this.y))}toAltitude(){return dh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/lh*(t=fh(this.y),1/Math.cos(t*Math.PI/180));var t;}}function mh(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class gh{constructor(t,e,r){if(!function(t,e,r){return !(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=bh(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=mh(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=mh(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*z,(t.y*e-this.y)*z)}toString(){return `${this.z}/${this.x}/${this.y}`}}class xh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=bh(t,e.z,e.z,e.x,e.y);}}class vh{constructor(t,e,r,n,i){if(this.terrainRttPosMatrix32f=null,t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new gh(r,+n,+i),this.key=bh(e,t,r,n,i);}clone(){return new vh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new vh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?bh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):bh(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new vh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new vh(e,this.wrap,e,r,n),new vh(e,this.wrap,e,r+1,n),new vh(e,this.wrap,e,r,n+1),new vh(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new tl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Ah{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class Sh{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new rs(z,16,0),this.grid3D=new rs(z,16,0),this.featureIndexArray=new Ia,this.promoteId=e;}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new hu.VectorTile(new Qu(this.rawTileData)).layers,this.sourceLayerCoder=new _h(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params,s=z/t.tileSize/t.scale,a=ui(i.filter),o=t.queryGeometry,u=t.queryPadding*s,c=Mh(o),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=Mh(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new l(e,r),new l(e,i),new l(n,i),new l(n,r)];if(t.length>2)for(const e of s)if(Lo(t,e))return !0;for(let e=0;e(p||(p=Ao(e)),r.queryIntersectsFeature({queryGeometry:o,feature:e,featureState:n,geometry:p,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))));}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!h.some((t=>s.has(t))))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=So(f,!0);if(!i.filter(new ks(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new ks(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const a=e instanceof Es?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function Mh(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {minX:e,minY:r,maxX:n,maxY:i}}function Ih(t,e){return e-t}function zh(t,e,r,n,i){const s=[];for(let a=0;a=n&&c.x>=n||(a.x>=n?a=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=n&&(c=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=i&&c.y>=i||(a.y>=i?a=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y>=i&&(c=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),u&&a.equals(u[u.length-1])||(u=[a],s.push(u)),u.push(c)))));}}return s}is("FeatureIndex",Sh,{omit:["rawTileData","sourceLayerCoder"]});class Ph extends l{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new Ph(this.x,this.y,this.angle,this.segment)}}function Ch(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function Bh(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=fr.number(n.x,i.x,c),p=fr.number(n.y,i.y,c),f=new Ph(h,p,i.angleTo(n),r);return f._round(),!a||Ch(t,f,o,a,e)?f:void 0}l+=s;}}function Fh(t,e,r,n,i,s,a,o,l){const u=Vh(n,s,a),c=Eh(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new Ph(g,x,y,e);r._round(),n&&!Ch(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=$h(t,h/2,r,n,i,s,a,!0,l)),f}is("Anchor",Ph);const Lh=ac;function Oh(t,e,r,n){const i=[],s=t.image,a=s.pixelRatio,o=s.paddedRect.w-2*Lh,u=s.paddedRect.h-2*Lh;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=s.stretchX||[[0,o]],p=s.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=o-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,A=m,S=0,k=g;if(s.content&&n){const e=s.content,r=e[2]-e[0],n=e[3]-e[1];(s.textFitWidth||s.textFitHeight)&&(c=Bc(t)),x=Dh(h,0,e[0]),b=Dh(p,0,e[1]),v=Dh(h,e[0],e[2]),w=Dh(p,e[1],e[3]),_=e[0]-x,S=e[1]-b,A=r-v,k=n-w;}const M=c.x1,I=c.y1,z=c.x2-M,P=c.y2-I,C=(t,n,i,o)=>{const u=Rh(t.stretch-x,v,z,M),c=Nh(t.fixed-_,A,t.stretch,d),h=Rh(n.stretch-b,w,P,I),p=Nh(n.fixed-S,k,n.stretch,y),f=Rh(i.stretch-x,v,z,M),m=Nh(i.fixed-_,A,i.stretch,d),g=Rh(o.stretch-b,w,P,I),C=Nh(o.fixed-S,k,o.stretch,y),B=new l(u,h),V=new l(f,h),E=new l(f,g),T=new l(u,g),F=new l(c/a,p/a),$=new l(m/a,C/a),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),r=[e,-t,t,e];B._matMult(r),V._matMult(r),T._matMult(r),E._matMult(r);}const O=t.stretch+t.fixed,D=n.stretch+n.fixed;return {tl:B,tr:V,bl:T,br:E,tex:{x:s.paddedRect.x+Lh+O,y:s.paddedRect.y+Lh+D,w:i.stretch+i.fixed-O,h:o.stretch+o.fixed-D},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:$,minFontScaleX:A/a/z,minFontScaleY:k/a/P,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=jh(h,m,d),e=jh(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {const u=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?Bc(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};u.y1=u.y1*a-o[0],u.y2=u.y2*a+o[2],u.x1=u.x1*a-o[3],u.x2=u.x2*a+o[1];const p=s.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const t=new l(u.x1,u.y1),e=new l(u.x2,u.y1),r=new l(u.x1,u.y2),n=new l(u.x2,u.y2),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,i);}this.boxEndIndex=t.length;}}class qh{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}function Gh(t,e=1,r=!1){let n=1/0,i=1/0,s=-1/0,a=-1/0;const o=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const u=Math.min(s-n,a-i);let c=u/2;const h=new qh([],Zh);if(0===u)return new l(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Kh(n.p.x-c,n.p.y-c,c,t)),h.push(new Kh(n.p.x+c,n.p.y-c,c,t)),h.push(new Kh(n.p.x-c,n.p.y+c,c,t)),h.push(new Kh(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Zh(t,e){return e.max-t.max}function Kh(t,e,r,n){this.p=new l(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Fo(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var Xh;t.aB=void 0,(Xh=t.aB||(t.aB={}))[Xh.center=1]="center",Xh[Xh.left=2]="left",Xh[Xh.right=3]="right",Xh[Xh.top=4]="top",Xh[Xh.bottom=5]="bottom",Xh[Xh["top-left"]=6]="top-left",Xh[Xh["top-right"]=7]="top-right",Xh[Xh["bottom-left"]=8]="bottom-left",Xh[Xh["bottom-right"]=9]="bottom-right";const Hh=7,Yh=Number.POSITIVE_INFINITY;function Jh(t,e){return e[1]!==Yh?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case "top-right":case "top-left":case "top":i=r-Hh;break;case "bottom-right":case "bottom-left":case "bottom":i=-r+Hh;}switch(t){case "top-right":case "bottom-right":case "right":n=-e;break;case "top-left":case "bottom-left":case "left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case "top-right":case "top-left":n=i-Hh;break;case "bottom-right":case "bottom-left":n=-i+Hh;break;case "bottom":n=-e+Hh;break;case "top":n=e-Hh;}switch(t){case "top-right":case "bottom-right":r=-i;break;case "top-left":case "bottom-left":r=i;break;case "left":r=e;break;case "right":r=-e;}return [r,n]}(t,e[0])}function Wh(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*Hu));n.startsWith("top")?i[1]-=Hh:n.startsWith("bottom")&&(i[1]+=Hh),e[r+1]=i;}return new Fe(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Hu,Yh]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Hu));const s=[];for(const t of a)s.push(t,Jh(t,n));return new Fe(s)}return null}function Qh(t){switch(t){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function tp(e,r,n,i,s,a,o,l,u,c,h,p){let f=a.textMaxSize.evaluate(r,{});void 0===f&&(f=o);const d=e.layers[0].layout,y=d.get("icon-offset").evaluate(r,{},h),m=rp(n.horizontal),g=o/24,x=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*d.get("symbol-spacing"),_=d.get("text-padding")*e.tilePixelRatio,A=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),s=i&&i.values;return [s[0]*n,s[1]*n,s[2]*n,s[3]*n]}(d,r,h,e.tilePixelRatio),S=d.get("text-max-angle")/180*Math.PI,k="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),M="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),I=d.get("symbol-placement"),P=w/2,C=d.get("icon-text-fit");let B;i&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(B=Vc(i,n.vertical,C,d.get("icon-text-fit-padding"),y,g)),m&&(i=Vc(i,m,C,d.get("icon-text-fit-padding"),y,g)));const V=h?p.line.getGranularityForZoomLevel(h.z):1,E=(l,p)=>{p.x<0||p.x>=z||p.y<0||p.y>=z||function(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k){const M=e.addToLineVertexArray(r,n);let I,z,P,C,B=0,V=0,E=0,T=0,F=-1,$=-1;const L={};let O=to("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},S)+90;P=new Uh(u,r,c,h,p,i.vertical,f,d,y,t),o&&(C=new Uh(u,r,c,h,p,o,g,x,y,t));}if(s){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),a=Oh(s,n,A,i),f=o?Oh(o,n,A,i):void 0;z=new Uh(u,r,c,h,p,s,g,x,!1,n),B=4*a.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[Tc*l.layout.get("icon-size").evaluate(w,{})],y[0]>Fc&&U(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ec}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[Tc*_.compositeIconSizes[0].evaluate(w,{},S),Tc*_.compositeIconSizes[1].evaluate(w,{},S)],(y[0]>Fc||y[1]>Fc)&&U(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ec}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,y,b,v,w,t.al.none,r,M.lineStartIndex,M.lineLength,-1,S),F=e.icon.placedSymbolArray.length-1,f&&(V=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.al.vertical,r,M.lineStartIndex,M.lineLength,-1,S),$=e.icon.placedSymbolArray.length-1);}const D=Object.keys(i.horizontal);for(const n of D){const s=i.horizontal[n];if(!I){O=to(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},S);I=new Uh(u,r,c,h,p,s,f,d,y,t);}const o=1===s.positionedLines.length;if(E+=ep(e,r,s,a,l,y,w,m,M,i.vertical?t.al.horizontal:t.al.horizontalOnly,o?D:[n],L,F,_,S),o)break}i.vertical&&(T+=ep(e,r,i.vertical,a,l,y,w,m,M,t.al.vertical,["vertical"],L,$,_,S));const j=I?I.boxStartIndex:e.collisionBoxArray.length,R=I?I.boxEndIndex:e.collisionBoxArray.length,N=P?P.boxStartIndex:e.collisionBoxArray.length,q=P?P.boxEndIndex:e.collisionBoxArray.length,G=z?z.boxStartIndex:e.collisionBoxArray.length,Z=z?z.boxEndIndex:e.collisionBoxArray.length,K=C?C.boxStartIndex:e.collisionBoxArray.length,X=C?C.boxEndIndex:e.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(I,H),H=Y(P,H),H=Y(z,H),H=Y(C,H);const J=H>-1?1:0;J&&(H*=k/Hu),e.glyphOffsetArray.length>=Gc.MAX_GLYPHS&&U("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=Wh(l,w,S),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,F,$,O,j,R,N,q,G,Z,K,X,c,E,T,B,V,J,0,f,H,Q,tt);}(e,p,l,n,i,s,B,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,x,[_,_,_,_],k,u,b,A,M,y,r,a,c,h,o);};if("line"===I)for(const t of zh(r.geometry,0,0,z,z)){const r=Nl(t,V),s=Fh(r,w,S,n.vertical||m,i,24,v,e.overscaling,z);for(const t of s)m&&np(e,m.text,P,t)||E(r,t);}else if("line-center"===I){for(const t of r.geometry)if(t.length>1){const e=Nl(t,V),r=Th(e,S,n.vertical||m,i,24,v);r&&E(e,r);}}else if("Polygon"===r.type)for(const t of Wr(r.geometry,0)){const e=Gh(t,16);E(Nl(t[0],V,!0),new Ph(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry){const e=Nl(t,V);E(e,new Ph(e[0].x,e[0].y,0));}else if("Point"===r.type)for(const t of r.geometry)for(const e of t)E([e],new Ph(e.x,e.y,0));}function ep(t,e,r,n,i,s,a,o,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,s,a,o){const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=ic+1,p=!0,f=1,d=0;const y=(i||o)&&n.vertical,m=n.metrics.advance*n.scale/2;if(o&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Hu-n.metrics.width*n.scale)/2:(n.scale-1)*Hu)),n.imageName){const t=a[n.imageName];p=t.sdf,f=t.pixelRatio,h=ac/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],A=w+s.w/b*n.scale/f,S=_+s.h/b*n.scale/f,k=new l(w,_),M=new l(A,_),I=new l(w,S),z=new l(A,S);if(y){const t=new l(-m,m-cc),e=-Math.PI/2,r=Hu/2-m,i=new l(5-cc-r,-(n.imageName?r:0)),s=new l(...v);k._rotateAround(e,t)._add(i)._add(s),M._rotateAround(e,t)._add(i)._add(s),I._rotateAround(e,t)._add(i)._add(s),z._rotateAround(e,t)._add(i)._add(s);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),M._matMult(r),I._matMult(r),z._matMult(r);}const P=new l(0,0),C=new l(0,0);c.push({tl:k,tr:M,bl:I,br:z,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,o,i,s,a,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[Tc*i.layout.get("text-size").evaluate(a,{})],x[0]>Fc&&U(`${t.layerIds[0]}: Value for "text-size" is >= ${Ec}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[Tc*d.compositeTextSizes[0].evaluate(a,{},y),Tc*d.compositeTextSizes[1].evaluate(a,{},y)],(x[0]>Fc||x[1]>Fc)&&U(`${t.layerIds[0]}: Value for "text-size" is >= ${Ec}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,o,s,a,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function rp(t){for(const e in t)return t[e];return null}function np(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=ip[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new sp(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=ip.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ap(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)cp(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];cp(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function ap(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;op(t,e,a,n,i,s),ap(t,e,r,n,a-1,1-s),ap(t,e,r,a+1,i,1-s);}function op(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);op(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(lp(t,e,n,r),e[2*i+s]>a&&lp(t,e,n,i);oa;)l--;}e[2*n+s]===a?lp(t,e,n,l):(l++,lp(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function lp(t,e,r,n){up(t,r,n),up(e,2*r,2*n),up(e,2*r+1,2*n+1);}function up(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function cp(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}var hp;t.co=void 0,(hp=t.co||(t.co={})).create="create",hp.load="load",hp.fullLoad="fullLoad";let pp=null,fp=[];const dp=1e3/60,yp="loadTime",mp="fullLoadTime",gp={mark(t){performance.mark(t);},frame(t){const e=t;null!=pp&&fp.push(e-pp),pp=e;},clearMetrics(){pp=null,fp=[],performance.clearMeasures(yp),performance.clearMeasures(mp);for(const e in t.co)performance.clearMarks(t.co[e]);},getPerformanceMetrics(){performance.measure(yp,t.co.create,t.co.load),performance.measure(mp,t.co.create,t.co.fullLoad);const e=performance.getEntriesByName(yp)[0].duration,r=performance.getEntriesByName(mp)[0].duration,n=fp.length,i=1/(fp.reduce(((t,e)=>t+e),0)/n/1e3),s=fp.filter((t=>t>dp)).reduce(((t,e)=>t+(e-dp)/dp),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:s/(n+s)*100,totalFrames:n}}};t.$=yh,t.A=m,t.B=fr,t.C=ks,t.D=Ts,t.E=mt,t.F=Wi,t.G=function(t){if(null==Z){const e=t.navigator?t.navigator.userAgent:null;Z=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return Z},t.H=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ih((()=>this.process())),this.subscription=W(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=G(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=e?W(e.signal,"abort",(()=>{null==s||s.unsubscribe(),delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),sh):null;this.resolveRejects[i]={resolve:t=>{null==s||s.unsubscribe(),r(t);},reject:t=>{null==s||s.unsubscribe(),n(t);}};const a=[],o=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:ls(t.data,a)});this.target.postMessage(o,{transfer:a});}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(G(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(us(r.error)):e.resolve(us(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=us(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i);}catch(e){this.completeTask(t,e);}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?ls(e):null,data:ls(r,n)};this.target.postMessage(i,{transfer:n});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.I=oc,t.J=ot,t.K=function(){var t=new m(16);return m!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.L=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=a*y+c*m+d*g+e[15]),t},t.M=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.N=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*o+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*s+b*u+w*f+_*g,t[3]=v*a+b*c+w*d+_*x,t[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*s+b*u+w*f+_*g,t[7]=v*a+b*c+w*d+_*x,t[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*s+b*u+w*f+_*g,t[11]=v*a+b*c+w*d+_*x,t[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*s+b*u+w*f+_*g,t[15]=v*a+b*c+w*d+_*x,t},t.O=function(t,e){const r={};for(let n=0;n{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e);};for(const r of t){const t=window.document.createElement("source");ht(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t);}}))},t.a3=Pt,t.a4=function(){return O++},t.a5=ga,t.a6=Gc,t.a7=ui,t.a8=So,t.a9=Ah,t.aA=function(t,e,r,n,i=!1){if(!r[0]&&!r[1])return [0,0];const s=i?"map"===n?-t.bearingInRadians:0:"viewport"===n?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e];}return [i?r[0]:P(e,r[0],t.zoom),i?r[1]:P(e,r[1],t.zoom)]},t.aC=Lc,t.aD=Qh,t.aE=Ac,t.aF=sp,t.aG=Gs,t.aH=Ll,t.aI=za,t.aJ=qa,t.aK=ja,t.aL=$,t.aM=tt,t.aN=dh,t.aO=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},t.aP=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},t.aQ=function(t){var e=new m(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aR=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},t.aS=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},t.aT=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.aU=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},t.aV=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aW=xh,t.aX=bh,t.aY=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.aZ=function(t){var e=new m(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.a_=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.aa=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.ab=Q,t.ac=function(t){return Math.pow(2,t)},t.ad=x,t.ae=F,t.af=85.051129,t.ag=ph,t.ah=function(t){return Math.log(t)/Math.LN2},t.ai=function(t){var e=t[0],r=t[1];return e*e+r*r},t.aj=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ak=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:a}=t,o=i?F(hr.interpolationFactor(i,e,s,a),0,1):0;"camera"===t.kind?n=fr.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.am=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/Tc:"composite"===t.kind?fr.number(n/Tc,i/Tc,r):e},t.an=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,A=i*u-s*l,S=c*y-h*d,k=c*m-p*d,M=c*g-f*d,I=h*m-p*y,z=h*g-f*y,P=p*g-f*m,C=x*P-v*z+b*I+w*M-_*k+A*S;return C?(t[0]=(o*P-l*z+u*I)*(C=1/C),t[1]=(i*z-n*P-s*I)*C,t[2]=(y*A-m*_+g*w)*C,t[3]=(p*_-h*A-f*w)*C,t[4]=(l*M-a*P-u*k)*C,t[5]=(r*P-i*M+s*k)*C,t[6]=(m*b-d*A-g*v)*C,t[7]=(c*A-p*b+f*v)*C,t[8]=(a*z-o*M+u*S)*C,t[9]=(n*M-r*z-s*S)*C,t[10]=(d*_-y*b+g*x)*C,t[11]=(h*b-c*_-f*x)*C,t[12]=(o*k-a*I-l*S)*C,t[13]=(r*I-n*k+i*S)*C,t[14]=(y*v-d*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null},t.ao=M,t.ap=function(t){return Math.hypot(t[0],t[1])},t.aq=function(t){return t[0]=0,t[1]=0,t},t.ar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},t.as=Rc,t.at=S,t.au=function(t,e,r,n){const i=e.y-t.y,s=e.x-t.x,a=n.y-r.y,o=n.x-r.x,u=a*s-o*i;if(0===u)return null;const c=(o*(t.y-r.y)-a*(t.x-r.x))/u;return new l(t.x+c*s,t.y+c*i)},t.av=zh,t.aw=zo,t.ax=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return [e,r,n,i]},t.ay=Hu,t.az=P,t.b=K,t.b$=class extends da{},t.b0=function(){const t=new Float32Array(16);return x(t),t},t.b1=function(){const t=new Float64Array(16);return x(t),t},t.b2=function(){return new Float64Array(16)},t.b3=function(t,e,r){const n=new Float64Array(4);return function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u;}(n,t,e-90,r),n},t.b4=function(t,e,r,n){var i,s,a,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],m=r[2],g=r[3];return (s=u*f+c*d+h*m+p*g)<0&&(s=-s,f=-f,d=-d,m=-m,g=-g),1-s>y?(i=Math.acos(s),a=Math.sin(i),o=Math.sin((1-n)*i)/a,l=Math.sin(n*i)/a):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*m,t[3]=o*p+l*g,t},t.b5=function(t){const e=new Float64Array(9);var r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v;h=(i=(n=t)[0])*(l=i+i),p=(s=n[1])*l,d=(a=n[2])*l,y=a*(u=s+s),g=(o=n[3])*l,x=o*u,v=o*(c=a+a),(r=e)[0]=1-(f=s*u)-(m=a*c),r[3]=p-v,r[6]=d+x,r[1]=p+v,r[4]=1-h-m,r[7]=y-g,r[2]=d-x,r[5]=y+g,r[8]=1-h-f;const b=tt(-Math.asin(F(e[2],-1,1)));let w,_;return Math.hypot(e[5],e[8])<.001?(w=0,_=-tt(Math.atan2(e[3],e[4]))):(w=tt(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),_=tt(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:w,pitch:b+90,bearing:_}},t.b6=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b7=ke,t.b8=ao,t.b9=Ol,t.bA=function(t){if("custom"===t.type)return new nh(t);switch(t.type){case "background":return new Qc(t);case "circle":return new Go(t);case "fill":return new Yl(t);case "fill-extrusion":return new wu(t);case "heatmap":return new nl(t);case "hillshade":return new al(t);case "line":return new Lu(t);case "raster":return new rh(t);case "symbol":return new Yc(t)}},t.bB=R,t.bC=function(t,e){if(!t)return [{command:"setStyle",args:[e]}];let r=[];try{if(!bt(t.version,e.version))return [{command:"setStyle",args:[e]}];bt(t.center,e.center)||r.push({command:"setCenter",args:[e.center]}),bt(t.state,e.state)||r.push({command:"setGlobalState",args:[e.state]}),bt(t.centerAltitude,e.centerAltitude)||r.push({command:"setCenterAltitude",args:[e.centerAltitude]}),bt(t.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),bt(t.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),bt(t.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),bt(t.roll,e.roll)||r.push({command:"setRoll",args:[e.roll]}),bt(t.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),bt(t.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),bt(t.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),bt(t.light,e.light)||r.push({command:"setLight",args:[e.light]}),bt(t.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),bt(t.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),bt(t.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const n={},i=[];!function(t,e,r,n){let i;for(i in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)||At(i,r,n));for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)?bt(t[i],e[i])||("geojson"===t[i].type&&"geojson"===e[i].type&&kt(t,e,i)?wt(r,{command:"setGeoJSONSourceData",args:[i,e[i].data]}):St(i,e,r,n)):_t(i,e,r));}(t.sources,e.sources,i,n);const s=[];t.layers&&t.layers.forEach((t=>{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):s.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(It),i=e.map(It),s=t.reduce(zt,{}),a=e.reduce(zt,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;tr?i-360:i+360;return Math.abs(i)0?a:-a},t.bt=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bu=ah,t.bv=function(t,e){const r=C(t,2*Math.PI),n=C(e,2*Math.PI);return Math.min(Math.abs(r-n),Math.abs(r-n+2*Math.PI),Math.abs(r-n-2*Math.PI))},t.bw=function(){const t={},e=gt.$version;for(const r in gt.$root){const n=gt.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.bx=cs,t.by=ut,t.bz=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r"symbol"===t.type,t.c4=t=>"circle"===t.type,t.c5=t=>"heatmap"===t.type,t.c6=t=>"line"===t.type,t.c7=t=>"fill"===t.type,t.c8=t=>"fill-extrusion"===t.type,t.c9=t=>"hillshade"===t.type,t.cA=Zl,t.cB=yu,t.cC=hu,t.cD=Qu,t.cE=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start);}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.cF=function(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if(d())try{return yield H(t,r,n,i,s)}catch(t){}return function(t,e,r,n,i){const s=t.width,a=t.height;Y&&J||(Y=new OffscreenCanvas(s,a),J=Y.getContext("2d",{willReadFrequently:!0})),Y.width=s,Y.height=a,J.drawImage(t,0,0,s,a);const o=J.getImageData(e,r,n,i);return J.clearRect(0,0,s,a),o.data}(t,r,n,i,s)}))},t.cG=wh,t.cH=r,t.cI=s,t.cJ=cu,t.cK=Wu,t.cL=ei,t.cM=Ss,t.ca=t=>"raster"===t.type,t.cb=t=>"background"===t.type,t.cc=t=>"custom"===t.type,t.cd=E,t.ce=function(t,e,r){const n=I(e.x-r.x,e.y-r.y),i=I(t.x-r.x,t.y-r.y);var s,a;return tt(Math.atan2(n[0]*i[1]-n[1]*i[0],(s=n)[0]*(a=i)[0]+s[1]*a[1]))},t.cf=T,t.cg=function(t,e){return rt[e]&&(t instanceof MouseEvent||t instanceof WheelEvent)},t.ch=function(t,e){return et[e]&&"touches"in t},t.ci=function(t){return et[t]||rt[t]},t.cj=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},t.ck=function(t,e){const{x:r,y:n}=yh.fromLngLat(e);return !(t<0||t>25||n<0||n>=1||r<0||r>=1)},t.cl=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cm=class extends Xs{},t.cn=gp,t.cp=function(t){return t.message===nt},t.cq=lt,t.cr=function(t,e){st.REGISTERED_PROTOCOLS[t]=e;},t.cs=function(t){delete st.REGISTERED_PROTOCOLS[t];},t.ct=function(t,e){const r={};for(let n=0;nt*Hu));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(i,{},e.canonical)*Hu:1/0,w=()=>{e.bucket.allowVerticalPlacement&&ps(s)&&(d.vertical=fc(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,b,a,m,"left",f,g,t.al.vertical,!0,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.g=at,t.h=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=X;}));},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):X;})),t.i=G,t.j=(t,e)=>ct(L(t,{type:"json"}),e),t.k=yt,t.l=dt,t.m=ct,t.n=(t,e)=>ct(L(t,{type:"arrayBuffer"}),e),t.o=function(t){return new Qu(t).readFields(ec,[])},t.p=sc,t.q=Qo,t.r=Ds,t.s=W,t.t=Ji,t.u=hs,t.v=gt,t.w=U,t.x=es,t.y=Yi,t.z=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}};})); + +define("worker",["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const o of t){this._layerConfigs[o.id]=o;const t=this._layers[o.id]=e.bA(o);t._featureFilter=e.a7(t.filter),this.keyCache[o.id]&&delete this.keyCache[o.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=e.ct(Object.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let r=this.familiesBySource[i];r||(r=this.familiesBySource[i]={});const s=o.sourceLayer||"_geojsonTileLayer";let n=r[s];n||(n=r[s]=[]),n.push(t);}}}class o{constructor(t){const o={},i=[];for(const e in t){const r=t[e],s=o[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};i.push(o),s[e]={rect:o,metrics:t.metrics};}}const{w:r,h:s}=e.p(i),n=new e.q({width:r||1,height:s||1});for(const i in t){const r=t[i];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=o[i][t].rect;e.q.copy(s.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap);}}this.image=n,this.positions=o;}}e.cu("GlyphAtlas",o);class i{constructor(t){this.tileID=new e.Y(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,i,s,n,a){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a5;const l=new e.cv(Object.keys(t.layers).sort()),c=new e.cw(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:s,subdivisionGranularity:a},d=i.familiesBySource[this.source];for(const o in d){const i=t.layers[o];if(!i)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(o),a=[];for(let e=0;e=o.maxzoom||"none"!==o.visibility&&(r(t,this.zoom,s),(u[o.id]=o.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}const f=e.bF(h.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let g=Promise.resolve({});if(Object.keys(f).length){const e=new AbortController;this.inFlightDependencies.push(e),g=n.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const p=Object.keys(h.iconDependencies);let m=Promise.resolve({});if(p.length){const e=new AbortController;this.inFlightDependencies.push(e),m=n.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},e);}const y=Object.keys(h.patternDependencies);let v=Promise.resolve({});if(y.length){const e=new AbortController;this.inFlightDependencies.push(e),v=n.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const[w,x,_]=yield Promise.all([g,m,v]),b=new o(w),M=new e.cx(x,_);for(const t in u){const o=u[t];o instanceof e.a6?(r(o.layers,this.zoom,s),e.cy({bucket:o,glyphMap:w,glyphPositions:b.positions,imageMap:x,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):o.hasPattern&&(o instanceof e.cz||o instanceof e.cA||o instanceof e.cB)&&(r(o.layers,this.zoom,s),o.addFeatures(h,this.tileID.canonical,M.patternPositions));}return this.status="done",{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:M,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function r(t,o,i){const r=new e.C(o);for(const e of t)e.recalculate(r,i);}class s{constructor(e,t,o){this.actor=e,this.layerIndex=t,this.availableImages=o,this.fetching={},this.loading={},this.loaded={};}loadVectorTile(t,o){return e._(this,void 0,void 0,(function*(){const i=yield e.n(t.request,o);try{return {vectorTile:new e.cC.VectorTile(new e.cD(i.data)),rawData:i.data,cacheControl:i.cacheControl,expires:i.expires}}catch(e){const o=new Uint8Array(i.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cE(t.request),s=new i(t);this.loading[o]=s;const n=new AbortController;s.abort=n;try{const i=yield this.loadVectorTile(t,n);if(delete this.loading[o],!i)return null;const a=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}s.vectorTile=i.vectorTile;const u=s.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[o]=s,this.fetching[o]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[o];}}catch(e){throw delete this.loading[o],s.status="done",this.loaded[o]=s,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid;if(!this.loaded||!this.loaded[o])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const i=this.loaded[o];if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=yield i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let s;if(this.fetching[o]){const{rawTileData:t,cacheControl:i,resourceTiming:n}=this.fetching[o];delete this.fetching[o],s=e.e({rawTileData:t.slice(0)},r,i,n);}else s=r;return s}if("done"===i.status&&i.vectorTile)return i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){const e=this.loading,o=t.uid;e&&e[o]&&e[o].abort&&(e[o].abort.abort(),delete e[o]);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid];}))}}class n{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:i,rawImageData:r,redFactor:s,greenFactor:n,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cF(r,-1,-1,c,u)):r,d=new e.cG(o,h,i,s,n,a,l);return this.loaded=this.loaded||{},this.loaded[o]=d,d}))}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}var a,l,c=function(){if(l)return a;function e(e,o){if(0!==e.length){t(e[0],o);for(var i=1;i=Math.abs(a)?o-l+a:a-l+o,o=l;}o+i>=0!=!!t&&e.reverse();}return l=1,a=function t(o,i){var r,s=o&&o.type;if("FeatureCollection"===s)for(r=0;r>31}function c(e,t){for(var o=e.loadGeometry(),i=e.type,r=0,s=0,n=o.length,c=0;ce},_=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;const M=3,S=5,I=6;class P{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const s=[];for(let t=0;t=o;e--){const o=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,r=180;else if(o>r){const e=this.getClusters([o,i,180,s],t),n=this.getClusters([-180,i,r,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(D(o),C(s),D(r),C(i)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+S]>1?k(l,t,this.clusterProps):this.points[l[t+M]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(i);const s=r.data;if(t*this.stride>=s.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const o=t*this.stride;s[o+4]===e&&l.push(s[o+S]>1?k(s,o,this.clusterProps):this.points[s[o+M]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(o-a)/r,c=(o+1+a)/r,u={features:[]};return this._addTileFeatures(i.range((t-a)/r,l,(t+1+a)/r,c),i.data,t,o,r,u),0===t&&this._addTileFeatures(i.range(1-a/r,l,1,c),i.data,r,o,r,u),t===r-1&&this._addTileFeatures(i.range(0,l,a/r,c),i.data,-1,o,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=i?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,o,i,r):r1;let l,c,u;if(a)l=T(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+M]];l=o.properties;const[i,r]=o.geometry.coordinates;c=D(i),u=C(r);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-o)),Math.round(this.options.extent*(u*r-i))]],tags:l};let d;d=a||this.options.generateId?t[e+M]:this.points[t[e+M]].id,void 0!==d&&(h.id=d),s.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:r,minPoints:s}=this.options,n=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+S]);}if(f>d&&f>=s){let e,s=i*d,n=u*d,g=-1;const p=((o/c|0)<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+S];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=p,r&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)));}a[o+4]=p,l.push(s/f,n/f,1/0,p,-1,f),r&&l.push(g);}else {for(let e=0;e1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+S]>1){const i=this.clusterProps[e[t+I]];return o?Object.assign({},i):i}const i=this.points[e[t+M]].properties,r=this.options.map(i);return o&&r===i?Object.assign({},r):r}}function k(e,t,o){return {type:"Feature",id:e[t+M],properties:T(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),O(e[t+1])]}};var i;}function T(e,t,o){const i=e[t+S],r=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,s=e[t+I],n=-1===s?{}:Object.assign({},o[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+M],point_count:i,point_count_abbreviated:r})}function D(e){return e/360+.5}function C(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function O(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function L(e,t,o,i){let r=i;const s=t+(o-t>>1);let n,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;ir)n=i,r=t;else if(t===r){const e=Math.abs(i-s);ei&&(n-t>3&&L(e,t,n,i),e[n+2]=r,o-n>3&&L(e,n,o,i));}function F(e,t,o,i,r,s){let n=r-o,a=s-i;if(0!==n||0!==a){const l=((e-o)*n+(t-i)*a)/(n*n+a*a);l>1?(o=r,i=s):l>0&&(o+=n*l,i+=a*l);}return n=e-o,a=t-i,n*n+a*a}function G(e,t,o,i){const r={id:null==e?null:e,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)z(r,o);else if("Polygon"===t)z(r,o[0]);else if("MultiLineString"===t)for(const e of o)z(r,e);else if("MultiPolygon"===t)for(const e of o)z(r,e[0]);return r}function z(e,t){for(let o=0;o0&&(n+=i?(r*l-a*s)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-s,2))),r=a,s=l;}const a=t.length-3;t[2]=1,L(t,0,a,o),t[a+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function Z(e,t,o,i){for(let r=0;r1?1:o}function W(e,t,o,i,r,s,n,a){if(i/=t,s>=(o/=t)&&n=i)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const n=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(n>=o&&c=i)continue;let u=[];if("Point"===s||"MultiPoint"===s)R(e,u,o,i,r);else if("LineString"===s)Y(e,u,o,i,r,!1,a.lineMetrics);else if("MultiLineString"===s)q(e,u,o,i,r,!1);else if("Polygon"===s)q(e,u,o,i,r,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];q(t,e,o,i,r,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(G(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(G(t.id,s,u,t.tags));}}return l.length?l:null}function R(e,t,o,i,r){for(let s=0;s=o&&n<=i&&H(t,e[s],e[s+1],e[s+2]);}}function Y(e,t,o,i,r,s,n){let a=V(e);const l=0===r?X:B;let c,u,h=e.start;for(let d=0;do&&(u=l(a,f,g,m,y,o),n&&(a.start=h+c*u)):v>i?w=o&&(u=l(a,f,g,m,y,o),x=!0),w>i&&v<=i&&(u=l(a,f,g,m,y,i),x=!0),!s&&x&&(n&&(a.end=h+c*u),t.push(a),a=V(e)),n&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===r?f:g;p>=o&&p<=i&&H(a,f,g,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&H(a,a[0],a[1],a[2]),a.length&&t.push(a);}function V(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function q(e,t,o,i,r,s){for(const n of e)Y(n,t,o,i,r,s,!1);}function H(e,t,o,i){e.push(t,o,i);}function X(e,t,o,i,r,s){const n=(s-t)/(i-t);return H(e,s,o+(r-o)*n,1),n}function B(e,t,o,i,r,s){const n=(s-o)/(r-o);return H(e,t+(i-t)*n,s,1),n}function $(e,t){const o=[];for(let i=0;i0&&t.size<(r?n:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;en)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;r&&function(e,t){let o=0;for(let t=0,i=e.length,r=i-2;t0===t)for(let t=0,o=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=ee(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(o!==s>>e||i!==n>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,v=null,w=null,x=null,_=W(e,u,o-f,o+p,0,d.minX,d.maxX,l),b=W(e,u,o+g,o+m,0,d.minX,d.maxX,l);e=null,_&&(y=W(_,u,i-f,i+p,1,d.minY,d.maxY,l),v=W(_,u,i+g,i+m,1,d.minY,d.maxY,l),_=null),b&&(w=W(b,u,i-f,i+p,1,d.minY,d.maxY,l),x=W(b,u,i+g,i+m,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(v||[],t+1,2*o,2*i+1),a.push(w||[],t+1,2*o+1,2*i),a.push(x||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:r,debug:s}=i;if(e<0||e>24)return null;const n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[se(c,u,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),s>1&&console.timeEnd("drilling down"),this.tiles[a]?K(this.tiles[a],r):null):null}}function se(e,t,o){return 32*((1<{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,n);},t}(t)).load((yield this._pendingData).features):(r=yield this._pendingData,new re(r,t.geojsonVtOptions)),this.loaded={};const o={};if(i){const e=i.finish();e&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}return o}catch(t){if(delete this._pendingRequest,e.cp(t))return {abandoned:!0};throw t}var r;}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){let i=yield this.loadGeoJSON(t,o);if(delete this._pendingRequest,"object"!=typeof i)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(i,!0),t.filter){const o=e.cL(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const r=i.features.filter((e=>o.value.evaluate({zoom:0},e)));i={type:"FeatureCollection",features:r};}return i}))}loadGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){const{promoteId:i}=t;if(t.request){const r=yield e.j(t.request,o);return this._dataUpdateable=ae(r.data,i)?le(r.data,i):void 0,r.data}if("string"==typeof t.data)try{const e=JSON.parse(t.data);return this._dataUpdateable=ae(e,i)?le(e,i):void 0,e}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return function(e,t,o){var i,r,s,n;if(t.removeAll&&e.clear(),t.remove)for(const o of t.remove)e.delete(o);if(t.add)for(const i of t.add){const t=ne(i,o);null!=t&&e.set(t,i);}if(t.update)for(const o of t.update){let t=e.get(o.id);if(null==t)continue;const a=!o.removeAllProperties&&((null===(i=o.removeProperties)||void 0===i?void 0:i.length)>0||(null===(r=o.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((o.newGeometry||o.removeAllProperties||a)&&(t=Object.assign({},t),e.set(o.id,t),a&&(t.properties=Object.assign({},t.properties))),o.newGeometry&&(t.geometry=o.newGeometry),o.removeAllProperties)t.properties={};else if((null===(s=o.removeProperties)||void 0===s?void 0:s.length)>0)for(const e of o.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:i}of o.addOrUpdateProperties)t.properties[e]=i;}}(this._dataUpdateable,t.dataDiff,i),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class ue{constructor(t){this.self=t,this.actor=new e.H(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.cr,this.self.removeProtocol=e.cs,this.self.registerRTLTextPlugin=t=>{e.cM.setMethods(t);},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,o)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,o.source).removeTile(o);})))),this.actor.registerMessageHandler("GCEZ",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterExpansionZoom(o)})))),this.actor.registerMessageHandler("GCC",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterChildren(o)})))),this.actor.registerMessageHandler("GCL",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterLeaves(o)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,o)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][o.type]||!this.workerSources[t][o.type][o.source])return;const e=this.workerSources[t][o.type][o.source];delete this.workerSources[t][o.type][o.source],void 0!==e.removeSource&&e.removeSource(o);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t];})))),this.actor.registerMessageHandler("SR",((t,o)=>e._(this,void 0,void 0,(function*(){this.referrer=o;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,o)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(o);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(o.layers,o.removedIds);})))),this.actor.registerMessageHandler("SL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(o);}))));}_setImages(t,o){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=o;for(const e in this.workerSources[t]){const i=this.workerSources[t][e];for(const e in i)i[e].availableImages=o;}}))}_syncRTLPluginState(t,o){return e._(this,void 0,void 0,(function*(){return yield e.cM.syncState(o,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let o=this.layerIndexes[e];return o||(o=this.layerIndexes[e]=new t),o}_getWorkerSource(e,t,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][o]){const i={sendAsync:(t,o)=>(t.targetMapId=e,this.actor.sendAsync(t,o))};switch(t){case "vector":this.workerSources[e][t][o]=new s(i,this._getLayerIndex(e),this._getAvailableImages(e));break;case "geojson":this.workerSources[e][t][o]=new ce(i,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][o]=new this.externalWorkerSourceTypes[t](i,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][o]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue})); + +define("index",["exports","./shared"],(function(e,t){"use strict";var i="5.5.0";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let o,a;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,i,r){const o=requestAnimationFrame((e=>{a(),i(e);})),{unsubscribe:a}=t.s(e.signal,"abort",(()=>{a(),cancelAnimationFrame(o),r(t.c());}),!1);},frameAsync(e){return new Promise(((t,i)=>{this.frame(e,t,i);}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(o||(o=document.createElement("a")),o.href=e,o.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==a&&(a=matchMedia("(prefers-reduced-motion: reduce)")),a.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",n.suppressClickInternal,!0);}),0);}static getScale(e){const t=e.getBoundingClientRect();return {x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const o=i.boundingClientRect;return new t.P((r.clientX-o.left)/i.x-e.clientLeft,(r.clientY-o.top)/i.y-e.clientTop)}static mousePos(e,t){const i=n.getScale(e);return n.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=n.getScale(e);for(let o=0;o{c&&_(c),c=null,d=!0;},h.onerror=()=>{u=!0,c=null;},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,r,o,a;e.resetRequestQueue=()=>{i=[],r=0,o=0,a={};},e.addThrottleControl=e=>{const t=o++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],n();},e.getImage=(e,r,o=!0)=>new Promise(((a,s)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:o,state:"queued",onError:e=>{s(e);},onSuccess:e=>{a(e);}}),n();}));const s=e=>t._(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:i,supportImageRefresh:o,onError:a,onSuccess:s,abortController:l}=e,h=!1===o&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((e,t)=>e&&"accept"===t),!0));r++;const u=h?c(i,l):t.m(i,l);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(t){delete e.abortController,a(t);}finally{r--,n();}var d;})),n=()=>{const e=(()=>{for(const e of Object.keys(a))if(a[e]())return !0;return !1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e);}},c=(e,i)=>new Promise(((r,o)=>{const a=new Image,s=e.url,n=e.credentials;n&&"include"===n?a.crossOrigin="use-credentials":(n&&"same-origin"===n||!t.d(s))&&(a.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{a.src="",o(t.c());})),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,r({data:a});},a.onerror=()=>{a.onerror=a.onload=null,i.signal.aborted||o(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},a.src=s;}));}(p||(p={})),p.resetRequestQueue();class m{constructor(e){this._transformRequestFn=e;}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e;}}function f(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:o}of e){const e=`${r}${o}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:o}));}}return t}function g(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}class v{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:o,height:a}=e,s=!(this.size&&this.size[0]===o&&this.size[1]===a||r),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),s)this.size=[o,a],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,o,a,0,this.format,l.UNSIGNED_BYTE,e.data);else {const{x:i,y:s}=r||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,s,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,s,o,a,l.RGBA,l.UNSIGNED_BYTE,e.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D),n.pixelStoreUnpackFlipY.setDefault(),n.pixelStoreUnpack.setDefault(),n.pixelStoreUnpackPremultiplyAlpha.setDefault();}bind(e,t,i){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),i!==o.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=o.LINEAR),e!==this.filter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,t),this.wrap=t);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t);}_validate(e,i){let r=!0;const o=i.data||i.spriteData;return this._validateStretch(i.stretchX,o&&o.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,o&&o.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return !0;let i=0;for(const r of e){if(r[0]{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t});}))}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.l("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return {width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else {const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},o=new t.I(i,r);this.patterns[e]={bin:i,position:o};}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new v(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE);}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),o=this.atlasImage;o.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,a=i.y+1,s=this.getImage(e).data,n=s.width,l=s.height;t.R.copy(s,o,{x:0,y:0},{x:r,y:a},{width:n,height:l}),t.R.copy(s,o,{x:0,y:l-1},{x:r,y:a-1},{width:n,height:1}),t.R.copy(s,o,{x:0,y:0},{x:r,y:a+l},{width:n,height:1}),t.R.copy(s,o,{x:n-1,y:0},{x:r-1,y:a},{width:1,height:l}),t.R.copy(s,o,{x:0,y:0},{x:r+n,y:a},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e);}}}const y=1e20;function w(e,t,i,r,o,a,s,n,l){for(let c=t;c-1);l++,a[l]=n,s[l]=c,s[l+1]=y;}for(let n=0,l=0;n65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[o])return {stack:e,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[o]){const i=P.loadGlyphRange(e,o,this.url,this.requestManager);t.requests[o]=i;}const a=yield t.requests[o];for(const e in a)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=a[+e]);return t.ranges[o]=!0,{stack:e,id:i,glyph:a[i]||null}}))}_doesCharSupportLocalGlyph(e){return !!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||t.u["CJK Unified Ideographs"](e)||t.u["Hangul Syllables"](e)||t.u.Hiragana(e)||t.u.Katakana(e)||t.u["CJK Symbols and Punctuation"](e)||t.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,i,r){const o=this.localIdeographFontFamily;if(!o)return;if(!this._doesCharSupportLocalGlyph(r))return;let a=e.tinySDF;if(!a){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),a=e.tinySDF=new P.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:t});}const s=a.draw(String.fromCharCode(r));return {id:r,bitmap:new t.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}P.loadGlyphRange=function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=256*i,s=a+255,n=o.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${a}-${s}`),"Glyphs"),l=yield t.n(n,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${a}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c}))},P.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:a="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const n=this.size=e+4*t,l=this._createCanvas(n),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${a} ${e}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:a}=this.ctx.measureText(e),s=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-o))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=n+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),_={data:d,width:c,height:h,glyphWidth:n,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(e,m,m+s);const v=p.getImageData(m,m,n,l);g.fill(y,0,u),f.fill(0,0,u);for(let e=0;e0?e*e:0,f[r]=e<0?e*e:0;}}w(g,0,0,c,h,c,this.f,this.v,this.z),w(f,m,m,n,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++a]);const l=Math.abs(n-s.left),c=Math.abs(n-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.data[o+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let o=0,a=e[o];for(let t=0;t1&&(a=e[++o]);const i=Math.abs(t-a.left),s=Math.abs(t-a.right),n=Math.min(i,s);this.data[r+t]=Math.max(0,Math.min(255,(a.isDash?n:-n)+128));}}addDash(e,i){const r=i?7:0,o=2*r+1;if(this.nextRow+o>this.height)return t.w("LineAtlas out of space"),null;let a=0;for(let t=0;t{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[z]}numActive(){return Object.keys(this.active).length}}const A=Math.floor(s.hardwareConcurrency/2);let L,k;function F(){return L||(L=new D),L}D.workerCount=t.G(globalThis)?Math.max(Math.min(A,3),1):1;class B{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let e=0;e{e.remove();})),this.actors=[],e&&this.workerPool.release(this.id);}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t);}}function O(){return k||(k=new B(F(),t.J),k.registerMessageHandler("GR",((e,i,r)=>t.m(i,r)))),k}function j(e,i){const r=t.K();return t.L(r,r,[1,1,0]),t.M(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.N(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function Z(e,t,i,r,o,a,s){var n;const l=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return !0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return !0}return !1}(null!==(n=null==o?void 0:o.layers)&&void 0!==n?n:null,t,e.id),c=a.maxPitchScaleFactor(),h=e.tilesIn(r,c,l);h.sort(N);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,o,a,c,j(e.transform,r.tileID),s?(e,t)=>s(r.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const r of e[i])U(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,o=r.wrappedTileID,a=i[o]=i[o]||{};for(const i in e){const r=e[i],o=a[i]=a[i]||{},s=t[i]=t[i]||[];for(const e of r)o[e.featureIndex]||(o[e.featureIndex]=!0,s.push(e));}}return t}(u),e)}function N(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function U(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r;}function G(e,i,r){return t._(this,void 0,void 0,(function*(){let o=e;if(e.url?o=(yield t.j(i.transformRequest(e.url,"Source"),r)).data:yield s.frameAsync(r),!o)return null;const a=t.O(t.e(o,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in o&&o.vector_layers&&(a.vectorLayerIds=o.vector_layers.map((e=>e.id))),a}))}class V{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])));}setNorthEast(e){return this._ne=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}extend(e){const i=this._sw,r=this._ne;let o,a;if(e instanceof t.Q)o=e,a=e;else {if(!(e instanceof V))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(V.convert(e)):this.extend(t.Q.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.Q.convert(e)):this;if(o=e._sw,a=e._ne,!o||!a)return this}return i||r?(i.lng=Math.min(o.lng,i.lng),i.lat=Math.min(o.lat,i.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)):(this._sw=new t.Q(o.lng,o.lat),this._ne=new t.Q(a.lng,a.lat)),this}getCenter(){return new t.Q((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.Q(this.getWest(),this.getNorth())}getSouthEast(){return new t.Q(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:r}=t.Q.convert(e);let o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&o}static convert(e){return e instanceof V?e:e?new V(e):e}static fromLngLat(e,i=0){const r=360*i/40075017,o=r/Math.cos(Math.PI/180*e.lat);return new V(new t.Q(e.lng-o,e.lat-r),new t.Q(e.lng+o,e.lat+r))}adjustAntiMeridian(){const e=new t.Q(this._sw.lng,this._sw.lat),i=new t.Q(this._ne.lng,this._ne.lat);return new V(e,e.lng>i.lng?new t.Q(i.lng+360,i.lat):i)}}class q{constructor(e,t,i){this.bounds=V.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.U(this.bounds.getWest())*i),o=Math.floor(t.S(this.bounds.getNorth())*i),a=Math.ceil(t.U(this.bounds.getEast())*i),s=Math.ceil(t.S(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((t,i)=>{e.reloadPromise={resolve:t,reject:i};}))}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null);}}))}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject);}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class H extends t.E{constructor(e,i,r,o){super(),this.id=e,this.dispatcher=r,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.O(i,["url","scheme","tileSize"]));}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield G(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e));}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}serialize(){return t.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const i=yield p.getImage(this.map._requestManager.transformRequest(t,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const t=this.map.painter.context,r=t.gl,o=i.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new v(t,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController);}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture);}))}hasTransition(){return !1}}class $ extends H{constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield p.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const o=t.b(r)&&t.V()?r:yield this.readImageNow(r),a={type:this.type,uid:e.uid,source:this.id,rawImageData:o,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:a});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded";}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.W()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.X(e,-1,-1,i,r))}catch(e){}}return s.getImageData(e,1)}))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,a=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,n=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.Y(e.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.Y(e.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return t._(this,void 0,void 0,(function*(){const e=new V,t=yield this.getData();let i;switch(t.type){case "FeatureCollection":i=t.features.map((e=>this.getCoordinatesFromGeometry(e.geometry))).flat(1/0);break;case "Feature":i=this.getCoordinatesFromGeometry(t.geometry);break;default:i=this.getCoordinatesFromGeometry(t);}if(0==i.length)return e;for(let t=0;t0&&t.e(o,{resourceTiming:r}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content"})));}catch(e){if(this._pendingLoads--,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e));}}))}loaded(){return 0===this._pendingLoads}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t);}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0;}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}}class K extends t.E{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t;}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield p.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading());}catch(e){this._request=null,this._loaded=!0,this.fire(new t.k(e));}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.$.fromLngLat);var r;return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s=Math.max(o-i,a-r),n=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,n);return new t.a1(n,Math.floor((i+o)/2*l),Math.floor((r+a)/2*l))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new v(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}_getOverlappingTileRanges(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s={};for(let e=0;e<=t.a0;e++){const t=Math.pow(2,e),n=Math.floor(i*t),l=Math.floor(r*t),c=Math.floor(o*t),h=Math.floor(a*t);s[e]={minTileX:n,minTileY:l,maxTileX:c,maxTileY:h};}return s}}class Q extends K{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a2(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading();}catch(e){this.fire(new t.k(e));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.a3(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new v(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Y extends K{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.a3(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new v(i,this.canvas,r.RGBA,{premultiply:!0});let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}}const J={},ee=e=>{switch(e){case "geojson":return X;case "image":return K;case "raster":return H;case "raster-dem":return $;case "vector":return W;case "video":return Q;case "canvas":return Y}return J[e]},te="RTLPluginLoaded";class ie extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=O();}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(te));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let re=null;function oe(){return re||(re=new ie),re}class ae{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a4(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r;}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6&&i.hasRTLText){this.hasRTLText=!0,oe().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage);}else this.collisionBoxArray=new t.a5;}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new v(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new v(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null);}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture);}queryRenderedFeatures(e,t,i,r,o,a,s,n,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:o,scale:a,tileSize:this.tileSize,pixelPosMatrix:c,transform:n,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const o=r.loadVTLayers(),a=i&&i.sourceLayer?i.sourceLayer:"",s=o._geojsonTileLayer||o[a];if(!s)return;const n=t.a7(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,o);}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class ne{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,i,r){const o=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},t.e(this.stateChanges[e][o],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null);}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,i){const r=String(i),o=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete o[e];}return o}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,i){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}r[e]=r[e]||{},t.e(r[e],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i);}}const le=89.25;function ce(e,i){const r=t.ae(i.lat,-85.051129,t.af);return new t.P(t.U(i.lng)*e,t.S(r)*e)}function he(e,i){return new t.$(i.x/e,i.y/e).toLngLat()}function ue(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.ab(90-e.pitch)),Math.tan(t.ab(le-e.pitch)))}function de(e,i){const r=e.canonical,o=i/t.ac(r.z),a=r.x+Math.pow(2,r.z)*e.wrap,s=t.ad(new Float64Array(16));return t.L(s,s,[a*o,r.y*o,0]),t.M(s,s,[o/t.Z,o/t.Z,1]),s}function _e(e,i,r,o,a){const s=t.$.fromLngLat(e,i),n=a*t.ag(1,e.lat),l=n*Math.cos(t.ab(r)),c=Math.sqrt(n*n-l*l),h=c*Math.sin(t.ab(-o)),u=c*Math.cos(t.ab(-o));return new t.$(s.x+h,s.y+u,s.z+l)}function pe(e,t,i){const r=t.intersectsFrustum(e);if(!i)return r;const o=t.intersectsPlane(i);return 0===r||0===o?0:2===r&&2===o?2:1}function me(e,t,i){let r=0;const o=(i-t)/10;for(let a=0;a<10;a++)r+=o*Math.pow(Math.cos(t+(a+.5)/10*(i-t)),e);return r}function fe(e,i){return function(r,o,a,s,n){const l=2*((e-1)/t.ah(Math.cos(t.ab(le-n))/Math.cos(t.ab(le)))-1),c=Math.acos(a/s),h=2*me(l-1,0,t.ab(n/2)),u=Math.min(t.ab(le),c+t.ab(n/2)),d=me(l-1,Math.min(u,c-t.ab(n/2)),u),_=Math.atan(o/a),p=Math.hypot(o,a);let m=r;return m+=t.ah(s/p/Math.max(.5,Math.cos(t.ab(n/2)))),m+=l*t.ah(Math.cos(_))/2,m-=t.ah(Math.max(1,d/h/i))/2,m}}const ge=fe(9.314,3);function ve(e,i){const r=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ah(e.tileSize/i.tileSize));return Math.max(0,r)}function xe(e,i){const r=e.getCameraFrustum(),o=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.$.fromLngLat(e.center,e.elevation);a.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const n=e.getCoveringTilesDetailsProvider(),l=n.allowVariableZoom(e,i),c=ve(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),_=Math.pow(2,d),p=[_*a.x,_*a.y,0],m=[_*s.x,_*s.y,0],f=Math.hypot(s.x-a.x,s.y-a.y),g=Math.abs(s.z-a.z),v=Math.hypot(f,g),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],y=[];if(e.renderWorldCopies&&n.allowWorldCopies())for(let e=1;e<=3;e++)b.push(x(-e)),b.push(x(e));for(b.push(x(0));b.length>0;){const _=b.pop(),f=_.x,x=_.y;let w=_.fullyVisible;const T={x:f,y:x,z:_.zoom},P=n.getTileAABB(T,_.wrap,e.elevation,i);if(!w){const e=pe(r,P,o);if(0===e)continue;w=2===e;}const C=n.distanceToTile2d(a.x,a.y,T,P);let M=c;l&&(M=(i.calculateTileZoom||ge)(e.zoom+t.ah(e.tileSize/i.tileSize),C,g,v,e.fov)),M=(i.roundZoom?Math.round:Math.floor)(M),M=Math.max(0,M);const I=Math.min(M,u);if(_.wrap=n.getWrap(s,T,_.wrap),_.zoom>=I){if(_.zoom>1),wrap:_.wrap,fullyVisible:w});}return y.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}class be extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((e,t,i,r)=>{const o=new(ee(t.type))(e,t,i,r);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return o})(e,t,i,this),this._tiles={},this._cache=new se(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ne,this._didEmitContent=!1,this._updated=!1;}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e);}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(e,i,r){return t._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,r);}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain);}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e);}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(ye).map((e=>e.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,o=i.tileID,a=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(o.canonical.x,o.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-o.overscaledZ||s.y-a.y||s.x-a.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(ye).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)(e||"errored"!==this._tiles[t].state)&&this._reloadTile(t,"reloading");}}_reloadTile(e,i){return t._(this,void 0,void 0,(function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i));}))}_tileLoaded(e,i,r){e.timeAdded=s.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[a]&&(e.neighboringTiles[a].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const o in this._tiles){let a=this._tiles[o];if(r[o]||!a.hasData()||a.tileID.overscaledZ<=t||a.tileID.overscaledZ>i)continue;let s=a.tileID;for(;a&&a.tileID.overscaledZ>t+1;){const e=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[e.key],a&&a.hasData()&&(s=e);}let n=s;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]||e[n.canonical.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e]);}}_updateCoveredAndRetainedTiles(e,t,i,r,o,a){const n={},l={},c=Object.keys(e),h=s.now();for(const i of c){const r=e[i],o=this._tiles[i];if(!o||0!==o.fadeEndTime&&o.fadeEndTime<=h)continue;const a=this.findLoadedParent(r,t),s=this.findLoadedSibling(r),c=a||s||null;c&&(this._addTile(c.tileID),n[c.tileID.key]=c.tileID),l[i]=r;}this._retainLoadedChildren(l,r,i,e);for(const t in n)e[t]||(this._coveredTiles[t]=!0,e[t]=n[t]);if(a){const t={},i={};for(const e of o)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const r in i){const o=i[r].children(this._source.maxzoom);this._tiles[o[0].key]&&this._tiles[o[1].key]&&this._tiles[o[2].key]&&this._tiles[o[3].key]&&(t[o[0].key]=e[o[0].key]=o[0],t[o[1].key]=e[o[1].key]=o[1],t[o[2].key]=e[o[2].key]=o[2],t[o[3].key]=e[o[3].key]=o[3],delete i[r]);}for(const r in i){const o=i[r],a=this.findLoadedParent(o,this._source.minzoom),s=this.findLoadedSibling(o),n=a||s||null;if(n){t[n.tileID.key]=e[n.tileID.key]=n.tileID;for(const e in t)t[e].isChildOf(n.tileID)&&delete t[e];}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0);}}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.Y(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=xe(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const o=ve(e,this._source),a=Math.max(o-be.maxOverzooming,this._source.minzoom),s=Math.max(o+be.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of r)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const r=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[r.key]=r;}r=r.concat(Object.values(e));}const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,o);we(this._source.type)&&this._updateCoveredAndRetainedTiles(l,a,s,o,r,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.aj(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e);}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e);}_updateRetainedTiles(e,t){var i;const r={},o={},a=Math.max(t-be.maxOverzooming,this._source.minzoom),s=Math.max(t+be.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);r[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=s.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){r[e.key]=e;continue}}else {const e=s.children(this._source.maxzoom);if(r[e[0].key]&&r[e[1].key]&&r[e[2].key]&&r[e[3].key])continue}let n=e.wasRequested();for(let t=s.overscaledZ-1;t>=a;--t){const a=s.scaledTo(t);if(o[a.key])break;if(o[a.key]=!0,e=this.getTile(a),!e&&n&&(e=this._addTile(a)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=e.wasRequested(),t)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i;}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new ae(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}refreshTiles(e){for(const t in this._tiles)this._isIdRenderable(t)&&e.some((e=>e.equals(this._tiles[t].tileID.canonical)))&&this._reloadTile(t,"expired");}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset();}tilesIn(e,i,r){const o=[],a=this.transform;if(!a)return o;const s=r?a.getCameraQueryGeometry(e):e,n=e.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),l=s.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),c=this.getIds();let h=1/0,u=1/0,d=-1/0,_=-1/0;for(const e of l)h=Math.min(h,e.x),u=Math.min(u,e.y),d=Math.max(d,e.x),_=Math.max(_,e.y);for(let e=0;e=0&&f[1].y+m>=0){const e=n.map((e=>s.getTilePoint(e))),t=l.map((e=>s.getTilePoint(e)));o.push({tile:r,tileID:s,queryGeometry:e,cameraQueryGeometry:t,scale:p});}}return o}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return !0;if(we(this._source.type)){const e=s.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}}function ye(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function we(e){return "raster"===e||"image"===e||"video"===e}be.maxOverzooming=10,be.maxUnderzooming=3;class Te{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(o-s)/n:0;return this.points[a].mult(1-l).add(this.points[i].mult(l))}}function Pe(e,t){let i=!0;return "always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Ce{constructor(e,t,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return [];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(o)return [{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e0}hitTestCircle(e,t,i,r,o){const a=e-i,s=e+i,n=t-i,l=t+i;if(s<0||a>this.width||l<0||n>this.height)return !1;const c=[];return this._forEachCell(a,n,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},o),c.length>0}_queryCell(e,t,i,r,o,a,s,n){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const o=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,d=this.boxKeys[s];if(e<=o[u+2]&&t<=o[u+3]&&i>=o[u+0]&&r>=o[u+1]&&(!n||n(d))&&(!c||!Pe(h,d.overlapMode))&&(a.push({key:d,x1:o[u],y1:o[u+1],x2:o[u+2],y2:o[u+3]}),c))return !0}}const d=this.circleCells[o];if(null!==d){const o=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],e,t,i,r)&&(!n||n(d))&&(!c||!Pe(h,d.overlapMode))){const e=o[u],t=o[u+1],i=o[u+2];if(a.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return !0}}}return !1}_queryCellCircle(e,t,i,r,o,a,s,n){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(r))&&!Pe(h,r.overlapMode))return a.push(!0),!0}}const d=this.circleCells[o];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!n||n(r))&&!Pe(h,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,i,r,o,a,s,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(o.call(this,e,t,i,r,this.xCellCount*l+d,a,s,n))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,o,a){const s=r-e,n=o-t,l=i+a;return l*l>s*s+n*n}_circleAndRectCollide(e,t,i,r,o,a,s){const n=(a-r)/2,l=Math.abs(e-(r+n));if(l>n+i)return !1;const c=(s-o)/2,h=Math.abs(t-(o+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}function Me(e,i,o){const a=t.K();if(!e){const{vecSouth:e,vecEast:t}=Ee(i),o=r();o[0]=t[0],o[1]=t[1],o[2]=e[0],o[3]=e[1],s=o,(d=(l=(n=o)[0])*(u=n[3])-(h=n[2])*(c=n[1]))&&(s[0]=u*(d=1/d),s[1]=-c*d,s[2]=-h*d,s[3]=l*d),a[0]=o[0],a[1]=o[1],a[4]=o[2],a[5]=o[3];}var s,n,l,c,h,u,d;return t.M(a,a,[1/o,1/o,1]),a}function Ie(e,i,r,o){if(e){const e=t.K();if(!i){const{vecSouth:t,vecEast:i}=Ee(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1];}return t.M(e,e,[o,o,1]),e}return r.pixelsToClipSpaceMatrix}function Ee(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),o=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),n=t.ao();n[0]=-a*o*r-s*i,n[1]=-s*o*r+a*i;const l=t.ap(n);l<1e-9?t.aq(n):t.ar(n,n,1/l);const c=t.ao();c[0]=a*o*i-s*r,c[1]=s*o*i+a*r;const h=t.ap(c);return h<1e-9?t.aq(c):t.ar(c,c,1/h),{vecEast:c,vecSouth:n}}function Se(e,i,r,o){let a;o?(a=[e,i,o(e,i),1],t.at(a,a,r)):(a=[e,i,0,1],We(a,a,r));const s=a[3];return {point:new t.P(a[0]/s,a[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Re(e,t){return .5+e/t*.5}function ze(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function De(e,i,r,o,a,s,n,l,c,h,u,d,_){const p=r?e.textSizeData:e.iconSizeData,m=t.ak(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const v=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let y=!1;for(let r=0;rMath.abs(r.x-i.x)*o?{useVertical:!0}:(e===t.al.vertical?i.yr.x)?{needsFlipping:!0}:null}function ke(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:o,fontSize:a,flip:s,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=a/24,_=o.lineOffsetX*d,p=o.lineOffsetY*d;let m;if(o.numGlyphs>1){const e=o.glyphStartIndex+o.numGlyphs,t=o.lineStartIndex,a=o.lineStartIndex+o.lineLength,c=Ae(d,l,_,p,s,o,u,i);if(!c)return {notEnoughRoom:!0};const f=je(c.first.point.x,c.first.point.y,i,r),g=je(c.last.point.x,c.last.point.y,i,r);if(n&&!s){const e=Le(o.writingMode,f,g,h);if(e)return e}m=[c.first];for(let r=o.glyphStartIndex+1;r0?n.point:Fe(i.tileAnchorPoint,s,e,1,i),c=je(e.x,e.y,i,r),u=je(l.x,l.y,i,r),d=Le(o.writingMode,c,u,h);if(d)return d}const e=Ge(d*l.getoffsetX(o.glyphStartIndex),_,p,s,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[e];}for(const e of m)t.as(c,e.point,e.angle);return {}}function Fe(e,t,i,r,o){const a=e.add(e.sub(t)._unit()),s=Oe(a.x,a.y,o).point,n=i.sub(s);return i.add(n._mult(r/n.mag()))}function Be(e,i,r){const o=i.projectionCache;if(o.projections[e])return o.projections[e];const a=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Oe(a.x,a.y,i);if(s.signedDistanceFromCamera>0)return o.projections[e]=s.point,o.anyProjectionOccluded=o.anyProjectionOccluded||s.isOccluded,s.point;const n=e-r.direction;return Fe(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),a,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Oe(e,t,i){const r=e+i.translation[0],o=t+i.translation[1];let a;return i.pitchWithMap?(a=Se(r,o,i.pitchedLabelPlaneMatrix,i.getElevation),a.isOccluded=!1):(a=i.transform.projectTileCoordinates(r,o,i.unwrappedTileID,i.getElevation),a.point.x=(.5*a.point.x+.5)*i.width,a.point.y=(.5*-a.point.y+.5)*i.height),a}function je(e,i,r,o){if(r.pitchWithMap){const a=[e,i,0,1];return t.at(a,a,o),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}return {x:e/r.width*2-1,y:i/r.height*2-1}}function Ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ne(e,t,i){return e._unit()._perp()._mult(t*i)}function Ue(e,i,r,o,a,s,n,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=r.add(i);if(e+c.direction=a)return l.projectionCache.offsets[e]=h,h;const u=Be(e+c.direction,l,c),d=Ne(u.sub(r),n,c.direction),_=r.add(d),p=u.add(d);return l.projectionCache.offsets[e]=t.au(s,h,_,p)||h,l.projectionCache.offsets[e]}function Ge(e,t,i,r,o,a,s,n,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,_=h>0?a+o:a+o+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=Oe(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const b=Math.abs(c),y=[];let w;for(;v+x<=b;){if(_+=h,_=s)return null;v+=x,g=f,m=p;const e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:g};if(f=Be(_,n,e),0===i)y.push(g),w=f.sub(g);else {let t;const r=f.sub(g);t=0===r.mag()?Ne(Be(_+h,n,e).sub(f),i,h):Ne(r,i,h),m||(m=g.add(t)),p=Ue(_,t,f,a,s,m,i,n,e),y.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((b-v)/x)._add(m||g),P=u+Math.atan2(f.y-g.y,f.x-g.x);return y.push(T),{point:T,angle:l?P:0,path:y}}const Ve=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function qe(e,t){for(let i=0;i=1;e--)_.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let f=[];if(_.length>0){const e=_[0].clone(),i=_[0].clone();for(let t=1;t<_.length;t++)e.x=Math.min(e.x,_[t].x),e.y=Math.min(e.y,_[t].y),i.x=Math.max(i.x,_[t].x),i.y=Math.max(i.y,_[t].y);f=e.x>=r.x&&i.x<=o.x&&e.y>=r.y&&i.y<=o.y?[_]:i.xo.x||i.yo.y?[]:t.av([_],r.x,r.y,o.x,o.y);}for(const t of f){a.reset(t,.25*i);let r=0;r=a.length<=.5*i?1:Math.ceil(a.paddedLength/p)+1;for(let t=0;t{const t=Se(e.x,e.y,r,i.getElevation),o=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height,o}))}(e,i);return function(e){let t=0,i=0,r=0,o=0;for(let a=0;ai&&(i=o,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let r=1/0,o=1/0,a=-1/0,s=-1/0;for(const n of e){const e=new t.P(n.x+He,n.y+He);r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y),i.push(e);}const n=this.grid.query(r,o,a,s).concat(this.ignoredGrid.query(r,o,a,s)),l={},c={};for(const e of n){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const o=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aw(i,o)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex));}return c}insertCollisionBox(e,t,i,r,o,a){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,r,o,a){const s=i?this.ignoredGrid:this.grid,n={bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t};for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,o,c,u)));S=e.some((e=>!e.isOccluded)),E=e.map((e=>new t.P(e.x,e.y)));}else S=!0;return {box:t.ax(E),allPointsOccluded:!S}}}class Xe{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Ke{constructor(e,t,i,r,o){this.text=new Xe(e?e.text:null,t,i,o),this.icon=new Xe(e?e.icon:null,t,r,o);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Qe{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i;}}class Ye{constructor(e,t,i,r,o){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=o;}}class Je{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function et(e,i,r,o,a){const{horizontalAlign:s,verticalAlign:n}=t.aE(e);return new t.P(-(s-.5)*i+o[0]*a,-(n-.5)*r+o[1]*a)}class tt{constructor(e,t,i,r,o){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new $e(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Je(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,o){const a=r.getBucket(i),s=r.latestFeatureIndex;if(!a||!s||i.id!==a.layerIds[0])return;const n=r.collisionBoxArray,l=a.layers[0].layout,c=a.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.Z,d=r.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=t.az(r,1,this.transform.zoom),m=t.aA(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),f=t.aA(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),g=Me(_,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new Ye(a.bucketInstanceId,s,a.sourceLayerIndex,a.index,r.tileID);const v={bucket:a,layout:l,translationText:m,translationIcon:f,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.ak(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(o)for(const t of a.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:v});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v});}attemptAnchorPlacement(e,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v,x,b){const y=t.aB[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=et(y,r,o,w,a),P=this.collisionIndex.placeCollisionBox(i,d,l,c,h,n,s,f,u.predicate,x,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,c,h,n,s,g,u.predicate,x,T,b).placeable)&&P.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID].text&&(e=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:w,width:r,height:o,anchor:y,textBoxScale:a,prevAnchor:e},this.markUsedJustification(p,y,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:T,placedGlyphBoxes:P}}}placeLayerBucketPart(e,i,r){const{bucket:o,layout:a,translationText:s,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=e.parameters,m=a.get("text-optional"),f=a.get("icon-optional"),g=t.aC(a,"text-overlap","text-allow-overlap"),v="always"===g,x=t.aC(a,"icon-overlap","icon-allow-overlap"),b="always"===x,y="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),T="none"!==a.get("icon-text-fit"),P="viewport-y"===a.get("symbol-z-order"),C=v&&(b||!o.hasIconData()||f),M=b&&(v||!o.hasTextData()||m);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d);const I=this.retainedQueryData[o.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(I),S=this.transform.getFastPathSimpleProjectionMatrix(I),R=(e,d,b)=>{var P,R;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new Qe(!1,!1,!1));let z=!1,D=!1,A=!0,L=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,j=null,Z=0,N=0,U=0;d.textFeatureIndex?Z=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(Z=e.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let r=t.al.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(o,r,e));}return r},a=(i,r)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===t.al.vertical?(k=r(),F=k):k=i(),k&&k.placeable)break}else k=i();},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,h,I,l,w,y,s,p.predicate,E,void 0,S);return r&&r.placeable&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),r};a((()=>r(G,t.al.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.al.vertical):{box:null,offscreen:null}})),i(k&&k.placeable);}else {let _=t.aB[null===(R=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[e.crossTileID])||void 0===R?void 0:R.anchor];const m=(t,i,a)=>{const d=t.x2-t.x1,m=t.y2-t.y1,f=e.textBoxScale,v=T&&"never"===x?i:null;let b=null,P="never"===g?1:2,C="never";_&&P++;for(let i=0;im(G,d.iconBox,t.al.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.al.vertical):{box:null,occluded:!0,offscreen:null}})),k&&(z=k.placeable,A=k.offscreen);const f=i(k&&k.placeable);if(!z&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,f));}}}if(B=k,z=B&&B.placeable,A=B&&B.offscreen,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),n=t.am(o.textSizeData,_,i),h=a.get("text-padding");O=this.collisionIndex.placeCollisionCircles(g,i,o.lineVertexArray,o.glyphOffsetArray,n,l,c,r,w,p.predicate,e.collisionCircleDiameter,h,s,E),O.circles.length&&O.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),z=v||O.circles.length>0&&!O.collisionDetected,A=A&&O.offscreen;}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,I,l,w,y,n,p.predicate,E,T&&L?L:void 0,S);F&&F.placeable&&d.verticalIconBox?(j=e(d.verticalIconBox),D=j.placeable):(j=e(d.iconBox),D=j.placeable),A=A&&j.offscreen;}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,q=f||0===e.numIconVertices;V||q?q?V||(D=D&&z):z=D&&z:D=z=D&&z;const W=D&&j.placeable;if(z&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,a.get("text-ignore-placement"),o.bucketInstanceId,F&&F.placeable&&N?N:Z,p.ID),W&&this.collisionIndex.insertCollisionBox(j.box,x,a.get("icon-ignore-placement"),o.bucketInstanceId,U,p.ID),O&&z&&this.collisionIndex.insertCollisionCircles(O.circles,g,a.get("text-ignore-placement"),o.bucketInstanceId,Z,p.ID),r&&this.storeCollisionData(o.bucketInstanceId,b,d,B,j,O),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===o.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Qe((z||C)&&!(null==B?void 0:B.occluded),(D||M)&&!(null==j?void 0:j.occluded),A||o.justReloaded),i[e.crossTileID]=!0;};if(P){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=o.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];R(o.symbolInstances.get(i),o.collisionArrays[i],i);}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID);}markUsedOrientation(e,i,r){const o=i===t.al.horizontal||i===t.al.horizontalOnly?i:0,a=i===t.al.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,o=t?t.opacities:{},a=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],a=o[e];a?(this.opacities[e]=new Ke(a,r,t.text,t.icon),i=i||t.text!==a.text.placed||t.icon!==a.icon.placed):(this.opacities[e]=new Ke(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon);}for(const e in o){const t=o[e];if(!this.opacities[e]){const o=new Ke(t,r,!1,!1);o.isHidden()||(this.opacities[e]=o,i=i||t.text.placed||t.icon.placed);}}for(const e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray);}}updateBucketOpacities(e,i,r,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const a=e.layers[0],s=a.layout,n=new Ke(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),_="none"!==s.get("icon-text-fit"),p=new Ke(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const m=(e,t,i)=>{for(let r=0;r0,v=this.placedOrientations[o.crossTileID],x=v===t.al.vertical,b=v===t.al.horizontal||v===t.al.horizontalOnly;if(a>0||s>0){const t=ht(c.text);m(e.text,a,x?ut:t),m(e.text,s,b?ut:t);const i=c.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||x?1:0);})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||b?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o));}if(g){const t=ht(c.icon),i=!(_&&o.verticalPlacedIconSymbolIndex&&x);o.placedIconSymbolIndex>=0&&(m(e.icon,o.numIconVertices,i?t:ut),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=c.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,o.numVerticalIconVertices,i?ut:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden());}const y=f&&f.has(i)?f.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const r=e.collisionArrays[i];if(r){let i=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(i=et(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1;}if(r.textBox||r.verticalTextBox){let o;r.textBox&&(o=x),r.verticalTextBox&&(o=b),it(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||o,y.text,i.x,i.y);}}if(r.iconBox||r.verticalIconBox){const t=Boolean(!b&&r.verticalIconBox);let o;r.iconBox&&(o=t),r.verticalIconBox&&(o=!t),it(e.iconCollisionBox.collisionVertexArray,c.icon.placed,o,y.icon,_?i.x:0,_?i.y:0);}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId]);}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function it(e,t,i,r,o,a){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-He,n=r[1]-He,l=r[2]-He,c=r[3]-He;e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,c),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,c);}const rt=Math.pow(2,25),ot=Math.pow(2,24),at=Math.pow(2,17),st=Math.pow(2,16),nt=Math.pow(2,9),lt=Math.pow(2,8),ct=Math.pow(2,1);function ht(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*rt+t*ot+i*at+t*st+i*nt+t*lt+i*ct+t}const ut=0;class dt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,r,o){const a=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex!this._forceFullPlacement&&s.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=a)&&(!r.maxzoom||r.maxzoom>a)){if(this._inProgressLayer||(this._inProgressLayer=new dt(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const pt=512/t.Z/2;class mt{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const o=new Map;for(let e=0;e({x:Math.floor(e.anchorX*pt),y:Math.floor(e.anchorY*pt)}))),crossTileIDs:i.map((e=>e.crossTileID))};if(r.positions.length>128){const e=new t.aF(r.positions.length,16,Uint16Array);for(const{x:t,y:i}of r.positions)e.add(t,i);e.finish(),delete r.positions,r.index=e;}this._symbolsByKey[e]=r;}}getScaledCoordinates(e,i){const{x:r,y:o,z:a}=this.tileID.canonical,{x:s,y:n,z:l}=i.canonical,c=pt/Math.pow(2,l-a),h=(n*t.Z+e.anchorY)*c,u=o*t.Z*pt;return {x:Math.floor((s*t.Z+e.anchorX)*c-r*t.Z*pt),y:Math.floor(h-u)}}findMatches(e,t,i){const r=this.tileID.canonical.ze))}}class ft{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class gt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const o=i[e];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),r[o.tileID.key]=o;}this.indexes[e]=r;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in o){const a=o[i];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,r);}else {const a=o[e.scaledTo(Number(i)).key];a&&a.findMatches(t.symbolInstances,e,r);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var xt="void main() {fragColor=vec4(1.0);}";const bt={prelude:yt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:yt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:yt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:yt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:yt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:yt("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:yt(xt,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:yt("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:yt("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:yt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:yt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:yt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:yt(xt,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:yt("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:yt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:yt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:yt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:yt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:yt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;switch(u_method){case BASIC:\nbasic_hillshade(deriv);break;case COMBINED:\ncombined_hillshade(deriv);break;case IGOR:\nigor_hillshade(deriv);break;case MULTIDIRECTIONAL:\nmultidirectional_hillshade(deriv);break;case STANDARD:\ndefault:\nstandard_hillshade(deriv);break;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:yt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:yt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:yt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:yt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:yt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:yt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:yt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:yt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:yt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:yt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:yt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:yt("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:yt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function yt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=a?a.concat(o):o,n={};return {fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\nout ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,staticUniforms:s}}class wt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}var Tt=t.aG([{name:"a_pos",type:"Int16",components:2}]);const Pt="#define PROJECTION_MERCATOR",Ct="mercator";class Mt{constructor(){this._cachedMesh=null;}get name(){return "mercator"}get useSubdivision(){return !1}get shaderVariantName(){return Ct}get shaderDefine(){return Pt}get shaderPreludeCode(){return bt.projectionMercator}get vertexShaderPreludeCode(){return bt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aH.noSubdivision}get useGlobeControls(){return !1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,o,a){if(this._cachedMesh)return this._cachedMesh;const s=new t.aI;s.emplaceBack(0,0),s.emplaceBack(t.Z,0),s.emplaceBack(0,t.Z),s.emplaceBack(t.Z,t.Z);const n=e.createVertexBuffer(s,Tt.members),l=t.aJ.simpleSegment(0,0,4,2),c=new t.aK;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new wt(n,h,l),this._cachedMesh}recalculate(){}hasTransition(){return !1}setErrorQueryLatitudeDegrees(e){}}class It{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r;}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.B.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.B.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.B.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.B.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.ae((this.left+e-this.right)/2,0,e),o=t.ae((this.top+i-this.bottom)/2,0,i);return new t.P(r,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new It(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Et(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0;}function St(e){return Math.max(0,Math.floor(e))}class Rt{constructor(e,i,r,o,a,s){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==o?0:o,this._maxPitch=null==a?60:a,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.Q(0,0),this._elevation=0,this._zoom=0,this._tileZoom=St(this._zoom),this._scale=t.ac(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new It,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0;}apply(e,i,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=St(this._zoom),this._scale=t.ac(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new It(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices();}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e;}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)));}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)));}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aL(e,-180,180)*Math.PI/180;var o,a,s,n,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),o=this._rotationMatrix,s=-this._bearingInRadians,n=(a=this._rotationMatrix)[0],l=a[1],c=a[2],h=a[3],u=Math.sin(s),d=Math.cos(s),o[0]=n*d+c*u,o[1]=l*d+h*u,o[2]=n*-u+c*d,o[3]=l*-u+h*d);}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ae(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices());}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices());}get fovInRadians(){return this._fovInRadians}get fov(){return t.aM(this._fovInRadians)}setFov(e){e=t.ae(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ab(e),this._calcMatrices());}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.ac(i),this._constrain(),this._calcMatrices());}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices();}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices();}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices();}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new V([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-85.051129,t.af]);}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return [i[0],e];{let r=e.x,o=e.y,a=e.x,s=e.y;for(const e of i)r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y);return [new t.P(r,o),new t.P(a,o),new t.P(a,s),new t.P(r,s),new t.P(r,o)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1;}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ad(new Float64Array(16));t.M(e,e,[this._width/2,-this._height/2,1]),t.L(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ad(new Float64Array(16)),t.M(e,e,[1,-1,1]),t.L(e,e,[-1,-1,0]),t.M(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height;}this._callbacks.calcMatrices();}calculateCenterFromCameraLngLatAlt(e,i,r,o){const a=void 0!==r?r:this.bearing,s=o=void 0!==o?o:this.pitch,n=t.$.fromLngLat(e,i),l=-Math.cos(t.ab(s)),c=Math.sin(t.ab(s)),h=c*Math.sin(t.ab(a)),u=-c*Math.cos(t.ab(a));let d=this.elevation;const _=i-d;let p;l*_>=0||Math.abs(l)<.1?(p=1e4,d=i+p*l):p=-_/l;let m,f,g=t.aN(1,n.y),v=0;do{if(v+=1,v>10)break;f=p/g,m=new t.$(n.x+h*f,n.y+u*f),g=1/m.meterInMercatorCoordinateUnits();}while(Math.abs(p-f*g)>1e-12);return {center:m.toLngLat(),elevation:d,zoom:t.ah(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.ag(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,o=t.$.fromLngLat(this.center,this.elevation),a=_e(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(a.toLngLat(),t.aN(a.z,o.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom);}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.ag(1,this.center.lat)*this.worldSize;return _e(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return [0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class Dt{distanceToTile2d(e,t,i,r){const o=r.distanceX([e,t]),a=r.distanceY([e,t]);return Math.hypot(o,a)}getWrap(e,t,i){return i}getTileAABB(e,i,r,o){var a,s;let n=r,l=r;if(o.terrain){const c=new t.Y(e.z,i,e.z,e.x,e.y),h=o.terrain.getMinMaxElevation(c);n=null!==(a=h.minElevation)&&void 0!==a?a:r,l=null!==(s=h.maxElevation)&&void 0!==s?s:r;}const c=1<o}allowWorldCopies(){return !0}recalculateCache(){}}class At{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i;}static fromInvProjectionMatrix(e,i=1,r=0){const o=Math.pow(2,r),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const a=1/(r=t.at([],r,e))[3]/i*o;return t.aR(r,r,[a,a,1/r[3],a])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.aS([],a[e[0]],a[e[1]]),r=t.aS([],a[e[2]],a[e[1]]),o=t.aT([],t.aU([],i,r)),s=-t.aV(o,a[e[1]]);return o.concat(s)})),n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of a)for(let t=0;t<3;t++)n[t]=Math.min(n[t],e[t]),l[t]=Math.max(l[t],e[t]);return new At(a,s,new zt(n,l))}}class Lt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,r,o){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,r,o),this._coveringTilesDetailsProvider=new Dt;}clone(){const e=new Lt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i);}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.aW(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),n=Math.floor(Math.min(r.x,o.x,a.x,s.x)),l=Math.floor(Math.max(r.x,o.x,a.x,s.x)),c=1;for(let r=n-c;r<=l+c;r++)0!==r&&i.push(new t.aW(r,e));}return i}getCameraFrustum(){return At.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i);}setLocationAtPoint(e,i){const r=t.ag(this.elevation,this.center.lat),o=this.screenPointToMercatorCoordinateAtZ(i,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),s=t.$.fromLngLat(e),n=new t.$(s.x-(o.x-a.x),s.y-(o.y-a.y));this.setCenter(null==n?void 0:n.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap());}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.$.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.$.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,o=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.at(o,o,this._pixelMatrixInverse),t.at(a,a,this._pixelMatrixInverse);const s=o[3],n=a[3],l=o[1]/s,c=a[1]/n,h=o[2]/s,u=a[2]/n,d=h===u?0:(r-h)/(u-h);return new t.$(t.B.number(o[0]/s,a[0]/n,d)/this.worldSize,t.B.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.at(o,o,r),new t.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this._helper._height/2-ue(this));return (new V).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-ue(this)}calculatePosMatrix(e,i=!1,r){var o;const a=null!==(o=e.key)&&void 0!==o?o:t.aX(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(a)){const e=s.get(a);return r?e.f32:e.f64}const n=de(e,this.worldSize);t.N(n,i?this._alignedProjMatrix:this._viewProjMatrix,n);const l={f64:n,f32:new Float32Array(n)};return s.set(a,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const o=de(e,this.worldSize);return t.N(o,this._fogMatrix,o),r.set(i,new Float32Array(o)),r.get(i)}getConstrained(e,i){i=t.ae(+i,this.minZoom,this.maxZoom);const r={center:new t.Q(e.lng,e.lat),zoom:i};let o=this._helper._lngRange;this._helper._renderWorldCopies||null!==o||(o=[-179.9999999999,180-1e-10]);const a=this.tileSize*t.ac(r.zoom);let s=0,n=a,l=0,c=a,h=0,u=0;const{x:d,y:_}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.S(e[1])*a,n=t.S(e[0])*a,n-s<_&&(h=_/(n-s));}o&&(l=t.aL(t.U(o[0])*a,0,a),c=t.aL(t.U(o[1])*a,0,a),cn&&(g=n-e);}if(o){const e=(l+c)/2;let i=p;this._helper._renderWorldCopies&&(i=t.aL(p,e-a/2,e+a/2));const r=d/2;i-rc&&(f=c-r);}if(void 0!==f||void 0!==g){const e=new t.P(null!=f?f:p,null!=g?g:m);r.center=he(a,e).wrap();}return r}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const o=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-o*this._helper._pixelPerMeter/Math.cos(i),s=o<0?a:e,n=Math.PI/2+this.pitchInRadians,l=t.ab(this.fov)*(Math.abs(Math.cos(t.ab(this.roll)))*this.height+Math.abs(Math.sin(t.ab(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*s/Math.sin(t.ae(Math.PI-n-l,.01,Math.PI-.01)),h=ue(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.ab(.75),_=u>d?2*u*(.5+r.y/(2*h)):d,p=Math.sin(_)*s/Math.sin(t.ae(Math.PI-n-_,.01,Math.PI-.01)),m=Math.min(c,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50;}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=ce(this.worldSize,this.center),r=i.x,o=i.y;this._helper._pixelPerMeter=t.ag(1,this.center.lat)*this.worldSize;const a=t.ab(Math.min(this.pitch,le)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a));let n;this._calculateNearFarZIfNeeded(s,a,e),n=new Float64Array(16),t.aY(n,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.an(this._invProjMatrix,n),n[8]=2*-e.x/this._helper._width,n[9]=2*e.y/this._helper._height,this._projectionMatrix=t.aZ(n),t.M(n,n,[1,-1,1]),t.L(n,n,[0,0,-this._helper.cameraToCenterDistance]),t.a_(n,n,-this.rollInRadians),t.a$(n,n,this.pitchInRadians),t.a_(n,n,-this.bearingInRadians),t.L(n,n,[-r,-o,0]),this._mercatorMatrix=t.M([],n,[this.worldSize,this.worldSize,this.worldSize]),t.M(n,n,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n),t.L(n,n,[0,0,-this.elevation]),this._viewProjMatrix=n,this._invViewProjMatrix=t.an([],n);const l=[0,0,-1,1];t.at(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.aY(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.M(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.a_(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.a$(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.a_(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.L(this._fogMatrix,this._fogMatrix,[-r,-o,0]),t.M(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),_=r-Math.round(r)+u*c+d*h,p=o-Math.round(o)+u*h+d*c,m=new Float64Array(n);if(t.L(m,m,[_>.5?_-1:_,p>.5?p-1:p,0]),this._alignedProjMatrix=m,n=t.an(new Float64Array(16),this._pixelMatrix),!n)throw new Error("failed to invert matrix");this._pixelMatrixInverse=n,this._clearMatrixCaches();}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear();}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.at(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.ag(1,this.center.lat)*this.worldSize;return _e(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.$.fromLngLat(e),o=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.at(o,o,this._viewProjMatrix),o[2]/o[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:o}=e,a=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;let n;return n=i&&i.terrainRttPosMatrix32f&&o?i.terrainRttPosMatrix32f:s||t.b0(),{mainMatrix:n,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n}}isLocationOccluded(e){return !1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aQ(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,o){const a=this.calculatePosMatrix(r);let s;o?(s=[e,i,o(e,i),1],t.at(s,s,a)):(s=[e,i,0,1],We(s,s,a));const n=s[3];return {point:new t.P(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t);}getMatrixForModel(e,i){const r=t.$.fromLngLat(e,i),o=r.meterInMercatorCoordinateUnits(),a=t.b1();return t.L(a,a,[r.x,r.y,r.z]),t.a_(a,a,Math.PI),t.a$(a,a,Math.PI/2),t.M(a,a,[-o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=new t.Y(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),o=de(i,this.worldSize);t.N(o,this._viewProjMatrix,o),r.tileMercatorCoords=[0,0,1,1];const a=[t.Z,t.Z,this.worldSize/this._helper.pixelsPerMeter],s=t.b2();return t.M(s,o,a),r.fallbackMatrix=s,r.mainMatrix=s,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function kt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");}function Ft(e){if(e.useSlerp)if(e.k<1){const i=t.b3(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.b3(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),o=new Float64Array(4);t.b4(o,i,r,e.k);const a=t.b5(o);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing);}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.B.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.B.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.B.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k));}function Bt(e,i,r,o,a){const s=a.padding,n=ce(a.worldSize,r.getNorthWest()),l=ce(a.worldSize,r.getNorthEast()),c=ce(a.worldSize,r.getSouthEast()),h=ce(a.worldSize,r.getSouthWest()),u=t.ab(-o),d=n.rotate(u),_=l.rotate(u),p=c.rotate(u),m=h.rotate(u),f=new t.P(Math.max(d.x,_.x,m.x,p.x),Math.max(d.y,_.y,m.y,p.y)),g=new t.P(Math.min(d.x,_.x,m.x,p.x),Math.min(d.y,_.y,m.y,p.y)),v=f.sub(g),x=(a.width-(s.left+s.right+i.left+i.right))/v.x,b=(a.height-(s.top+s.bottom+i.top+i.bottom))/v.y;if(b<0||x<0)return void kt();const y=Math.min(t.ah(a.scale*Math.min(x,b)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ab(o)),P=w.add(T).mult(a.scale/t.ac(y));return {center:he(a.worldSize,n.add(c).div(2).sub(P)),zoom:y,bearing:o}}class Ot{get useGlobeControls(){return !1}handlePanInertia(e,t){return {easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around);}cameraForBoxAndBearing(e,t,i,r,o){return Bt(e,t,i,r,o)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.Q.convert(i.center));}handleEaseTo(e,i){const r=e.zoom,o=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},n=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=n?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:_,zoom:p}=e.getConstrained(t.Q.convert(i.center||d),null!=h?h:r);Et(e,_);const m=ce(e.worldSize,d),f=ce(e.worldSize,_).sub(m),g=t.ac(p-r);return c=p!==r,{easeFunc:n=>{if(c&&e.setZoom(t.B.number(r,p,n)),t.b6(a,s)||Ft({startEulerAngles:a,endEulerAngles:s,tr:e,k:n,useSlerp:a.roll!=s.roll}),l&&(e.interpolatePadding(o,i.padding,n),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else {const i=t.ac(e.zoom-r),o=p>r?Math.min(2,g):Math.max(.5,g),a=Math.pow(o,1-n),s=he(e.worldSize,m.add(f.mult(n*a)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,u);}},isZooming:c,elevationCenter:_}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.zoom,a=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),r?+i.zoom:o),s=a.center,n=a.zoom;Et(e,s);const l=ce(e.worldSize,i.locationAtOffset),c=ce(e.worldSize,s).sub(l),h=c.mag(),u=t.ac(n-o);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,o,n),a=e.getConstrained(s,r).zoom;d=t.ac(a-o);}return {easeFunc:(i,r,a,h)=>{e.setZoom(1===i?n:o+t.ah(r));const u=1===i?s:he(e.worldSize,l.add(c.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h);},scaleOfZoom:u,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:h}}}class jt{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i;}}jt.Replace=[1,0],jt.disabled=new jt(jt.Replace,t.b7.transparent,[!1,!1,!1,!1]),jt.unblended=new jt(jt.Replace,t.b7.transparent,[!0,!0,!0,!0]),jt.alphaBlended=new jt([1,771],t.b7.transparent,[!0,!0,!0,!0]);const Zt=2305;class Nt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Nt.disabled=new Nt(!1,1029,Zt),Nt.backCCW=new Nt(!0,1029,Zt),Nt.frontCCW=new Nt(!0,1028,Zt);class Ut{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Ut.ReadOnly=!1,Ut.ReadWrite=!0,Ut.disabled=new Ut(519,Ut.ReadOnly,[0,1]);const Gt=7680;class Vt{constructor(e,t,i,r,o,a){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=o,this.pass=a;}}Vt.disabled=new Vt({func:519,mask:0},0,0,Gt,Gt,Gt);const qt=new WeakMap;function Wt(e){var t;if(qt.has(e))return qt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return qt.set(e,i),i}}class Ht{get awaitingQuery(){return !!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const o=new t.aI;o.emplaceBack(-1,-1),o.emplaceBack(2,-1),o.emplaceBack(-1,2);const a=new t.aK;a.emplaceBack(0,1,2),this._fullscreenTriangle=new wt(i.createVertexBuffer(o,Tt.members),i.createIndexBuffer(a),t.aJ.simpleSegment(0,0,o.length,a.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Wt(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null));}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null;}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer);}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,o=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.b7.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,o.TRIANGLES,Ut.disabled,Vt.disabled,jt.unblended,Nt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Wt(o)){o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.readBuffer(o.COLOR_ATTACHMENT0),o.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const e=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);o.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e};}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null};}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Wt(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Ht._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount;}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const $t=t.Z/128;function Xt(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,o=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=o+1,n=a+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=r+(e.generateBorders?1:0),u=r+(e.generateBorders||e.extendToSouthPole?1:0),d=s*n,_=o*a*6,p=s*n>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,f=new Int16Array(2*d);let g=0;for(let i=c;i<=u;i++)for(let o=l;o<=h;o++){let a=o/r*t.Z;-1===o&&(a=-64),o===r+1&&(a=t.Z+$t);let s=i/r*t.Z;-1===i&&(s=e.extendToNorthPole?t.b9:-64),i===r+1&&(s=e.extendToSouthPole?t.ba:t.Z+$t),f[g++]=a,f[g++]=s;}const v=m?new Uint32Array(_):new Uint16Array(_);let x=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return "globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy();}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e);}getMeshFromTileID(e,t,i,r,o){return this.currentProjection.getMeshFromTileID(e,t,i,r,o)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator");}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e);}}function ei(e){const t=ri(e.worldSize,e.center.lat);return 2*Math.PI*t}function ti(e,i,r,o,a){const s=1/(1<1e-6){const o=e[0]/r,a=Math.acos(e[2]/r),s=(o>0?a:-a)/Math.PI*180;return new t.Q(t.aL(s,-180,180),i)}return new t.Q(0,i)}function ai(e){return Math.cos(e*Math.PI/180)}function si(e,i){const r=ai(e),o=ai(i);return t.ah(o/r)}function ni(e,i){const r=e.rotate(i.bearingInRadians),o=i.zoom+si(i.center.lat,0),a=t.bc(1/ai(i.center.lat),1/ai(Math.min(Math.abs(i.center.lat),60)),t.bf(o,7,3,0,1)),s=360/ei({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.Q(i.center.lng-r.x*s*a,t.ae(i.center.lat+r.y*s,-85.051129,t.af))}function li(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function ci(e,i,r,o){const a=e.lat+r*o;if(Math.abs(r)>1){const s=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,n=Math.abs(e.lat+r)*Math.PI/180,l=li(s+o*(n-s)),c=li(s),h=li(n);return new t.Q(e.lng+i*((l-c)/(h-c)),a)}return new t.Q(e.lng+i*o,a)}class hi{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=e;}recalculateCache(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1;}getTileAABB(e,t,i,r){const o=`${e.z}_${e.x}_${e.y}`,a=this._cache.get(o);if(a)return a;const s=this._cachePrevious.get(o);if(s)return this._cache.set(o,s),s;const n=this._aabbFactory(e,t,i,r);return this._cache.set(o,n),this._hadAnyChanges=!0,n}}function ui(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function di(e,t,i,r,o){const a=e-i;let s;return s=a<0?Math.min(-a,1+a-o):a>1?Math.min(Math.max(a-o,0),1-a):0,Math.max(s,ui(t,r,o))}class _i{constructor(){this._aabbCache=new hi(this._computeTileAABB);}recalculateCache(){this._aabbCache.recalculateCache();}distanceToTile2d(e,t,i,r){const o=1<4}allowWorldCopies(){return !1}getTileAABB(e,t,i,r){return this._aabbCache.getTileAABB(e,t,i,r)}_computeTileAABB(e,i,r,o){if(e.z<=0)return new zt([-1,-1,-1],[1,1,1]);if(1===e.z)return new zt([0===e.x?-1:0,0===e.y?0:-1,-1],[0===e.x?0:1,0===e.y?1:0,1]);{const i=[ti(0,0,e.x,e.y,e.z),ti(t.Z,0,e.x,e.y,e.z),ti(t.Z,t.Z,e.x,e.y,e.z),ti(0,t.Z,e.x,e.y,e.z)],r=[1,1,1],o=[-1,-1,-1];for(const e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);if(0===e.y||e.y===(1<{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new _i;}clone(){const e=new pi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e);}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bh();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return {mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,o=Math.sin(i)*r,a=Math.cos(i)*r+1,s=1/Math.sqrt(o*o+a*a)*1;let n=-o,l=a;const c=Math.sqrt(n*n+l*l);n/=c,l/=c;const h=[0,n,l];t.bl(h,h,[0,0,0],-this.bearingInRadians),t.bm(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bn(h,h,[0,0,0],this.center.lng*Math.PI/180);const u=1/t.bo(h);return t.aO(h,h,u),[...h,-s*u]}isLocationOccluded(e){return !this.isSurfacePointVisible(ii(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,o=Math.cos(r),a=[Math.sin(i)*o,Math.sin(r),Math.cos(i)*o],s=[a[2],0,-a[0]],n=[0,0,0];t.aU(n,s,a),t.aT(s,s),t.aT(n,n);const l=[0,0,0];return t.aT(l,[s[0]*e[0]+n[0]*e[1]+a[0]*e[2],s[1]*e[0]+n[1]*e[1]+a[1]*e[2],s[2]*e[0]+n[2]*e[1]+a[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const o=function(e,i,r){const o=1/(1<a&&(a=i),rn&&(n=r);}const h=[c.lng+s,c.lat+l,c.lng+a,c.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new V(h)}getConstrained(e,i){const r=t.ae(e.lat,-85.051129,t.af),o=t.ae(+i,this.minZoom+si(0,r),this.maxZoom);return {center:new t.Q(e.lng,r),zoom:o}}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=ii(this.unprojectScreenPoint(i)),o=ii(e),a=t.bh();t.br(a);const s=t.bh();t.bn(s,r,a,-this.center.lng*Math.PI/180),t.bm(s,s,a,this.center.lat*Math.PI/180);const n=o[0]*o[0]+o[2]*o[2],l=s[0]*s[0];if(n=-g&&p<=g,x=f>=-g&&f<=g;let b,y;if(v&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bv(u,e)+t.bv(p,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return !1;const i=t.bk();return t.at(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.aV(e,i),o=t.bh(),a=t.bh();t.aO(a,i,r),t.aS(o,e,a);const s=1-t.aV(o,o);if(s<0)return null;const n=t.aV(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(s),c=n/l,h=l;return {tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),o=this.rayPlanetIntersection(i,r);if(o){const e=t.bh();t.aP(e,i,[r[0]*o.tMin,r[1]*o.tMin,r[2]*o.tMin]);const a=t.bh();return t.aT(a,e),oi(a)}const a=this._cachedClippingPlane,s=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],n=-t.bt(a,i)/s,l=t.bh();if(n>0)t.aP(l,i,[r[0]*n,r[1]*n,r[2]*n]);else {const e=t.bh();t.aP(e,i,[2*r[0],2*r[1],2*r[2]]);const o=t.bt(this._cachedClippingPlane,e);t.aS(l,e,[this._cachedClippingPlane[0]*o,this._cachedClippingPlane[1]*o,this._cachedClippingPlane[2]*o]);}const c=function(e){const i=t.bh();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(a);return oi(function(e,i,r){const o=t.bh();t.aS(o,r,e);const a=t.bh();return t.bi(a,e,o,i/t.bj(o)),a}(c.center,c.radius,l))}getMatrixForModel(e,i){const r=t.Q.convert(e),o=1/t.bu,a=t.b1();return t.bp(a,a,r.lng/180*Math.PI),t.a$(a,a,-r.lat/180*Math.PI),t.L(a,a,[0,0,1+i/t.bu]),t.a$(a,a,.5*Math.PI),t.M(a,a,[o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.Y(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class mi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache();}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Lt,this._verticalPerspectiveTransform=new pi;}clone(){const e=new mi;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians);}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return {mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bc(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bc(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const o=this._mercatorTransform.getPitchedTextCorrection(e,i,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.bc(o,a,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ);}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e);}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e);}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform);}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class fi{get useGlobeControls(){return !0}handlePanInertia(e,i){const r=ni(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,o=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const a=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-a;if(0===s)return;const n=t.bq(i.center.lng,o.lng),l=n/(Math.abs(n/180)+1),c=t.bq(i.center.lat,o.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*t.aV(u,h),_=t.bh();t.aP(_,u,[h[0]*d,h[1]*d,h[2]*d]);const p=t.bo(_)-1,m=Math.exp(.5*-Math.max(p-.3,0)),f=ri(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=t.bf(f,.9,.5,1,.25),v=(1-t.ac(-s))*Math.min(m,g),x=i.center.lat,b=i.zoom,y=new t.Q(i.center.lng+l*v,t.ae(i.center.lat+c*v,-85.051129,t.af));i.setLocationAtPoint(o,r);const w=i.center,T=t.bf(Math.abs(n),45,85,0,1),P=t.bf(f,.75,.35,0,1),C=Math.pow(Math.max(T,P),.25),M=t.bq(w.lng,y.lng),I=t.bq(w.lat,y.lat);i.setCenter(new t.Q(w.lng+M*C,w.lat+I*C).wrap()),i.setZoom(b+si(x,i.center.lat));}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,o=t.zoom;t.setCenter(ni(e.panDelta,t).wrap()),t.setZoom(o+si(r,t.center.lat));}cameraForBoxAndBearing(e,i,r,o,a){const s=Bt(e,i,r,o,a),n=i.left/a.width*2-1,l=(a.width-i.right)/a.width*2-1,c=i.top/a.height*-2+1,h=(a.height-i.bottom)/a.height*-2+1,u=t.bq(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),_=u?r.getWest():r.getEast(),p=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),f=d+.5*t.bq(d,_),g=p+.5*t.bq(p,m),v=a.clone();v.setCenter(s.center),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);const x=v.modelViewProjectionMatrix,b=[ii(r.getNorthWest()),ii(r.getNorthEast()),ii(r.getSouthWest()),ii(r.getSouthEast()),ii(new t.Q(_,g)),ii(new t.Q(d,g)),ii(new t.Q(f,p)),ii(new t.Q(f,m))],y=ii(s.center);let w=Number.POSITIVE_INFINITY;for(const e of b)n<0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"x",n))),l>0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"x",l))),c>0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"y",c))),h<0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"y",h)));if(Number.isFinite(w)&&0!==w)return s.zoom=v.zoom+t.ah(w),s;kt();}handleJumpToCenterZoom(e,i){const r=e.center.lat,o=e.getConstrained(i.center?t.Q.convert(i.center):e.center,e.zoom).center;e.setCenter(o.wrap());const a=void 0!==i.zoom?+i.zoom:e.zoom+si(r,o.lat);e.zoom!==a&&e.setZoom(a);}handleEaseTo(e,i){const r=e.zoom,o=e.center,a=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.Q.convert(i.center):o,d=e.getConstrained(u,r).center;Et(e,d);const _=e.clone();_.setCenter(d),_.setZoom(l?+i.zoom:r+si(o.lat,u.lat)),_.setBearing(i.bearing);const p=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));_.setLocationAtPoint(d,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,f=l?+i.zoom:r+si(o.lat,m.lat),g=r+si(o.lat,0),v=f+si(m.lat,0),x=t.bq(o.lng,m.lng),b=t.bq(o.lat,m.lat),y=t.ac(v-g);return h=f!==r,{easeFunc:r=>{if(t.b6(s,n)||Ft({startEulerAngles:s,endEulerAngles:n,tr:e,k:r,useSlerp:s.roll!=n.roll}),c&&e.interpolatePadding(a,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else {const t=v>g?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-r),a=ci(o,x,b,r*i);e.setCenter(a.wrap());}if(h){const i=t.B.number(g,v,r)+si(0,e.center.lat);e.setZoom(i);}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.center,a=e.zoom,s=e.padding,n=!e.isPaddingEqual(i.padding),l=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),a).center,c=r?+i.zoom:e.zoom+si(e.center.lat,l.lat),h=e.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(l,u);const d=h.center;Et(e,d);const _=function(e,i,r){const o=ii(i),a=ii(r),s=t.aV(o,a),n=Math.acos(s),l=ei(e);return n/(2*Math.PI)*l}(e,o,d),p=a+si(o.lat,0),m=c+si(d.lat,0),f=t.ac(m-p);let g;if("number"==typeof i.minZoom){const r=+i.minZoom+si(d.lat,0),o=Math.min(r,p,m)+si(0,d.lat),a=e.getConstrained(d,o).zoom+si(d.lat,0);g=t.ac(a-p);}const v=t.bq(o.lng,d.lng),x=t.bq(o.lat,d.lat);return {easeFunc:(r,a,l,h)=>{const u=ci(o,v,x,l);n&&e.interpolatePadding(s,i.padding,r);const _=1===r?d:u;e.setCenter(_.wrap());const m=p+t.ah(a);e.setZoom(1===r?c:m+si(0,_.lat));},scaleOfZoom:f,targetCenter:d,scaleOfMinZoom:g,pixelPathLength:_}}static solveVectorScale(e,t,i,r,o){const a="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],n=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],h=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+o*l===n+o*h||s[3]*(n-c)+a[3]*(h-l)+n*h==c*l?null:(c+a[3]-o*h-o*s[3])/(c-n-o*h+o*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.x(e,i&&i.filter((e=>"source.canvas"!==e.identifier))),xi=t.bw();class bi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload();}},this.map=e,this.dispatcher=new B(F(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler("GI",((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new P(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new R(256,512),this.crossTileSymbolIndex=new vt,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bx,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",t.by()),oe().on(te,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t);}}));}loadURL(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const a=this._loadStyleRequest;t.j(o,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,i,r);})).catch((e=>{this._loadStyleRequest=null,e&&!a.signal.aborted&&this.fire(new t.k(e));}));}loadJSON(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r);})).catch((()=>{}));}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(xi,{validate:!1});}_load(e,i,r){var o,a;const s=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!vi(this,t.y(s))){this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new I(this.stylesheet.light),this._setProjectionInternal((null===(o=this.stylesheet.projection)||void 0===o?void 0:o.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(a=this.stylesheet.terrain)&&void 0!==a?a:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"));}}_createLayers(){const e=t.bz(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.bA(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e;}}_loadSprite(e,i=!1,r=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=f(e),n=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of a){const a=i.transformRequest(g(r,n,".json"),"SpriteJSON");l[e]=t.j(a,o);const s=i.transformRequest(g(r,n,".png"),"SpriteImage");c[e]=p.getImage(s,o);}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,(function*(){const t={};for(const r in e){t[r]={};const o=s.getImageCanvasContext((yield i[r]).data),a=(yield e[r]).data;for(const e in a){const{width:i,height:s,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=a[e];t[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:s,x:n,y:l,context:o}};}}return t}))}(l,c)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[t]){const o="default"===t?r:`${t}:${r}`;this._spritesImagesIds[t].push(o),o in this.imageManager.images?this.imageManager.updateImage(o,e[t][r],!1):this.imageManager.addImage(o,e[t][r]),i&&(this._changedImages[o]=!0);}}})).catch((e=>{this._spriteRequest=null,o=e,this.fire(new t.k(o));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),r&&r(o);}));}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const o=i.getSource();("geojson"===o.type||o.vectorLayerIds&&-1===o.vectorLayerIds.indexOf(r))&&this.fire(new t.k(new Error(`Source layer "${r}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bB(r):r);const o=[];for(const a of e)if(r[a]){const e=i?t.bB(r[a]):r[a];o.push(e);}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize());}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return !0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return !0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return !0;for(const e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else {if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates();}const r={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const e in r){const i=this.sourceCaches[e];!!r[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){var r;this._checkLoaded();const o=this.serialize();if(e=i.transformStyle?i.transformStyle(o,e):e,(null===(r=i.validate)||void 0===r||r)&&vi(this,t.y(e)))return !1;(e=t.bB(e)).layers=t.bz(e.layers);const a=t.bC(o,e),s=this._getOperationsToPerform(a);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return !1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case "setCenter":case "setZoom":case "setBearing":case "setPitch":case "setRoll":continue;case "addLayer":t.push((()=>this.addLayer.apply(this,r.args)));break;case "removeLayer":t.push((()=>this.removeLayer.apply(this,r.args)));break;case "setPaintProperty":t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case "setLayoutProperty":t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case "setFilter":t.push((()=>this.setFilter.apply(this,r.args)));break;case "addSource":t.push((()=>this.addSource.apply(this,r.args)));break;case "removeSource":t.push((()=>this.removeSource.apply(this,r.args)));break;case "setLayerZoomRange":t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case "setLight":t.push((()=>this.setLight.apply(this,r.args)));break;case "setGeoJSONSourceData":t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case "setGlyphs":t.push((()=>this.setGlyphs.apply(this,r.args)));break;case "setSprite":t.push((()=>this.setSprite.apply(this,r.args)));break;case "setTerrain":t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case "setSky":t.push((()=>this.setSky.apply(this,r.args)));break;case "setProjection":this.setProjection.apply(this,r.args);break;case "setTransition":t.push((()=>{}));break;default:i.push(r.command);}return {operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(e,t){this.imageManager.updateImage(e,t);}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.y.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=this.sourceCaches[e]=new be(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,(()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e}))),o.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0;}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.k(new Error(`Layer "${o}" already exists on this map.`)));let a;if("custom"===e.type){if(vi(this,t.bD(e)))return;a=t.bA(e);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(o,e.source),e=t.bB(e),e=t.e(e,{source:o})),this._validate(t.y.layer,`layers.${o}`,e,{arrayIndex:-1},r))return;a=t.bA(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:o}});}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));else {if(this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=a,this._removedLayers[o]&&a.source&&"custom"!==a.type){const e=this._removedLayers[o];delete this._removedLayers[o],e.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause());}this._updateLayer(a),a.onAdd&&a.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(e){return this._layers[e]}getLayersOrder(){return [...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!t.bE(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.y.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.bB(i),this._updateLayer(o)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.bB(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bE(a.getLayoutProperty(i),r)||(a.setLayoutProperty(i,r,o),this._updateLayer(a)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bE(a.getPaintProperty(i),r)||(a.setPaintProperty(i,r,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,a=this.sourceCaches[r];if(void 0===a)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=a.getSource().type;"geojson"===s&&o?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||o?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),a.setFeatureState(o,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.getSource().type,s="vector"===a?e.sourceLayer:void 0;"vector"!==a||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.sourceCaches[i];if(void 0!==o)return "vector"!==o.getSource().type||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.getFeatureState(r,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bF(this.sourceCaches,(e=>e.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,o=this.stylesheet;return t.bG({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,projection:o.projection,sources:e,layers:i,terrain:r},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a)){i[a]=o;for(const t of e){const e=t[a];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let a=this._order.length-1;a>=0;a--){const s=this._order[a];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&a.push(function(e,t,i,r,o,a,s){const n={},l=a.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(N);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,o.filter,o.layers,o.availableImages,e);for(const e in r){const t=n[e]=n[e]||[],o=r[e];o.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of o)t.push(e);}}return function(e,t,i){for(const r in e)for(const o of e[r])U(o,i[t[r].source]);return e}(n,e,i)}(this._layers,s,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.y.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],o={};for(let e=0;ee.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);a=a||r;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),e.zoom))&&(this.pauseablePlacement=new _t(e,this.map.terrain,this._order,o,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.now()),n=!0),a&&this.pauseablePlacement.placement.setStale()),n||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles();}getImages(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e}))}getGlyphs(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.y.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}addSprite(e,i,r={},o){this._checkLoaded();const a=[{id:e,url:i}],s=[...f(this.stylesheet.sprite),...a];this._validate(t.y.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(a,!0,o));}removeSprite(e){this._checkLoaded();const i=f(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return f(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.y.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)));}}var yi=t.aG([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class wi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(e,t,i,r,o,a,s,n,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.b7.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(o):0,u_horizon_color:r?r.properties.get("horizon-color"):t.b7.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:a?1:0}),Pi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Ci(e){const t=[];for(let i=0;i({u_depth:new t.bH(e,i.u_depth),u_terrain:new t.bH(e,i.u_terrain),u_terrain_dim:new t.b8(e,i.u_terrain_dim),u_terrain_matrix:new t.bJ(e,i.u_terrain_matrix),u_terrain_unpack:new t.bK(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.b8(e,i.u_terrain_exaggeration)}))(e,C),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bJ(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bK(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bK(e,i.u_projection_clipping_plane),u_projection_transition:new t.b8(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bJ(e,i.u_projection_fallback_matrix)}))(e,C),this.binderUniforms=r?r.getUniforms(e,C):[];}draw(e,t,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v){const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(o),e.setCullFace(a),n){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,n.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,n.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(n[e]);}if(l)for(const e in l)this.projectionUniforms[Pi[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,_,{zoom:p});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1;}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new wi)).bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,f,g,v),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2);}}}function Ii(e,i,r){const o=1/t.az(r,1,i.transform.tileZoom),a=Math.pow(2,r.tileID.overscaledZ),s=r.tileSize*Math.pow(2,i.transform.tileZoom)/a,n=s*(r.tileID.canonical.x+r.tileID.wrap*a),l=s*r.tileID.canonical.y;return {u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[o,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}const Ei=(e,i,r,o)=>{const a=e.style.light,s=a.properties.get("position"),n=[s.x,s.y,s.z],l=t.bN();"viewport"===a.properties.get("anchor")&&t.bO(l,e.transform.bearingInRadians),t.bP(n,n,l);const c=e.transform.transformLightDirection(n),h=a.properties.get("color");return {u_lightpos:n,u_lightpos_globe:c,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:o}},Si=(e,i,r,o,a,s,n)=>t.e(Ei(e,i,r,o),Ii(s,e,n),{u_height_factor:-Math.pow(2,a.overscaledZ)/n.tileSize/8}),Ri=(e,i,r,o)=>t.e(Ii(i,e,r),{u_fill_translate:o}),zi=(e,t)=>({u_world:e,u_fill_translate:t}),Di=(e,i,r,o,a)=>t.e(Ri(e,i,r,a),{u_world:o}),Ai=(e,i,r,o,a)=>{const s=e.transform;let n,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.az(i,1,s.zoom);n=!0,l=[e,e],c=e/(t.Z*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*a;}else n=!1,l=s.pixelsToGLUnits;return {u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:o}},Li=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),ki=e=>({u_viewport_size:[e.width,e.height]}),Fi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Bi=(e,i,r,o)=>{const a=t.az(e,1,i)/(t.Z*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*o;return {u_extrude_scale:t.az(e,1,i),u_intensity:r,u_globe_extrude_scale:a}},Oi=(e,i,r,o)=>{const a=t.K();t.bQ(a,0,e.width,e.height,0,0,1);const s=e.context.gl;return {u_matrix:a,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:r,u_color_ramp:o,u_opacity:i.paint.get("heatmap-opacity")}},ji=(e,t,i)=>{const r=i.paint.get("hillshade-accent-color");let o;switch(i.paint.get("hillshade-method")){case "basic":o=4;break;case "combined":o=1;break;case "igor":o=2;break;case "multidirectional":o=3;break;default:o=0;}const a=i.getIlluminationProperties();for(let t=0;t{const r=i.stride,o=t.K();return t.bQ(o,0,t.Z,-8192,0,0,1),t.L(o,o,[0,-8192,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Ni(e,i){const r=Math.pow(2,i.canonical.z),o=i.canonical.y;return [new t.$(0,o/r).toLngLat().lat,new t.$(0,(o+1)/r).toLngLat().lat]}const Ui=(e,i,r,o)=>{const a=e.transform;return {u_translation:Hi(e,i,r),u_ratio:o/t.az(i,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Gi=(e,i,r,o,a)=>t.e(Ui(e,i,r,o),{u_image:0,u_image_height:a}),Vi=(e,i,r,o,a)=>{const s=e.transform,n=Wi(i,s);return {u_translation:Hi(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:o/t.az(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[n,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},qi=(e,i,r,o,a,s)=>{const n=e.lineAtlas,l=Wi(i,e.transform),c="round"===r.layout.get("line-cap"),h=n.getDash(a.from,c),u=n.getDash(a.to,c),d=h.width*s.fromScale,_=u.width*s.toScale;return t.e(Ui(e,i,r,o),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:s.t})};function Wi(e,i){return 1/t.az(e,1,i.tileZoom)}function Hi(e,i,r){return t.aA(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const $i=(e,t,i,r,o)=>{return {u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=r.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Xi(r.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]};var a,s;};function Xi(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Ki=(e,t,i,r,o,a,s,n,l,c,h,u,d)=>{const _=s.transform;return {u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_pitch:_.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:o,u_is_variable_anchor:a,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},Qi=(e,i,r,o,a,s,n,l,c,h,u,d,_,p)=>{const m=n.transform;return t.e(Ki(e,i,r,o,a,s,n,l,c,h,u,d,p),{u_gamma_scale:o?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:1})},Yi=(e,i,r,o,a,s,n,l,c,h,u,d,_)=>t.e(Qi(e,i,r,o,a,s,n,l,c,h,!0,u,0,_),{u_texsize_icon:d,u_texture_icon:1}),Ji=(e,t)=>({u_opacity:e,u_color:t}),er=(e,i,r,o,a)=>t.e(function(e,i,r,o){const a=r.imageManager.getPattern(e.from.toString()),s=r.imageManager.getPattern(e.to.toString()),{width:n,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(o.tileID.canonical.x+o.tileID.wrap*c),d=h*o.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.az(o,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,a,i,o),{u_opacity:e}),tr=(e,t)=>{},ir={fillExtrusion:(e,i)=>({u_lightpos:new t.bL(e,i.u_lightpos),u_lightpos_globe:new t.bL(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bL(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bL(e,i.u_lightpos),u_lightpos_globe:new t.bL(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bL(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_height_factor:new t.b8(e,i.u_height_factor),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bM(e,i.u_fill_translate),u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bM(e,i.u_world),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bM(e,i.u_world),u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bM(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bH(e,i.u_scale_with_map),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_extrude_scale:new t.bM(e,i.u_extrude_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale),u_translate:new t.bM(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bM(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bM(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bI(e,i.u_color),u_overlay:new t.bH(e,i.u_overlay),u_overlay_scale:new t.b8(e,i.u_overlay_scale)}),depth:tr,clippingMask:tr,heatmap:(e,i)=>({u_extrude_scale:new t.b8(e,i.u_extrude_scale),u_intensity:new t.b8(e,i.u_intensity),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bJ(e,i.u_matrix),u_world:new t.bM(e,i.u_world),u_image:new t.bH(e,i.u_image),u_color_ramp:new t.bH(e,i.u_color_ramp),u_opacity:new t.b8(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bH(e,i.u_image),u_latrange:new t.bM(e,i.u_latrange),u_exaggeration:new t.b8(e,i.u_exaggeration),u_altitudes:new t.bS(e,i.u_altitudes),u_azimuths:new t.bS(e,i.u_azimuths),u_accent:new t.bI(e,i.u_accent),u_method:new t.bH(e,i.u_method),u_shadows:new t.bR(e,i.u_shadows),u_highlights:new t.bR(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bJ(e,i.u_matrix),u_image:new t.bH(e,i.u_image),u_dimension:new t.bM(e,i.u_dimension),u_zoom:new t.b8(e,i.u_zoom),u_unpack:new t.bK(e,i.u_unpack)}),line:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_image:new t.bH(e,i.u_image),u_image_height:new t.b8(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_texsize:new t.bM(e,i.u_texsize),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_image:new t.bH(e,i.u_image),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_patternscale_a:new t.bM(e,i.u_patternscale_a),u_patternscale_b:new t.bM(e,i.u_patternscale_b),u_sdfgamma:new t.b8(e,i.u_sdfgamma),u_image:new t.bH(e,i.u_image),u_tex_y_a:new t.b8(e,i.u_tex_y_a),u_tex_y_b:new t.b8(e,i.u_tex_y_b),u_mix:new t.b8(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bM(e,i.u_tl_parent),u_scale_parent:new t.b8(e,i.u_scale_parent),u_buffer_scale:new t.b8(e,i.u_buffer_scale),u_fade_t:new t.b8(e,i.u_fade_t),u_opacity:new t.b8(e,i.u_opacity),u_image0:new t.bH(e,i.u_image0),u_image1:new t.bH(e,i.u_image1),u_brightness_low:new t.b8(e,i.u_brightness_low),u_brightness_high:new t.b8(e,i.u_brightness_high),u_saturation_factor:new t.b8(e,i.u_saturation_factor),u_contrast_factor:new t.b8(e,i.u_contrast_factor),u_spin_weights:new t.bL(e,i.u_spin_weights),u_coords_top:new t.bK(e,i.u_coords_top),u_coords_bottom:new t.bK(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texture:new t.bH(e,i.u_texture),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texture:new t.bH(e,i.u_texture),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bH(e,i.u_is_halo),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texsize_icon:new t.bM(e,i.u_texsize_icon),u_texture:new t.bH(e,i.u_texture),u_texture_icon:new t.bH(e,i.u_texture_icon),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bH(e,i.u_is_halo),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_color:new t.bI(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_image:new t.bH(e,i.u_image),u_pattern_tl_a:new t.bM(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bM(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bM(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bM(e,i.u_pattern_br_b),u_texsize:new t.bM(e,i.u_texsize),u_mix:new t.b8(e,i.u_mix),u_pattern_size_a:new t.bM(e,i.u_pattern_size_a),u_pattern_size_b:new t.bM(e,i.u_pattern_size_b),u_scale_a:new t.b8(e,i.u_scale_a),u_scale_b:new t.b8(e,i.u_scale_b),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.b8(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bH(e,i.u_texture),u_ele_delta:new t.b8(e,i.u_ele_delta),u_fog_matrix:new t.bJ(e,i.u_fog_matrix),u_fog_color:new t.bI(e,i.u_fog_color),u_fog_ground_blend:new t.b8(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.b8(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bI(e,i.u_horizon_color),u_horizon_fog_blend:new t.b8(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.b8(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.b8(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bH(e,i.u_texture),u_terrain_coords_id:new t.b8(e,i.u_terrain_coords_id),u_ele_delta:new t.b8(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.b8(e,i.u_input),u_output_expected:new t.b8(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bL(e,i.u_sun_pos),u_atmosphere_blend:new t.b8(e,i.u_atmosphere_blend),u_globe_position:new t.bL(e,i.u_globe_position),u_globe_radius:new t.b8(e,i.u_globe_radius),u_inv_proj_matrix:new t.bJ(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bI(e,i.u_sky_color),u_horizon_color:new t.bI(e,i.u_horizon_color),u_horizon:new t.bM(e,i.u_horizon),u_horizon_normal:new t.bM(e,i.u_horizon_normal),u_sky_horizon_blend:new t.b8(e,i.u_sky_horizon_blend),u_sky_blend:new t.b8(e,i.u_sky_blend)})};class rr{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const or={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ar{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const o=e.gl;this.buffer=o.createBuffer(),e.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&(h.push({circleArray:f,circleOffset:d,coord:_}),u+=f.length/4,d=u),m&&c.draw(s,l.LINES,Ut.disabled,Vt.disabled,e.colorModeForRenderPass(),Nt.disabled,Li(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(_),n.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer);}if(!a||!h.length)return;const _=e.useProgram("collisionCircle"),p=new t.bT;p.resize(4*u),p._trim();let m=0;for(const e of h)for(let t=0;t=0&&(f[g.associatedIconIndex]={shiftedAnchor:E,angle:S});}else qe(g.numGlyphs,p);}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");De(c,e,a,O,j,v,h,i,l.toUnwrapped(),f.width,f.height,N,t);}const q=a&&P||V,W=x||q?Hr:v?O:e.transform.clipSpaceToPixelsMatrix,H=p&&0!==r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let $;$=p?c.iconsInText?Yi(T.kind,S,b,v,x,q,e,W,Z,N,z,k,M):Qi(T.kind,S,b,v,x,q,e,W,Z,N,a,z,0,M):Ki(T.kind,S,b,v,x,q,e,W,Z,N,a,z,M);const X={program:E,buffers:u,uniformValues:$,projectionData:U,atlasTexture:D,atlasTextureIcon:F,atlasInterpolation:A,atlasInterpolationIcon:L,isSDF:p,hasHalo:H};if(y&&c.canOverlap){w=!0;const e=u.segments.get();for(const i of e)C.push({segments:new t.aJ([i]),sortKey:i.sortKey,state:X,terrainData:R});}else C.push({segments:u.segments,sortKey:0,state:X,terrainData:R});}w&&C.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of C){const i=t.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,Jr(i.buffers,t.segments,r,e,i.program,T,u,d,o,i.projectionData,t.terrainData)),o.u_is_halo=0;}Jr(i.buffers,t.segments,r,e,i.program,T,u,d,i.uniformValues,i.projectionData,t.terrainData);}}function Jr(e,t,i,r,o,a,s,n,l,c,h){const u=r.context;o.draw(u,u.gl.TRIANGLES,a,s,n,Nt.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer);}function eo(e,i,r,o,a){const s=e.context,n=s.gl,l=Vt.disabled,c=new jt([n.ONE,n.ONE],t.b7.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=o.key;let d=r.heatmapFbos.get(u);d||(d=io(s,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.b7.transparent});const _=h.programConfigurations.get(r.id),p=e.useProgram("heatmap",_,!a),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),f=e.style.map.terrain.getTerrainData(o);p.draw(s,n.TRIANGLES,Ut.disabled,l,c,Nt.disabled,Bi(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),f,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,_);}function to(e,t,i,r,o){const a=e.context,s=a.gl,n=e.transform;a.setColorMode(e.colorModeForRenderPass());const l=ro(a,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),a.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=n.getProjectionData({overscaledTileID:i,applyTerrainMatrix:o,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(a,s.TRIANGLES,Ut.disabled,Vt.disabled,e.colorModeForRenderPass(),Nt.disabled,Oi(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,n.zoom),h.destroy(),t.heatmapFbos.delete(c);}function io(e,t,i){var r,o;const a=e.gl,s=a.createTexture();a.bindTexture(a.TEXTURE_2D,s),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);const n=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:a.UNSIGNED_BYTE,l=null!==(o=e.RGBA16F)&&void 0!==o?o:a.RGBA;a.texImage2D(a.TEXTURE_2D,0,l,t,i,0,a.RGBA,n,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function ro(e,t){return t.colorRampTexture||(t.colorRampTexture=new v(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function oo(e,t,i,r,o){if(!i||!r||!r.imageAtlas)return;const a=r.imageAtlas.patternPositions;let s=a[i.to.toString()],n=a[i.from.toString()];if(!s&&n&&(s=n),!n&&s&&(n=s),!s||!n){const e=o.getPaintProperty(t);s=a[e],n=a[e];}s&&n&&e.setConstantPatternPositions(s,n);}function ao(e,i,r,o,a,s,n,l){const c=e.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),_=r.getCrossfadeParameters();let p,m,f,g,v;const x=e.transform,b=r.paint.get("fill-translate"),y=r.paint.get("fill-translate-anchor");n?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=c.LINES):(m=d?"fillPattern":"fill",p=c.TRIANGLES);const w=u.constantOr(null);for(const u of o){const o=i.getTile(u);if(d&&!o.patternsLoaded())continue;const T=o.getBucket(r);if(!T)continue;const P=T.programConfigurations.get(r.id),C=e.useProgram(m,P),M=e.style.map.terrain&&e.style.map.terrain.getTerrainData(u);d&&(e.context.activeTexture.set(c.TEXTURE0),o.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),P.updatePaintBuffers(_)),oo(P,h,w,o,r);const I=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),E=t.aA(x,o,b,y);if(n){g=T.indexBuffer2,v=T.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];f="fillOutlinePattern"===m&&d?Di(e,_,o,t,E):zi(t,E);}else g=T.indexBuffer,v=T.segments,f=d?Ri(e,_,o,E):{u_fill_translate:E};const S=e.stencilModeForClipping(u);C.draw(e.context,p,a,S,s,Nt.backCCW,f,M,I,r.id,T.layoutVertexBuffer,g,v,r.paint,e.transform.zoom,P);}}function so(e,i,r,o,a,s,n,l){const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),_=d.constantOr(1),p=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),f=d.constantOr(null),g=e.transform;for(const d of o){const o=i.getTile(d),v=o.getBucket(r);if(!v)continue;const x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),b=v.programConfigurations.get(r.id),y=e.useProgram(_?"fillExtrusionPattern":"fillExtrusion",b);_&&(e.context.activeTexture.set(h.TEXTURE0),o.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const w=g.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});oo(b,u,f,o,r);const T=t.aA(g,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),C=_?Si(e,P,m,T,d,p,o):Ei(e,P,m,T);y.draw(c,c.gl.TRIANGLES,a,s,n,Nt.backCCW,C,x,w,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer);}}function no(e,t,i,r,o,a,s,n,l){var c;const h=e.style.projection,u=e.context,d=e.transform,_=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,p),f=!e.options.moving;for(const p of r){const r=t.getTile(p),g=r.fbo;if(!g)continue;const v=h.getMeshFromTileID(u,p.canonical,n,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(p);u.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,g.colorAttachment.get());const b=d.getProjectionData({overscaledTileID:p,aligned:f,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(u,_.TRIANGLES,a,o[p.overscaledZ],s,Nt.backCCW,ji(e,r,i),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments);}}const lo=[new t.P(0,0),new t.P(t.Z,0),new t.P(t.Z,t.Z),new t.P(0,t.Z)];function co(e,t,i,r,o,a,s,n,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=e.context,d=u.gl,_=e.useProgram("raster"),p=e.transform,m=e.style.projection,f=e.colorModeForRenderPass(),g=!e.options.moving;for(const v of r){const r=e.getDepthModeForSublayer(v.overscaledZ-h,1===i.paint.get("raster-opacity")?Ut.ReadWrite:Ut.ReadOnly,d.LESS),x=t.getTile(v);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const b=t.findLoadedParent(v,0),y=t.findLoadedSibling(v),w=ho(x,b||y||null,t,i,e.transform,e.style.map.terrain);let T,P;const C="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),b?(b.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,b.tileID.overscaledZ-x.tileID.overscaledZ),P=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const M=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),I=p.getProjectionData({overscaledTileID:v,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),E=$i(P||[0,0],T||1,w,i,n),S=m.getMeshFromTileID(u,v.canonical,a,s,"raster");_.draw(u,d.TRIANGLES,r,o?o[v.overscaledZ]:Vt.disabled,f,l?Nt.frontCCW:Nt.backCCW,E,M,I,i.id,S.vertexBuffer,S.indexBuffer,S.segments);}}function ho(e,i,r,o,a,n){const l=o.paint.get("raster-fade-duration");if(!n&&l>0){const o=s.now(),n=(o-e.timeAdded)/l,c=i?(o-i.timeAdded)/l:-1,h=r.getSource(),u=ve(a,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),_=d&&e.refreshedUponExpiration?1:t.ae(d?n:1-c,0,1);return e.refreshedUponExpiration&&n>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-_}:{opacity:_,mix:0}}return {opacity:1,mix:0}}const uo=new t.b7(1,0,0,1),_o=new t.b7(0,1,0,1),po=new t.b7(0,0,1,1),mo=new t.b7(1,0,1,1),fo=new t.b7(0,1,1,1);function go(e,t,i,r){xo(e,0,t+i/2,e.transform.width,i,r);}function vo(e,t,i,r){xo(e,t-i/2,0,i,e.transform.height,r);}function xo(e,t,i,r,o,a){const s=e.context,n=s.gl;n.enable(n.SCISSOR_TEST),n.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,o*e.pixelRatio),s.clear({color:a}),n.disable(n.SCISSOR_TEST);}function bo(e,i,r){const o=e.context,a=o.gl,s=e.useProgram("debug"),n=Ut.disabled,l=Vt.disabled,c=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);o.activeTexture.set(a.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,_=Math.floor((d&&d.byteLength||0)/1024),p=i.getTile(r).tileSize,m=512/Math.min(p,512)*(r.overscaledZ/e.transform.zoom)*.5;let f=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(f+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,o=e.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(t,5,5),o.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,`${f} ${_}kB`);const g=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(o,a.TRIANGLES,n,l,jt.alphaBlended,Nt.disabled,Fi(t.b7.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(o,a.LINE_STRIP,n,l,c,Nt.disabled,Fi(t.b7.red),u,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function yo(e,t,i,r){const{isRenderingGlobe:o}=r,a=e.context,s=a.gl,n=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),u=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const _=t.getMeshFrameDelta(n.zoom),p=n.calculateFogMatrix(r.tileID.toUnwrapped()),m=Ti(_,p,e.style.sky,n.pitch,o),f=n.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(a,s.TRIANGLES,c,Vt.disabled,l,Nt.backCCW,m,d,f,"terrain",i.vertexBuffer,i.indexBuffer,i.segments);}}function wo(e,i){if(!i.mesh){const r=new t.aI;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const o=new t.aK;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),i.mesh=new wt(e.createVertexBuffer(r,Tt.members),e.createIndexBuffer(o),t.aJ.simpleSegment(0,0,r.length,o.length));}return i.mesh}class To{constructor(e,i){this.context=new Vr(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ad(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=be.maxUnderzooming+be.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new vt;}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize();}setup(){const e=this.context,i=new t.aI;i.emplaceBack(0,0),i.emplaceBack(t.Z,0),i.emplaceBack(0,t.Z),i.emplaceBack(t.Z,t.Z),this.tileExtentBuffer=e.createVertexBuffer(i,Tt.members),this.tileExtentSegments=t.aJ.simpleSegment(0,0,4,2);const r=new t.aI;r.emplaceBack(0,0),r.emplaceBack(t.Z,0),r.emplaceBack(0,t.Z),r.emplaceBack(t.Z,t.Z),this.debugBuffer=e.createVertexBuffer(r,Tt.members),this.debugSegments=t.aJ.simpleSegment(0,0,4,5);const o=new t.b_;o.emplaceBack(0,0,0,0),o.emplaceBack(t.Z,0,t.Z,0),o.emplaceBack(0,t.Z,0,t.Z),o.emplaceBack(t.Z,t.Z,t.Z,t.Z),this.rasterBoundsBuffer=e.createVertexBuffer(o,yi.members),this.rasterBoundsSegments=t.aJ.simpleSegment(0,0,4,2);const a=new t.aI;a.emplaceBack(0,0),a.emplaceBack(t.Z,0),a.emplaceBack(0,t.Z),a.emplaceBack(t.Z,t.Z),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,Tt.members),this.rasterBoundsSegmentsPosOnly=t.aJ.simpleSegment(0,0,4,5);const s=new t.aI;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Tt.members),this.viewportSegments=t.aJ.simpleSegment(0,0,4,2);const n=new t.b$;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);const l=new t.aK;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Vt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new wt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.K();t.bQ(r,0,this.width,this.height,0,0,1),t.M(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const o={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,Ut.disabled,this.stencilClearMode,jt.disabled,Nt.disabled,null,null,o,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(jt.disabled),r.setDepthMode(Ut.disabled);const o={};for(const e of t)o[e.key]=this.nextStencilID++;this._renderTileMasks(o,t,i,!0),this._renderTileMasks(o,t,i,!1),this._tileClippingMaskIDs=o;}_renderTileMasks(e,t,i,r){const o=this.context,a=o.gl,s=this.style.projection,n=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=s.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=n.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(o,a.TRIANGLES,Ut.disabled,new Vt({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),jt.disabled,i?Nt.disabled:Nt.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments);}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,o=this.useProgram("depth"),a=this.getDepthModeFor3D(),s=xe(r,{tileSize:r.tileSize});for(const n of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(n),l=i.getMeshFromTileID(this.context,n.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(e,t.TRIANGLES,a,Vt.disabled,jt.disabled,Nt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Vt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Vt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(this.clearStencil(),o>1){const e={},a={};for(let i=0;i0};for(const e in n){const t=n[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse();}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.b7.black:t.b7.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,o=((e,t,i)=>{const r=Math.cos(t.rollInRadians),o=Math.sin(t.rollInRadians),a=ue(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return {u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-a*o)*i,(t.height/2+a*r)*i],u_horizon_normal:[-o,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),a=new Ut(r.LEQUAL,Ut.ReadWrite,[0,1]),s=Vt.disabled,n=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=wo(i,t);l.draw(i,r.TRIANGLES,a,s,n,Nt.disabled,o,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments);}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[a[this.currentLayer]],t=n[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,u);}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:o}))(c,u,[p[0],p[1],p[2]],d,_),f=wo(o,i);s.draw(o,a.TRIANGLES,n,Vt.disabled,jt.alphaBlended,Nt.disabled,m,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments);}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[])),o=r.filter((e=>"vector"===e.getSource().type)),a=r.filter((e=>"vector"!==e.getSource().type)),s=e=>{(!i||i.getSource().maxzooms(e))),i||a.forEach((e=>s(e))),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;ru.getElevation(a,e,t):null;Kr(s,d,_,c,h,f,i,p,g,t.aA(h,e,n,l),a.toUnwrapped(),r);}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),a),0!==r.paint.get("icon-opacity").constantOr(1)&&Yr(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,n),0!==r.paint.get("text-opacity").constantOr(1)&&Yr(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,n),i.map.showCollisionBoxes&&(Wr(e,i,r,o,!0),Wr(e,i,r,o,!1));}(e,i,r,o,this.style.placement.variableOffsets,a):t.c4(r)?function(e,i,r,o,a){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=a,n=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===n.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,_=e.transform,p=e.getDepthModeForSublayer(0,Ut.ReadOnly),m=Vt.disabled,f=e.colorModeForRenderPass(),g=[],v=_.getCircleRadiusCorrection();for(let a=0;ae.sortKey-t.sortKey));for(const t of g){const{programConfiguration:i,program:o,layoutVertexBuffer:a,indexBuffer:s,uniformValues:n,terrainData:l,projectionData:c}=t.state;o.draw(u,d.TRIANGLES,p,m,f,Nt.backCCW,n,l,c,r.id,a,s,t.segments,r.paint,e.transform.zoom,i);}}(e,i,r,o,a):t.c5(r)?function(e,i,r,o,a){if(0===r.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:n,isRenderingGlobe:l}=a;if(e.style.map.terrain){for(const t of o){const o=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?eo(e,o,r,t,l):"translucent"===e.renderPass&&to(e,r,t,n,l));}s.viewport.set([0,0,e.width,e.height]);}else "offscreen"===e.renderPass?function(e,i,r,o){const a=e.context,s=a.gl,n=e.transform,l=Vt.disabled,c=new jt([s.ONE,s.ONE],t.b7.transparent,[!0,!0,!0,!0]);((function(e,i,r){const o=e.gl;e.activeTexture.set(o.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let a=r.heatmapFbos.get(t.bW);a?(o.bindTexture(o.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=io(e,i.width/4,i.height/4),r.heatmapFbos.set(t.bW,a));}))(a,e,r),a.clear({color:t.b7.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return !1;if(!e.from||!e.to)return !0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return !t||!i}useProgram(e,t,i=!1,r=[]){this.cache=this.cache||{};const o=!!this.style.map.terrain,a=this.style.projection,s=i?bt.projectionMercator:a.shaderPreludeCode,n=i?Pt:a.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Ct:a.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(o?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||(this.cache[l]=new Mi(this.context,bt[e],t,ir[e],this._showOverdrawInspector,o,s,n,r)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new v(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Po(e,t){let i,r=!1,o=null,a=null;const s=()=>{o=null,r&&(e.apply(a,i),o=setTimeout(s,t),r=!1);};return (...e)=>(r=!0,a=this,i=e,o||s(),o)}class Co{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return !1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e);},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let o=window.location.href.replace(/(#.+)?$/,r);o=o.replace("&&","&"),window.history.replaceState(window.history.state,null,o);},this._updateHash=Po(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e);}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),a=Math.round(t.lng*o)/o,s=Math.round(t.lat*o)/o,n=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${a}/${s}/${i}`:`${i}/${s}/${a}`,(n||l)&&(c+="/"+Math.round(10*n)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return `#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return !1;try{new t.Q(+e[2],+e[1]);}catch(e){return !1}const i=+e[0],r=+(e[3]||0),o=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&o>=this._map.getMinPitch()&&o<=this._map.getMaxPitch()}}const Mo={linearity:.3,easing:t.cd(0,0,.3,1)},Io=t.e({deceleration:2500,maxSpeed:1400},Mo),Eo=t.e({deceleration:20,maxSpeed:1400},Mo),So=t.e({deceleration:1e3,maxSpeed:360},Mo),Ro=t.e({deceleration:1e3,maxSpeed:90},Mo),zo=t.e({deceleration:1e3,maxSpeed:360},Mo);class Do{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=s.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const a=Lo(i.pan.mag(),r,t.e({},Io,e||{})),s=i.pan.mult(a.amount/i.pan.mag()),n=this._map.cameraHelper.handlePanInertia(s,this._map.transform);o.center=n.easingCenter,o.offset=n.easingOffset,Ao(o,a);}if(i.zoom){const e=Lo(i.zoom,r,Eo);o.zoom=this._map.transform.zoom+e.amount,Ao(o,e);}if(i.bearing){const e=Lo(i.bearing,r,So);o.bearing=this._map.transform.bearing+t.ae(e.amount,-179,179),Ao(o,e);}if(i.pitch){const e=Lo(i.pitch,r,Ro);o.pitch=this._map.transform.pitch+e.amount,Ao(o,e);}if(i.roll){const e=Lo(i.roll,r,zo);o.roll=this._map.transform.roll+t.ae(e.amount,-179,179),Ao(o,e);}if(o.zoom||o.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;o.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),t.e(o,{noMoveStart:!0})}}function Ao(e,t){(!e.duration||e.durationi.unproject(e))),l=a.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1;}}class Bo extends t.l{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class Oo{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){delete this._mousedownPos;}wheel(e){return this._firePreventable(new Bo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ko(e.type,this._map,e))}mouseup(e){this._map.fire(new ko(e.type,this._map,e));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ko(e.type,this._map,e));}dblclick(e){return this._firePreventable(new ko(e.type,this._map,e))}mouseover(e){this._map.fire(new ko(e.type,this._map,e));}mouseout(e){this._map.fire(new ko(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Fo(e.type,this._map,e))}touchmove(e){this._map.fire(new Fo(e.type,this._map,e));}touchend(e){this._map.fire(new Fo(e.type,this._map,e));}touchcancel(e){this._map.fire(new Fo(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class jo{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(e){this._map.fire(new ko(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ko("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ko(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Zo{constructor(e){this._map=e;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class No{constructor(e,t){this._map=e,this._tr=new Zo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(r,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function Uo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=Uo(r,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=Uo(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Vo{constructor(e){this.singleTap=new Go(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class qo{constructor(e){this._tr=new Zo(e),this._zoomIn=new Vo({numTouches:1,numTaps:2}),this._zoomOut=new Vo({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),o=this._zoomOut.touchend(e,t,i),a=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(r)},{originalEvent:e})}):o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(o)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Wo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset();}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e);}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return !this._moved&&r.dist(i)!0}),t=new Xo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t;}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)));}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)));}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Qo=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault();};};class Yo{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0);}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const o=Uo(r,i),a=new t.P(0,0),s=new t.P(0,0);let n=0;for(const e in o){const t=o[e],i=this._touches[e];i&&(a._add(t),s._add(t.sub(i)),n++,o[e]=t);}if(this._touches=o,this._shouldBePrevented(n)||!s.mag())return;const l=s.div(n);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class sa extends Jo{constructor(e){super(),this._currentTouchCount=0,this._map=e;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length;}_start(e){this._lastPoints=e,aa(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),o=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,o=t.mag()>=2;if(!r&&!o)return;if(!r||!o)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const a=e.y>0==t.y>0;return aa(e)&&aa(t)&&a}}const na={panStep:100,bearingStep:15,pitchStep:10};class la{constructor(e){this._tr=new Zo(e);const t=na;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,o=0,a=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),o=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),o=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const n=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:ca,zoom:t?Math.round(n.zoom)+t*(e.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+r*this._pitchStep,offset:[-o*this._panStep,-a*this._panStep],center:n.center},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function ca(e){return e*(2-e)}const ha=4.000244140625;class ua{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);},this._map=e,this._tr=new Zo(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(e){return !!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=s.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%ha==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=n.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.Q.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t);}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>ha?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const o="number"!=typeof this._targetZoom?e.scale:t.ac(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),t.ah(o*r)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,o=this._easing;let a,n=!1;if("wheel"===this._type&&r&&o){const e=s.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=o(l);a=t.B.number(r,i,c),l<1?this._frameId||(this._frameId=!0):n=!0;}else a=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout;}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!n,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cf;if(this._prevEase){const e=this._prevEase,r=(s.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(o*o+1e-4)*.01,n=Math.sqrt(.0729-a*a);i=t.cd(a,n,.25,1);}return this._prevEase={start:s.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class da{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class _a{constructor(e){this._tr=new Zo(e),this.reset();}reset(){this._active=!1;}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class pa{constructor(){this._tap=new Vo({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],o=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;o&&a?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(e,t,i);}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ma{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class fa{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class ga{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class va{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=n.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const o=document.createElement("div");o.className="maplibregl-mobile-message",o.textContent=i,this._container.appendChild(o),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(n.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const xa=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class ba extends t.l{}function ya(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class wa{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`);},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===e.type?void 0:e,o={needsRenderFrame:!1},a={},s={};for(const{handlerName:l,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(s,h,l))c.reset();else if(c[i||e.type]){if(t.cg(e,i||e.type)){const t=n.mousePos(this._map.getCanvas(),e);u=c[i||e.type](e,t);}else if(t.ch(e,i||e.type)){const t=this._getMapTouches(e.touches),r=n.touchPos(this._map.getCanvas(),t);u=c[i||e.type](e,r,t);}else t.ci(i||e.type)||(u=c[i||e.type](e));this.mergeHandlerResult(o,a,u,l,r),u&&u.needsRenderFrame&&this._triggerRenderFrame();}(u||c.isActive())&&(s[l]=c);}const l={};for(const e in this._previousActiveHandlers)s[e]||(l[e]=r);this._previousActiveHandlers=s,(Object.keys(l).length||ya(o))&&(this._changes.push([o,a,l]),this._triggerRenderFrame()),(Object.keys(s).length||ya(o))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=o;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map));},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Do(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)n.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[e,t,i]of this._listeners)n.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new Oo(i,e));const o=i.boxZoom=new No(i,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const a=i.cooperativeGestures=new va(i,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();const s=new qo(i),l=new _a(i);i.doubleClickZoom=new da(l,s),this._add("tapZoom",s),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new pa;this._add("tapDragZoom",c);const h=i.touchPitch=new sa(i);this._add("touchPitch",h),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:o=100,rotateDegreesPerPixelMoved:a=.8},s){const l=new $o({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Wo({clickTolerance:i,move:(e,i)=>{const n=s();if(r&&Math.abs(n.y-e.y)>o)return {bearingDelta:t.ce(new t.P(e.x,i.y),i,n)};let l=(i.x-e.x)*a;return r&&i.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Wo({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:Qo})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const o=new $o({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Wo({clickTolerance:t,move:(e,t)=>{const o=r();let a=(t.x-e.x)*i;return t.y0===n.mouseButton(e)&&!e.ctrlKey});return new Wo({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Qo})}(e),f=new Yo(e,i);i.dragPan=new ma(r,m,f),this._add("mousePan",m),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new oa,v=new ia;i.touchZoomRotate=new ga(r,v,g,c),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",v,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const x=i.scrollZoom=new ua(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const b=i.keyboard=new la(i);this._add("keyboard",b),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new jo(i));}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[];}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(xa(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,o,a){if(!r)return;t.e(e,r);const s={handlerName:o,originalEvent:r.originalEvent||a};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s);}_applyChanges(){const e={},i={},r={};for(const[o,a,s]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(e.rollDelta=(e.rollDelta||0)+o.rollDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.e(i,a),t.e(r,s);this._updateMapTransform(e,i,r),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,o=r._getTransformForUpdate(),a=r.terrain;if(!(ya(e)||a&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:n,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u=u||r.transform.centerPoint,a&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const _={panDelta:s,zoomDelta:n,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const p=u.distSqr(o.centerPoint)<.01?o.center:o.screenPointToLocation(s?u.sub(s):u);a?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?o.setCenter(o.screenPointToLocation(o.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(_,o,p):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(_,o,p))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._map.cameraHelper.handleMapControlsPan(_,o,p)),r._applyUpdatedTransform(o),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,i,r){const o=xa(this._eventsInProgress),a=xa(e),n={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(n[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!o&&a&&this._fireEvent("movestart",a.originalEvent);for(const e in n)this._fireEvent(e,n[e]);a&&this._fireEvent("move",a.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||r,l[`${e}end`]=c);}for(const e in l)this._fireEvent(e,l[e]);const h=xa(this._eventsInProgress),u=(o||a)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e);}if(r&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ba("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class Ta extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState;}));}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t;}getCenter(){return new t.Q(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e;}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){f.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.l("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.l("rollstart",e));}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.setElevation(t.B.number(this._elevationStart,this._elevationTarget,e));}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return {};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:o,roll:a,pitch:s,bearing:n,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==o&&t.setZoom(o),void 0!==a&&t.setRoll(a),void 0!==s&&t.setPitch(s),void 0!==n&&t.setBearing(n),i.apply(t);}this.transform.apply(i);}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,o=this._rotating,a=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l("zoomend",e)),o&&this.fire(new t.l("rotateend",e)),a&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e));}flyTo(e,i){if(!e.essential&&s.prefersReducedMotion){const r=t.O(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cf},e);const r=this._getTransformForUpdate(),o=r.bearing,a=r.pitch,n=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:a,u="roll"in e?this._normalizeBearing(e.roll,n):n,d="padding"in e?e.padding:r.padding,_=t.P.convert(e.offset);let p=r.centerPoint.add(_);const m=r.screenPointToLocation(p),f=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:_,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let g=e.curve;const v=Math.max(r.width,r.height),x=v/f.scaleOfZoom,b=f.pixelPathLength;"number"==typeof f.scaleOfMinZoom&&(g=Math.sqrt(v/f.scaleOfMinZoom/b*2));const y=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*y*y*b*b)/(2*(e?x:v)*y*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const C=w(!1);let M=function(e){return P(C)/P(C+g*e)},I=function(e){return v*((P(C)*(T(t=C+g*e)/P(t))-T(C))/y)/b;var t;},E=(w(!0)-C)/g;if(Math.abs(b)<2e-6||!isFinite(E)){if(Math.abs(v-x)<1e-6)return this.easeTo(e,i);const t=x0,M=e=>Math.exp(t*g*e);}return e.duration="duration"in e?+e.duration:1e3*E/("screenSpeed"in e?+e.screenSpeed/g:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==a,this._rolling=u!==n,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease((s=>{const m=s*E,g=1/M(m),v=I(m);this._rotating&&r.setBearing(t.B.number(o,c,s)),this._pitching&&r.setPitch(t.B.number(a,h,s)),this._rolling&&r.setRoll(t.B.number(n,u,s)),this._padding&&(r.interpolatePadding(l,d,s),p=r.centerPoint.add(_)),f.easeFunc(s,g,v,p),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t);}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.aL(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class Ca{constructor(e=Pa){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=e;}getDefaultPosition(){return "bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style.sourceCaches;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return !1;return !0}));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=n.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class Ma{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact");}},this.options=e;}getDefaultPosition(){return "bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=n.create("div","maplibregl-ctrl");const t=n.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class Ia{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var Ea=t.aG([{name:"a_pos3d",type:"Int16",components:3}]);class Sa extends t.E{constructor(e){super(),this._lastTilesetChange=s.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const r={};for(const o of xe(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float64Array(16),t.bQ(o.terrainRttPosMatrix32f,0,t.Z,t.Z,0,0,1),this._tiles[o.key]=new ae(o,this.tileSize),this._lastTilesetChange=s.now());for(const e in this._tiles)r[e]||delete this._tiles[e];}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID,a=e.clone(),s=t.b2();if(o.canonical.equals(e.canonical))t.bQ(s,0,t.Z,t.Z,0,0,1);else if(o.canonical.isChildOf(e.canonical)){const i=o.canonical.z-e.canonical.z,r=o.canonical.x-(o.canonical.x>>i<>i<>i;t.bQ(s,0,n,n,0,0,1),t.L(s,s,[-r*n,-a*n,0]);}else {if(!e.canonical.isChildOf(o.canonical))continue;{const i=e.canonical.z-o.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bQ(s,0,t.Z,t.Z,0,0,1),t.L(s,s,[r*n,a*n,0]),t.M(s,s,[1/2**i,1/2**i,0]);}}a.terrainRttPosMatrix32f=new Float32Array(s),i[r]=a;}return i}_getTerrainCoordsForTileRanges(e,i){const r={};for(const o of this._renderableTilesKeys){const a=this._tiles[o].tileID;if(!this._isWithinTileRanges(a,i))continue;const s=e.clone(),n=t.b2();if(a.canonical.z===e.canonical.z){const i=e.canonical.x-a.canonical.x,r=e.canonical.y-a.canonical.y;t.bQ(n,0,t.Z,t.Z,0,0,1),t.L(n,n,[i*t.Z,r*t.Z,0]);}else if(a.canonical.z>e.canonical.z){const i=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>i<>i<>i),l=e.canonical.y-(a.canonical.y>>i),c=t.Z>>i;t.bQ(n,0,c,c,0,0,1),t.L(n,n,[-r*c+s*t.Z,-o*c+l*t.Z,0]);}else {const i=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i)-a.canonical.x,l=(e.canonical.y>>i)-a.canonical.y,c=t.Z<i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!o||!o.dem);)o=this.sourceCache.getTileByID(e.scaledTo(r--).key);return o}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Ra{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Sa(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(e,i,r,o=t.Z){var a;if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?o=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=e.canonical.x-(e.canonical.x>>o<>o<>8<<4|e>>8,i[t+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),o=new v(e,r,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,o=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(a,n-s-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,_=(1<0,o=r&&0===e.canonical.y,a=r&&e.canonical.y===(1<e.id!==t)),this._recentlyUsed.push(e.id);}stampObject(e){e.stamp=++this._stamp;}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1;}freeAllObjects(){for(const e of this._objects)this.freeObject(e);}isFull(){return !(this._objects.length!e.inUse))}}const Da={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Aa{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new za(e.context,30,t.sourceCache.tileSize*t.qualityFactor);}destruct(){this.pool.destruct();}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates(),r=e.sourceCaches[t].getSource(),o=r instanceof K?r.terrainTileRanges:null;for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e,o);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e]);}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],r=i.source;if(Da[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join();}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[]);}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return !1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),o=e.type,a=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Da[o]&&(this._prevType&&Da[this._prevType]||this._stacks.push([]),this._prevType=o,this._stacks[this._stacks.length-1].push(e.id),!s))return !0;if(Da[this._prevType]||Da[o]&&s){this._prevType=o;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const o of this._renderableTiles){if(this.pool.isFull()&&(yo(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(o),o.rtt[e]){const t=this.pool.getObjectForId(o.rtt[e].id);if(t.stamp===o.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),o.rtt[e]={id:s.id,stamp:s.stamp},a.context.bindFramebuffer.set(s.fbo.framebuffer),a.context.clear({color:t.b7.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=e=>{this.move(e,n.mousePos(this.element,e));},this.mouseup=e=>{this._rotatePitchHanlder.dragEnd(e),this.offTemp();},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend));},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos));},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10,this.element=i;const o=new Ko;this._rotatePitchHanlder=new Wo({clickTolerance:3,move:(e,o)=>{const a=i.getBoundingClientRect(),s=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return {bearingDelta:t.ce(new t.P(e.x,o.y),o,s),pitchDelta:r?-.5*(o.y-e.y):void 0}},moveStateManager:o,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(i,"mousedown",this.mousedown),n.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(i,"touchcancel",this.reset);}startMove(e,t){this._rotatePitchHanlder.dragStart(e,t),n.disableDrag();}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:o}=this._rotatePitchHanlder.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),o&&i.setPitch(i.getPitch()+o);}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp();}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend);}}let ja;function Za(e,i,r,o=!1){if(o||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const a=new t.Q(e.lng,e.lat);if(e=new t.Q(e.lng,e.lat),i){const o=new t.Q(e.lng-360,e.lat),a=new t.Q(e.lng+360,e.lat),s=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(o).distSqr(i)180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360;}return e.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:a}const Na={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Ua(e,t,i){const r=e.classList;for(const e in Na)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`);}class Ga extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=Za(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${Na[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`),s.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type);})).catch((()=>{}));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive";},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=n.create("div");const i=n.createNS("http://www.w3.org/2000/svg","svg"),r=41,o=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${o}px`),i.setAttributeNS(null,"viewBox",`0 0 ${o} ${r}`);const a=n.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");const s=n.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=n.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=n.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t);}const h=n.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=n.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=n.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=n.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=n.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=n.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=n.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),s.appendChild(l),s.appendChild(h),s.appendChild(d),s.appendChild(p),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();})),Ua(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-13.5,-1*(t-i)]}:this._offset;}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;const o=null===(i=this._map)||void 0===i?void 0:i.terrain,a=this._map.transform.isLocationOccluded(this._lngLat);if(!o||a){const e=a?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const s=this._map,n=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-n<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,h=Math.sin(s.getPitch()*Math.PI/180)*c,u=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+h)-u>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity;}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e);}removeClassName(e){this._element.classList.remove(e);}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return (void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Va={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let qa=0,Wa=!1;const Ha={maxWidth:100,unit:"metric"};function $a(e,t,i){const r=i&&i.maxWidth||100,o=e._container.clientHeight/2,a=e._container.clientWidth/2,s=e.unproject([a-r/2,o]),n=e.unproject([a+r/2,o]),l=Math.round(e.project(n).x-e.project(s).x),c=Math.min(r,l,e._container.clientWidth),h=s.distanceTo(n);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Xa(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Xa(t,c,i,e._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?Xa(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Xa(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):Xa(t,c,h,e._getUIString("ScaleControl.Meters"));}function Xa(e,t,i,r){const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(o/i)+"px",e.innerHTML=`${o} ${r}`;}const Ka={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Qa=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ya(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Ya(new t.P(0,0))}const Ja=i;e.AJAXError=t.cq,e.Event=t.l,e.Evented=t.E,e.LngLat=t.Q,e.MercatorCoordinate=t.$,e.Point=t.P,e.addProtocol=t.cr,e.config=t.a,e.removeProtocol=t.cs,e.AttributionControl=Ca,e.BoxZoomHandler=No,e.CanvasSource=Y,e.CooperativeGesturesHandler=va,e.DoubleClickZoomHandler=da,e.DragPanHandler=ma,e.DragRotateHandler=fa,e.EdgeInsets=It,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},e.GeoJSONSource=X,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "BACKGROUND":case "BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.Q(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),a=t.e({bearing:o},this.options.fitBoundsOptions),s=V.fromLngLat(i,r);this._map.fitBounds(s,a,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.Q(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&Wa)return;this.options.trackUserLocation&&this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ga({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ga({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")));}));}},this.options=t.e({},Va,e);}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(void 0!==ja&&!e)return ja;if(void 0===window.navigator.permissions)return ja=!!window.navigator.geolocation,ja;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ja="denied"!==e.state;}catch(e){ja=!!window.navigator.geolocation;}return ja}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,qa=0,Wa=!1;}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case "ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),r=t.distanceTo(i),o=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.l("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":qa--,Wa=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case "BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case "WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),qa++,qa>1?(e={maximumAge:6e5,timeout:0},Wa=!0):(e=this.options.positionOptions,Wa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon();},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"));};}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0;}},e.Hash=Co,e.ImageSource=K,e.KeyboardHandler=la,e.LngLatBounds=V,e.LogoControl=Ma,e.Map=class extends Ta{constructor(e){var i,r;t.cn.mark(t.co.create);const o=Object.assign(Object.assign(Object.assign({},Fa),e),{canvasContextAttributes:Object.assign(Object.assign({},Fa.canvasContextAttributes),e.canvasContextAttributes)});if(null!=o.minZoom&&null!=o.maxZoom&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=o.minPitch&&null!=o.maxPitch&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=o.minPitch&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=o.maxPitch&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const a=new Lt,s=new Ot;if(void 0!==o.minZoom&&a.setMinZoom(o.minZoom),void 0!==o.maxZoom&&a.setMaxZoom(o.maxZoom),void 0!==o.minPitch&&a.setMinPitch(o.minPitch),void 0!==o.maxPitch&&a.setMaxPitch(o.maxPitch),void 0!==o.renderWorldCopies&&a.setRenderWorldCopies(o.renderWorldCopies),super(a,s,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ia,this._controls=[],this._mapId=t.a4(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.l("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=!0===o.trackResize,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=!0===o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=!0===o.crossSourceCollisions,this._collectResourceTiming=!0===o.collectResourceTiming,this._locale=Object.assign(Object.assign({},La),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this.transformCameraUpdate=o.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===o.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=p.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(o.transformRequest),"string"==typeof o.container){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else {if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container;}if(o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})),this.once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Po((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw());}),50);this._resizeObserver=new ResizeObserver((i=>{e?t(i):e=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new wa(this,o),this._hash=o.hash&&new Co("string"==typeof o.hash&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,t.e({},o.fitBoundsOptions,{duration:0}))));const n="string"==typeof o.style||!("globe"===(null===(r=null===(i=o.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,n),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new Ca("boolean"==typeof o.attributionControl?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Ma,o.logoPosition),this.on("style.load",(()=>{if(n||this._resizeTransform(),this.transform.unmodified){const e=t.O(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e);}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.l(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.l("sourcedataabort",e));}));}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return -1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){const[r,o]=this._containerDimensions(),a=this._getClampedPixelRatio(r,o);if(this._resizeCanvas(r,o,a),this.painter.resize(r,o,a),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(r,o);this._resizeCanvas(r,o,t),this.painter.resize(r,o,t);}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e);}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,o=this.getPixelRatio(),a=e*o,s=t*o;return Math.min(a>i?i/a:1,s>r?r/s:1)*o}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(V.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.Q.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e))),s=0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[];s.length?r||(r=!0,i.call(this,new ko(e,this,o.originalEvent,{features:s}))):r=!1;};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e)));(0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[]).length?r=!0:r&&(r=!1,i.call(this,new ko(e,this,o.originalEvent)));},a=t=>{r&&(r=!1,i.call(this,new ko(e,this,t.originalEvent)));};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:a}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),o=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];o.length&&(e.features=o,i.call(this,e),delete e.features);};return {layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t);}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let e=0;et.includes(e)))){for(const e in o.delegates)this.off(e,o.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,o);for(const e in o.delegates)this.on(e,o.delegates[e]);return {unsubscribe:()=>{this._removeDelegatedListener(e,r,i);}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);for(const t in o.delegates){const a=o.delegates[t];o.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),a(...t);};}this._saveDelegatedListener(e,o);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return [];let r;const o=e instanceof t.P||Array.isArray(e),a=o?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(o?{}:e)||{},a instanceof t.P||"number"==typeof a[0])r=[t.P.convert(a)];else {const e=t.P.convert(a[0]),i=t.P.convert(a[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e];}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return !1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new bi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new bi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,"Style");t.j(r,new AbortController).then((e=>{this._updateDiff(e.data,i);})).catch((e=>{e&&this.fire(new t.k(e));}));}else "object"==typeof e&&this._updateDiff(e,i);}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no source with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new Ra(this.painter,i,e),this.painter.renderToTexture=new Aa(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=fe(Math.max(1,e),Math.max(1,t));}else for(const i in this.style.sourceCaches)this.style.sourceCaches[i].getSource().calculateTileZoom=fe(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const r=this.style.sourceCaches[e];if(!r)throw new Error(`There is no source cache with ID "${e}", cannot refresh tile`);void 0===i?r.reload():r.refreshTiles(i.map((e=>new t.a1(e.z,e.x,e.y))));}addImage(e,i,r={}){const{pixelRatio:o=1,sdf:a=!1,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:s,data:d}=i,_=i;return this.style.addImage(e,{data:new t.R({width:r,height:s},new Uint8Array(d)),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0,userImage:_}),_.onAdd&&_.onAdd(this,e),this}}{const{width:r,height:d,data:_}=s.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},_),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0});}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||t.b(i)?s.getImageData(i):i,{width:a,height:n,data:l}=o;if(void 0===a||void 0===n)return this.fire(new t.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(a!==r.data.width||n!==r.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e){return p.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,(e=>{e||this._update(!0);})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0);})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const o=this._controlContainer=n.create("div","maplibregl-control-container",e),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{a[e]=n.create("div",`maplibregl-ctrl-${e} `,o);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type);}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new To(i,this.transform),l.testSupport(i);}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}));}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_render(e){var i,r,o,a,n;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=s.now();this.style.zoomHistory.update(e,i);const r=new t.C(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=r.crossFadingFactor();1===o&&o===this._crossFadingFactor||(h=!0,this._crossFadingFactor=o),this.style.update(r);}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(o=this.style.projection)||void 0===o||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(a=this.style.projection)||void 0===a?void 0:a.transitionState,null===(n=this.style.projection)||void 0===n?void 0:n.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cn.mark(t.co.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cn.mark(t.co.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),p.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cn.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(e=>{t.cn.frame(e),this._frameRequest=null;try{this._render(e);}catch(e){if(!t.cp(e)&&!function(e){return e.message===Ur}(e))throw e}}),(()=>{})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get version(){return ka}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=ko,e.MapTouchEvent=Fo,e.MapWheelEvent=Bo,e.Marker=Ga,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`;},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i);},this.options=t.e({},Ba,e),this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e});})),this._compassIcon=n.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Oa(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(e,t){const i=n.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:void 0);},this.remove=()=>(this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point);},this._onMouseMove=e=>{this._update(e.point);},this._onDrag=e=>{this._update(e.point);},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Za(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const r=Ya(this.options.offset);if(!i){const e=this._container.offsetWidth,o=this._container.offsetHeight;let a;a=t.y+r.bottom.ythis._map.transform.height-o?["bottom"]:[],t.xthis._map.transform.width-e/2&&a.push("right"),i=0===a.length?"bottom":a.join("-");}let o=t.add(r[i]);this.options.subpixelPositioning||(o=o.round()),n.setTransform(this._container,`${Na[i]} translate(${o.x}px,${o.y}px)`),Ua(this._container,i,"popup"),this._updateOpacity();},this._onClose=()=>{this.remove();},this.options=t.e(Object.create(Ka),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Qa);e&&e.focus();}},e.RasterDEMTileSource=$,e.RasterTileSource=H,e.ScaleControl=class{constructor(e){this._onMove=()=>{$a(this._map,this._container,this.options);},this.setUnit=e=>{this.options.unit=e,$a(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},Ha),e);}getDefaultPosition(){return "bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},e.ScrollZoomHandler=ua,e.Style=bi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=e;}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},e.TwoFingersTouchPitchHandler=sa,e.TwoFingersTouchRotateHandler=oa,e.TwoFingersTouchZoomHandler=ia,e.TwoFingersTouchZoomRotateHandler=ga,e.VectorTileSource=W,e.VideoSource=Q,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,(function*(){if(ee(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{J[e]=t;})(e,i);})),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(z),L=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},e.createTileMesh=Xt,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return oe().getRTLTextPluginStatus()},e.getVersion=function(){return Ja},e.getWorkerCount=function(){return D.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return O().broadcast("IS",e)},e.prewarm=function(){F().acquire(z);},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e;},e.setRTLTextPlugin=function(e,t){return oe().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){D.workerCount=e;},e.setWorkerUrl=function(e){t.a.WORKER_URL=e;};})); + +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + + +var maplibregl$1 = maplibregl; + +return maplibregl$1; + +})); +//# sourceMappingURL=maplibre-gl.js.map diff --git a/docs/articles/getting-started_files/maplibregl-binding-0.1.4.9000/maplibregl.js b/docs/articles/getting-started_files/maplibregl-binding-0.1.4.9000/maplibregl.js new file mode 100644 index 00000000..01895aae --- /dev/null +++ b/docs/articles/getting-started_files/maplibregl-binding-0.1.4.9000/maplibregl.js @@ -0,0 +1,1932 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/maplibregl-binding-0.2.0.9000/maplibregl.js b/docs/articles/getting-started_files/maplibregl-binding-0.2.0.9000/maplibregl.js new file mode 100644 index 00000000..4ea4f853 --- /dev/null +++ b/docs/articles/getting-started_files/maplibregl-binding-0.2.0.9000/maplibregl.js @@ -0,0 +1,2135 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[layer.popup]; + + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), + ); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/maplibregl-binding-0.2.0/maplibregl.js b/docs/articles/getting-started_files/maplibregl-binding-0.2.0/maplibregl.js new file mode 100644 index 00000000..01895aae --- /dev/null +++ b/docs/articles/getting-started_files/maplibregl-binding-0.2.0/maplibregl.js @@ -0,0 +1,1932 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/maplibregl-binding-0.2.1/maplibregl.js b/docs/articles/getting-started_files/maplibregl-binding-0.2.1/maplibregl.js new file mode 100644 index 00000000..4ea4f853 --- /dev/null +++ b/docs/articles/getting-started_files/maplibregl-binding-0.2.1/maplibregl.js @@ -0,0 +1,2135 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[layer.popup]; + + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), + ); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/getting-started_files/maplibregl-binding-0.2.2.9000/maplibregl.js b/docs/articles/getting-started_files/maplibregl-binding-0.2.2.9000/maplibregl.js new file mode 100644 index 00000000..b43114cf --- /dev/null +++ b/docs/articles/getting-started_files/maplibregl-binding-0.2.2.9000/maplibregl.js @@ -0,0 +1,3133 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case 'get': + return properties[expression[1]]; + case 'concat': + return expression.slice(1).map(item => evaluateExpression(item, properties)).join(''); + case 'to-string': + return String(evaluateExpression(expression[1], properties)); + case 'to-number': + return Number(evaluateExpression(expression[1], properties)); + case 'number-format': + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || 'en-US'; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty('min-fraction-digits')) { + formatOptions.minimumFractionDigits = options['min-fraction-digits']; + } + if (options.hasOwnProperty('max-fraction-digits')) { + formatOptions.maximumFractionDigits = options['max-fraction-digits']; + } + if (options.hasOwnProperty('min-integer-digits')) { + formatOptions.minimumIntegerDigits = options['min-integer-digits']; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty('useGrouping')) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(tooltipProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + window._mapboxPopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layerId] === popup) { + delete window._mapboxPopups[layerId]; + } + }); +} + +// Helper function to generate draw styles based on parameters +function generateDrawStyles(styling) { + if (!styling) return null; + + return [ + // Point styles + { + 'id': 'gl-draw-point-active', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'true']], + 'paint': { + 'circle-radius': styling.vertex_radius + 2, + 'circle-color': styling.active_color + } + }, + { + 'id': 'gl-draw-point', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'false']], + 'paint': { + 'circle-radius': styling.vertex_radius, + 'circle-color': styling.point_color + } + }, + // Line styles + { + 'id': 'gl-draw-line', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'LineString']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Polygon fill + { + 'id': 'gl-draw-polygon-fill', + 'type': 'fill', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'paint': { + 'fill-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-outline-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-opacity': styling.fill_opacity + } + }, + // Polygon outline + { + 'id': 'gl-draw-polygon-stroke', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Midpoints + { + 'id': 'gl-draw-polygon-midpoint', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'midpoint']], + 'paint': { + 'circle-radius': 3, + 'circle-color': styling.active_color + } + }, + // Vertex point halos + { + 'id': 'gl-draw-vertex-halo-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 4, + styling.vertex_radius + 2 + ], + 'circle-color': '#FFF' + } + }, + // Vertex points + { + 'id': 'gl-draw-vertex-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 2, + styling.vertex_radius + ], + 'circle-color': styling.active_color + } + } + ]; +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, layer.popup, layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + // Check if the feature has an id + const featureId = e.features[0].id; + + // Only proceed if the feature has an id + if (featureId !== undefined && featureId !== null) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = featureId; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: true }, + ); + } + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), + ); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe control if enabled + if (x.globe_control) { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, x.globe_control.position); + map.controls.push(globeControl); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + // Generate styles if styling parameters provided + if (x.draw_control.styling) { + const generatedStyles = generateDrawStyles(x.draw_control.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + // Fix MapLibre compatibility - ensure we always have custom styles + if (!drawOptions.styles) { + drawOptions.styles = generateDrawStyles({ + vertex_radius: 5, + active_color: '#fbb03b', + point_color: '#3bb2d0', + line_color: '#3bb2d0', + fill_color: '#3bb2d0', + fill_opacity: 0.1, + line_width: 2 + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (x.draw_control.source) { + addSourceFeaturesToDraw(draw, x.draw_control.source, map); + } + + // Process any queued features + if (x.draw_features_queue) { + x.draw_features_queue.forEach(function(data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn('Source not found or has no data:', sourceId); + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + // Initialize with empty object, will be populated after map loads + let initialView = {}; + + // Capture the initial view after the map has loaded and all view operations are complete + map.once('load', function() { + initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + }); + + resetControl.onclick = function () { + // Only reset if we have captured the initial view + if (initialView.center) { + map.easeTo(initialView); + } + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDraw: function () { + return draw; // Return the draw instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + + // Helper function to update drawn features + function updateDrawnFeatures() { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + var drawnFeatures = drawControl.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(drawnFeatures) + ); + } + // Store drawn features in the widget's data + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, message.layer.popup, message.layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + // Check if the feature has an id + const featureId = e.features[0].id; + + // Only proceed if the feature has an id + if (featureId !== undefined && featureId !== null) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = featureId; + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: true }, + ); + } + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + // Check both message.layer and message.layer.id as keys due to different message formats + if (window._mapboxPopups) { + // First check if we have a popup stored with message.layer key + if (window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + // Also check if we have a popup stored with message.layer.id key, which happens when added via add_layer + if (message.layer && message.layer.id && window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + delete window._mapboxPopups[message.layer.id]; + } + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if (window._mapboxClickHandlers) { + // First check for handlers stored with message.layer key + if (window._mapboxClickHandlers[message.layer]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Also check for handlers stored with message.layer.id key from add_layer + if (message.layer && message.layer.id && window._mapboxClickHandlers[message.layer.id]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer.id] + ); + delete window._mapboxClickHandlers[message.layer.id]; + } + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + console.log("[MapGL Debug] Current style sources:", Object.keys(currentStyle.sources)); + console.log("[MapGL Debug] Current style layers:", currentStyle.layers.map(l => l.id)); + + // Store layer IDs we know were added by the user via R code + // This is the most reliable way to identify user-added layers + const knownUserLayerIds = []; + + // For each layer in the current style, determine if it's a user-added layer + currentStyle.layers.forEach(function(layer) { + const layerId = layer.id; + + // Critical: Check for nc_counties specifically since we know that's used in the test app + if (layerId === "nc_counties") { + console.log("[MapGL Debug] Found explicit test layer:", layerId); + knownUserLayerIds.push(layerId); + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found source from test layer:", layer.source); + userSourceIds.push(layer.source); + } + return; // Skip other checks for this layer + } + + // These are common patterns for user-added layers from R code + if ( + // Specific layer IDs from the R package + layerId.endsWith("_counties") || + layerId.endsWith("_label") || + layerId.endsWith("_layer") || + + // Look for hover handlers - only user-added layers have these + (window._mapboxHandlers && window._mapboxHandlers[layerId]) || + + // If the layer ID contains these strings, it's likely user-added + layerId.includes("user") || + layerId.includes("custom") || + + // If the paint property has a hover case, it's user-added + (layer.paint && Object.values(layer.paint).some(value => + Array.isArray(value) && + value[0] === "case" && + Array.isArray(value[1]) && + value[1][1] && + Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && + value[1][1][1] === "hover")) + ) { + console.log("[MapGL Debug] Found user layer:", layerId); + knownUserLayerIds.push(layerId); + // Also include its source + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found user source from layer:", layer.source); + userSourceIds.push(layer.source); + } + } + }); + + // For each source, determine if it's a user-added source + for (const sourceId in currentStyle.sources) { + const source = currentStyle.sources[sourceId]; + + // Strategy 1: All GeoJSON sources are likely user-added + if (source.type === "geojson") { + console.log("[MapGL Debug] Found user GeoJSON source:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 2: Check for source data URL patterns typical of R-generated data + else if (source.url && typeof source.url === 'string' && + (source.url.includes("data:application/json") || + source.url.includes("blob:"))) { + console.log("[MapGL Debug] Found user source with data URL:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 3: Standard filtering - exclude common base map sources + else if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") && + sourceId !== "openmaptiles" && // Common in MapLibre styles + !(sourceId.startsWith("carto") && sourceId !== "carto-source") && // Filter CARTO base sources but keep user ones + !(sourceId.startsWith("maptiler") && !sourceId.includes("user")) && // Filter MapTiler sources but keep user ones + !sourceId.includes("terrain") && // Common terrain sources + !sourceId.includes("hillshade") && // Common hillshade sources + !(sourceId.includes("basemap") && !sourceId.includes("user")) // Filter basemap sources but keep user ones + ) { + console.log("[MapGL Debug] Found user source via filtering:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + + // Identify layers using user-added sources or known user layer IDs + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source) || knownUserLayerIds.includes(layer.id)) { + userLayers.push(layer); + } + }); + + // Log detected user sources and layers + console.log("[MapGL Debug] Detected user sources:", userSourceIds); + console.log("[MapGL Debug] Detected user layers:", userLayers.map(l => l.id)); + + // Store them for potential use outside the onStyleLoad event + // This helps in case the event timing is different in MapLibre + if (!window._mapglPreservedData) { + window._mapglPreservedData = {}; + } + window._mapglPreservedData[map.getContainer().id] = { + sources: userSourceIds.map(id => ({id, source: currentStyle.sources[id]})), + layers: userLayers + }; + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + console.log("[MapGL Debug] style.load event fired"); + + try { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + try { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + console.log("[MapGL Debug] Re-adding source:", sourceId); + map.addSource(sourceId, source); + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding source:", sourceId, err); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Re-adding layer:", layer.id); + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + console.log("[MapGL Debug] Re-adding mousemove handler for:", layer.id); + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + console.log("[MapGL Debug] Re-adding mouseleave handler for:", layer.id); + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Check if we need to restore tooltip handlers + const layerId = layer.id; + if (layerId === "nc_counties" || layer.tooltip) { + console.log("[MapGL Debug] Restoring tooltip for:", layerId); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = layer.tooltip || "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding layer:", layer.id, err); + } + }); + } catch (err) { + console.error("[MapGL Debug] Error in style.load handler:", err); + } + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + + // Add a backup mechanism specific to MapLibre + // Some MapLibre styles or versions may have different event timing + if (userLayers.length > 0) { + // Set a timeout to check if layers were added after a reasonable delay + setTimeout(function() { + try { + console.log("[MapGL Debug] Running backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Backup restoration needed for layers"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding layer", layer.id, err); + } + }); + } else { + console.log("[MapGL Debug] Backup check: layers already restored properly"); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in backup restoration:", err); + } + }, 500); // 500ms delay - faster recovery + + // Add a second backup with a bit more delay in case the first one fails + setTimeout(function() { + try { + console.log("[MapGL Debug] Running second backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Second backup restoration needed"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Second backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Second backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Second backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Second backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding layer", layer.id, err); + } + }); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in second backup:", err); + } + }, 1000); // 1 second delay for second backup + } + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + // Create the draw control + var drawControl = new MapboxDraw(drawOptions); + map.addControl(drawControl, message.position); + map.controls.push(drawControl); + + // Store the draw control on the widget for later access + widget.drawControl = drawControl; + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(drawControl, message.source, map); + } + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + const features = drawControl.getAll(); + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + drawControl.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_features_to_draw") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + if (message.data.clear_existing) { + drawControl.deleteAll(); + } + addSourceFeaturesToDraw(drawControl, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn('Draw control not initialized'); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_popup") { + const layerId = message.layer; + const newPopupProperty = message.popup; + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + delete window._mapboxPopups[layerId]; + } + + // Remove old click handler if any + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + delete window._mapboxClickHandlers[layerId]; + } + + // Remove old hover handlers for cursor change + map.off("mouseenter", layerId); + map.off("mouseleave", layerId); + + // Create new click handler + const clickHandler = function (e) { + onClickPopup(e, map, newPopupProperty, layerId); + }; + + // Add the new event handler + map.on("click", layerId, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } else if (message.type === "add_globe_control") { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, message.position); + map.controls.push(globeControl); + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } + }); +} diff --git a/docs/articles/getting-started_files/maplibregl-binding-0.2.2/maplibregl.js b/docs/articles/getting-started_files/maplibregl-binding-0.2.2/maplibregl.js new file mode 100644 index 00000000..212c00db --- /dev/null +++ b/docs/articles/getting-started_files/maplibregl-binding-0.2.2/maplibregl.js @@ -0,0 +1,2758 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[layer.popup]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[layer.id]) { + window._mapboxPopups[layer.id].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layer.id] === popup) { + delete window._mapboxPopups[layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), + ); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe control if enabled + if (x.globe_control) { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, x.globe_control.position); + map.controls.push(globeControl); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[message.layer.popup]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[message.layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[message.layer.id] === popup) { + delete window._mapboxPopups[message.layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + // Check both message.layer and message.layer.id as keys due to different message formats + if (window._mapboxPopups) { + // First check if we have a popup stored with message.layer key + if (window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + // Also check if we have a popup stored with message.layer.id key, which happens when added via add_layer + if (message.layer && message.layer.id && window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + delete window._mapboxPopups[message.layer.id]; + } + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if (window._mapboxClickHandlers) { + // First check for handlers stored with message.layer key + if (window._mapboxClickHandlers[message.layer]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Also check for handlers stored with message.layer.id key from add_layer + if (message.layer && message.layer.id && window._mapboxClickHandlers[message.layer.id]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer.id] + ); + delete window._mapboxClickHandlers[message.layer.id]; + } + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + console.log("[MapGL Debug] Current style sources:", Object.keys(currentStyle.sources)); + console.log("[MapGL Debug] Current style layers:", currentStyle.layers.map(l => l.id)); + + // Store layer IDs we know were added by the user via R code + // This is the most reliable way to identify user-added layers + const knownUserLayerIds = []; + + // For each layer in the current style, determine if it's a user-added layer + currentStyle.layers.forEach(function(layer) { + const layerId = layer.id; + + // Critical: Check for nc_counties specifically since we know that's used in the test app + if (layerId === "nc_counties") { + console.log("[MapGL Debug] Found explicit test layer:", layerId); + knownUserLayerIds.push(layerId); + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found source from test layer:", layer.source); + userSourceIds.push(layer.source); + } + return; // Skip other checks for this layer + } + + // These are common patterns for user-added layers from R code + if ( + // Specific layer IDs from the R package + layerId.endsWith("_counties") || + layerId.endsWith("_label") || + layerId.endsWith("_layer") || + + // Look for hover handlers - only user-added layers have these + (window._mapboxHandlers && window._mapboxHandlers[layerId]) || + + // If the layer ID contains these strings, it's likely user-added + layerId.includes("user") || + layerId.includes("custom") || + + // If the paint property has a hover case, it's user-added + (layer.paint && Object.values(layer.paint).some(value => + Array.isArray(value) && + value[0] === "case" && + Array.isArray(value[1]) && + value[1][1] && + Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && + value[1][1][1] === "hover")) + ) { + console.log("[MapGL Debug] Found user layer:", layerId); + knownUserLayerIds.push(layerId); + // Also include its source + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found user source from layer:", layer.source); + userSourceIds.push(layer.source); + } + } + }); + + // For each source, determine if it's a user-added source + for (const sourceId in currentStyle.sources) { + const source = currentStyle.sources[sourceId]; + + // Strategy 1: All GeoJSON sources are likely user-added + if (source.type === "geojson") { + console.log("[MapGL Debug] Found user GeoJSON source:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 2: Check for source data URL patterns typical of R-generated data + else if (source.url && typeof source.url === 'string' && + (source.url.includes("data:application/json") || + source.url.includes("blob:"))) { + console.log("[MapGL Debug] Found user source with data URL:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 3: Standard filtering - exclude common base map sources + else if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") && + sourceId !== "openmaptiles" && // Common in MapLibre styles + !(sourceId.startsWith("carto") && sourceId !== "carto-source") && // Filter CARTO base sources but keep user ones + !(sourceId.startsWith("maptiler") && !sourceId.includes("user")) && // Filter MapTiler sources but keep user ones + !sourceId.includes("terrain") && // Common terrain sources + !sourceId.includes("hillshade") && // Common hillshade sources + !(sourceId.includes("basemap") && !sourceId.includes("user")) // Filter basemap sources but keep user ones + ) { + console.log("[MapGL Debug] Found user source via filtering:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + + // Identify layers using user-added sources or known user layer IDs + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source) || knownUserLayerIds.includes(layer.id)) { + userLayers.push(layer); + } + }); + + // Log detected user sources and layers + console.log("[MapGL Debug] Detected user sources:", userSourceIds); + console.log("[MapGL Debug] Detected user layers:", userLayers.map(l => l.id)); + + // Store them for potential use outside the onStyleLoad event + // This helps in case the event timing is different in MapLibre + if (!window._mapglPreservedData) { + window._mapglPreservedData = {}; + } + window._mapglPreservedData[map.getContainer().id] = { + sources: userSourceIds.map(id => ({id, source: currentStyle.sources[id]})), + layers: userLayers + }; + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + console.log("[MapGL Debug] style.load event fired"); + + try { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + try { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + console.log("[MapGL Debug] Re-adding source:", sourceId); + map.addSource(sourceId, source); + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding source:", sourceId, err); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Re-adding layer:", layer.id); + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + console.log("[MapGL Debug] Re-adding mousemove handler for:", layer.id); + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + console.log("[MapGL Debug] Re-adding mouseleave handler for:", layer.id); + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Check if we need to restore tooltip handlers + const layerId = layer.id; + if (layerId === "nc_counties" || layer.tooltip) { + console.log("[MapGL Debug] Restoring tooltip for:", layerId); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = layer.tooltip || "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding layer:", layer.id, err); + } + }); + } catch (err) { + console.error("[MapGL Debug] Error in style.load handler:", err); + } + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + + // Add a backup mechanism specific to MapLibre + // Some MapLibre styles or versions may have different event timing + if (userLayers.length > 0) { + // Set a timeout to check if layers were added after a reasonable delay + setTimeout(function() { + try { + console.log("[MapGL Debug] Running backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Backup restoration needed for layers"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding layer", layer.id, err); + } + }); + } else { + console.log("[MapGL Debug] Backup check: layers already restored properly"); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in backup restoration:", err); + } + }, 500); // 500ms delay - faster recovery + + // Add a second backup with a bit more delay in case the first one fails + setTimeout(function() { + try { + console.log("[MapGL Debug] Running second backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Second backup restoration needed"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Second backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Second backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Second backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Second backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding layer", layer.id, err); + } + }); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in second backup:", err); + } + }, 1000); // 1 second delay for second backup + } + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } else if (message.type === "add_globe_control") { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, message.position); + map.controls.push(globeControl); + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } + }); +} diff --git a/docs/articles/getting-started_files/pmtiles-3.2.0/pmtiles.js b/docs/articles/getting-started_files/pmtiles-3.2.0/pmtiles.js new file mode 100644 index 00000000..d3d188da --- /dev/null +++ b/docs/articles/getting-started_files/pmtiles-3.2.0/pmtiles.js @@ -0,0 +1,1738 @@ +"use strict"; +var pmtiles = (() => { + var __defProp = Object.defineProperty; + var __getOwnPropDesc = Object.getOwnPropertyDescriptor; + var __getOwnPropNames = Object.getOwnPropertyNames; + var __hasOwnProp = Object.prototype.hasOwnProperty; + var __pow = Math.pow; + var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; + }; + var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + var __async = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); + }; + + // index.ts + var js_exports = {}; + __export(js_exports, { + Compression: () => Compression, + EtagMismatch: () => EtagMismatch, + FetchSource: () => FetchSource, + FileSource: () => FileSource, + PMTiles: () => PMTiles, + Protocol: () => Protocol, + ResolvedValueCache: () => ResolvedValueCache, + SharedPromiseCache: () => SharedPromiseCache, + TileType: () => TileType, + bytesToHeader: () => bytesToHeader, + findTile: () => findTile, + getUint64: () => getUint64, + leafletRasterLayer: () => leafletRasterLayer, + readVarint: () => readVarint, + tileIdToZxy: () => tileIdToZxy, + tileTypeExt: () => tileTypeExt, + zxyToTileId: () => zxyToTileId + }); + + // node_modules/fflate/esm/browser.js + var u8 = Uint8Array; + var u16 = Uint16Array; + var i32 = Int32Array; + var fleb = new u8([ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 3, + 3, + 3, + 3, + 4, + 4, + 4, + 4, + 5, + 5, + 5, + 5, + 0, + /* unused */ + 0, + 0, + /* impossible */ + 0 + ]); + var fdeb = new u8([ + 0, + 0, + 0, + 0, + 1, + 1, + 2, + 2, + 3, + 3, + 4, + 4, + 5, + 5, + 6, + 6, + 7, + 7, + 8, + 8, + 9, + 9, + 10, + 10, + 11, + 11, + 12, + 12, + 13, + 13, + /* unused */ + 0, + 0 + ]); + var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); + var freb = function(eb, start) { + var b = new u16(31); + for (var i = 0; i < 31; ++i) { + b[i] = start += 1 << eb[i - 1]; + } + var r = new i32(b[30]); + for (var i = 1; i < 30; ++i) { + for (var j = b[i]; j < b[i + 1]; ++j) { + r[j] = j - b[i] << 5 | i; + } + } + return { b, r }; + }; + var _a = freb(fleb, 2); + var fl = _a.b; + var revfl = _a.r; + fl[28] = 258, revfl[258] = 28; + var _b = freb(fdeb, 0); + var fd = _b.b; + var revfd = _b.r; + var rev = new u16(32768); + for (i = 0; i < 32768; ++i) { + x = (i & 43690) >> 1 | (i & 21845) << 1; + x = (x & 52428) >> 2 | (x & 13107) << 2; + x = (x & 61680) >> 4 | (x & 3855) << 4; + rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1; + } + var x; + var i; + var hMap = function(cd, mb, r) { + var s = cd.length; + var i = 0; + var l = new u16(mb); + for (; i < s; ++i) { + if (cd[i]) + ++l[cd[i] - 1]; + } + var le = new u16(mb); + for (i = 1; i < mb; ++i) { + le[i] = le[i - 1] + l[i - 1] << 1; + } + var co; + if (r) { + co = new u16(1 << mb); + var rvb = 15 - mb; + for (i = 0; i < s; ++i) { + if (cd[i]) { + var sv = i << 4 | cd[i]; + var r_1 = mb - cd[i]; + var v = le[cd[i] - 1]++ << r_1; + for (var m = v | (1 << r_1) - 1; v <= m; ++v) { + co[rev[v] >> rvb] = sv; + } + } + } + } else { + co = new u16(s); + for (i = 0; i < s; ++i) { + if (cd[i]) { + co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i]; + } + } + } + return co; + }; + var flt = new u8(288); + for (i = 0; i < 144; ++i) + flt[i] = 8; + var i; + for (i = 144; i < 256; ++i) + flt[i] = 9; + var i; + for (i = 256; i < 280; ++i) + flt[i] = 7; + var i; + for (i = 280; i < 288; ++i) + flt[i] = 8; + var i; + var fdt = new u8(32); + for (i = 0; i < 32; ++i) + fdt[i] = 5; + var i; + var flrm = /* @__PURE__ */ hMap(flt, 9, 1); + var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1); + var max = function(a) { + var m = a[0]; + for (var i = 1; i < a.length; ++i) { + if (a[i] > m) + m = a[i]; + } + return m; + }; + var bits = function(d, p, m) { + var o = p / 8 | 0; + return (d[o] | d[o + 1] << 8) >> (p & 7) & m; + }; + var bits16 = function(d, p) { + var o = p / 8 | 0; + return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7); + }; + var shft = function(p) { + return (p + 7) / 8 | 0; + }; + var slc = function(v, s, e) { + if (s == null || s < 0) + s = 0; + if (e == null || e > v.length) + e = v.length; + var n = new u8(e - s); + n.set(v.subarray(s, e)); + return n; + }; + var ec = [ + "unexpected EOF", + "invalid block type", + "invalid length/literal", + "invalid distance", + "stream finished", + "no stream handler", + , + "no callback", + "invalid UTF-8 data", + "extra field too long", + "date not in range 1980-2099", + "filename too long", + "stream finishing", + "invalid zip data" + // determined by unknown compression method + ]; + var err = function(ind, msg, nt) { + var e = new Error(msg || ec[ind]); + e.code = ind; + if (Error.captureStackTrace) + Error.captureStackTrace(e, err); + if (!nt) + throw e; + return e; + }; + var inflt = function(dat, st, buf, dict) { + var sl = dat.length, dl = dict ? dict.length : 0; + if (!sl || st.f && !st.l) + return buf || new u8(0); + var noBuf = !buf || st.i != 2; + var noSt = st.i; + if (!buf) + buf = new u8(sl * 3); + var cbuf = function(l2) { + var bl = buf.length; + if (l2 > bl) { + var nbuf = new u8(Math.max(bl * 2, l2)); + nbuf.set(buf); + buf = nbuf; + } + }; + var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n; + var tbts = sl * 8; + do { + if (!lm) { + final = bits(dat, pos, 1); + var type = bits(dat, pos + 1, 3); + pos += 3; + if (!type) { + var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l; + if (t > sl) { + if (noSt) + err(0); + break; + } + if (noBuf) + cbuf(bt + l); + buf.set(dat.subarray(s, t), bt); + st.b = bt += l, st.p = pos = t * 8, st.f = final; + continue; + } else if (type == 1) + lm = flrm, dm = fdrm, lbt = 9, dbt = 5; + else if (type == 2) { + var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4; + var tl = hLit + bits(dat, pos + 5, 31) + 1; + pos += 14; + var ldt = new u8(tl); + var clt = new u8(19); + for (var i = 0; i < hcLen; ++i) { + clt[clim[i]] = bits(dat, pos + i * 3, 7); + } + pos += hcLen * 3; + var clb = max(clt), clbmsk = (1 << clb) - 1; + var clm = hMap(clt, clb, 1); + for (var i = 0; i < tl; ) { + var r = clm[bits(dat, pos, clbmsk)]; + pos += r & 15; + var s = r >> 4; + if (s < 16) { + ldt[i++] = s; + } else { + var c = 0, n = 0; + if (s == 16) + n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1]; + else if (s == 17) + n = 3 + bits(dat, pos, 7), pos += 3; + else if (s == 18) + n = 11 + bits(dat, pos, 127), pos += 7; + while (n--) + ldt[i++] = c; + } + } + var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit); + lbt = max(lt); + dbt = max(dt); + lm = hMap(lt, lbt, 1); + dm = hMap(dt, dbt, 1); + } else + err(1); + if (pos > tbts) { + if (noSt) + err(0); + break; + } + } + if (noBuf) + cbuf(bt + 131072); + var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1; + var lpos = pos; + for (; ; lpos = pos) { + var c = lm[bits16(dat, pos) & lms], sym = c >> 4; + pos += c & 15; + if (pos > tbts) { + if (noSt) + err(0); + break; + } + if (!c) + err(2); + if (sym < 256) + buf[bt++] = sym; + else if (sym == 256) { + lpos = pos, lm = null; + break; + } else { + var add = sym - 254; + if (sym > 264) { + var i = sym - 257, b = fleb[i]; + add = bits(dat, pos, (1 << b) - 1) + fl[i]; + pos += b; + } + var d = dm[bits16(dat, pos) & dms], dsym = d >> 4; + if (!d) + err(3); + pos += d & 15; + var dt = fd[dsym]; + if (dsym > 3) { + var b = fdeb[dsym]; + dt += bits16(dat, pos) & (1 << b) - 1, pos += b; + } + if (pos > tbts) { + if (noSt) + err(0); + break; + } + if (noBuf) + cbuf(bt + 131072); + var end = bt + add; + if (bt < dt) { + var shift2 = dl - dt, dend = Math.min(dt, end); + if (shift2 + bt < 0) + err(3); + for (; bt < dend; ++bt) + buf[bt] = dict[shift2 + bt]; + } + for (; bt < end; bt += 4) { + buf[bt] = buf[bt - dt]; + buf[bt + 1] = buf[bt + 1 - dt]; + buf[bt + 2] = buf[bt + 2 - dt]; + buf[bt + 3] = buf[bt + 3 - dt]; + } + bt = end; + } + } + st.l = lm, st.p = lpos, st.b = bt, st.f = final; + if (lm) + final = 1, st.m = lbt, st.d = dm, st.n = dbt; + } while (!final); + return bt == buf.length ? buf : slc(buf, 0, bt); + }; + var et = /* @__PURE__ */ new u8(0); + var gzs = function(d) { + if (d[0] != 31 || d[1] != 139 || d[2] != 8) + err(6, "invalid gzip data"); + var flg = d[3]; + var st = 10; + if (flg & 4) + st += (d[10] | d[11] << 8) + 2; + for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]) + ; + return st + (flg & 2); + }; + var gzl = function(d) { + var l = d.length; + return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0; + }; + var zls = function(d, dict) { + if ((d[0] & 15) != 8 || d[0] >> 4 > 7 || (d[0] << 8 | d[1]) % 31) + err(6, "invalid zlib data"); + if ((d[1] >> 5 & 1) == +!dict) + err(6, "invalid zlib data: " + (d[1] & 32 ? "need" : "unexpected") + " dictionary"); + return (d[1] >> 3 & 4) + 2; + }; + function inflateSync(data, opts) { + return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary); + } + function gunzipSync(data, opts) { + var st = gzs(data); + if (st + 8 > data.length) + err(6, "invalid gzip data"); + return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary); + } + function unzlibSync(data, opts) { + return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary); + } + function decompressSync(data, opts) { + return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzipSync(data, opts) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflateSync(data, opts) : unzlibSync(data, opts); + } + var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder(); + var tds = 0; + try { + td.decode(et, { stream: true }); + tds = 1; + } catch (e) { + } + + // v2.ts + var shift = (n, shift2) => { + return n * __pow(2, shift2); + }; + var unshift = (n, shift2) => { + return Math.floor(n / __pow(2, shift2)); + }; + var getUint24 = (view, pos) => { + return shift(view.getUint16(pos + 1, true), 8) + view.getUint8(pos); + }; + var getUint48 = (view, pos) => { + return shift(view.getUint32(pos + 2, true), 16) + view.getUint16(pos, true); + }; + var compare = (tz, tx, ty, view, i) => { + if (tz !== view.getUint8(i)) + return tz - view.getUint8(i); + const x = getUint24(view, i + 1); + if (tx !== x) + return tx - x; + const y = getUint24(view, i + 4); + if (ty !== y) + return ty - y; + return 0; + }; + var queryLeafdir = (view, z, x, y) => { + const offsetLen = queryView(view, z | 128, x, y); + if (offsetLen) { + return { + z, + x, + y, + offset: offsetLen[0], + length: offsetLen[1], + isDir: true + }; + } + return null; + }; + var queryTile = (view, z, x, y) => { + const offsetLen = queryView(view, z, x, y); + if (offsetLen) { + return { + z, + x, + y, + offset: offsetLen[0], + length: offsetLen[1], + isDir: false + }; + } + return null; + }; + var queryView = (view, z, x, y) => { + let m = 0; + let n = view.byteLength / 17 - 1; + while (m <= n) { + const k = n + m >> 1; + const cmp = compare(z, x, y, view, k * 17); + if (cmp > 0) { + m = k + 1; + } else if (cmp < 0) { + n = k - 1; + } else { + return [getUint48(view, k * 17 + 7), view.getUint32(k * 17 + 13, true)]; + } + } + return null; + }; + var entrySort = (a, b) => { + if (a.isDir && !b.isDir) { + return 1; + } + if (!a.isDir && b.isDir) { + return -1; + } + if (a.z !== b.z) { + return a.z - b.z; + } + if (a.x !== b.x) { + return a.x - b.x; + } + return a.y - b.y; + }; + var parseEntry = (dataview, i) => { + const zRaw = dataview.getUint8(i * 17); + const z = zRaw & 127; + return { + z, + x: getUint24(dataview, i * 17 + 1), + y: getUint24(dataview, i * 17 + 4), + offset: getUint48(dataview, i * 17 + 7), + length: dataview.getUint32(i * 17 + 13, true), + isDir: zRaw >> 7 === 1 + }; + }; + var sortDir = (a) => { + const entries = []; + const view = new DataView(a); + for (let i = 0; i < view.byteLength / 17; i++) { + entries.push(parseEntry(view, i)); + } + return createDirectory(entries); + }; + var createDirectory = (entries) => { + entries.sort(entrySort); + const buffer = new ArrayBuffer(17 * entries.length); + const arr = new Uint8Array(buffer); + for (let i = 0; i < entries.length; i++) { + const entry = entries[i]; + let z = entry.z; + if (entry.isDir) + z = z | 128; + arr[i * 17] = z; + arr[i * 17 + 1] = entry.x & 255; + arr[i * 17 + 2] = entry.x >> 8 & 255; + arr[i * 17 + 3] = entry.x >> 16 & 255; + arr[i * 17 + 4] = entry.y & 255; + arr[i * 17 + 5] = entry.y >> 8 & 255; + arr[i * 17 + 6] = entry.y >> 16 & 255; + arr[i * 17 + 7] = entry.offset & 255; + arr[i * 17 + 8] = unshift(entry.offset, 8) & 255; + arr[i * 17 + 9] = unshift(entry.offset, 16) & 255; + arr[i * 17 + 10] = unshift(entry.offset, 24) & 255; + arr[i * 17 + 11] = unshift(entry.offset, 32) & 255; + arr[i * 17 + 12] = unshift(entry.offset, 48) & 255; + arr[i * 17 + 13] = entry.length & 255; + arr[i * 17 + 14] = entry.length >> 8 & 255; + arr[i * 17 + 15] = entry.length >> 16 & 255; + arr[i * 17 + 16] = entry.length >> 24 & 255; + } + return buffer; + }; + var deriveLeaf = (view, tile) => { + if (view.byteLength < 17) + return null; + const numEntries = view.byteLength / 17; + const entry = parseEntry(view, numEntries - 1); + if (entry.isDir) { + const leafLevel = entry.z; + const levelDiff = tile.z - leafLevel; + const leafX = Math.trunc(tile.x / (1 << levelDiff)); + const leafY = Math.trunc(tile.y / (1 << levelDiff)); + return { z: leafLevel, x: leafX, y: leafY }; + } + return null; + }; + function getHeader(source) { + return __async(this, null, function* () { + const resp = yield source.getBytes(0, 512e3); + const dataview = new DataView(resp.data); + const jsonSize = dataview.getUint32(4, true); + const rootEntries = dataview.getUint16(8, true); + const dec = new TextDecoder("utf-8"); + const jsonMetadata = JSON.parse( + dec.decode(new DataView(resp.data, 10, jsonSize)) + ); + let tileCompression = 0 /* Unknown */; + if (jsonMetadata.compression === "gzip") { + tileCompression = 2 /* Gzip */; + } + let minzoom = 0; + if ("minzoom" in jsonMetadata) { + minzoom = +jsonMetadata.minzoom; + } + let maxzoom = 0; + if ("maxzoom" in jsonMetadata) { + maxzoom = +jsonMetadata.maxzoom; + } + let centerLon = 0; + let centerLat = 0; + let centerZoom = 0; + let minLon = -180; + let minLat = -85; + let maxLon = 180; + let maxLat = 85; + if (jsonMetadata.bounds) { + const split = jsonMetadata.bounds.split(","); + minLon = +split[0]; + minLat = +split[1]; + maxLon = +split[2]; + maxLat = +split[3]; + } + if (jsonMetadata.center) { + const split = jsonMetadata.center.split(","); + centerLon = +split[0]; + centerLat = +split[1]; + centerZoom = +split[2]; + } + const header = { + specVersion: dataview.getUint16(2, true), + rootDirectoryOffset: 10 + jsonSize, + rootDirectoryLength: rootEntries * 17, + jsonMetadataOffset: 10, + jsonMetadataLength: jsonSize, + leafDirectoryOffset: 0, + leafDirectoryLength: void 0, + tileDataOffset: 0, + tileDataLength: void 0, + numAddressedTiles: 0, + numTileEntries: 0, + numTileContents: 0, + clustered: false, + internalCompression: 1 /* None */, + tileCompression, + tileType: 1 /* Mvt */, + minZoom: minzoom, + maxZoom: maxzoom, + minLon, + minLat, + maxLon, + maxLat, + centerZoom, + centerLon, + centerLat, + etag: resp.etag + }; + return header; + }); + } + function getZxy(header, source, cache, z, x, y, signal) { + return __async(this, null, function* () { + let rootDir = yield cache.getArrayBuffer( + source, + header.rootDirectoryOffset, + header.rootDirectoryLength, + header + ); + if (header.specVersion === 1) { + rootDir = sortDir(rootDir); + } + const entry = queryTile(new DataView(rootDir), z, x, y); + if (entry) { + const resp = yield source.getBytes(entry.offset, entry.length, signal); + let tileData = resp.data; + const view = new DataView(tileData); + if (view.getUint8(0) === 31 && view.getUint8(1) === 139) { + tileData = decompressSync(new Uint8Array(tileData)); + } + return { + data: tileData + }; + } + const leafcoords = deriveLeaf(new DataView(rootDir), { z, x, y }); + if (leafcoords) { + const leafdirEntry = queryLeafdir( + new DataView(rootDir), + leafcoords.z, + leafcoords.x, + leafcoords.y + ); + if (leafdirEntry) { + let leafDir = yield cache.getArrayBuffer( + source, + leafdirEntry.offset, + leafdirEntry.length, + header + ); + if (header.specVersion === 1) { + leafDir = sortDir(leafDir); + } + const tileEntry = queryTile(new DataView(leafDir), z, x, y); + if (tileEntry) { + const resp = yield source.getBytes( + tileEntry.offset, + tileEntry.length, + signal + ); + let tileData = resp.data; + const view = new DataView(tileData); + if (view.getUint8(0) === 31 && view.getUint8(1) === 139) { + tileData = decompressSync(new Uint8Array(tileData)); + } + return { + data: tileData + }; + } + } + } + return void 0; + }); + } + var v2_default = { + getHeader, + getZxy + }; + + // adapters.ts + var leafletRasterLayer = (source, options) => { + let loaded = false; + let mimeType = ""; + const cls = L.GridLayer.extend({ + createTile: (coord, done) => { + const el = document.createElement("img"); + const controller = new AbortController(); + const signal = controller.signal; + el.cancel = () => { + controller.abort(); + }; + if (!loaded) { + source.getHeader().then((header) => { + if (header.tileType === 1 /* Mvt */) { + console.error( + "Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details." + ); + } else if (header.tileType === 2) { + mimeType = "image/png"; + } else if (header.tileType === 3) { + mimeType = "image/jpeg"; + } else if (header.tileType === 4) { + mimeType = "image/webp"; + } else if (header.tileType === 5) { + mimeType = "image/avif"; + } + }); + loaded = true; + } + source.getZxy(coord.z, coord.x, coord.y, signal).then((arr) => { + if (arr) { + const blob = new Blob([arr.data], { type: mimeType }); + const imageUrl = window.URL.createObjectURL(blob); + el.src = imageUrl; + el.cancel = void 0; + done(void 0, el); + } + }).catch((e) => { + if (e.name !== "AbortError") { + throw e; + } + }); + return el; + }, + _removeTile: function(key) { + const tile = this._tiles[key]; + if (!tile) { + return; + } + if (tile.el.cancel) + tile.el.cancel(); + tile.el.width = 0; + tile.el.height = 0; + tile.el.deleted = true; + L.DomUtil.remove(tile.el); + delete this._tiles[key]; + this.fire("tileunload", { + tile: tile.el, + coords: this._keyToTileCoords(key) + }); + } + }); + return new cls(options); + }; + var v3compat = (v4) => (requestParameters, arg2) => { + if (arg2 instanceof AbortController) { + return v4(requestParameters, arg2); + } + const abortController = new AbortController(); + v4(requestParameters, abortController).then( + (result) => { + return arg2( + void 0, + result.data, + result.cacheControl || "", + result.expires || "" + ); + }, + (err2) => { + return arg2(err2); + } + ).catch((e) => { + return arg2(e); + }); + return { cancel: () => abortController.abort() }; + }; + var Protocol = class { + /** + * Initialize the MapLibre PMTiles protocol. + * + * * metadata: also load the metadata section of the PMTiles. required for some "inspect" functionality + * and to automatically populate the map attribution. Requires an extra HTTP request. + */ + constructor(options) { + /** @hidden */ + this.tilev4 = (params, abortController) => __async(this, null, function* () { + if (params.type === "json") { + const pmtilesUrl2 = params.url.substr(10); + let instance2 = this.tiles.get(pmtilesUrl2); + if (!instance2) { + instance2 = new PMTiles(pmtilesUrl2); + this.tiles.set(pmtilesUrl2, instance2); + } + if (this.metadata) { + return { + data: yield instance2.getTileJson(params.url) + }; + } + const h = yield instance2.getHeader(); + return { + data: { + tiles: [`${params.url}/{z}/{x}/{y}`], + minzoom: h.minZoom, + maxzoom: h.maxZoom, + bounds: [h.minLon, h.minLat, h.maxLon, h.maxLat] + } + }; + } + const re = new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/); + const result = params.url.match(re); + if (!result) { + throw new Error("Invalid PMTiles protocol URL"); + } + const pmtilesUrl = result[1]; + let instance = this.tiles.get(pmtilesUrl); + if (!instance) { + instance = new PMTiles(pmtilesUrl); + this.tiles.set(pmtilesUrl, instance); + } + const z = result[2]; + const x = result[3]; + const y = result[4]; + const header = yield instance.getHeader(); + const resp = yield instance == null ? void 0 : instance.getZxy(+z, +x, +y, abortController.signal); + if (resp) { + return { + data: new Uint8Array(resp.data), + cacheControl: resp.cacheControl, + expires: resp.expires + }; + } + if (header.tileType === 1 /* Mvt */) { + return { data: new Uint8Array() }; + } + return { data: null }; + }); + this.tile = v3compat(this.tilev4); + this.tiles = /* @__PURE__ */ new Map(); + this.metadata = (options == null ? void 0 : options.metadata) || false; + } + /** + * Add a {@link PMTiles} instance to the global protocol instance. + * + * For remote fetch sources, references in MapLibre styles like pmtiles://http://... + * will resolve to the same instance if the URLs match. + */ + add(p) { + this.tiles.set(p.source.getKey(), p); + } + /** + * Fetch a {@link PMTiles} instance by URL, for remote PMTiles instances. + */ + get(url) { + return this.tiles.get(url); + } + }; + + // index.ts + function toNum(low, high) { + return (high >>> 0) * 4294967296 + (low >>> 0); + } + function readVarintRemainder(l, p) { + const buf = p.buf; + let b = buf[p.pos++]; + let h = (b & 112) >> 4; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 3; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 10; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 17; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 24; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 1) << 31; + if (b < 128) + return toNum(l, h); + throw new Error("Expected varint not more than 10 bytes"); + } + function readVarint(p) { + const buf = p.buf; + let b = buf[p.pos++]; + let val = b & 127; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 7; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 14; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 21; + if (b < 128) + return val; + b = buf[p.pos]; + val |= (b & 15) << 28; + return readVarintRemainder(val, p); + } + function rotate(n, xy, rx, ry) { + if (ry === 0) { + if (rx === 1) { + xy[0] = n - 1 - xy[0]; + xy[1] = n - 1 - xy[1]; + } + const t = xy[0]; + xy[0] = xy[1]; + xy[1] = t; + } + } + function idOnLevel(z, pos) { + const n = __pow(2, z); + let rx = pos; + let ry = pos; + let t = pos; + const xy = [0, 0]; + let s = 1; + while (s < n) { + rx = 1 & t / 2; + ry = 1 & (t ^ rx); + rotate(s, xy, rx, ry); + xy[0] += s * rx; + xy[1] += s * ry; + t = t / 4; + s *= 2; + } + return [z, xy[0], xy[1]]; + } + var tzValues = [ + 0, + 1, + 5, + 21, + 85, + 341, + 1365, + 5461, + 21845, + 87381, + 349525, + 1398101, + 5592405, + 22369621, + 89478485, + 357913941, + 1431655765, + 5726623061, + 22906492245, + 91625968981, + 366503875925, + 1466015503701, + 5864062014805, + 23456248059221, + 93824992236885, + 375299968947541, + 1501199875790165 + ]; + function zxyToTileId(z, x, y) { + if (z > 26) { + throw Error("Tile zoom level exceeds max safe number limit (26)"); + } + if (x > __pow(2, z) - 1 || y > __pow(2, z) - 1) { + throw Error("tile x/y outside zoom level bounds"); + } + const acc = tzValues[z]; + const n = __pow(2, z); + let rx = 0; + let ry = 0; + let d = 0; + const xy = [x, y]; + let s = n / 2; + while (s > 0) { + rx = (xy[0] & s) > 0 ? 1 : 0; + ry = (xy[1] & s) > 0 ? 1 : 0; + d += s * s * (3 * rx ^ ry); + rotate(s, xy, rx, ry); + s = s / 2; + } + return acc + d; + } + function tileIdToZxy(i) { + let acc = 0; + const z = 0; + for (let z2 = 0; z2 < 27; z2++) { + const numTiles = (1 << z2) * (1 << z2); + if (acc + numTiles > i) { + return idOnLevel(z2, i - acc); + } + acc += numTiles; + } + throw Error("Tile zoom level exceeds max safe number limit (26)"); + } + var Compression = /* @__PURE__ */ ((Compression2) => { + Compression2[Compression2["Unknown"] = 0] = "Unknown"; + Compression2[Compression2["None"] = 1] = "None"; + Compression2[Compression2["Gzip"] = 2] = "Gzip"; + Compression2[Compression2["Brotli"] = 3] = "Brotli"; + Compression2[Compression2["Zstd"] = 4] = "Zstd"; + return Compression2; + })(Compression || {}); + function defaultDecompress(buf, compression) { + return __async(this, null, function* () { + if (compression === 1 /* None */ || compression === 0 /* Unknown */) { + return buf; + } + if (compression === 2 /* Gzip */) { + if (typeof globalThis.DecompressionStream === "undefined") { + return decompressSync(new Uint8Array(buf)); + } + const stream = new Response(buf).body; + if (!stream) { + throw Error("Failed to read response stream"); + } + const result = stream.pipeThrough( + // biome-ignore lint: needed to detect DecompressionStream in browser+node+cloudflare workers + new globalThis.DecompressionStream("gzip") + ); + return new Response(result).arrayBuffer(); + } + throw Error("Compression method not supported"); + }); + } + var TileType = /* @__PURE__ */ ((TileType2) => { + TileType2[TileType2["Unknown"] = 0] = "Unknown"; + TileType2[TileType2["Mvt"] = 1] = "Mvt"; + TileType2[TileType2["Png"] = 2] = "Png"; + TileType2[TileType2["Jpeg"] = 3] = "Jpeg"; + TileType2[TileType2["Webp"] = 4] = "Webp"; + TileType2[TileType2["Avif"] = 5] = "Avif"; + return TileType2; + })(TileType || {}); + function tileTypeExt(t) { + if (t === 1 /* Mvt */) + return ".mvt"; + if (t === 2 /* Png */) + return ".png"; + if (t === 3 /* Jpeg */) + return ".jpg"; + if (t === 4 /* Webp */) + return ".webp"; + if (t === 5 /* Avif */) + return ".avif"; + return ""; + } + var HEADER_SIZE_BYTES = 127; + function findTile(entries, tileId) { + let m = 0; + let n = entries.length - 1; + while (m <= n) { + const k = n + m >> 1; + const cmp = tileId - entries[k].tileId; + if (cmp > 0) { + m = k + 1; + } else if (cmp < 0) { + n = k - 1; + } else { + return entries[k]; + } + } + if (n >= 0) { + if (entries[n].runLength === 0) { + return entries[n]; + } + if (tileId - entries[n].tileId < entries[n].runLength) { + return entries[n]; + } + } + return null; + } + var FileSource = class { + constructor(file) { + this.file = file; + } + getKey() { + return this.file.name; + } + getBytes(offset, length) { + return __async(this, null, function* () { + const blob = this.file.slice(offset, offset + length); + const a = yield blob.arrayBuffer(); + return { data: a }; + }); + } + }; + var FetchSource = class { + constructor(url, customHeaders = new Headers()) { + this.url = url; + this.customHeaders = customHeaders; + this.mustReload = false; + let userAgent = ""; + if ("navigator" in globalThis) { + userAgent = globalThis.navigator.userAgent || ""; + } + const isWindows = userAgent.indexOf("Windows") > -1; + const isChromiumBased = /Chrome|Chromium|Edg|OPR|Brave/.test(userAgent); + this.chromeWindowsNoCache = false; + if (isWindows && isChromiumBased) { + this.chromeWindowsNoCache = true; + } + } + getKey() { + return this.url; + } + /** + * Mutate the custom [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) set for all requests to the remote archive. + */ + setHeaders(customHeaders) { + this.customHeaders = customHeaders; + } + getBytes(offset, length, passedSignal, etag) { + return __async(this, null, function* () { + let controller; + let signal; + if (passedSignal) { + signal = passedSignal; + } else { + controller = new AbortController(); + signal = controller.signal; + } + const requestHeaders = new Headers(this.customHeaders); + requestHeaders.set("range", `bytes=${offset}-${offset + length - 1}`); + let cache; + if (this.mustReload) { + cache = "reload"; + } else if (this.chromeWindowsNoCache) { + cache = "no-store"; + } + let resp = yield fetch(this.url, { + signal, + cache, + headers: requestHeaders + //biome-ignore lint: "cache" is incompatible between cloudflare workers and browser + }); + if (offset === 0 && resp.status === 416) { + const contentRange = resp.headers.get("Content-Range"); + if (!contentRange || !contentRange.startsWith("bytes */")) { + throw Error("Missing content-length on 416 response"); + } + const actualLength = +contentRange.substr(8); + resp = yield fetch(this.url, { + signal, + cache: "reload", + headers: { range: `bytes=0-${actualLength - 1}` } + //biome-ignore lint: "cache" is incompatible between cloudflare workers and browser + }); + } + let newEtag = resp.headers.get("Etag"); + if (newEtag == null ? void 0 : newEtag.startsWith("W/")) { + newEtag = null; + } + if (resp.status === 416 || etag && newEtag && newEtag !== etag) { + this.mustReload = true; + throw new EtagMismatch( + `Server returned non-matching ETag ${etag} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.` + ); + } + if (resp.status >= 300) { + throw Error(`Bad response code: ${resp.status}`); + } + const contentLength = resp.headers.get("Content-Length"); + if (resp.status === 200 && (!contentLength || +contentLength > length)) { + if (controller) + controller.abort(); + throw Error( + "Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving." + ); + } + const a = yield resp.arrayBuffer(); + return { + data: a, + etag: newEtag || void 0, + cacheControl: resp.headers.get("Cache-Control") || void 0, + expires: resp.headers.get("Expires") || void 0 + }; + }); + } + }; + function getUint64(v, offset) { + const wh = v.getUint32(offset + 4, true); + const wl = v.getUint32(offset + 0, true); + return wh * __pow(2, 32) + wl; + } + function bytesToHeader(bytes, etag) { + const v = new DataView(bytes); + const specVersion = v.getUint8(7); + if (specVersion > 3) { + throw Error( + `Archive is spec version ${specVersion} but this library supports up to spec version 3` + ); + } + return { + specVersion, + rootDirectoryOffset: getUint64(v, 8), + rootDirectoryLength: getUint64(v, 16), + jsonMetadataOffset: getUint64(v, 24), + jsonMetadataLength: getUint64(v, 32), + leafDirectoryOffset: getUint64(v, 40), + leafDirectoryLength: getUint64(v, 48), + tileDataOffset: getUint64(v, 56), + tileDataLength: getUint64(v, 64), + numAddressedTiles: getUint64(v, 72), + numTileEntries: getUint64(v, 80), + numTileContents: getUint64(v, 88), + clustered: v.getUint8(96) === 1, + internalCompression: v.getUint8(97), + tileCompression: v.getUint8(98), + tileType: v.getUint8(99), + minZoom: v.getUint8(100), + maxZoom: v.getUint8(101), + minLon: v.getInt32(102, true) / 1e7, + minLat: v.getInt32(106, true) / 1e7, + maxLon: v.getInt32(110, true) / 1e7, + maxLat: v.getInt32(114, true) / 1e7, + centerZoom: v.getUint8(118), + centerLon: v.getInt32(119, true) / 1e7, + centerLat: v.getInt32(123, true) / 1e7, + etag + }; + } + function deserializeIndex(buffer) { + const p = { buf: new Uint8Array(buffer), pos: 0 }; + const numEntries = readVarint(p); + const entries = []; + let lastId = 0; + for (let i = 0; i < numEntries; i++) { + const v = readVarint(p); + entries.push({ tileId: lastId + v, offset: 0, length: 0, runLength: 1 }); + lastId += v; + } + for (let i = 0; i < numEntries; i++) { + entries[i].runLength = readVarint(p); + } + for (let i = 0; i < numEntries; i++) { + entries[i].length = readVarint(p); + } + for (let i = 0; i < numEntries; i++) { + const v = readVarint(p); + if (v === 0 && i > 0) { + entries[i].offset = entries[i - 1].offset + entries[i - 1].length; + } else { + entries[i].offset = v - 1; + } + } + return entries; + } + function detectVersion(a) { + const v = new DataView(a); + if (v.getUint16(2, true) === 2) { + console.warn( + "PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade" + ); + return 2; + } + if (v.getUint16(2, true) === 1) { + console.warn( + "PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade" + ); + return 1; + } + return 3; + } + var EtagMismatch = class extends Error { + }; + function getHeaderAndRoot(source, decompress) { + return __async(this, null, function* () { + const resp = yield source.getBytes(0, 16384); + const v = new DataView(resp.data); + if (v.getUint16(0, true) !== 19792) { + throw new Error("Wrong magic number for PMTiles archive"); + } + if (detectVersion(resp.data) < 3) { + return [yield v2_default.getHeader(source)]; + } + const headerData = resp.data.slice(0, HEADER_SIZE_BYTES); + const header = bytesToHeader(headerData, resp.etag); + const rootDirData = resp.data.slice( + header.rootDirectoryOffset, + header.rootDirectoryOffset + header.rootDirectoryLength + ); + const dirKey = `${source.getKey()}|${header.etag || ""}|${header.rootDirectoryOffset}|${header.rootDirectoryLength}`; + const rootDir = deserializeIndex( + yield decompress(rootDirData, header.internalCompression) + ); + return [header, [dirKey, rootDir.length, rootDir]]; + }); + } + function getDirectory(source, decompress, offset, length, header) { + return __async(this, null, function* () { + const resp = yield source.getBytes(offset, length, void 0, header.etag); + const data = yield decompress(resp.data, header.internalCompression); + const directory = deserializeIndex(data); + if (directory.length === 0) { + throw new Error("Empty directory is invalid"); + } + return directory; + }); + } + var ResolvedValueCache = class { + constructor(maxCacheEntries = 100, prefetch = true, decompress = defaultDecompress) { + this.cache = /* @__PURE__ */ new Map(); + this.maxCacheEntries = maxCacheEntries; + this.counter = 1; + this.decompress = decompress; + } + getHeader(source) { + return __async(this, null, function* () { + const cacheKey = source.getKey(); + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = cacheValue.data; + return data; + } + const res = yield getHeaderAndRoot(source, this.decompress); + if (res[1]) { + this.cache.set(res[1][0], { + lastUsed: this.counter++, + data: res[1][2] + }); + } + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: res[0] + }); + this.prune(); + return res[0]; + }); + } + getDirectory(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = cacheValue.data; + return data; + } + const directory = yield getDirectory( + source, + this.decompress, + offset, + length, + header + ); + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: directory + }); + this.prune(); + return directory; + }); + } + // for v2 backwards compatibility + getArrayBuffer(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const resp = yield source.getBytes(offset, length, void 0, header.etag); + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: resp.data + }); + this.prune(); + return resp.data; + }); + } + prune() { + if (this.cache.size > this.maxCacheEntries) { + let minUsed = Infinity; + let minKey = void 0; + this.cache.forEach((cacheValue, key) => { + if (cacheValue.lastUsed < minUsed) { + minUsed = cacheValue.lastUsed; + minKey = key; + } + }); + if (minKey) { + this.cache.delete(minKey); + } + } + } + invalidate(source) { + return __async(this, null, function* () { + this.cache.delete(source.getKey()); + }); + } + }; + var SharedPromiseCache = class { + constructor(maxCacheEntries = 100, prefetch = true, decompress = defaultDecompress) { + this.cache = /* @__PURE__ */ new Map(); + this.invalidations = /* @__PURE__ */ new Map(); + this.maxCacheEntries = maxCacheEntries; + this.counter = 1; + this.decompress = decompress; + } + getHeader(source) { + return __async(this, null, function* () { + const cacheKey = source.getKey(); + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + getHeaderAndRoot(source, this.decompress).then((res) => { + if (res[1]) { + this.cache.set(res[1][0], { + lastUsed: this.counter++, + data: Promise.resolve(res[1][2]) + }); + } + resolve(res[0]); + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + getDirectory(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + getDirectory(source, this.decompress, offset, length, header).then((directory) => { + resolve(directory); + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + // for v2 backwards compatibility + getArrayBuffer(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + source.getBytes(offset, length, void 0, header.etag).then((resp) => { + resolve(resp.data); + if (this.cache.has(cacheKey)) { + } + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + prune() { + if (this.cache.size >= this.maxCacheEntries) { + let minUsed = Infinity; + let minKey = void 0; + this.cache.forEach((cacheValue, key) => { + if (cacheValue.lastUsed < minUsed) { + minUsed = cacheValue.lastUsed; + minKey = key; + } + }); + if (minKey) { + this.cache.delete(minKey); + } + } + } + invalidate(source) { + return __async(this, null, function* () { + const key = source.getKey(); + if (this.invalidations.get(key)) { + return yield this.invalidations.get(key); + } + this.cache.delete(source.getKey()); + const p = new Promise((resolve, reject) => { + this.getHeader(source).then((h) => { + resolve(); + this.invalidations.delete(key); + }).catch((e) => { + reject(e); + }); + }); + this.invalidations.set(key, p); + }); + } + }; + var PMTiles = class { + constructor(source, cache, decompress) { + if (typeof source === "string") { + this.source = new FetchSource(source); + } else { + this.source = source; + } + if (decompress) { + this.decompress = decompress; + } else { + this.decompress = defaultDecompress; + } + if (cache) { + this.cache = cache; + } else { + this.cache = new SharedPromiseCache(); + } + } + /** + * Return the header of the archive, + * including information such as tile type, min/max zoom, bounds, and summary statistics. + */ + getHeader() { + return __async(this, null, function* () { + return yield this.cache.getHeader(this.source); + }); + } + /** @hidden */ + getZxyAttempt(z, x, y, signal) { + return __async(this, null, function* () { + const tileId = zxyToTileId(z, x, y); + const header = yield this.cache.getHeader(this.source); + if (header.specVersion < 3) { + return v2_default.getZxy(header, this.source, this.cache, z, x, y, signal); + } + if (z < header.minZoom || z > header.maxZoom) { + return void 0; + } + let dO = header.rootDirectoryOffset; + let dL = header.rootDirectoryLength; + for (let depth = 0; depth <= 3; depth++) { + const directory = yield this.cache.getDirectory( + this.source, + dO, + dL, + header + ); + const entry = findTile(directory, tileId); + if (entry) { + if (entry.runLength > 0) { + const resp = yield this.source.getBytes( + header.tileDataOffset + entry.offset, + entry.length, + signal, + header.etag + ); + return { + data: yield this.decompress(resp.data, header.tileCompression), + cacheControl: resp.cacheControl, + expires: resp.expires + }; + } + dO = header.leafDirectoryOffset + entry.offset; + dL = entry.length; + } else { + return void 0; + } + } + throw Error("Maximum directory depth exceeded"); + }); + } + /** + * Primary method to get a single tile's bytes from an archive. + * + * Returns undefined if the tile does not exist in the archive. + */ + getZxy(z, x, y, signal) { + return __async(this, null, function* () { + try { + return yield this.getZxyAttempt(z, x, y, signal); + } catch (e) { + if (e instanceof EtagMismatch) { + this.cache.invalidate(this.source); + return yield this.getZxyAttempt(z, x, y, signal); + } + throw e; + } + }); + } + /** @hidden */ + getMetadataAttempt() { + return __async(this, null, function* () { + const header = yield this.cache.getHeader(this.source); + const resp = yield this.source.getBytes( + header.jsonMetadataOffset, + header.jsonMetadataLength, + void 0, + header.etag + ); + const decompressed = yield this.decompress( + resp.data, + header.internalCompression + ); + const dec = new TextDecoder("utf-8"); + return JSON.parse(dec.decode(decompressed)); + }); + } + /** + * Return the arbitrary JSON metadata of the archive. + */ + getMetadata() { + return __async(this, null, function* () { + try { + return yield this.getMetadataAttempt(); + } catch (e) { + if (e instanceof EtagMismatch) { + this.cache.invalidate(this.source); + return yield this.getMetadataAttempt(); + } + throw e; + } + }); + } + /** + * Construct a [TileJSON](https://github.com/mapbox/tilejson-spec) object. + * + * baseTilesUrl is the desired tiles URL, excluding the suffix `/{z}/{x}/{y}.{ext}`. + * For example, if the desired URL is `http://example.com/tileset/{z}/{x}/{y}.mvt`, + * the baseTilesUrl should be `https://example.com/tileset`. + */ + getTileJson(baseTilesUrl) { + return __async(this, null, function* () { + const header = yield this.getHeader(); + const metadata = yield this.getMetadata(); + const ext = tileTypeExt(header.tileType); + return { + tilejson: "3.0.0", + scheme: "xyz", + tiles: [`${baseTilesUrl}/{z}/{x}/{y}${ext}`], + // biome-ignore lint: TileJSON spec + vector_layers: metadata.vector_layers, + attribution: metadata.attribution, + description: metadata.description, + name: metadata.name, + version: metadata.version, + bounds: [header.minLon, header.minLat, header.maxLon, header.maxLat], + center: [header.centerLon, header.centerLat, header.centerZoom], + minzoom: header.minZoom, + maxzoom: header.maxZoom + }; + }); + } + }; + return __toCommonJS(js_exports); +})(); diff --git a/docs/articles/images/story-1a.gif b/docs/articles/images/story-1a.gif new file mode 100644 index 00000000..2677753e Binary files /dev/null and b/docs/articles/images/story-1a.gif differ diff --git a/docs/articles/images/story-1b.gif b/docs/articles/images/story-1b.gif new file mode 100644 index 00000000..7187ec3b Binary files /dev/null and b/docs/articles/images/story-1b.gif differ diff --git a/docs/articles/images/story-1c.gif b/docs/articles/images/story-1c.gif new file mode 100644 index 00000000..ebbdd45a Binary files /dev/null and b/docs/articles/images/story-1c.gif differ diff --git a/docs/articles/images/story-2.gif b/docs/articles/images/story-2.gif new file mode 100644 index 00000000..a00dfc4a Binary files /dev/null and b/docs/articles/images/story-2.gif differ diff --git a/docs/articles/images/story-3.gif b/docs/articles/images/story-3.gif new file mode 100644 index 00000000..87518d83 Binary files /dev/null and b/docs/articles/images/story-3.gif differ diff --git a/docs/articles/index.html b/docs/articles/index.html index b4bd1c76..74962d36 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -1,5 +1,5 @@ -Articles • mapgl +Articles • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 -

@@ -48,6 +51,8 @@

All vignettes

Using mapgl with Shiny
+
Building story maps with mapgl
+
@@ -57,7 +62,7 @@

All vignettes

diff --git a/docs/articles/layers-overview.html b/docs/articles/layers-overview.html index 473b37f5..ef74810d 100644 --- a/docs/articles/layers-overview.html +++ b/docs/articles/layers-overview.html @@ -6,16 +6,15 @@ Layers overview • mapgl - - - - - - + + + + + - - + + @@ -26,7 +25,7 @@ mapgl - 0.1.4 + 0.2.2.9000 @@ -59,18 +62,18 @@ - - - - - - -
+ + + + + + +
@@ -105,9 +108,9 @@

Using layers: an overviewlibrary(mapgl) library(sf) -nc <- st_read(system.file("shape/nc.shp", package="sf"))

+nc <- st_read(system.file("shape/nc.shp", package="sf"))
## Reading layer `nc' from data source 
-##   `/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/sf/shape/nc.shp' 
+##   `/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/sf/shape/nc.shp' 
 ##   using driver `ESRI Shapefile'
 ## Simple feature collection with 100 features and 14 fields
 ## Geometry type: MULTIPOLYGON
@@ -121,7 +124,7 @@ 

Using layers: an overview fill_color = "blue", fill_opacity = 0.5)

-

An overview of available layers in mapgl are below. +

An overview of available layers in mapgl are below. Layers can be used with either mapboxgl() or maplibre() maps.

@@ -147,7 +150,7 @@

Line layers= 0.7 )
- +

Circle layers @@ -165,16 +168,16 @@

Circle layersset.seed(1234) # Define the bounding box for Washington DC (approximately) -bbox <- st_bbox(c( +bbox <- st_bbox(c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), -crs = st_crs(4326)) +crs = st_crs(4326)) # Generate 30 random points within the bounding box -random_points <- st_as_sf( +random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox["xmin"], bbox["xmax"]), @@ -389,7 +392,7 @@

Markers diff --git a/docs/articles/layers-overview_files/h3j-h3t-0.9.2/h3j_h3t.js b/docs/articles/layers-overview_files/h3j-h3t-0.9.2/h3j_h3t.js new file mode 100644 index 00000000..16631aa5 --- /dev/null +++ b/docs/articles/layers-overview_files/h3j-h3t-0.9.2/h3j_h3t.js @@ -0,0 +1,3 @@ +!function(A){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=A();else if("function"==typeof define&&define.amd)define([],A);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).h3j_h3t=A()}}((function(){return function A(e,r,t){function i(o,a){if(!r[o]){if(!e[o]){var f="function"==typeof require&&require;if(!a&&f)return f(o,!0);if(n)return n(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var u=r[o]={exports:{}};e[o][0].call(u.exports,(function(A){return i(e[o][1][A]||A)}),u,u.exports,A,e,r,t)}return r[o].exports}for(var n="function"==typeof require&&require,o=0;o>3}if(n--,1===i||2===i)o+=A.readSVarint(),a+=A.readSVarint(),1===i&&(e&&f.push(e),e=[]),e.push(new t(o,a));else{if(7!==i)throw new Error("unknown command "+i);e&&e.push(e[0].clone())}}return e&&f.push(e),f},i.prototype.bbox=function(){var A=this._pbf;A.pos=this._geometry;for(var e=A.readVarint()+A.pos,r=1,t=0,i=0,n=0,o=1/0,a=-1/0,f=1/0,s=-1/0;A.pos>3}if(t--,1===r||2===r)(i+=A.readSVarint())a&&(a=i),(n+=A.readSVarint())s&&(s=n);else if(7!==r)throw new Error("unknown command "+r)}return[o,f,a,s]},i.prototype.toGeoJSON=function(A,e,r){var t,n,a=this.extent*Math.pow(2,r),f=this.extent*A,s=this.extent*e,u=this.loadGeometry(),l=i.types[this.type];function h(A){for(var e=0;e>3;e=1===t?A.readString():2===t?A.readFloat():3===t?A.readDouble():4===t?A.readVarint64():5===t?A.readVarint():6===t?A.readSVarint():7===t?A.readBoolean():null}return e}(r))}e.exports=i,i.prototype.feature=function(A){if(A<0||A>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[A];var e=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,e,this.extent,this._keys,this._values)}},{"./vectortilefeature.js":4}],6:[function(A,e,r){!function(A,t){"object"==typeof r&&void 0!==e?e.exports=t():A.geojsonvt=t()}(this,(function(){"use strict";function A(r,t,i,n){for(var o,a=n,f=i-t>>1,s=i-t,u=r[t],l=r[t+1],h=r[i],c=r[i+1],d=t+3;da)o=d,a=g;else if(g===a){var w=Math.abs(d-f);wn&&(o-t>3&&A(r,t,o,n),r[o+2]=a,i-o>3&&A(r,o,i,n))}function e(A,e,r,t,i,n){var o=i-r,a=n-t;if(0!==o||0!==a){var f=((A-r)*o+(e-t)*a)/(o*o+a*a);f>1?(r=i,t=n):f>0&&(r+=o*f,t+=a*f)}return(o=A-r)*o+(a=e-t)*a}function r(A,e,r,i){var n={id:void 0===A?null:A,type:e,geometry:r,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(A){var e=A.geometry,r=A.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)t(A,e);else if("Polygon"===r||"MultiLineString"===r)for(var i=0;i0&&(a+=i?(n*h-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(h-o,2))),n=l,o=h}var c=r.length-3;r[2]=1,A(r,0,c,t),r[c+2]=1,r.size=Math.abs(a),r.start=0,r.end=r.size}function a(A,e,r,t){for(var i=0;i1?1:r}function u(A,e,t,i,n,o,a,f){if(i/=e,o>=(t/=e)&&a=i)return null;for(var s=[],u=0;u=t&&B=i)){var b=[];if("Point"===w||"MultiPoint"===w)l(g,b,t,i,n);else if("LineString"===w)h(g,b,t,i,n,!1,f.lineMetrics);else if("MultiLineString"===w)d(g,b,t,i,n,!1);else if("Polygon"===w)d(g,b,t,i,n,!0);else if("MultiPolygon"===w)for(var v=0;v=r&&o<=t&&(e.push(A[n]),e.push(A[n+1]),e.push(A[n+2]))}}function h(A,e,r,t,i,n,o){for(var a,f,s=c(A),u=0===i?w:p,l=A.start,h=0;hr&&(f=u(s,d,B,v,m,r),o&&(s.start=l+a*f)):k>t?M=r&&(f=u(s,d,B,v,m,r),Q=!0),M>t&&k<=t&&(f=u(s,d,B,v,m,t),Q=!0),!n&&Q&&(o&&(s.end=l+a*f),e.push(s),s=c(A)),o&&(l+=a)}var y=A.length-3;d=A[y],B=A[y+1],b=A[y+2],(k=0===i?d:B)>=r&&k<=t&&g(s,d,B,b),y=s.length-3,n&&y>=3&&(s[y]!==s[0]||s[y+1]!==s[1])&&g(s,s[0],s[1],s[2]),s.length&&e.push(s)}function c(A){var e=[];return e.size=A.size,e.start=A.start,e.end=A.end,e}function d(A,e,r,t,i,n){for(var o=0;oo.maxX&&(o.maxX=u),l>o.maxY&&(o.maxY=l)}return o}function M(A,e,r,t){var i=e.geometry,n=e.type,o=[];if("Point"===n||"MultiPoint"===n)for(var a=0;a0&&e.size<(i?o:t))r.numPoints+=e.length/3;else{for(var a=[],f=0;fo)&&(r.numSimplified++,a.push(e[f]),a.push(e[f+1])),r.numPoints++;i&&function(A,e){for(var r=0,t=0,i=A.length,n=i-2;t0===e)for(t=0,i=A.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var t=function(A,e){var r=[];if("FeatureCollection"===A.type)for(var t=0;t1&&console.time("creation"),c=this.tiles[h]=k(A,e,r,t,f),this.tileCoords.push({z:e,x:r,y:t}),s)){s>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,t,c.numFeatures,c.numPoints,c.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(c.source=A,i){if(e===f.maxZoom||e===i)continue;var g=1<1&&console.time("clipping");var w,p,B,b,v,m,M=.5*f.buffer/f.extent,Q=.5-M,y=.5+M,x=1+M;w=p=B=b=null,v=u(A,l,r-M,r+y,0,c.minX,c.maxX,f),m=u(A,l,r+Q,r+x,0,c.minX,c.maxX,f),A=null,v&&(w=u(v,l,t-M,t+y,1,c.minY,c.maxY,f),p=u(v,l,t+Q,t+x,1,c.minY,c.maxY,f),v=null),m&&(B=u(m,l,t-M,t+y,1,c.minY,c.maxY,f),b=u(m,l,t+Q,t+x,1,c.minY,c.maxY,f),m=null),s>1&&console.timeEnd("clipping"),a.push(w||[],e+1,2*r,2*t),a.push(p||[],e+1,2*r,2*t+1),a.push(B||[],e+1,2*r+1,2*t),a.push(b||[],e+1,2*r+1,2*t+1)}}},y.prototype.getTile=function(A,e,r){var t=this.options,i=t.extent,n=t.debug;if(A<0||A>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",A,e,r);for(var f,s=A,u=e,l=r;!f&&s>0;)s--,u=Math.floor(u/2),l=Math.floor(l/2),f=this.tiles[E(s,u,l)];return f&&f.source?(n>1&&console.log("found parent tile z%d-%d-%d",s,u,l),n>1&&console.time("drilling down"),this.splitTile(f.source,s,u,l,A,e,r),n>1&&console.timeEnd("drilling down"),this.tiles[a]?v(this.tiles[a],i):null):null},function(A,e){return new y(A,e)}}))},{}],7:[function(A,e,r){var t=function(A){var e,r=void 0!==(A=A||{})?A:{},t={};for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);var i,n=[],o="";document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",i=function(A,e,r){var t=new XMLHttpRequest;t.open("GET",A,!0),t.responseType="arraybuffer",t.onload=function(){if(200==t.status||0==t.status&&t.response)e(t.response);else{var i=J(A);i?e(i.buffer):r()}},t.onerror=r,t.send(null)};var a=r.print||console.log.bind(console),f=r.printErr||console.warn.bind(console);for(e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);t=null,r.arguments&&(n=r.arguments);var s=0,u=function(){return s};var l=!1;function h(A){var e,t=r["_"+A];return e="Cannot call unknown function "+A+", make sure it is exported",t||fA("Assertion failed: "+e),t}function c(A,e,r,t,i){var n={string:function(A){var e=0;if(null!=A&&0!==A){var r=1+(A.length<<2);(function(A,e,r){(function(A,e,r,t){if(!(t>0))return 0;for(var i=r,n=r+t-1,o=0;o=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&A.charCodeAt(++o);if(a<=127){if(r>=n)break;e[r++]=a}else if(a<=2047){if(r+1>=n)break;e[r++]=192|a>>6,e[r++]=128|63&a}else if(a<=65535){if(r+2>=n)break;e[r++]=224|a>>12,e[r++]=128|a>>6&63,e[r++]=128|63&a}else{if(r+3>=n)break;e[r++]=240|a>>18,e[r++]=128|a>>12&63,e[r++]=128|a>>6&63,e[r++]=128|63&a}}e[r]=0})(A,B,e,r)})(A,e=AA(r),r)}return e},array:function(A){var e=AA(A.length);return function(A,e){p.set(A,e)}(A,e),e}};var o=h(A),a=[],f=0;if(t)for(var s=0;s=t);)++i;if(i-e>16&&A.subarray&&d)return d.decode(A.subarray(e,i));for(var n="";e>10,56320|1023&s)}}else n+=String.fromCharCode((31&o)<<6|a)}else n+=String.fromCharCode(o)}return n}(B,A,e):""}var w,p,B,b,v,m,k;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");function M(A,e){return A%e>0&&(A+=e-A%e),A}function Q(A){w=A,r.HEAP8=p=new Int8Array(A),r.HEAP16=b=new Int16Array(A),r.HEAP32=v=new Int32Array(A),r.HEAPU8=B=new Uint8Array(A),r.HEAPU16=new Uint16Array(A),r.HEAPU32=new Uint32Array(A),r.HEAPF32=m=new Float32Array(A),r.HEAPF64=k=new Float64Array(A)}var y=r.TOTAL_MEMORY||33554432;function E(A){for(;A.length>0;){var e=A.shift();if("function"!=typeof e){var t=e.func;"number"==typeof t?void 0===e.arg?r.dynCall_v(t):r.dynCall_vi(t,e.arg):t(void 0===e.arg?null:e.arg)}else e()}}y=(w=r.buffer?r.buffer:new ArrayBuffer(y)).byteLength,Q(w),v[6004]=5266928;var x=[],D=[],_=[],I=[];var F=Math.abs,C=Math.ceil,P=Math.floor,U=Math.min,G=0,S=null,T=null;r.preloadedImages={},r.preloadedAudios={};var V,H,R=null,L="data:application/octet-stream;base64,";function z(A){return String.prototype.startsWith?A.startsWith(L):0===A.indexOf(L)}R="data:application/octet-stream;base64,AAAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAABAAAAAMAAAAGAAAABQAAAAIAAAAAAAAAAgAAAAMAAAABAAAABAAAAAYAAAAAAAAABQAAAAMAAAAGAAAABAAAAAUAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAABAAAABQAAAAIAAAAAAAAAAQAAAAMAAAAGAAAABAAAAAYAAAAAAAAABQAAAAIAAAABAAAABAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAgAAAAMAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAABgAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAABgAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAAAAAACAAAAAwAAAAQAAAAFAAAABgAAAAAAAAABAAAAAwAAAAQAAAAFAAAABgAAAAAAAAABAAAAAgAAAAQAAAAFAAAABgAAAAAAAAABAAAAAgAAAAMAAAAFAAAABgAAAAAAAAABAAAAAgAAAAMAAAAEAAAABgAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAAAAAAABgAAAAAAAAADAAAAAgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAUAAAAEAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAEAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAUAAAACAAAABAAAAAMAAAAIAAAAAQAAAAcAAAAGAAAACQAAAAAAAAADAAAAAgAAAAIAAAAGAAAACgAAAAsAAAAAAAAAAQAAAAUAAAADAAAADQAAAAEAAAAHAAAABAAAAAwAAAAAAAAABAAAAH8AAAAPAAAACAAAAAMAAAAAAAAADAAAAAUAAAACAAAAEgAAAAoAAAAIAAAAAAAAABAAAAAGAAAADgAAAAsAAAARAAAAAQAAAAkAAAACAAAABwAAABUAAAAJAAAAEwAAAAMAAAANAAAAAQAAAAgAAAAFAAAAFgAAABAAAAAEAAAAAAAAAA8AAAAJAAAAEwAAAA4AAAAUAAAAAQAAAAcAAAAGAAAACgAAAAsAAAAYAAAAFwAAAAUAAAACAAAAEgAAAAsAAAARAAAAFwAAABkAAAACAAAABgAAAAoAAAAMAAAAHAAAAA0AAAAaAAAABAAAAA8AAAADAAAADQAAABoAAAAVAAAAHQAAAAMAAAAMAAAABwAAAA4AAAB/AAAAEQAAABsAAAAJAAAAFAAAAAYAAAAPAAAAFgAAABwAAAAfAAAABAAAAAgAAAAMAAAAEAAAABIAAAAhAAAAHgAAAAgAAAAFAAAAFgAAABEAAAALAAAADgAAAAYAAAAjAAAAGQAAABsAAAASAAAAGAAAAB4AAAAgAAAABQAAAAoAAAAQAAAAEwAAACIAAAAUAAAAJAAAAAcAAAAVAAAACQAAABQAAAAOAAAAEwAAAAkAAAAoAAAAGwAAACQAAAAVAAAAJgAAABMAAAAiAAAADQAAAB0AAAAHAAAAFgAAABAAAAApAAAAIQAAAA8AAAAIAAAAHwAAABcAAAAYAAAACwAAAAoAAAAnAAAAJQAAABkAAAAYAAAAfwAAACAAAAAlAAAACgAAABcAAAASAAAAGQAAABcAAAARAAAACwAAAC0AAAAnAAAAIwAAABoAAAAqAAAAHQAAACsAAAAMAAAAHAAAAA0AAAAbAAAAKAAAACMAAAAuAAAADgAAABQAAAARAAAAHAAAAB8AAAAqAAAALAAAAAwAAAAPAAAAGgAAAB0AAAArAAAAJgAAAC8AAAANAAAAGgAAABUAAAAeAAAAIAAAADAAAAAyAAAAEAAAABIAAAAhAAAAHwAAACkAAAAsAAAANQAAAA8AAAAWAAAAHAAAACAAAAAeAAAAGAAAABIAAAA0AAAAMgAAACUAAAAhAAAAHgAAADEAAAAwAAAAFgAAABAAAAApAAAAIgAAABMAAAAmAAAAFQAAADYAAAAkAAAAMwAAACMAAAAuAAAALQAAADgAAAARAAAAGwAAABkAAAAkAAAAFAAAACIAAAATAAAANwAAACgAAAA2AAAAJQAAACcAAAA0AAAAOQAAABgAAAAXAAAAIAAAACYAAAB/AAAAIgAAADMAAAAdAAAALwAAABUAAAAnAAAAJQAAABkAAAAXAAAAOwAAADkAAAAtAAAAKAAAABsAAAAkAAAAFAAAADwAAAAuAAAANwAAACkAAAAxAAAANQAAAD0AAAAWAAAAIQAAAB8AAAAqAAAAOgAAACsAAAA+AAAAHAAAACwAAAAaAAAAKwAAAD4AAAAvAAAAQAAAABoAAAAqAAAAHQAAACwAAAA1AAAAOgAAAEEAAAAcAAAAHwAAACoAAAAtAAAAJwAAACMAAAAZAAAAPwAAADsAAAA4AAAALgAAADwAAAA4AAAARAAAABsAAAAoAAAAIwAAAC8AAAAmAAAAKwAAAB0AAABFAAAAMwAAAEAAAAAwAAAAMQAAAB4AAAAhAAAAQwAAAEIAAAAyAAAAMQAAAH8AAAA9AAAAQgAAACEAAAAwAAAAKQAAADIAAAAwAAAAIAAAAB4AAABGAAAAQwAAADQAAAAzAAAARQAAADYAAABHAAAAJgAAAC8AAAAiAAAANAAAADkAAABGAAAASgAAACAAAAAlAAAAMgAAADUAAAA9AAAAQQAAAEsAAAAfAAAAKQAAACwAAAA2AAAARwAAADcAAABJAAAAIgAAADMAAAAkAAAANwAAACgAAAA2AAAAJAAAAEgAAAA8AAAASQAAADgAAABEAAAAPwAAAE0AAAAjAAAALgAAAC0AAAA5AAAAOwAAAEoAAABOAAAAJQAAACcAAAA0AAAAOgAAAH8AAAA+AAAATAAAACwAAABBAAAAKgAAADsAAAA/AAAATgAAAE8AAAAnAAAALQAAADkAAAA8AAAASAAAAEQAAABQAAAAKAAAADcAAAAuAAAAPQAAADUAAAAxAAAAKQAAAFEAAABLAAAAQgAAAD4AAAArAAAAOgAAACoAAABSAAAAQAAAAEwAAAA/AAAAfwAAADgAAAAtAAAATwAAADsAAABNAAAAQAAAAC8AAAA+AAAAKwAAAFQAAABFAAAAUgAAAEEAAAA6AAAANQAAACwAAABWAAAATAAAAEsAAABCAAAAQwAAAFEAAABVAAAAMQAAADAAAAA9AAAAQwAAAEIAAAAyAAAAMAAAAFcAAABVAAAARgAAAEQAAAA4AAAAPAAAAC4AAABaAAAATQAAAFAAAABFAAAAMwAAAEAAAAAvAAAAWQAAAEcAAABUAAAARgAAAEMAAAA0AAAAMgAAAFMAAABXAAAASgAAAEcAAABZAAAASQAAAFsAAAAzAAAARQAAADYAAABIAAAAfwAAAEkAAAA3AAAAUAAAADwAAABYAAAASQAAAFsAAABIAAAAWAAAADYAAABHAAAANwAAAEoAAABOAAAAUwAAAFwAAAA0AAAAOQAAAEYAAABLAAAAQQAAAD0AAAA1AAAAXgAAAFYAAABRAAAATAAAAFYAAABSAAAAYAAAADoAAABBAAAAPgAAAE0AAAA/AAAARAAAADgAAABdAAAATwAAAFoAAABOAAAASgAAADsAAAA5AAAAXwAAAFwAAABPAAAATwAAAE4AAAA/AAAAOwAAAF0AAABfAAAATQAAAFAAAABEAAAASAAAADwAAABjAAAAWgAAAFgAAABRAAAAVQAAAF4AAABlAAAAPQAAAEIAAABLAAAAUgAAAGAAAABUAAAAYgAAAD4AAABMAAAAQAAAAFMAAAB/AAAASgAAAEYAAABkAAAAVwAAAFwAAABUAAAARQAAAFIAAABAAAAAYQAAAFkAAABiAAAAVQAAAFcAAABlAAAAZgAAAEIAAABDAAAAUQAAAFYAAABMAAAASwAAAEEAAABoAAAAYAAAAF4AAABXAAAAUwAAAGYAAABkAAAAQwAAAEYAAABVAAAAWAAAAEgAAABbAAAASQAAAGMAAABQAAAAaQAAAFkAAABhAAAAWwAAAGcAAABFAAAAVAAAAEcAAABaAAAATQAAAFAAAABEAAAAagAAAF0AAABjAAAAWwAAAEkAAABZAAAARwAAAGkAAABYAAAAZwAAAFwAAABTAAAATgAAAEoAAABsAAAAZAAAAF8AAABdAAAATwAAAFoAAABNAAAAbQAAAF8AAABqAAAAXgAAAFYAAABRAAAASwAAAGsAAABoAAAAZQAAAF8AAABcAAAATwAAAE4AAABtAAAAbAAAAF0AAABgAAAAaAAAAGIAAABuAAAATAAAAFYAAABSAAAAYQAAAH8AAABiAAAAVAAAAGcAAABZAAAAbwAAAGIAAABuAAAAYQAAAG8AAABSAAAAYAAAAFQAAABjAAAAUAAAAGkAAABYAAAAagAAAFoAAABxAAAAZAAAAGYAAABTAAAAVwAAAGwAAAByAAAAXAAAAGUAAABmAAAAawAAAHAAAABRAAAAVQAAAF4AAABmAAAAZQAAAFcAAABVAAAAcgAAAHAAAABkAAAAZwAAAFsAAABhAAAAWQAAAHQAAABpAAAAbwAAAGgAAABrAAAAbgAAAHMAAABWAAAAXgAAAGAAAABpAAAAWAAAAGcAAABbAAAAcQAAAGMAAAB0AAAAagAAAF0AAABjAAAAWgAAAHUAAABtAAAAcQAAAGsAAAB/AAAAZQAAAF4AAABzAAAAaAAAAHAAAABsAAAAZAAAAF8AAABcAAAAdgAAAHIAAABtAAAAbQAAAGwAAABdAAAAXwAAAHUAAAB2AAAAagAAAG4AAABiAAAAaAAAAGAAAAB3AAAAbwAAAHMAAABvAAAAYQAAAG4AAABiAAAAdAAAAGcAAAB3AAAAcAAAAGsAAABmAAAAZQAAAHgAAABzAAAAcgAAAHEAAABjAAAAdAAAAGkAAAB1AAAAagAAAHkAAAByAAAAcAAAAGQAAABmAAAAdgAAAHgAAABsAAAAcwAAAG4AAABrAAAAaAAAAHgAAAB3AAAAcAAAAHQAAABnAAAAdwAAAG8AAABxAAAAaQAAAHkAAAB1AAAAfwAAAG0AAAB2AAAAcQAAAHkAAABqAAAAdgAAAHgAAABsAAAAcgAAAHUAAAB5AAAAbQAAAHcAAABvAAAAcwAAAG4AAAB5AAAAdAAAAHgAAAB4AAAAcwAAAHIAAABwAAAAeQAAAHcAAAB2AAAAeQAAAHQAAAB4AAAAdwAAAHUAAABxAAAAdgAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAEAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAQAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAADAAAABQAAAAEAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAgAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAABQAAAAUAAAAAAAAAAAAAAP////8BAAAAAAAAAAMAAAAEAAAAAgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAQAAAP//////////AQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAIAAAAAAAAAAAAAAAEAAAACAAAABgAAAAQAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAoAAAACAAAAAAAAAAAAAAABAAAAAQAAAAUAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAAAAAAAAAAAAAEAAAADAAAABwAAAAYAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAHAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAAAAAAAAAAAAQAAAAAAAAAJAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAAAAAAAAAAAAQAAAAQAAAAIAAAACgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAAAAAAAAAAABAAAACwAAAA8AAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA4AAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAgAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAAAAAAAAAAABAAAADAAAABAAAAAMAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAEAAAAKAAAAEwAAAAgAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAJAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAgAAAAAAAAAAAAAAAQAAAA0AAAARAAAADQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABMAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAAAAAAAAAAAAAEAAAAOAAAAEgAAAA8AAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAAAAAABAAAA//////////8TAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABIAAAAAAAAAGAAAAAAAAAAhAAAAAAAAAB4AAAAAAAAAIAAAAAMAAAAxAAAAAQAAADAAAAADAAAAMgAAAAMAAAAIAAAAAAAAAAUAAAAFAAAACgAAAAUAAAAWAAAAAAAAABAAAAAAAAAAEgAAAAAAAAApAAAAAQAAACEAAAAAAAAAHgAAAAAAAAAEAAAAAAAAAAAAAAAFAAAAAgAAAAUAAAAPAAAAAQAAAAgAAAAAAAAABQAAAAUAAAAfAAAAAQAAABYAAAAAAAAAEAAAAAAAAAACAAAAAAAAAAYAAAAAAAAADgAAAAAAAAAKAAAAAAAAAAsAAAAAAAAAEQAAAAMAAAAYAAAAAQAAABcAAAADAAAAGQAAAAMAAAAAAAAAAAAAAAEAAAAFAAAACQAAAAUAAAAFAAAAAAAAAAIAAAAAAAAABgAAAAAAAAASAAAAAQAAAAoAAAAAAAAACwAAAAAAAAAEAAAAAQAAAAMAAAAFAAAABwAAAAUAAAAIAAAAAQAAAAAAAAAAAAAAAQAAAAUAAAAQAAAAAQAAAAUAAAAAAAAAAgAAAAAAAAAHAAAAAAAAABUAAAAAAAAAJgAAAAAAAAAJAAAAAAAAABMAAAAAAAAAIgAAAAMAAAAOAAAAAQAAABQAAAADAAAAJAAAAAMAAAADAAAAAAAAAA0AAAAFAAAAHQAAAAUAAAABAAAAAAAAAAcAAAAAAAAAFQAAAAAAAAAGAAAAAQAAAAkAAAAAAAAAEwAAAAAAAAAEAAAAAgAAAAwAAAAFAAAAGgAAAAUAAAAAAAAAAQAAAAMAAAAAAAAADQAAAAUAAAACAAAAAQAAAAEAAAAAAAAABwAAAAAAAAAaAAAAAAAAACoAAAAAAAAAOgAAAAAAAAAdAAAAAAAAACsAAAAAAAAAPgAAAAMAAAAmAAAAAQAAAC8AAAADAAAAQAAAAAMAAAAMAAAAAAAAABwAAAAFAAAALAAAAAUAAAANAAAAAAAAABoAAAAAAAAAKgAAAAAAAAAVAAAAAQAAAB0AAAAAAAAAKwAAAAAAAAAEAAAAAwAAAA8AAAAFAAAAHwAAAAUAAAADAAAAAQAAAAwAAAAAAAAAHAAAAAUAAAAHAAAAAQAAAA0AAAAAAAAAGgAAAAAAAAAfAAAAAAAAACkAAAAAAAAAMQAAAAAAAAAsAAAAAAAAADUAAAAAAAAAPQAAAAMAAAA6AAAAAQAAAEEAAAADAAAASwAAAAMAAAAPAAAAAAAAABYAAAAFAAAAIQAAAAUAAAAcAAAAAAAAAB8AAAAAAAAAKQAAAAAAAAAqAAAAAQAAACwAAAAAAAAANQAAAAAAAAAEAAAABAAAAAgAAAAFAAAAEAAAAAUAAAAMAAAAAQAAAA8AAAAAAAAAFgAAAAUAAAAaAAAAAQAAABwAAAAAAAAAHwAAAAAAAAAyAAAAAAAAADAAAAAAAAAAMQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAIQAAAAMAAAAYAAAAAwAAABIAAAADAAAAEAAAAAMAAABGAAAAAAAAAEMAAAAAAAAAQgAAAAMAAAA0AAAAAwAAADIAAAAAAAAAMAAAAAAAAAAlAAAAAwAAACAAAAAAAAAAHgAAAAMAAABTAAAAAAAAAFcAAAADAAAAVQAAAAMAAABKAAAAAwAAAEYAAAAAAAAAQwAAAAAAAAA5AAAAAQAAADQAAAADAAAAMgAAAAAAAAAZAAAAAAAAABcAAAAAAAAAGAAAAAMAAAARAAAAAAAAAAsAAAADAAAACgAAAAMAAAAOAAAAAwAAAAYAAAADAAAAAgAAAAMAAAAtAAAAAAAAACcAAAAAAAAAJQAAAAMAAAAjAAAAAwAAABkAAAAAAAAAFwAAAAAAAAAbAAAAAwAAABEAAAAAAAAACwAAAAMAAAA/AAAAAAAAADsAAAADAAAAOQAAAAMAAAA4AAAAAwAAAC0AAAAAAAAAJwAAAAAAAAAuAAAAAwAAACMAAAADAAAAGQAAAAAAAAAkAAAAAAAAABQAAAAAAAAADgAAAAMAAAAiAAAAAAAAABMAAAADAAAACQAAAAMAAAAmAAAAAwAAABUAAAADAAAABwAAAAMAAAA3AAAAAAAAACgAAAAAAAAAGwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAFAAAAAAAAAAzAAAAAwAAACIAAAAAAAAAEwAAAAMAAABIAAAAAAAAADwAAAADAAAALgAAAAMAAABJAAAAAwAAADcAAAAAAAAAKAAAAAAAAABHAAAAAwAAADYAAAADAAAAJAAAAAAAAABAAAAAAAAAAC8AAAAAAAAAJgAAAAMAAAA+AAAAAAAAACsAAAADAAAAHQAAAAMAAAA6AAAAAwAAACoAAAADAAAAGgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAMwAAAAMAAABSAAAAAwAAAEAAAAAAAAAALwAAAAAAAABMAAAAAwAAAD4AAAAAAAAAKwAAAAMAAABhAAAAAAAAAFkAAAADAAAARwAAAAMAAABiAAAAAwAAAFQAAAAAAAAARQAAAAAAAABgAAAAAwAAAFIAAAADAAAAQAAAAAAAAABLAAAAAAAAAEEAAAAAAAAAOgAAAAMAAAA9AAAAAAAAADUAAAADAAAALAAAAAMAAAAxAAAAAwAAACkAAAADAAAAHwAAAAMAAABeAAAAAAAAAFYAAAAAAAAATAAAAAMAAABRAAAAAwAAAEsAAAAAAAAAQQAAAAAAAABCAAAAAwAAAD0AAAAAAAAANQAAAAMAAABrAAAAAAAAAGgAAAADAAAAYAAAAAMAAABlAAAAAwAAAF4AAAAAAAAAVgAAAAAAAABVAAAAAwAAAFEAAAADAAAASwAAAAAAAAA5AAAAAAAAADsAAAAAAAAAPwAAAAMAAABKAAAAAAAAAE4AAAADAAAATwAAAAMAAABTAAAAAwAAAFwAAAADAAAAXwAAAAMAAAAlAAAAAAAAACcAAAADAAAALQAAAAMAAAA0AAAAAAAAADkAAAAAAAAAOwAAAAAAAABGAAAAAwAAAEoAAAAAAAAATgAAAAMAAAAYAAAAAAAAABcAAAADAAAAGQAAAAMAAAAgAAAAAwAAACUAAAAAAAAAJwAAAAMAAAAyAAAAAwAAADQAAAAAAAAAOQAAAAAAAAAuAAAAAAAAADwAAAAAAAAASAAAAAMAAAA4AAAAAAAAAEQAAAADAAAAUAAAAAMAAAA/AAAAAwAAAE0AAAADAAAAWgAAAAMAAAAbAAAAAAAAACgAAAADAAAANwAAAAMAAAAjAAAAAAAAAC4AAAAAAAAAPAAAAAAAAAAtAAAAAwAAADgAAAAAAAAARAAAAAMAAAAOAAAAAAAAABQAAAADAAAAJAAAAAMAAAARAAAAAwAAABsAAAAAAAAAKAAAAAMAAAAZAAAAAwAAACMAAAAAAAAALgAAAAAAAABHAAAAAAAAAFkAAAAAAAAAYQAAAAMAAABJAAAAAAAAAFsAAAADAAAAZwAAAAMAAABIAAAAAwAAAFgAAAADAAAAaQAAAAMAAAAzAAAAAAAAAEUAAAADAAAAVAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAWQAAAAAAAAA3AAAAAwAAAEkAAAAAAAAAWwAAAAMAAAAmAAAAAAAAAC8AAAADAAAAQAAAAAMAAAAiAAAAAwAAADMAAAAAAAAARQAAAAMAAAAkAAAAAwAAADYAAAAAAAAARwAAAAAAAABgAAAAAAAAAGgAAAAAAAAAawAAAAMAAABiAAAAAAAAAG4AAAADAAAAcwAAAAMAAABhAAAAAwAAAG8AAAADAAAAdwAAAAMAAABMAAAAAAAAAFYAAAADAAAAXgAAAAMAAABSAAAAAAAAAGAAAAAAAAAAaAAAAAAAAABUAAAAAwAAAGIAAAAAAAAAbgAAAAMAAAA6AAAAAAAAAEEAAAADAAAASwAAAAMAAAA+AAAAAwAAAEwAAAAAAAAAVgAAAAMAAABAAAAAAwAAAFIAAAAAAAAAYAAAAAAAAABVAAAAAAAAAFcAAAAAAAAAUwAAAAMAAABlAAAAAAAAAGYAAAADAAAAZAAAAAMAAABrAAAAAwAAAHAAAAADAAAAcgAAAAMAAABCAAAAAAAAAEMAAAADAAAARgAAAAMAAABRAAAAAAAAAFUAAAAAAAAAVwAAAAAAAABeAAAAAwAAAGUAAAAAAAAAZgAAAAMAAAAxAAAAAAAAADAAAAADAAAAMgAAAAMAAAA9AAAAAwAAAEIAAAAAAAAAQwAAAAMAAABLAAAAAwAAAFEAAAAAAAAAVQAAAAAAAABfAAAAAAAAAFwAAAAAAAAAUwAAAAAAAABPAAAAAAAAAE4AAAAAAAAASgAAAAMAAAA/AAAAAQAAADsAAAADAAAAOQAAAAMAAABtAAAAAAAAAGwAAAAAAAAAZAAAAAUAAABdAAAAAQAAAF8AAAAAAAAAXAAAAAAAAABNAAAAAQAAAE8AAAAAAAAATgAAAAAAAAB1AAAABAAAAHYAAAAFAAAAcgAAAAUAAABqAAAAAQAAAG0AAAAAAAAAbAAAAAAAAABaAAAAAQAAAF0AAAABAAAAXwAAAAAAAABaAAAAAAAAAE0AAAAAAAAAPwAAAAAAAABQAAAAAAAAAEQAAAAAAAAAOAAAAAMAAABIAAAAAQAAADwAAAADAAAALgAAAAMAAABqAAAAAAAAAF0AAAAAAAAATwAAAAUAAABjAAAAAQAAAFoAAAAAAAAATQAAAAAAAABYAAAAAQAAAFAAAAAAAAAARAAAAAAAAAB1AAAAAwAAAG0AAAAFAAAAXwAAAAUAAABxAAAAAQAAAGoAAAAAAAAAXQAAAAAAAABpAAAAAQAAAGMAAAABAAAAWgAAAAAAAABpAAAAAAAAAFgAAAAAAAAASAAAAAAAAABnAAAAAAAAAFsAAAAAAAAASQAAAAMAAABhAAAAAQAAAFkAAAADAAAARwAAAAMAAABxAAAAAAAAAGMAAAAAAAAAUAAAAAUAAAB0AAAAAQAAAGkAAAAAAAAAWAAAAAAAAABvAAAAAQAAAGcAAAAAAAAAWwAAAAAAAAB1AAAAAgAAAGoAAAAFAAAAWgAAAAUAAAB5AAAAAQAAAHEAAAAAAAAAYwAAAAAAAAB3AAAAAQAAAHQAAAABAAAAaQAAAAAAAAB3AAAAAAAAAG8AAAAAAAAAYQAAAAAAAABzAAAAAAAAAG4AAAAAAAAAYgAAAAMAAABrAAAAAQAAAGgAAAADAAAAYAAAAAMAAAB5AAAAAAAAAHQAAAAAAAAAZwAAAAUAAAB4AAAAAQAAAHcAAAAAAAAAbwAAAAAAAABwAAAAAQAAAHMAAAAAAAAAbgAAAAAAAAB1AAAAAQAAAHEAAAAFAAAAaQAAAAUAAAB2AAAAAQAAAHkAAAAAAAAAdAAAAAAAAAByAAAAAQAAAHgAAAABAAAAdwAAAAAAAAByAAAAAAAAAHAAAAAAAAAAawAAAAAAAABkAAAAAAAAAGYAAAAAAAAAZQAAAAMAAABTAAAAAQAAAFcAAAADAAAAVQAAAAMAAAB2AAAAAAAAAHgAAAAAAAAAcwAAAAUAAABsAAAAAQAAAHIAAAAAAAAAcAAAAAAAAABcAAAAAQAAAGQAAAAAAAAAZgAAAAAAAAB1AAAAAAAAAHkAAAAFAAAAdwAAAAUAAABtAAAAAQAAAHYAAAAAAAAAeAAAAAAAAABfAAAAAQAAAGwAAAABAAAAcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAB+ogX28rbpPxqumpJv+fM/165tC4ns9D+XaEnTqUsEQFrOtNlC4PA/3U+0XG6P9b9TdUUBxTTjP4PUp8ex1ty/B1rD/EN43z+lcDi6LLrZP/a45NWEHMY/oJ5ijLDZ+j/xw3rjxWPjP2B8A46ioQdAotff3wla2z+FMSpA1jj+v6b5Y1mtPbS/cIu8K0F457/2esiyJpDNv98k5Ts2NeA/pvljWa09tD88ClUJ60MDQPZ6yLImkM0/4ONKxa0UBcD2uOTVhBzGv5G7JRxGave/8cN648Vj47+HCwtkjAXIv6LX398JWtu/qyheaCAL9D9TdUUBxTTjv4gyTxslhwVAB1rD/EN4378EH/28teoFwH6iBfbytum/F6ztFYdK/r/Xrm0Liez0vwcS6wNGWeO/Ws602ULg8L9TCtRLiLT8P8pi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAMuhRbbsNlBBYqHW9OmHIkF9XBuqnS31QAK37uYhNMhAOSo3UUupm0DC+6pc6JxvQHV9eseEEEJAzURsCyqlFEB8BQ4NMJjnPyy3tBoS97o/xawXQznRjj89J2K2CZxhP6vX43RIIDQ/S8isgygEBz+LvFHQkmzaPjFFFO7wMq4+AADMLkTtjkIAAOgkJqxhQgAAU7B0MjRCAADwpBcVB0IAAACYP2HaQQAAAIn/Ja5BzczM4Eg6gUHNzMxMU7BTQTMzMzNfgCZBAAAAAEi3+UAAAAAAwGPNQDMzMzMzy6BAmpmZmZkxc0AzMzMzM/NFQDMzMzMzMxlAzczMzMzM7D+ygXSx2U6RQKimJOvQKnpA23hmONTHY0A/AGcxyudNQNb3K647mzZA+S56rrwWIUAm4kUQ+9UJQKre9hGzh/M/BLvoy9WG3T+LmqMf8VHGP2m3nYNV37A/gbFHcyeCmT+cBPWBckiDP61tZACjKW0/q2RbYVUYVj8uDypVyLNAP6jGS5cA5zBBwcqhBdCNGUEGEhQ/JVEDQT6WPnRbNO1AB/AWSJgT1kDfUWNCNLDAQNk+5C33OqlAchWL34QSk0DKvtDIrNV8QNF0G3kFzGVASSeWhBl6UED+/0mNGuk4QGjA/dm/1CJALPLPMql6DEDSHoDrwpP1P2jouzWST+A/egAAAAAAAABKAwAAAAAAAPoWAAAAAAAAyqAAAAAAAAB6ZQQAAAAAAErGHgAAAAAA+mvXAAAAAADK8+MFAAAAAHqqOykAAAAASqmhIAEAAAD6oGvkBwAAAMpm8T43AAAAes+ZuIIBAABKrDQMkwoAAPq1cFUFSgAAyvkUViUGAgAAAAAAAwAAAAYAAAACAAAABQAAAAEAAAAEAAAAAAAAAAAAAAAFAAAAAwAAAAEAAAAGAAAABAAAAAIAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAA/////wAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAP////8AAAAAAAAAAAEAAAABAAAAAAAAAAAAAAD/////AAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAAAAAAABAAEAAAEBAAAAAAABAAAAAQAAAAEAAQAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAAYWxnb3MuYwBfcG9seWZpbGxJbnRlcm5hbABhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0dlb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9HZW9Cb3VuZGFyeQBwb2x5Z29uLT5uZXh0ID09IE5VTEwAbGlua2VkR2VvLmMAYWRkTmV3TGlua2VkUG9seWdvbgBuZXh0ICE9IE5VTEwAbG9vcCAhPSBOVUxMAGFkZE5ld0xpbmtlZExvb3AAcG9seWdvbi0+Zmlyc3QgPT0gTlVMTABhZGRMaW5rZWRMb29wAGNvb3JkICE9IE5VTEwAYWRkTGlua2VkQ29vcmQAbG9vcC0+Zmlyc3QgPT0gTlVMTABpbm5lckxvb3BzICE9IE5VTEwAbm9ybWFsaXplTXVsdGlQb2x5Z29uAGJib3hlcyAhPSBOVUxMAGNhbmRpZGF0ZXMgIT0gTlVMTABmaW5kUG9seWdvbkZvckhvbGUAY2FuZGlkYXRlQkJveGVzICE9IE5VTEwAcmV2RGlyICE9IElOVkFMSURfRElHSVQAbG9jYWxpai5jAGgzVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAcGVudGFnb25Sb3RhdGlvbnMgPj0gMABkaXJlY3Rpb25Sb3RhdGlvbnMgPj0gMABiYXNlQ2VsbCA9PSBvcmlnaW5CYXNlQ2VsbABiYXNlQ2VsbCAhPSBJTlZBTElEX0JBU0VfQ0VMTABsb2NhbElqa1RvSDMAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAd2l0aGluUGVudGFnb25Sb3RhdGlvbnMgPj0gMABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";function Y(A){return A}function O(A){return A.replace(/\b__Z[\w\d_]+/g,(function(A){return A===A?A:A+" ["+A+"]"}))}function j(){var A=new Error;if(!A.stack){try{throw new Error(0)}catch(e){A=e}if(!A.stack)return"(no stack trace available)"}return A.stack.toString()}function N(){return p.length}function Z(A){try{var e=new ArrayBuffer(A);if(e.byteLength!=A)return;return new Int8Array(e).set(p),$(e),Q(e),1}catch(A){}}var W="function"==typeof atob?atob:function(A){var e,r,t,i,n,o,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="",s=0;A=A.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{e=a.indexOf(A.charAt(s++))<<2|(i=a.indexOf(A.charAt(s++)))>>4,r=(15&i)<<4|(n=a.indexOf(A.charAt(s++)))>>2,t=(3&n)<<6|(o=a.indexOf(A.charAt(s++))),f+=String.fromCharCode(e),64!==n&&(f+=String.fromCharCode(r)),64!==o&&(f+=String.fromCharCode(t))}while(s>2]=A,i[a+4>>2]=e,(a=0!=(0|n))&&(i[n>>2]=0),0|UA(A,e))return I=o,0|(d=1);i[d>>2]=0;A:do{if((0|r)>=1)if(a)for(l=0,h=1,c=1,f=0,a=A;;){if(!(f|l)){if(0==(0|(a=0|U(a,e,4,d)))&0==(0|(e=0|M()))){a=2;break A}if(0|UA(a,e)){a=1;break A}}if(0==(0|(a=0|U(a,e,0|i[16+(l<<2)>>2],d)))&0==(0|(e=0|M()))){a=2;break A}if(i[(A=t+(c<<3)|0)>>2]=a,i[A+4>>2]=e,i[n+(c<<2)>>2]=h,A=(0|(f=f+1|0))==(0|h),u=6==(0|(s=l+1|0)),0|UA(a,e)){a=1;break A}if((0|(h=h+(u&A&1)|0))>(0|r)){a=0;break}l=A?u?0:s:l,c=c+1|0,f=A?0:f}else for(l=0,h=1,c=1,f=0,a=A;;){if(!(f|l)){if(0==(0|(a=0|U(a,e,4,d)))&0==(0|(e=0|M()))){a=2;break A}if(0|UA(a,e)){a=1;break A}}if(0==(0|(a=0|U(a,e,0|i[16+(l<<2)>>2],d)))&0==(0|(e=0|M()))){a=2;break A}if(i[(A=t+(c<<3)|0)>>2]=a,i[A+4>>2]=e,A=(0|(f=f+1|0))==(0|h),u=6==(0|(s=l+1|0)),0|UA(a,e)){a=1;break A}if((0|(h=h+(u&A&1)|0))>(0|r)){a=0;break}l=A?u?0:s:l,c=c+1|0,f=A?0:f}else a=0}while(0);return I=o,0|(d=a)}function P(A,e,r,t,n,o,a){r|=0,t|=0,n|=0,o|=0,a|=0;var f,s,u=0,l=0,h=0,c=0,d=0;if(s=I,I=I+16|0,f=s,0==(0|(A|=0))&0==(0|(e|=0)))I=s;else{if(u=0|Me(0|A,0|e,0|o,((0|o)<0)<<31>>31|0),M(),!(0==(0|(d=0|i[(c=l=t+(u<<3)|0)>>2]))&0==(0|(c=0|i[c+4>>2]))|(h=(0|d)==(0|A)&(0|c)==(0|e))))do{h=(0|(c=0|i[(d=l=t+((u=(u+1|0)%(0|o)|0)<<3)|0)>>2]))==(0|A)&(0|(d=0|i[d+4>>2]))==(0|e)}while(!(0==(0|c)&0==(0|d)|h));u=n+(u<<2)|0,h&&(0|i[u>>2])<=(0|a)||(i[(d=l)>>2]=A,i[d+4>>2]=e,i[u>>2]=a,(0|a)>=(0|r)||(d=a+1|0,i[f>>2]=0,P(c=0|U(A,e,2,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,3,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,1,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,5,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,4,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,6,f),0|M(),r,t,n,o,d))),I=s}}function U(A,e,r,t){A|=0,e|=0,r|=0;var n,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0;if((0|i[(t|=0)>>2])>0){a=0;do{r=0|fA(r),a=a+1|0}while((0|a)<(0|i[t>>2]))}n=0|Qe(0|A,0|e,45),M(),o=127&n,f=0|GA(A,e),a=0|Qe(0|A,0|e,52),M(),a&=15;A:do{if(a)for(;;){if(h=0|Qe(0|A,0|e,0|(l=3*(15-a|0)|0)),M(),h&=7,c=0==(0|RA(a)),a=a+-1|0,u=0|ye(7,0,0|l),e&=~(0|M()),A=(l=0|ye(0|i[(c?464:48)+(28*h|0)+(r<<2)>>2],0,0|l))|A&~u,e|=0|M(),!(r=0|i[(c?672:256)+(28*h|0)+(r<<2)>>2])){r=0;break A}if(!a){s=6;break}}else s=6}while(0);6==(0|s)&&(A|=h=0|ye(0|(c=0|i[880+(28*o|0)+(r<<2)>>2]),0,45),e=0|M()|-1040385&e,r=0|i[4304+(28*o|0)+(r<<2)>>2],127==(127&c|0)&&(c=0|ye(0|i[880+(28*o|0)+20>>2],0,45),e=0|M()|-1040385&e,r=0|i[4304+(28*o|0)+20>>2],A=0|TA(c|A,e),e=0|M(),i[t>>2]=1+(0|i[t>>2]))),s=0|Qe(0|A,0|e,45),M(),s&=127;A:do{if(0|S(s)){e:do{if(1==(0|GA(A,e))){if((0|o)!=(0|s)){if(0|R(s,0|i[7728+(28*o|0)>>2])){A=0|HA(A,e),f=1,e=0|M();break}A=0|TA(A,e),f=1,e=0|M();break}switch(0|f){case 5:A=0|HA(A,e),e=0|M(),i[t>>2]=5+(0|i[t>>2]),f=0;break e;case 3:A=0|TA(A,e),e=0|M(),i[t>>2]=1+(0|i[t>>2]),f=0;break e;default:return c=0,k(0|(h=0)),0|c}}else f=0}while(0);if((0|r)>0){a=0;do{A=0|SA(A,e),e=0|M(),a=a+1|0}while((0|a)!=(0|r))}if((0|o)!=(0|s)){if(!(0|T(s))){if(0!=(0|f)|5!=(0|GA(A,e)))break;i[t>>2]=1+(0|i[t>>2]);break}switch(127&n){case 8:case 118:break A}3!=(0|GA(A,e))&&(i[t>>2]=1+(0|i[t>>2]))}}else if((0|r)>0){a=0;do{A=0|TA(A,e),e=0|M(),a=a+1|0}while((0|a)!=(0|r))}}while(0);return i[t>>2]=((0|i[t>>2])+r|0)%6|0,c=A,k(0|(h=e)),0|c}function G(A,e,r,t,o,a){e|=0,r|=0,t|=0,o|=0,a|=0;var f,s,u,l,h,c,d,g,w,p=0,B=0,b=0,v=0,m=0,k=0,Q=0,y=0,E=0,x=0,D=0,_=0,F=0,C=0;if(w=I,I=I+48|0,c=w+32|0,d=w+16|0,g=w,(0|(p=0|i[(A|=0)>>2]))<=0)return I=w,0|(_=0);f=A+4|0,s=c+8|0,u=d+8|0,l=g+8|0,h=((0|e)<0)<<31>>31,D=0;A:for(;;){E=(B=0|i[f>>2])+(D<<4)|0,i[c>>2]=i[E>>2],i[c+4>>2]=i[E+4>>2],i[c+8>>2]=i[E+8>>2],i[c+12>>2]=i[E+12>>2],(0|D)==(p+-1|0)?(i[d>>2]=i[B>>2],i[d+4>>2]=i[B+4>>2],i[d+8>>2]=i[B+8>>2],i[d+12>>2]=i[B+12>>2]):(E=B+(D+1<<4)|0,i[d>>2]=i[E>>2],i[d+4>>2]=i[E+4>>2],i[d+8>>2]=i[E+8>>2],i[d+12>>2]=i[E+12>>2]),E=0|N(c,d,r);e:do{if((0|E)>0){x=+(0|E),y=0;r:for(;;){C=+(E-y|0),F=+(0|y),n[g>>3]=+n[c>>3]*C/x+ +n[d>>3]*F/x,n[l>>3]=+n[s>>3]*C/x+ +n[u>>3]*F/x,B=0|Me(0|(k=0|LA(g,r)),0|(Q=0|M()),0|e,0|h),M(),v=0|i[(b=p=a+(B<<3)|0)>>2],b=0|i[b+4>>2];t:do{if(0==(0|v)&0==(0|b))_=14;else for(m=0;;){if((0|m)>(0|e)){p=1;break t}if((0|v)==(0|k)&(0|b)==(0|Q)){p=7;break t}if(0==(0|(v=0|i[(b=p=a+((B=(B+1|0)%(0|e)|0)<<3)|0)>>2]))&0==(0|(b=0|i[b+4>>2]))){_=14;break}m=m+1|0}}while(0);switch(14==(0|_)&&(_=0,0==(0|k)&0==(0|Q)?p=7:(i[p>>2]=k,i[p+4>>2]=Q,p=0|i[t>>2],i[(m=o+(p<<3)|0)>>2]=k,i[m+4>>2]=Q,i[t>>2]=p+1,p=0)),7&p){case 7:case 0:break;default:break r}if((0|E)<=(0|(y=y+1|0))){_=8;break e}}if(0|p){p=-1,_=20;break A}}else _=8}while(0);if(8==(0|_)&&(_=0),(0|(D=D+1|0))>=(0|(p=0|i[A>>2]))){p=0,_=20;break}}return 20==(0|_)?(I=w,0|p):0}function S(A){return 0|i[7728+(28*(A|=0)|0)+16>>2]}function T(A){return 4==(0|(A|=0))|117==(0|A)|0}function V(A){return 0|i[11152+(216*(0|i[(A|=0)>>2])|0)+(72*(0|i[A+4>>2])|0)+(24*(0|i[A+8>>2])|0)+(i[A+12>>2]<<3)>>2]}function H(A){return 0|i[11152+(216*(0|i[(A|=0)>>2])|0)+(72*(0|i[A+4>>2])|0)+(24*(0|i[A+8>>2])|0)+(i[A+12>>2]<<3)+4>>2]}function R(A,e){return e|=0,(0|i[7728+(28*(A|=0)|0)+20>>2])==(0|e)?0|(e=1):0|(e=(0|i[7728+(28*A|0)+24>>2])==(0|e))}function L(A,e){return 0|i[880+(28*(A|=0)|0)+((e|=0)<<2)>>2]}function z(A,e){return e|=0,(0|i[880+(28*(A|=0)|0)>>2])==(0|e)?0|(e=0):(0|i[880+(28*A|0)+4>>2])==(0|e)?0|(e=1):(0|i[880+(28*A|0)+8>>2])==(0|e)?0|(e=2):(0|i[880+(28*A|0)+12>>2])==(0|e)?0|(e=3):(0|i[880+(28*A|0)+16>>2])==(0|e)?0|(e=4):(0|i[880+(28*A|0)+20>>2])==(0|e)?0|(e=5):0|((0|i[880+(28*A|0)+24>>2])==(0|e)?6:7)}function Y(A){return+n[(A|=0)+16>>3]<+n[A+24>>3]|0}function O(A,e){A|=0;var r,t,i=0;return(i=+n[(e|=0)>>3])>=+n[A+8>>3]&&i<=+n[A>>3]?(r=+n[A+16>>3],i=+n[A+24>>3],e=(t=+n[e+8>>3])>=i,A=t<=r&1,r>2]=0,l=l+4|0}while((0|l)<(0|h));return NA(e,o),OA(h=0|i[(l=o)>>2],l=0|i[l+4>>2],r),jA(h,l,t),s=+DA(r,t+8|0),n[r>>3]=+n[A>>3],n[(l=r+8|0)>>3]=+n[A+16>>3],n[t>>3]=+n[A+8>>3],n[(h=t+8|0)>>3]=+n[A+24>>3],u=+DA(r,t),h=~~+B(+u*u/+Ee(+ +f(+(+n[l>>3]-+n[h>>3])/(+n[r>>3]-+n[t>>3])),3)/(s*(2.59807621135*s)*.8)),I=a,0|(0==(0|h)?1:h)}function N(A,e,r){A|=0,e|=0,r|=0;var t,n,o,a,f,s=0,u=0;a=I,I=I+288|0,t=a+264|0,n=a+96|0,u=(s=o=a)+96|0;do{i[s>>2]=0,s=s+4|0}while((0|s)<(0|u));return NA(r,o),OA(s=0|i[(u=o)>>2],u=0|i[u+4>>2],t),jA(s,u,n),f=+DA(t,n+8|0),u=~~+B(+ +DA(A,e)/(2*f)),I=a,0|(0==(0|u)?1:u)}function Z(A,e,r,t){e|=0,r|=0,t|=0,i[(A|=0)>>2]=e,i[A+4>>2]=r,i[A+8>>2]=t}function W(A,e){A|=0;var r,t,o,a,s=0,u=0,l=0,h=0,c=0,d=0,g=0;i[(a=(e|=0)+8|0)>>2]=0,t=+n[A>>3],h=+f(+t),o=+n[A+8>>3],h+=.5*(c=+f(+o)/.8660254037844386),h-=+(0|(s=~~h)),c-=+(0|(A=~~c));do{if(h<.5){if(h<.3333333333333333){if(i[e>>2]=s,c<.5*(h+1)){i[e+4>>2]=A;break}A=A+1|0,i[e+4>>2]=A;break}if(A=(1&!(c<(g=1-h)))+A|0,i[e+4>>2]=A,g<=c&c<2*h){s=s+1|0,i[e>>2]=s;break}i[e>>2]=s;break}if(!(h<.6666666666666666)){if(s=s+1|0,i[e>>2]=s,c<.5*h){i[e+4>>2]=A;break}A=A+1|0,i[e+4>>2]=A;break}if(c<1-h){if(i[e+4>>2]=A,2*h-1>2]=s;break}}else A=A+1|0,i[e+4>>2]=A;s=s+1|0,i[e>>2]=s}while(0);do{if(t<0){if(1&A){s=~~(+(0|s)-(2*(+((d=0|ve(0|s,((0|s)<0)<<31>>31|0,0|(d=(A+1|0)/2|0),((0|d)<0)<<31>>31|0))>>>0)+4294967296*+(0|M()))+1)),i[e>>2]=s;break}s=~~(+(0|s)-2*(+((d=0|ve(0|s,((0|s)<0)<<31>>31|0,0|(d=(0|A)/2|0),((0|d)<0)<<31>>31|0))>>>0)+4294967296*+(0|M()))),i[e>>2]=s;break}}while(0);d=e+4|0,o<0&&(s=s-((1|A<<1)/2|0)|0,i[e>>2]=s,A=0-A|0,i[d>>2]=A),u=A-s|0,(0|s)<0?(l=0-s|0,i[d>>2]=u,i[a>>2]=l,i[e>>2]=0,A=u,s=0):l=0,(0|A)<0&&(s=s-A|0,i[e>>2]=s,l=l-A|0,i[a>>2]=l,i[d>>2]=0,A=0),r=s-l|0,u=A-l|0,(0|l)<0&&(i[e>>2]=r,i[d>>2]=u,i[a>>2]=0,A=u,s=r,l=0),(0|(u=(0|l)<(0|(u=(0|A)<(0|s)?A:s))?l:u))<=0||(i[e>>2]=s-u,i[d>>2]=A-u,i[a>>2]=l-u)}function J(A){var e,r=0,t=0,n=0,o=0,a=0;r=0|i[(A|=0)>>2],t=0|i[(e=A+4|0)>>2],(0|r)<0&&(t=t-r|0,i[e>>2]=t,i[(a=A+8|0)>>2]=(0|i[a>>2])-r,i[A>>2]=0,r=0),(0|t)<0?(r=r-t|0,i[A>>2]=r,o=(0|i[(a=A+8|0)>>2])-t|0,i[a>>2]=o,i[e>>2]=0,t=0):(a=o=A+8|0,o=0|i[o>>2]),(0|o)<0&&(r=r-o|0,i[A>>2]=r,t=t-o|0,i[e>>2]=t,i[a>>2]=0,o=0),(0|(n=(0|o)<(0|(n=(0|t)<(0|r)?t:r))?o:n))<=0||(i[A>>2]=r-n,i[e>>2]=t-n,i[a>>2]=o-n)}function K(A,e){e|=0;var r,t;t=0|i[(A|=0)+8>>2],r=+((0|i[A+4>>2])-t|0),n[e>>3]=+((0|i[A>>2])-t|0)-.5*r,n[e+8>>3]=.8660254037844386*r}function X(A,e,r){A|=0,e|=0,i[(r|=0)>>2]=(0|i[e>>2])+(0|i[A>>2]),i[r+4>>2]=(0|i[e+4>>2])+(0|i[A+4>>2]),i[r+8>>2]=(0|i[e+8>>2])+(0|i[A+8>>2])}function q(A,e,r){A|=0,e|=0,i[(r|=0)>>2]=(0|i[A>>2])-(0|i[e>>2]),i[r+4>>2]=(0|i[A+4>>2])-(0|i[e+4>>2]),i[r+8>>2]=(0|i[A+8>>2])-(0|i[e+8>>2])}function $(A,e){e|=0;var r,t=0;t=0|b(0|i[(A|=0)>>2],e),i[A>>2]=t,r=0|b(0|i[(t=A+4|0)>>2],e),i[t>>2]=r,e=0|b(0|i[(A=A+8|0)>>2],e),i[A>>2]=e}function AA(A){var e,r,t=0,n=0,o=0,a=0,f=0;f=(0|(r=0|i[(A|=0)>>2]))<0,A=(A=(n=(0|(a=((e=(0|(o=(0|i[A+4>>2])-(f?r:0)|0))<0)?0-o|0:0)+((0|i[A+8>>2])-(f?r:0))|0))<0)?0:a)-((o=(0|(n=(0|A)<(0|(n=(0|(t=(e?0:o)-(n?a:0)|0))<(0|(a=(f?0:r)-(e?o:0)-(n?a:0)|0))?t:a))?A:n))>0)?n:0)|0,t=t-(o?n:0)|0;A:do{switch(a-(o?n:0)|0){case 0:switch(0|t){case 0:return 0|(f=0==(0|A)?0:1==(0|A)?1:7);case 1:return 0|(f=0==(0|A)?2:1==(0|A)?3:7);default:break A}case 1:switch(0|t){case 0:return 0|(f=0==(0|A)?4:1==(0|A)?5:7);case 1:if(A)break A;return 0|(A=6);default:break A}}}while(0);return 0|(f=7)}function eA(A){var e,r,t=0,n=0,o=0,a=0,f=0;n=0|i[(e=(A|=0)+8|0)>>2],o=0|we(+((3*(t=(0|i[A>>2])-n|0)|0)-(n=(0|i[(r=A+4|0)>>2])-n|0)|0)/7),i[A>>2]=o,t=0|we(+((n<<1)+t|0)/7),i[r>>2]=t,i[e>>2]=0,n=t-o|0,(0|o)<0?(f=0-o|0,i[r>>2]=n,i[e>>2]=f,i[A>>2]=0,t=n,o=0,n=f):n=0,(0|t)<0&&(o=o-t|0,i[A>>2]=o,n=n-t|0,i[e>>2]=n,i[r>>2]=0,t=0),f=o-n|0,a=t-n|0,(0|n)<0?(i[A>>2]=f,i[r>>2]=a,i[e>>2]=0,t=a,a=f,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|t)<(0|a)?t:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=t-o,i[e>>2]=n-o)}function rA(A){var e,r,t=0,n=0,o=0,a=0,f=0;n=0|i[(e=(A|=0)+8|0)>>2],o=0|we(+(((t=(0|i[A>>2])-n|0)<<1)+(n=(0|i[(r=A+4|0)>>2])-n|0)|0)/7),i[A>>2]=o,t=0|we(+((3*n|0)-t|0)/7),i[r>>2]=t,i[e>>2]=0,n=t-o|0,(0|o)<0?(f=0-o|0,i[r>>2]=n,i[e>>2]=f,i[A>>2]=0,t=n,o=0,n=f):n=0,(0|t)<0&&(o=o-t|0,i[A>>2]=o,n=n-t|0,i[e>>2]=n,i[r>>2]=0,t=0),f=o-n|0,a=t-n|0,(0|n)<0?(i[A>>2]=f,i[r>>2]=a,i[e>>2]=0,t=a,a=f,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|t)<(0|a)?t:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=t-o,i[e>>2]=n-o)}function tA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],o=0|i[(r=A+4|0)>>2],a=0|i[(t=A+8|0)>>2],f=o+(3*n|0)|0,i[A>>2]=f,o=a+(3*o|0)|0,i[r>>2]=o,n=(3*a|0)+n|0,i[t>>2]=n,a=o-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=a,i[t>>2]=n,i[A>>2]=0,o=a,a=0):a=f,(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function iA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=(3*(n=0|i[(r=A+4|0)>>2])|0)+f|0,f=(o=0|i[(t=A+8|0)>>2])+(3*f|0)|0,i[A>>2]=f,i[r>>2]=a,n=(3*o|0)+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,f=0):o=a,(0|o)<0&&(f=f-o|0,i[A>>2]=f,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=f-n|0,a=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=a,i[t>>2]=0,f=e,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|a)<(0|f)?a:f))?n:o))<=0||(i[A>>2]=f-o,i[r>>2]=a-o,i[t>>2]=n-o)}function nA(A,e){A|=0;var r,t,n,o=0,a=0,f=0;((e|=0)+-1|0)>>>0>=6||(f=(0|i[15472+(12*e|0)>>2])+(0|i[A>>2])|0,i[A>>2]=f,n=A+4|0,a=(0|i[15472+(12*e|0)+4>>2])+(0|i[n>>2])|0,i[n>>2]=a,t=A+8|0,e=(0|i[15472+(12*e|0)+8>>2])+(0|i[t>>2])|0,i[t>>2]=e,o=a-f|0,(0|f)<0?(e=e-f|0,i[n>>2]=o,i[t>>2]=e,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,e=e-o|0,i[t>>2]=e,i[n>>2]=0,o=0),r=a-e|0,f=o-e|0,(0|e)<0?(i[A>>2]=r,i[n>>2]=f,i[t>>2]=0,a=r,e=0):f=o,(0|(o=(0|e)<(0|(o=(0|f)<(0|a)?f:a))?e:o))<=0||(i[A>>2]=a-o,i[n>>2]=f-o,i[t>>2]=e-o))}function oA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=(n=0|i[(r=A+4|0)>>2])+f|0,f=(o=0|i[(t=A+8|0)>>2])+f|0,i[A>>2]=f,i[r>>2]=a,n=o+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function aA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],a=0|i[(r=A+4|0)>>2],o=0|i[(t=A+8|0)>>2],f=a+n|0,i[A>>2]=f,a=o+a|0,i[r>>2]=a,n=o+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function fA(A){switch(0|(A|=0)){case 1:A=5;break;case 5:A=4;break;case 4:A=6;break;case 6:A=2;break;case 2:A=3;break;case 3:A=1}return 0|A}function sA(A){switch(0|(A|=0)){case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5;break;case 5:A=1}return 0|A}function uA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],o=0|i[(r=A+4|0)>>2],a=0|i[(t=A+8|0)>>2],f=o+(n<<1)|0,i[A>>2]=f,o=a+(o<<1)|0,i[r>>2]=o,n=(a<<1)+n|0,i[t>>2]=n,a=o-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=a,i[t>>2]=n,i[A>>2]=0,o=a,a=0):a=f,(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function lA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=((n=0|i[(r=A+4|0)>>2])<<1)+f|0,f=(o=0|i[(t=A+8|0)>>2])+(f<<1)|0,i[A>>2]=f,i[r>>2]=a,n=(o<<1)+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,f=0):o=a,(0|o)<0&&(f=f-o|0,i[A>>2]=f,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=f-n|0,a=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=a,i[t>>2]=0,f=e,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|a)<(0|f)?a:f))?n:o))<=0||(i[A>>2]=f-o,i[r>>2]=a-o,i[t>>2]=n-o)}function hA(A,e){e|=0;var r,t,n,o=0,a=0,f=0;return n=(0|(t=(0|i[(A|=0)>>2])-(0|i[e>>2])|0))<0,r=(0|(a=(0|i[A+4>>2])-(0|i[e+4>>2])-(n?t:0)|0))<0,e=(e=(A=(0|(f=(n?0-t|0:0)+(0|i[A+8>>2])-(0|i[e+8>>2])+(r?0-a|0:0)|0))<0)?0:f)-((a=(0|(A=(0|e)<(0|(A=(0|(o=(r?0:a)-(A?f:0)|0))<(0|(f=(n?0:t)-(r?a:0)-(A?f:0)|0))?o:f))?e:A))>0)?A:0)|0,o=o-(a?A:0)|0,0|((0|(A=(0|(A=f-(a?A:0)|0))>-1?A:0-A|0))>(0|(e=(0|(o=(0|o)>-1?o:0-o|0))>(0|(e=(0|e)>-1?e:0-e|0))?o:e))?A:e)}function cA(A,e){e|=0;var r;r=0|i[(A|=0)+8>>2],i[e>>2]=(0|i[A>>2])-r,i[e+4>>2]=(0|i[A+4>>2])-r}function dA(A,e){e|=0;var r,t,n,o=0,a=0,f=0;a=0|i[(A|=0)>>2],i[e>>2]=a,A=0|i[A+4>>2],i[(t=e+4|0)>>2]=A,i[(n=e+8|0)>>2]=0,o=A-a|0,(0|a)<0?(A=0-a|0,i[t>>2]=o,i[n>>2]=A,i[e>>2]=0,a=0):(o=A,A=0),(0|o)<0&&(a=a-o|0,i[e>>2]=a,A=A-o|0,i[n>>2]=A,i[t>>2]=0,o=0),r=a-A|0,f=o-A|0,(0|A)<0?(i[e>>2]=r,i[t>>2]=f,i[n>>2]=0,o=f,f=r,A=0):f=a,(0|(a=(0|A)<(0|(a=(0|o)<(0|f)?o:f))?A:a))<=0||(i[e>>2]=f-a,i[t>>2]=o-a,i[n>>2]=A-a)}function gA(A){var e,r,t,n;r=(n=0|i[(e=(A|=0)+8|0)>>2])-(0|i[A>>2])|0,i[A>>2]=r,A=(0|i[(t=A+4|0)>>2])-n|0,i[t>>2]=A,i[e>>2]=0-(A+r)}function wA(A){var e,r,t=0,n=0,o=0,a=0,f=0;t=0-(n=0|i[(A|=0)>>2])|0,i[A>>2]=t,i[(e=A+8|0)>>2]=0,a=(o=0|i[(r=A+4|0)>>2])+n|0,(0|n)>0?(i[r>>2]=a,i[e>>2]=n,i[A>>2]=0,t=0,o=a):n=0,(0|o)<0?(f=t-o|0,i[A>>2]=f,n=n-o|0,i[e>>2]=n,i[r>>2]=0,a=f-n|0,t=0-n|0,(0|n)<0?(i[A>>2]=a,i[r>>2]=t,i[e>>2]=0,o=t,n=0):(o=0,a=f)):a=t,(0|(t=(0|n)<(0|(t=(0|o)<(0|a)?o:a))?n:t))<=0||(i[A>>2]=a-t,i[r>>2]=o-t,i[e>>2]=n-t)}function pA(A,e,r,t){e|=0,r|=0,t|=0;var o,a=0,f=0,s=0,u=0;if(o=I,I=I+32|0,function(A,e){e|=0;var r=0,t=0,i=0;r=+n[(A=A|0)>>3],t=+l(+r),r=+h(+r),n[e+16>>3]=r,r=+n[A+8>>3],i=t*+l(+r),n[e>>3]=i,r=t*+h(+r),n[e+8>>3]=r}(A|=0,f=o),i[r>>2]=0,a=+fe(15888,f),(s=+fe(15912,f))>2]=1,a=s),(s=+fe(15936,f))>2]=2,a=s),(s=+fe(15960,f))>2]=3,a=s),(s=+fe(15984,f))>2]=4,a=s),(s=+fe(16008,f))>2]=5,a=s),(s=+fe(16032,f))>2]=6,a=s),(s=+fe(16056,f))>2]=7,a=s),(s=+fe(16080,f))>2]=8,a=s),(s=+fe(16104,f))>2]=9,a=s),(s=+fe(16128,f))>2]=10,a=s),(s=+fe(16152,f))>2]=11,a=s),(s=+fe(16176,f))>2]=12,a=s),(s=+fe(16200,f))>2]=13,a=s),(s=+fe(16224,f))>2]=14,a=s),(s=+fe(16248,f))>2]=15,a=s),(s=+fe(16272,f))>2]=16,a=s),(s=+fe(16296,f))>2]=17,a=s),(s=+fe(16320,f))>2]=18,a=s),(s=+fe(16344,f))>2]=19,a=s),(s=+d(+(1-.5*a)))<1e-16)return i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,void(I=o);if(r=0|i[r>>2],a=+EA((a=+n[16368+(24*r|0)>>3])-+EA(+function(A,e){A|=0;var r=0,t=0,i=0,o=0,a=0;return o=+n[(e=e|0)>>3],t=+l(+o),i=+n[e+8>>3]-+n[A+8>>3],a=t*+h(+i),r=+n[A>>3],+ +p(+a,+(+h(+o)*+l(+r)-+l(+i)*(t*+h(+r))))}(15568+(r<<4)|0,A))),u=0|RA(e)?+EA(a+-.3334731722518321):a,a=+c(+s)/.381966011250105,(0|e)>0){f=0;do{a*=2.6457513110645907,f=f+1|0}while((0|f)!=(0|e))}s=+l(+u)*a,n[t>>3]=s,u=+h(+u)*a,n[t+8>>3]=u,I=o}function BA(A,e,r,t,o){e|=0,r|=0,t|=0,o|=0;var a=0,u=0;if((a=+function(A){var e=0,r=0;return r=+n[(A=A|0)>>3],e=+n[A+8>>3],+ +s(+(r*r+e*e))}(A|=0))<1e-16)return e=15568+(e<<4)|0,i[o>>2]=i[e>>2],i[o+4>>2]=i[e+4>>2],i[o+8>>2]=i[e+8>>2],void(i[o+12>>2]=i[e+12>>2]);if(u=+p(+ +n[A+8>>3],+ +n[A>>3]),(0|r)>0){A=0;do{a/=2.6457513110645907,A=A+1|0}while((0|A)!=(0|r))}t?(a/=3,r=0==(0|RA(r)),a=+w(.381966011250105*(r?a:a/2.6457513110645907))):(a=+w(.381966011250105*a),0|RA(r)&&(u=+EA(u+.3334731722518321))),function(A,e,r,t){A|=0,e=+e,t|=0;var o=0,a=0,s=0,u=0;if((r=+r)<1e-16)return i[t>>2]=i[A>>2],i[t+4>>2]=i[A+4>>2],i[t+8>>2]=i[A+8>>2],void(i[t+12>>2]=i[A+12>>2]);a=e<0?e+6.283185307179586:e,a=e>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(o=+f(+(a+-3.141592653589793))<1e-16,e=+n[A>>3],o){e-=r,n[t>>3]=e,o=t;break}if(s=+l(+r),r=+h(+r),e=s*+h(+e)+ +l(+a)*(r*+l(+e)),e=+g(+((e=e>1?1:e)<-1?-1:e)),n[t>>3]=e,+f(+(e+-1.5707963267948966))<1e-16)return n[t>>3]=1.5707963267948966,void(n[t+8>>3]=0);if(+f(+(e+1.5707963267948966))<1e-16)return n[t>>3]=-1.5707963267948966,void(n[t+8>>3]=0);if(u=+l(+e),a=r*+h(+a)/u,r=+n[A>>3],e=(s-+h(+e)*+h(+r))/+l(+r)/u,s=a>1?1:a,e=e>1?1:e,(e=+n[A+8>>3]+ +p(+(s<-1?-1:s),+(e<-1?-1:e)))>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);return void(n[t+8>>3]=e)}e=+n[A>>3]+r,n[t>>3]=e,o=t}while(0);if(+f(+(e+-1.5707963267948966))<1e-16)return n[o>>3]=1.5707963267948966,void(n[t+8>>3]=0);if(+f(+(e+1.5707963267948966))<1e-16)return n[o>>3]=-1.5707963267948966,void(n[t+8>>3]=0);if((e=+n[A+8>>3])>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);n[t+8>>3]=e}(15568+(e<<4)|0,+EA(+n[16368+(24*e|0)>>3]-u),a,o)}function bA(A,e,r){e|=0,r|=0;var t,n;t=I,I=I+16|0,K((A|=0)+4|0,n=t),BA(n,0|i[A>>2],e,0,r),I=t}function vA(A,e,r,t,o){A|=0,e|=0,r|=0,t|=0,o|=0;var a,f,s,u,l,h,c,d,g,w,p,B,b,v,m,k,M,y,E,x,D,_,F=0,C=0,P=0,U=0,G=0,S=0;if(_=I,I=I+272|0,U=_+240|0,E=_,x=_+224|0,D=_+208|0,p=_+176|0,B=_+160|0,b=_+192|0,v=_+144|0,m=_+128|0,k=_+112|0,M=_+96|0,y=_+80|0,i[(F=_+256|0)>>2]=e,i[U>>2]=i[A>>2],i[U+4>>2]=i[A+4>>2],i[U+8>>2]=i[A+8>>2],i[U+12>>2]=i[A+12>>2],mA(U,F,E),i[o>>2]=0,(0|(U=t+r+(5==(0|t)&1)|0))<=(0|r))I=_;else{f=x+4|0,s=p+4|0,u=r+5|0,l=16848+((a=0|i[F>>2])<<2)|0,h=16928+(a<<2)|0,c=m+8|0,d=k+8|0,g=M+8|0,w=D+4|0,P=r;A:for(;;){C=E+(((0|P)%5|0)<<4)|0,i[D>>2]=i[C>>2],i[D+4>>2]=i[C+4>>2],i[D+8>>2]=i[C+8>>2],i[D+12>>2]=i[C+12>>2];do{}while(2==(0|kA(D,a,0,1)));if((0|P)>(0|r)&0!=(0|RA(e))){if(i[p>>2]=i[D>>2],i[p+4>>2]=i[D+4>>2],i[p+8>>2]=i[D+8>>2],i[p+12>>2]=i[D+12>>2],K(f,B),t=0|i[p>>2],F=0|i[17008+(80*t|0)+(i[x>>2]<<2)>>2],i[p>>2]=i[18608+(80*t|0)+(20*F|0)>>2],(0|(C=0|i[18608+(80*t|0)+(20*F|0)+16>>2]))>0){A=0;do{oA(s),A=A+1|0}while((0|A)<(0|C))}switch(C=18608+(80*t|0)+(20*F|0)+4|0,i[b>>2]=i[C>>2],i[b+4>>2]=i[C+4>>2],i[b+8>>2]=i[C+8>>2],$(b,3*(0|i[l>>2])|0),X(s,b,s),J(s),K(s,v),G=+(0|i[h>>2]),n[m>>3]=3*G,n[c>>3]=0,S=-1.5*G,n[k>>3]=S,n[d>>3]=2.598076211353316*G,n[M>>3]=S,n[g>>3]=-2.598076211353316*G,0|i[17008+(80*(0|i[p>>2])|0)+(i[D>>2]<<2)>>2]){case 1:A=k,t=m;break;case 3:A=M,t=k;break;case 2:A=m,t=M;break;default:A=12;break A}oe(B,v,t,A,y),BA(y,0|i[p>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])}if((0|P)<(0|u)&&(K(w,p),BA(p,0|i[D>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])),i[x>>2]=i[D>>2],i[x+4>>2]=i[D+4>>2],i[x+8>>2]=i[D+8>>2],i[x+12>>2]=i[D+12>>2],(0|(P=P+1|0))>=(0|U)){A=3;break}}3!=(0|A)?12==(0|A)&&Q(22474,22521,581,22531):I=_}}function mA(A,e,r){A|=0,e|=0,r|=0;var t,n=0,o=0,a=0,f=0,s=0;t=I,I=I+128|0,o=t,f=20208,s=(a=n=t+64|0)+60|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));f=20272,s=(a=o)+60|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));n=(s=0==(0|RA(0|i[e>>2])))?n:o,uA(o=A+4|0),lA(o),0|RA(0|i[e>>2])&&(iA(o),i[e>>2]=1+(0|i[e>>2])),i[r>>2]=i[A>>2],X(o,n,e=r+4|0),J(e),i[r+16>>2]=i[A>>2],X(o,n+12|0,e=r+20|0),J(e),i[r+32>>2]=i[A>>2],X(o,n+24|0,e=r+36|0),J(e),i[r+48>>2]=i[A>>2],X(o,n+36|0,e=r+52|0),J(e),i[r+64>>2]=i[A>>2],X(o,n+48|0,r=r+68|0),J(r),I=t}function kA(A,e,r,t){r|=0,t|=0;var n,o,a,f,s,u,l=0,h=0,c=0,d=0,g=0;if(u=I,I=I+32|0,s=u+12|0,o=u,g=(A|=0)+4|0,d=0|i[16928+((e|=0)<<2)>>2],d=(f=0!=(0|t))?3*d|0:d,l=0|i[g>>2],n=0|i[(a=A+8|0)>>2],f){if((0|(l=n+l+(t=0|i[(h=A+12|0)>>2])|0))==(0|d))return I=u,0|(g=1);c=h}else l=n+l+(t=0|i[(c=A+12|0)>>2])|0;if((0|l)<=(0|d))return I=u,0|(g=0);do{if((0|t)>0){if(t=0|i[A>>2],(0|n)>0){h=18608+(80*t|0)+60|0,t=A;break}t=18608+(80*t|0)+40|0,r?(Z(s,d,0,0),q(g,s,o),aA(o),X(o,s,g),h=t,t=A):(h=t,t=A)}else h=18608+(80*(0|i[A>>2])|0)+20|0,t=A}while(0);if(i[t>>2]=i[h>>2],(0|i[(l=h+16|0)>>2])>0){t=0;do{oA(g),t=t+1|0}while((0|t)<(0|i[l>>2]))}return A=h+4|0,i[s>>2]=i[A>>2],i[s+4>>2]=i[A+4>>2],i[s+8>>2]=i[A+8>>2],e=0|i[16848+(e<<2)>>2],$(s,f?3*e|0:e),X(g,s,g),J(g),t=f&&((0|i[a>>2])+(0|i[g>>2])+(0|i[c>>2])|0)==(0|d)?1:2,I=u,0|(g=t)}function MA(A,e){A|=0,e|=0;var r=0;do{r=0|kA(A,e,0,1)}while(2==(0|r));return 0|r}function QA(A,e,r,t,o){A|=0,e|=0,r|=0,t|=0,o|=0;var a,f,s,u,l,h,c,d,g,w,p,B,b,v,m,k,M,y,E=0,x=0,D=0,_=0,F=0;if(y=I,I=I+240|0,v=y+208|0,m=y,k=y+192|0,M=y+176|0,g=y+160|0,w=y+144|0,p=y+128|0,B=y+112|0,b=y+96|0,i[(E=y+224|0)>>2]=e,i[v>>2]=i[A>>2],i[v+4>>2]=i[A+4>>2],i[v+8>>2]=i[A+8>>2],i[v+12>>2]=i[A+12>>2],yA(v,E,m),i[o>>2]=0,(0|(d=t+r+(6==(0|t)&1)|0))<=(0|r))I=y;else{f=r+6|0,s=16928+((a=0|i[E>>2])<<2)|0,u=w+8|0,l=p+8|0,h=B+8|0,c=k+4|0,x=0,D=r,t=-1;A:for(;;){if(A=m+((E=(0|D)%6|0)<<4)|0,i[k>>2]=i[A>>2],i[k+4>>2]=i[A+4>>2],i[k+8>>2]=i[A+8>>2],i[k+12>>2]=i[A+12>>2],A=x,x=0|kA(k,a,0,1),(0|D)>(0|r)&0!=(0|RA(e))&&(1!=(0|A)&&(0|i[k>>2])!=(0|t))){switch(K(m+(((E+5|0)%6|0)<<4)+4|0,M),K(m+(E<<4)+4|0,g),_=+(0|i[s>>2]),n[w>>3]=3*_,n[u>>3]=0,F=-1.5*_,n[p>>3]=F,n[l>>3]=2.598076211353316*_,n[B>>3]=F,n[h>>3]=-2.598076211353316*_,E=0|i[v>>2],0|i[17008+(80*E|0)+(((0|t)==(0|E)?0|i[k>>2]:t)<<2)>>2]){case 1:A=p,t=w;break;case 3:A=B,t=p;break;case 2:A=w,t=B;break;default:A=8;break A}oe(M,g,t,A,b),0|ae(M,b)||0|ae(g,b)||(BA(b,0|i[v>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2]))}if((0|D)<(0|f)&&(K(c,M),BA(M,0|i[k>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])),(0|(D=D+1|0))>=(0|d)){A=3;break}t=0|i[k>>2]}3!=(0|A)?8==(0|A)&&Q(22557,22521,746,22602):I=y}}function yA(A,e,r){A|=0,e|=0,r|=0;var t,n=0,o=0,a=0,f=0,s=0;t=I,I=I+160|0,o=t,f=20336,s=(a=n=t+80|0)+72|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));f=20416,s=(a=o)+72|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));n=(s=0==(0|RA(0|i[e>>2])))?n:o,uA(o=A+4|0),lA(o),0|RA(0|i[e>>2])&&(iA(o),i[e>>2]=1+(0|i[e>>2])),i[r>>2]=i[A>>2],X(o,n,e=r+4|0),J(e),i[r+16>>2]=i[A>>2],X(o,n+12|0,e=r+20|0),J(e),i[r+32>>2]=i[A>>2],X(o,n+24|0,e=r+36|0),J(e),i[r+48>>2]=i[A>>2],X(o,n+36|0,e=r+52|0),J(e),i[r+64>>2]=i[A>>2],X(o,n+48|0,e=r+68|0),J(e),i[r+80>>2]=i[A>>2],X(o,n+60|0,r=r+84|0),J(r),I=t}function EA(A){var e;return e=(A=+A)<0?A+6.283185307179586:A,+(A>=6.283185307179586?e+-6.283185307179586:e)}function xA(A,e){return e|=0,+f(+(+n[(A|=0)>>3]-+n[e>>3]))<17453292519943298e-27?0|(e=+f(+(+n[A+8>>3]-+n[e+8>>3]))<17453292519943298e-27):0|(e=0)}function DA(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))*6371.007180918475}function _A(A,e,r){A|=0,r|=0;var t,i,o,a,f=0,u=0,d=0,g=0,B=0,b=0;return b=+n[(e|=0)>>3],o=+n[A>>3],B=+h(.5*(b-o)),d=+n[e+8>>3],i=+n[A+8>>3],g=+h(.5*(d-i)),t=+l(+o),a=+l(+b),g=2*+p(+ +s(+(g=B*B+g*(a*t*g))),+ +s(+(1-g))),B=+n[r>>3],b=+h(.5*(B-b)),f=+n[r+8>>3],d=+h(.5*(f-d)),u=+l(+B),d=2*+p(+ +s(+(d=b*b+d*(a*u*d))),+ +s(+(1-d))),B=+h(.5*(o-B)),f=+h(.5*(i-f)),f=2*+p(+ +s(+(f=B*B+f*(t*u*f))),+ +s(+(1-f))),4*+w(+ +s(+ +c(.5*(u=.5*(g+d+f)))*+c(.5*(u-g))*+c(.5*(u-d))*+c(.5*(u-f))))}function IA(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),45),M(),127&e|0}function FA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0;if(!(!0&134217728==(-16777216&(e|=0)|0)))return 0|(e=0);if(o=0|Qe(0|(A|=0),0|e,45),M(),(o&=127)>>>0>121)return 0|(e=0);r=0|Qe(0|A,0|e,52),M(),r&=15;do{if(0|r){for(i=1,t=0;;){if(n=0|Qe(0|A,0|e,3*(15-i|0)|0),M(),0!=(0|(n&=7))&(1^t)){if(1==(0|n)&0!=(0|S(o))){a=0,t=13;break}t=1}if(7==(0|n)){a=0,t=13;break}if(!(i>>>0>>0)){t=9;break}i=i+1|0}if(9==(0|t)){if(15!=(0|r))break;return 0|(a=1)}if(13==(0|t))return 0|a}}while(0);for(;;){if(a=0|Qe(0|A,0|e,3*(14-r|0)|0),M(),!(7==(7&a|0)&!0)){a=0,t=13;break}if(!(r>>>0<14)){a=1,t=13;break}r=r+1|0}return 13==(0|t)?0|a:0}function CA(A,e,r){r|=0;var t=0,i=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|(t&=15))>=(0|r)){if((0|t)!=(0|r))if(r>>>0<=15){if(A|=i=0|ye(0|r,0,52),e=0|M()|-15728641&e,(0|t)>(0|r))do{i=0|ye(7,0,3*(14-r|0)|0),r=r+1|0,A|=i,e=0|M()|e}while((0|r)<(0|t))}else e=0,A=0}else e=0,A=0;return k(0|e),0|A}function PA(A,e,r,t){r|=0,t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(f&=15))<=(0|r)){if((0|f)==(0|r))return i[(r=t)>>2]=A,void(i[r+4>>2]=e);if(n=(0|(u=0|ee(7,r-f|0)))/7|0,s=0|Qe(0|A,0|e,45),M(),0|S(127&s)){A:do{if(f)for(a=1;;){if(o=0|Qe(0|A,0|e,3*(15-a|0)|0),M(),0|(o&=7))break A;if(!(a>>>0>>0)){o=0;break}a=a+1|0}else o=0}while(0);a=0==(0|o)}else a=0;if(l=0|ye(f+1|0,0,52),o=0|M()|-15728641&e,PA(e=(l|A)&~(e=0|ye(7,0,0|(s=3*(14-f|0)|0))),f=o&~(0|M()),r,t),o=t+(n<<3)|0,!a)return PA((l=0|ye(1,0,0|s))|e,0|M()|f,r,o),l=o+(n<<3)|0,PA((u=0|ye(2,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(3,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(4,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(5,0,0|s))|e,0|M()|f,r,l),void PA((u=0|ye(6,0,0|s))|e,0|M()|f,r,l+(n<<3)|0);a=o+(n<<3)|0,(0|u)>6&&(_e(0|o,0,(l=(a>>>0>(u=o+8|0)>>>0?a:u)+-1+(0-o)|0)+8&-8|0),o=u+(l>>>3<<3)|0),PA((l=0|ye(2,0,0|s))|e,0|M()|f,r,o),l=o+(n<<3)|0,PA((u=0|ye(3,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(4,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(5,0,0|s))|e,0|M()|f,r,l),PA((u=0|ye(6,0,0|s))|e,0|M()|f,r,l+(n<<3)|0)}}function UA(A,e){var r=0,t=0,i=0;if(i=0|Qe(0|(A|=0),0|(e|=0),45),M(),!(0|S(127&i)))return 0|(i=0);i=0|Qe(0|A,0|e,52),M(),i&=15;A:do{if(i)for(t=1;;){if(r=0|Qe(0|A,0|e,3*(15-t|0)|0),M(),0|(r&=7))break A;if(!(t>>>0>>0)){r=0;break}t=t+1|0}else r=0}while(0);return 0|(i=0==(0|r)&1)}function GA(A,e){var r=0,t=0,i=0;if(i=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(i&=15))return 0|(i=0);for(t=1;;){if(r=0|Qe(0|A,0|e,3*(15-t|0)|0),M(),0|(r&=7)){t=5;break}if(!(t>>>0>>0)){r=0,t=5;break}t=t+1|0}return 5==(0|t)?0|r:0}function SA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0,f=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(f&=15))return f=A,k(0|(a=e)),0|f;for(a=1,r=0;;){t=0|ye(7,0,0|(n=3*(15-a|0)|0)),i=0|M(),o=0|Qe(0|A,0|e,0|n),M(),A=(n=0|ye(0|fA(7&o),0,0|n))|A&~t,e=(o=0|M())|e&~i;A:do{if(!r)if(0==(n&t|0)&0==(o&i|0))r=0;else if(t=0|Qe(0|A,0|e,52),M(),t&=15){r=1;e:for(;;){switch(o=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),7&o){case 1:break e;case 0:break;default:r=1;break A}if(!(r>>>0>>0)){r=1;break A}r=r+1|0}for(r=1;;){if(i=0|Qe(0|A,0|e,0|(o=3*(15-r|0)|0)),M(),n=0|ye(7,0,0|o),e&=~(0|M()),A=A&~n|(o=0|ye(0|fA(7&i),0,0|o)),e=0|e|M(),!(r>>>0>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return k(0|e),0|A}function TA(A,e){var r=0,t=0,i=0,n=0,o=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(t&=15))return t=A,k(0|(r=e)),0|t;for(r=1;o=0|Qe(0|A,0|e,0|(n=3*(15-r|0)|0)),M(),i=0|ye(7,0,0|n),e&=~(0|M()),A=(n=0|ye(0|fA(7&o),0,0|n))|A&~i,e=0|M()|e,r>>>0>>0;)r=r+1|0;return k(0|e),0|A}function VA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0,f=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(f&=15))return f=A,k(0|(a=e)),0|f;for(a=1,r=0;;){t=0|ye(7,0,0|(n=3*(15-a|0)|0)),i=0|M(),o=0|Qe(0|A,0|e,0|n),M(),A=(n=0|ye(0|sA(7&o),0,0|n))|A&~t,e=(o=0|M())|e&~i;A:do{if(!r)if(0==(n&t|0)&0==(o&i|0))r=0;else if(t=0|Qe(0|A,0|e,52),M(),t&=15){r=1;e:for(;;){switch(o=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),7&o){case 1:break e;case 0:break;default:r=1;break A}if(!(r>>>0>>0)){r=1;break A}r=r+1|0}for(r=1;;){if(n=0|ye(7,0,0|(i=3*(15-r|0)|0)),o=e&~(0|M()),e=0|Qe(0|A,0|e,0|i),M(),A=A&~n|(e=0|ye(0|sA(7&e),0,0|i)),e=0|o|M(),!(r>>>0>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return k(0|e),0|A}function HA(A,e){var r=0,t=0,i=0,n=0,o=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(t&=15))return t=A,k(0|(r=e)),0|t;for(r=1;n=0|ye(7,0,0|(o=3*(15-r|0)|0)),i=e&~(0|M()),e=0|Qe(0|A,0|e,0|o),M(),A=(e=0|ye(0|sA(7&e),0,0|o))|A&~n,e=0|M()|i,r>>>0>>0;)r=r+1|0;return k(0|e),0|A}function RA(A){return 0|(0|(A|=0))%2}function LA(A,e){A|=0;var r,t;return t=I,I=I+16|0,r=t,(e|=0)>>>0<=15&&2146435072!=(2146435072&i[A+4>>2]|0)&&2146435072!=(2146435072&i[A+8+4>>2]|0)?(!function(A,e,r){var t,i;t=I,I=I+16|0,pA(A|=0,e|=0,r|=0,i=t),W(i,r+4|0),I=t}(A,e,r),e=0|function(A,e){A|=0;var r,t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0;if(r=I,I=I+64|0,s=r+40|0,n=r+24|0,o=r+12|0,a=r,ye(0|(e|=0),0,52),t=134225919|M(),!e)return(0|i[A+4>>2])>2||(0|i[A+8>>2])>2||(0|i[A+12>>2])>2?(s=0,k(0|(f=0)),I=r,0|s):(ye(0|V(A),0,45),f=0|M()|t,s=-1,k(0|f),I=r,0|s);if(i[s>>2]=i[A>>2],i[s+4>>2]=i[A+4>>2],i[s+8>>2]=i[A+8>>2],i[s+12>>2]=i[A+12>>2],f=s+4|0,(0|e)>0)for(A=-1;i[n>>2]=i[f>>2],i[n+4>>2]=i[f+4>>2],i[n+8>>2]=i[f+8>>2],1&e?(eA(f),i[o>>2]=i[f>>2],i[o+4>>2]=i[f+4>>2],i[o+8>>2]=i[f+8>>2],tA(o)):(rA(f),i[o>>2]=i[f>>2],i[o+4>>2]=i[f+4>>2],i[o+8>>2]=i[f+8>>2],iA(o)),q(n,o,a),J(a),u=0|ye(7,0,0|(l=3*(15-e|0)|0)),t&=~(0|M()),A=(l=0|ye(0|AA(a),0,0|l))|A&~u,t=0|M()|t,(0|e)>1;)e=e+-1|0;else A=-1;A:do{if((0|i[f>>2])<=2&&(0|i[s+8>>2])<=2&&(0|i[s+12>>2])<=2){if(e=0|ye(0|(n=0|V(s)),0,45),e|=A,A=0|M()|-1040385&t,a=0|H(s),!(0|S(n))){if((0|a)<=0)break;for(o=0;;){if(n=0|Qe(0|e,0|A,52),M(),n&=15)for(t=1;s=0|Qe(0|e,0|A,0|(l=3*(15-t|0)|0)),M(),u=0|ye(7,0,0|l),A&=~(0|M()),e=e&~u|(l=0|ye(0|fA(7&s),0,0|l)),A=0|A|M(),t>>>0>>0;)t=t+1|0;if((0|(o=o+1|0))==(0|a))break A}}o=0|Qe(0|e,0|A,52),M(),o&=15;e:do{if(o){t=1;r:for(;;){switch(l=0|Qe(0|e,0|A,3*(15-t|0)|0),M(),7&l){case 1:break r;case 0:break;default:break e}if(!(t>>>0>>0))break e;t=t+1|0}if(0|R(n,0|i[s>>2]))for(t=1;u=0|ye(7,0,0|(s=3*(15-t|0)|0)),l=A&~(0|M()),A=0|Qe(0|e,0|A,0|s),M(),e=e&~u|(A=0|ye(0|sA(7&A),0,0|s)),A=0|l|M(),t>>>0>>0;)t=t+1|0;else for(t=1;s=0|Qe(0|e,0|A,0|(l=3*(15-t|0)|0)),M(),u=0|ye(7,0,0|l),A&=~(0|M()),e=e&~u|(l=0|ye(0|fA(7&s),0,0|l)),A=0|A|M(),t>>>0>>0;)t=t+1|0}}while(0);if((0|a)>0){t=0;do{e=0|SA(e,A),A=0|M(),t=t+1|0}while((0|t)!=(0|a))}}else e=0,A=0}while(0);return l=e,k(0|(u=A)),I=r,0|l}(r,e),A=0|M()):(A=0,e=0),k(0|A),I=t,0|e}function zA(A,e,r){var t,n=0,o=0,a=0;if(t=(r|=0)+4|0,o=0|Qe(0|(A|=0),0|(e|=0),52),M(),o&=15,a=0|Qe(0|A,0|e,45),M(),n=0==(0|o),0|S(127&a)){if(n)return 0|(a=1);n=1}else{if(n)return 0|(a=0);n=0==(0|i[t>>2])&&0==(0|i[r+8>>2])?0!=(0|i[r+12>>2])&1:1}for(r=1;1&r?tA(t):iA(t),a=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),nA(t,7&a),r>>>0>>0;)r=r+1|0;return 0|n}function YA(A,e,r){r|=0;var t,n,o=0,a=0,f=0,s=0,u=0,l=0;n=I,I=I+16|0,t=n,l=0|Qe(0|(A|=0),0|(e|=0),45),M(),l&=127;A:do{if(0!=(0|S(l))&&(f=0|Qe(0|A,0|e,52),M(),0!=(0|(f&=15)))){o=1;e:for(;;){switch(u=0|Qe(0|A,0|e,3*(15-o|0)|0),M(),7&u){case 5:break e;case 0:break;default:o=e;break A}if(!(o>>>0>>0)){o=e;break A}o=o+1|0}for(a=1,o=e;s=0|ye(7,0,0|(e=3*(15-a|0)|0)),u=o&~(0|M()),o=0|Qe(0|A,0|o,0|e),M(),A=A&~s|(o=0|ye(0|sA(7&o),0,0|e)),o=0|u|M(),a>>>0>>0;)a=a+1|0}else o=e}while(0);if(u=7728+(28*l|0)|0,i[r>>2]=i[u>>2],i[r+4>>2]=i[u+4>>2],i[r+8>>2]=i[u+8>>2],i[r+12>>2]=i[u+12>>2],0|zA(A,o,r)){if(s=r+4|0,i[t>>2]=i[s>>2],i[t+4>>2]=i[s+4>>2],i[t+8>>2]=i[s+8>>2],f=0|Qe(0|A,0|o,52),M(),u=15&f,1&f?(iA(s),f=u+1|0):f=u,0|S(l)){A:do{if(u)for(e=1;;){if(a=0|Qe(0|A,0|o,3*(15-e|0)|0),M(),0|(a&=7)){o=a;break A}if(!(e>>>0>>0)){o=0;break}e=e+1|0}else o=0}while(0);o=4==(0|o)&1}else o=0;if(0|kA(r,f,o,0)){if(0|S(l))do{}while(0!=(0|kA(r,f,0,0)));(0|f)!=(0|u)&&rA(s)}else(0|f)!=(0|u)&&(i[s>>2]=i[t>>2],i[s+4>>2]=i[t+4>>2],i[s+8>>2]=i[t+8>>2]);I=n}else I=n}function OA(A,e,r){r|=0;var t,i;t=I,I=I+16|0,YA(A|=0,e|=0,i=t),e=0|Qe(0|A,0|e,52),M(),bA(i,15&e,r),I=t}function jA(A,e,r){r|=0;var t,i,n=0,o=0;i=I,I=I+16|0,YA(A|=0,e|=0,t=i),n=0|Qe(0|A,0|e,45),M(),n=0==(0|S(127&n)),o=0|Qe(0|A,0|e,52),M(),o&=15;A:do{if(!n){if(0|o)for(n=1;;){if(!(0==((0|ye(7,0,3*(15-n|0)|0))&A|0)&0==((0|M())&e|0)))break A;if(!(n>>>0>>0))break;n=n+1|0}return vA(t,o,0,5,r),void(I=i)}}while(0);QA(t,o,0,6,r),I=i}function NA(A,e){e|=0;var r,t=0,n=0,o=0,a=0,f=0,s=0;if(ye(0|(A|=0),0,52),r=134225919|M(),(0|A)<1){n=0,t=0;do{0|S(n)&&(ye(0|n,0,45),f=0|r|M(),i[(A=e+(t<<3)|0)>>2]=-1,i[A+4>>2]=f,t=t+1|0),n=n+1|0}while(122!=(0|n))}else{f=0,t=0;do{if(0|S(f)){for(ye(0|f,0,45),n=1,o=-1,a=0|r|M();o&=~(s=0|ye(7,0,3*(15-n|0)|0)),a&=~(0|M()),(0|n)!=(0|A);)n=n+1|0;i[(s=e+(t<<3)|0)>>2]=o,i[s+4>>2]=a,t=t+1|0}f=f+1|0}while(122!=(0|f))}}function ZA(A,e,r,t){var n,o=0,a=0,f=0,s=0,u=0;if(n=I,I=I+64|0,f=n,(0|(A|=0))==(0|(r|=0))&(0|(e|=0))==(0|(t|=0))|!1|134217728!=(2013265920&e|0)|!1|134217728!=(2013265920&t|0))return I=n,0|(f=0);if(o=0|Qe(0|A,0|e,52),M(),o&=15,a=0|Qe(0|r,0|t,52),M(),(0|o)!=(15&a|0))return I=n,0|(f=0);if(a=o+-1|0,o>>>0>1&&(u=0|CA(A,e,a),s=0|M(),(0|u)==(0|(a=0|CA(r,t,a)))&(0|s)==(0|M()))){if(o=0|Qe(0|A,0|e,0|(a=3*(15^o)|0)),M(),o&=7,a=0|Qe(0|r,0|t,0|a),M(),0==(0|o)|0==(0|(a&=7)))return I=n,0|(u=1);if((0|i[21136+(o<<2)>>2])==(0|a))return I=n,0|(u=1);if((0|i[21168+(o<<2)>>2])==(0|a))return I=n,0|(u=1)}a=(o=f)+56|0;do{i[o>>2]=0,o=o+4|0}while((0|o)<(0|a));return F(A,e,1,f),o=(0|i[(u=f)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+8|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+16|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+24|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+32|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+40|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)?1:1&((0|i[(o=f+48|0)>>2])==(0|r)?(0|i[o+4>>2])==(0|t):0),I=n,0|(u=o)}function WA(A,e,r){r|=0;var t,n,o,a,f=0;if(o=I,I=I+16|0,n=o,f=0|Qe(0|(A|=0),0|(e|=0),56),M(),-1==(0|(e=0|function(A,e,r){r|=0;var t=0,n=0;if(t=0|UA(A=A|0,e=e|0),(r+-1|0)>>>0>5)return 0|(r=-1);if(1==(0|r)&(n=0!=(0|t)))return 0|(r=-1);return t=0|function(A,e){var r=0,t=0,n=0,o=0,a=0,f=0,s=0,u=0;if(u=I,I=I+32|0,o=u,YA(A=A|0,e=e|0,n=u+16|0),a=0|IA(A,e),s=0|GA(A,e),function(A,e){A=7728+(28*(A|=0)|0)|0,i[(e|=0)>>2]=i[A>>2],i[e+4>>2]=i[A+4>>2],i[e+8>>2]=i[A+8>>2],i[e+12>>2]=i[A+12>>2]}(a,o),e=0|function(A,e){A|=0;var r=0,t=0;if((e|=0)>>>0>20)return-1;do{if((0|i[11152+(216*e|0)>>2])!=(0|A))if((0|i[11152+(216*e|0)+8>>2])!=(0|A))if((0|i[11152+(216*e|0)+16>>2])!=(0|A))if((0|i[11152+(216*e|0)+24>>2])!=(0|A))if((0|i[11152+(216*e|0)+32>>2])!=(0|A))if((0|i[11152+(216*e|0)+40>>2])!=(0|A))if((0|i[11152+(216*e|0)+48>>2])!=(0|A))if((0|i[11152+(216*e|0)+56>>2])!=(0|A))if((0|i[11152+(216*e|0)+64>>2])!=(0|A))if((0|i[11152+(216*e|0)+72>>2])!=(0|A))if((0|i[11152+(216*e|0)+80>>2])!=(0|A))if((0|i[11152+(216*e|0)+88>>2])!=(0|A))if((0|i[11152+(216*e|0)+96>>2])!=(0|A))if((0|i[11152+(216*e|0)+104>>2])!=(0|A))if((0|i[11152+(216*e|0)+112>>2])!=(0|A))if((0|i[11152+(216*e|0)+120>>2])!=(0|A))if((0|i[11152+(216*e|0)+128>>2])!=(0|A)){if((0|i[11152+(216*e|0)+136>>2])!=(0|A)){if((0|i[11152+(216*e|0)+144>>2])==(0|A)){A=0,r=2,t=0;break}if((0|i[11152+(216*e|0)+152>>2])==(0|A)){A=0,r=2,t=1;break}if((0|i[11152+(216*e|0)+160>>2])==(0|A)){A=0,r=2,t=2;break}if((0|i[11152+(216*e|0)+168>>2])==(0|A)){A=1,r=2,t=0;break}if((0|i[11152+(216*e|0)+176>>2])==(0|A)){A=1,r=2,t=1;break}if((0|i[11152+(216*e|0)+184>>2])==(0|A)){A=1,r=2,t=2;break}if((0|i[11152+(216*e|0)+192>>2])==(0|A)){A=2,r=2,t=0;break}if((0|i[11152+(216*e|0)+200>>2])==(0|A)){A=2,r=2,t=1;break}if((0|i[11152+(216*e|0)+208>>2])==(0|A)){A=2,r=2,t=2;break}return-1}A=2,r=1,t=2}else A=2,r=1,t=1;else A=2,r=1,t=0;else A=1,r=1,t=2;else A=1,r=1,t=1;else A=1,r=1,t=0;else A=0,r=1,t=2;else A=0,r=1,t=1;else A=0,r=1,t=0;else A=2,r=0,t=2;else A=2,r=0,t=1;else A=2,r=0,t=0;else A=1,r=0,t=2;else A=1,r=0,t=1;else A=1,r=0,t=0;else A=0,r=0,t=2;else A=0,r=0,t=1;else A=0,r=0,t=0}while(0);return 0|i[11152+(216*e|0)+(72*r|0)+(24*A|0)+(t<<3)+4>>2]}(a,0|i[n>>2]),!(0|S(a)))return I=u,0|(s=e);switch(0|a){case 4:A=0,r=14;break;case 14:A=1,r=14;break;case 24:A=2,r=14;break;case 38:A=3,r=14;break;case 49:A=4,r=14;break;case 58:A=5,r=14;break;case 63:A=6,r=14;break;case 72:A=7,r=14;break;case 83:A=8,r=14;break;case 97:A=9,r=14;break;case 107:A=10,r=14;break;case 117:A=11,r=14;break;default:f=0,t=0}14==(0|r)&&(f=0|i[22096+(24*A|0)+8>>2],t=0|i[22096+(24*A|0)+16>>2]);(0|(A=0|i[n>>2]))!=(0|i[o>>2])&&(a=0|T(a))|(0|(A=0|i[n>>2]))==(0|t)&&(e=(e+1|0)%6|0);if(3==(0|s)&(0|A)==(0|t))return I=u,0|(s=(e+5|0)%6|0);if(!(5==(0|s)&(0|A)==(0|f)))return I=u,0|(s=e);return I=u,0|(s=(e+1|0)%6|0)}(A,e),n?0|(r=(5-t+(0|i[22384+(r<<2)>>2])|0)%5|0):0|(r=(6-t+(0|i[22416+(r<<2)>>2])|0)%6|0)}(t=(a=!0&268435456==(2013265920&e|0))?A:0,A=a?-2130706433&e|134217728:0,7&f))))return i[r>>2]=0,void(I=o);YA(t,A,n),f=0|Qe(0|t,0|A,52),M(),f&=15,0|UA(t,A)?vA(n,f,e,2,r):QA(n,f,e,2,r),I=o}function JA(A){A|=0;var e,r,t=0;return(e=0|be(1,12))||Q(22691,22646,49,22704),0|(t=0|i[(r=A+4|0)>>2])?(i[(t=t+8|0)>>2]=e,i[r>>2]=e,0|e):(0|i[A>>2]&&Q(22721,22646,61,22744),i[(t=A)>>2]=e,i[r>>2]=e,0|e)}function KA(A,e){A|=0,e|=0;var r,t;return(t=0|pe(24))||Q(22758,22646,78,22772),i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2],i[t+16>>2]=0,0|(r=0|i[(e=A+4|0)>>2])?(i[r+16>>2]=t,i[e>>2]=t,0|t):(0|i[A>>2]&&Q(22787,22646,82,22772),i[A>>2]=t,i[e>>2]=t,0|t)}function XA(A){var e,r,t=0,o=0,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,y=0,E=0,x=0,D=0,_=0,I=0,F=0,C=0,P=0,U=0,G=0,S=0;if(0|i[(s=(A|=0)+8|0)>>2])return 0|(S=1);if(!(a=0|i[A>>2]))return 0|(S=0);t=a,o=0;do{o=o+1|0,t=0|i[t+8>>2]}while(0!=(0|t));if(o>>>0<2)return 0|(S=0);(r=0|pe(o<<2))||Q(22807,22646,317,22826),(e=0|pe(o<<5))||Q(22848,22646,321,22826),i[A>>2]=0,i[(D=A+4|0)>>2]=0,i[s>>2]=0,o=0,U=0,x=0,w=0;A:for(;;){if(g=0|i[a>>2]){u=0,l=g;do{if(c=+n[l+8>>3],t=l,l=0|i[l+16>>2],h=+n[(s=(d=0==(0|l))?g:l)+8>>3],+f(+(c-h))>3.141592653589793){S=14;break}u+=(h-c)*(+n[t>>3]+ +n[s>>3])}while(!d);if(14==(0|S)){S=0,u=0,t=g;do{E=+n[t+8>>3],C=0|i[(P=t+16|0)>>2],y=+n[(C=0==(0|C)?g:C)+8>>3],u+=(+n[t>>3]+ +n[C>>3])*((y<0?y+6.283185307179586:y)-(E<0?E+6.283185307179586:E)),t=0|i[(0==(0|t)?a:P)>>2]}while(0!=(0|t))}u>0?(i[r+(U<<2)>>2]=a,U=U+1|0,s=x,t=w):S=19}else S=19;if(19==(0|S)){S=0;do{if(!o){if(w){s=D,l=w+8|0,t=a,o=A;break}if(0|i[A>>2]){S=27;break A}s=D,l=A,t=a,o=A;break}if(0|i[(t=o+8|0)>>2]){S=21;break A}if(!(o=0|be(1,12))){S=23;break A}i[t>>2]=o,s=o+4|0,l=o,t=w}while(0);if(i[l>>2]=a,i[s>>2]=a,l=e+(x<<5)|0,d=0|i[a>>2]){for(n[(g=e+(x<<5)+8|0)>>3]=17976931348623157e292,n[(w=e+(x<<5)+24|0)>>3]=17976931348623157e292,n[l>>3]=-17976931348623157e292,n[(p=e+(x<<5)+16|0)>>3]=-17976931348623157e292,k=17976931348623157e292,M=-17976931348623157e292,s=0,B=d,c=17976931348623157e292,v=17976931348623157e292,m=-17976931348623157e292,h=-17976931348623157e292;u=+n[B>>3],E=+n[B+8>>3],B=0|i[B+16>>2],y=+n[((b=0==(0|B))?d:B)+8>>3],u>3]=u,c=u),E>3]=E,v=E),u>m?n[l>>3]=u:u=m,E>h&&(n[p>>3]=E,h=E),k=E>0&EM?E:M,s|=+f(+(E-y))>3.141592653589793,!b;)m=u;s&&(n[p>>3]=M,n[w>>3]=k)}else i[l>>2]=0,i[l+4>>2]=0,i[l+8>>2]=0,i[l+12>>2]=0,i[l+16>>2]=0,i[l+20>>2]=0,i[l+24>>2]=0,i[l+28>>2]=0;s=x+1|0}if(a=0|i[(P=a+8|0)>>2],i[P>>2]=0,!a){S=45;break}x=s,w=t}if(21==(0|S))Q(22624,22646,35,22658);else if(23==(0|S))Q(22678,22646,37,22658);else if(27==(0|S))Q(22721,22646,61,22744);else if(45==(0|S)){A:do{if((0|U)>0){for(P=0==(0|s),F=s<<2,C=0==(0|A),I=0,t=0;;){if(_=0|i[r+(I<<2)>>2],P)S=73;else{if(!(x=0|pe(F))){S=50;break}if(!(D=0|pe(F))){S=52;break}e:do{if(C)o=0;else{for(s=0,o=0,l=A;a=e+(s<<5)|0,0|qA(0|i[l>>2],a,0|i[_>>2])?(i[x+(o<<2)>>2]=l,i[D+(o<<2)>>2]=a,b=o+1|0):b=o,l=0|i[l+8>>2];)s=s+1|0,o=b;if((0|b)>0)if(a=0|i[x>>2],1==(0|b))o=a;else for(p=0,B=-1,o=a,w=a;;){for(d=0|i[w>>2],a=0,l=0;g=(0|(s=0|i[i[x+(l<<2)>>2]>>2]))==(0|d)?a:a+(1&(0|qA(s,0|i[D+(l<<2)>>2],0|i[d>>2])))|0,(0|(l=l+1|0))!=(0|b);)a=g;if(o=(s=(0|g)>(0|B))?w:o,(0|(a=p+1|0))==(0|b))break e;p=a,B=s?g:B,w=0|i[x+(a<<2)>>2]}else o=0}}while(0);if(Be(x),Be(D),o){if(a=0|i[(s=o+4|0)>>2])o=a+8|0;else if(0|i[o>>2]){S=70;break}i[o>>2]=_,i[s>>2]=_}else S=73}if(73==(0|S)){if(S=0,0|(t=0|i[_>>2]))do{D=t,t=0|i[t+16>>2],Be(D)}while(0!=(0|t));Be(_),t=2}if((0|(I=I+1|0))>=(0|U)){G=t;break A}}50==(0|S)?Q(22863,22646,249,22882):52==(0|S)?Q(22901,22646,252,22882):70==(0|S)&&Q(22721,22646,61,22744)}else G=0}while(0);return Be(r),Be(e),0|(S=G)}return 0}function qA(A,e,r){A|=0;var t,o=0,a=0,f=0,s=0,u=0,l=0,h=0;if(!(0|O(e|=0,r|=0)))return 0|(A=0);if(e=0|Y(e),t=+n[r>>3],o=e&(o=+n[r+8>>3])<0?o+6.283185307179586:o,!(A=0|i[A>>2]))return 0|(A=0);if(e){e=0,r=A;A:for(;;){for(;s=+n[r>>3],l=+n[r+8>>3],h=0|i[(r=r+16|0)>>2],f=+n[(h=0==(0|h)?A:h)>>3],a=+n[h+8>>3],s>f?(u=s,s=l):(u=f,f=s,s=a,a=l),tu;)if(!(r=0|i[r>>2])){r=22;break A}if(o=(s=s<0?s+6.283185307179586:s)==o|(l=a<0?a+6.283185307179586:a)==o?o+-2220446049250313e-31:o,((l+=(t-f)/(u-f)*(s-l))<0?l+6.283185307179586:l)>o&&(e^=1),!(r=0|i[r>>2])){r=22;break}}if(22==(0|r))return 0|e}else{e=0,r=A;A:for(;;){for(;s=+n[r>>3],l=+n[r+8>>3],h=0|i[(r=r+16|0)>>2],f=+n[(h=0==(0|h)?A:h)>>3],a=+n[h+8>>3],s>f?(u=s,s=l):(u=f,f=s,s=a,a=l),tu;)if(!(r=0|i[r>>2])){r=22;break A}if(a+(t-f)/(u-f)*(s-a)>(o=s==o|a==o?o+-2220446049250313e-31:o)&&(e^=1),!(r=0|i[r>>2])){r=22;break}}if(22==(0|r))return 0|e}return 0}function $A(A,e,r,n,o){r|=0,n|=0,o|=0;var a,f,s,u,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0;if(u=I,I=I+32|0,v=u+16|0,s=u,l=0|Qe(0|(A|=0),0|(e|=0),52),M(),l&=15,p=0|Qe(0|r,0|n,52),M(),(0|l)!=(15&p|0))return I=u,0|(v=1);if(g=0|Qe(0|A,0|e,45),M(),g&=127,w=0|Qe(0|r,0|n,45),M(),p=(0|g)!=(0|(w&=127))){if(7==(0|(c=0|z(g,w))))return I=u,0|(v=2);7==(0|(d=0|z(w,g)))?Q(22925,22949,151,22959):(B=c,h=d)}else B=0,h=0;a=0|S(g),f=0|S(w),i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0;do{if(B){if(c=(0|(w=0|i[4304+(28*g|0)+(B<<2)>>2]))>0,f)if(c){g=0,d=r,c=n;do{d=0|VA(d,c),c=0|M(),1==(0|(h=0|sA(h)))&&(h=0|sA(1)),g=g+1|0}while((0|g)!=(0|w));w=h,g=d,d=c}else w=h,g=r,d=n;else if(c){g=0,d=r,c=n;do{d=0|HA(d,c),c=0|M(),h=0|sA(h),g=g+1|0}while((0|g)!=(0|w));w=h,g=d,d=c}else w=h,g=r,d=n;if(zA(g,d,v),p||Q(22972,22949,181,22959),(c=0!=(0|a))&(h=0!=(0|f))&&Q(22999,22949,182,22959),c){if(h=0|GA(A,e),0|t[22032+(7*h|0)+B>>0]){l=3;break}g=d=0|i[21200+(28*h|0)+(B<<2)>>2],b=26}else if(h){if(h=0|GA(g,d),0|t[22032+(7*h|0)+w>>0]){l=4;break}g=0,d=0|i[21200+(28*w|0)+(h<<2)>>2],b=26}else h=0;if(26==(0|b))if((0|d)<=-1&&Q(23030,22949,212,22959),(0|g)<=-1&&Q(23053,22949,213,22959),(0|d)>0){c=v+4|0,h=0;do{aA(c),h=h+1|0}while((0|h)!=(0|d));h=g}else h=g;if(i[s>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,nA(s,B),0|l)for(;0|RA(l)?tA(s):iA(s),(0|l)>1;)l=l+-1|0;if((0|h)>0){l=0;do{aA(s),l=l+1|0}while((0|l)!=(0|h))}X(b=v+4|0,s,b),J(b),b=50}else if(zA(r,n,v),0!=(0|a)&0!=(0|f))if((0|w)!=(0|g)&&Q(23077,22949,243,22959),h=0|GA(A,e),l=0|GA(r,n),0|t[22032+(7*h|0)+l>>0])l=5;else if((0|(h=0|i[21200+(28*h|0)+(l<<2)>>2]))>0){c=v+4|0,l=0;do{aA(c),l=l+1|0}while((0|l)!=(0|h));b=50}else b=50;else b=50}while(0);return 50==(0|b)&&(l=v+4|0,i[o>>2]=i[l>>2],i[o+4>>2]=i[l+4>>2],i[o+8>>2]=i[l+8>>2],l=0),I=u,0|(v=l)}function Ae(A,e,r,t){r|=0,t|=0;var n,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0;if(o=I,I=I+48|0,s=o+36|0,u=o+24|0,l=o+12|0,h=o,f=0|Qe(0|(A|=0),0|(e|=0),52),M(),f&=15,d=0|Qe(0|A,0|e,45),M(),n=0|S(d&=127),ye(0|f,0,52),p=134225919|M(),i[(w=t)>>2]=-1,i[w+4>>2]=p,!f)return(0|i[r>>2])>1||(0|i[r+4>>2])>1||(0|i[r+8>>2])>1||127==(0|(a=0|L(d,0|AA(r))))?(I=o,0|(p=1)):(g=0|ye(0|a,0,45),w=0|M(),w=-1040385&i[(d=t)+4>>2]|w,i[(p=t)>>2]=i[d>>2]|g,i[p+4>>2]=w,I=o,0|(p=0));for(i[s>>2]=i[r>>2],i[s+4>>2]=i[r+4>>2],i[s+8>>2]=i[r+8>>2];i[u>>2]=i[s>>2],i[u+4>>2]=i[s+4>>2],i[u+8>>2]=i[s+8>>2],0|RA(f)?(eA(s),i[l>>2]=i[s>>2],i[l+4>>2]=i[s+4>>2],i[l+8>>2]=i[s+8>>2],tA(l)):(rA(s),i[l>>2]=i[s>>2],i[l+4>>2]=i[s+4>>2],i[l+8>>2]=i[s+8>>2],iA(l)),q(u,l,h),J(h),B=0|i[(w=t)>>2],w=0|i[w+4>>2],r=0|ye(7,0,0|(b=3*(15-f|0)|0)),w&=~(0|M()),b=0|ye(0|AA(h),0,0|b),w=0|M()|w,i[(p=t)>>2]=b|B&~r,i[p+4>>2]=w,(0|f)>1;)f=f+-1|0;A:do{if((0|i[s>>2])<=1&&(0|i[s+4>>2])<=1&&(0|i[s+8>>2])<=1){h=127==(0|(u=0|L(d,f=0|AA(s))))?0:0|S(u);e:do{if(f){if(n){if(s=21408+(28*(0|GA(A,e))|0)+(f<<2)|0,(0|(s=0|i[s>>2]))>0){r=0;do{f=0|fA(f),r=r+1|0}while((0|r)!=(0|s))}if(1==(0|f)){a=3;break A}127==(0|(r=0|L(d,f)))&&Q(23104,22949,376,23134),0|S(r)?Q(23147,22949,377,23134):(g=s,c=f,a=r)}else g=0,c=f,a=u;if((0|(l=0|i[4304+(28*d|0)+(c<<2)>>2]))<=-1&&Q(23178,22949,384,23134),!h){if((0|g)<=-1&&Q(23030,22949,417,23134),0|g){f=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];do{r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,f=f+1|0}while((0|f)<(0|g))}if((0|l)<=0){f=54;break}for(f=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];;)if(r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,(0|(f=f+1|0))==(0|l)){f=54;break e}}if(7==(0|(u=0|z(a,d)))&&Q(22925,22949,393,23134),r=0|i[(f=t)>>2],f=0|i[f+4>>2],(0|l)>0){s=0;do{r=0|TA(r,f),f=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=f,s=s+1|0}while((0|s)!=(0|l))}if(r=0|GA(r,f),b=0|T(a),(0|(r=0|i[(b?21824:21616)+(28*u|0)+(r<<2)>>2]))<=-1&&Q(23030,22949,412,23134),r){f=0,s=0|i[(u=t)>>2],u=0|i[u+4>>2];do{s=0|SA(s,u),u=0|M(),i[(b=t)>>2]=s,i[b+4>>2]=u,f=f+1|0}while((0|f)<(0|r));f=54}else f=54}else if(0!=(0|n)&0!=(0|h))if(f=21408+(28*(b=0|GA(A,e))|0)+((0|GA(0|i[(f=t)>>2],0|i[f+4>>2]))<<2)|0,(0|(f=0|i[f>>2]))<=-1&&Q(23201,22949,433,23134),f){a=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];do{r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,a=a+1|0}while((0|a)<(0|f));a=u,f=54}else a=u,f=55;else a=u,f=54}while(0);if(54==(0|f)&&h&&(f=55),55==(0|f)&&1==(0|GA(0|i[(b=t)>>2],0|i[b+4>>2]))){a=4;break}p=0|i[(b=t)>>2],b=-1040385&i[b+4>>2],B=0|ye(0|a,0,45),b=0|b|M(),i[(a=t)>>2]=p|B,i[a+4>>2]=b,a=0}else a=2}while(0);return I=o,0|(b=a)}function ee(A,e){var r=0;if(!(e|=0))return 0|(r=1);r=A|=0,A=1;do{A=0|b(0==(1&e|0)?1:r,A),e>>=1,r=0|b(r,r)}while(0!=(0|e));return 0|A}function re(A,e,r){A|=0;var t,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0;if(!(0|O(e|=0,r|=0)))return 0|(d=0);if(e=0|Y(e),o=+n[r>>3],a=e&(a=+n[r+8>>3])<0?a+6.283185307179586:a,(0|(d=0|i[A>>2]))<=0)return 0|(d=0);if(t=0|i[A+4>>2],e){e=0,r=-1,A=0;A:for(;;){for(c=A;u=+n[t+(c<<4)>>3],h=+n[t+(c<<4)+8>>3],s=+n[t+((A=(r+2|0)%(0|d)|0)<<4)>>3],f=+n[t+(A<<4)+8>>3],u>s?(l=u,u=h):(l=s,s=u,u=f,f=h),ol;){if(!((0|(r=c+1|0))<(0|d))){r=22;break A}A=c,c=r,r=A}if(a=(u=u<0?u+6.283185307179586:u)==a|(h=f<0?f+6.283185307179586:f)==a?a+-2220446049250313e-31:a,((h+=(o-s)/(l-s)*(u-h))<0?h+6.283185307179586:h)>a&&(e^=1),(0|(A=c+1|0))>=(0|d)){r=22;break}r=c}if(22==(0|r))return 0|e}else{e=0,r=-1,A=0;A:for(;;){for(c=A;u=+n[t+(c<<4)>>3],h=+n[t+(c<<4)+8>>3],s=+n[t+((A=(r+2|0)%(0|d)|0)<<4)>>3],f=+n[t+(A<<4)+8>>3],u>s?(l=u,u=h):(l=s,s=u,u=f,f=h),ol;){if(!((0|(r=c+1|0))<(0|d))){r=22;break A}A=c,c=r,r=A}if(f+(o-s)/(l-s)*(u-f)>(a=u==a|f==a?a+-2220446049250313e-31:a)&&(e^=1),(0|(A=c+1|0))>=(0|d)){r=22;break}r=c}if(22==(0|r))return 0|e}return 0}function te(A,e){e|=0;var r,t,o,a,s,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0;if(!(t=0|i[(A|=0)>>2]))return i[e>>2]=0,i[e+4>>2]=0,i[e+8>>2]=0,i[e+12>>2]=0,i[e+16>>2]=0,i[e+20>>2]=0,i[e+24>>2]=0,void(i[e+28>>2]=0);if(n[(o=e+8|0)>>3]=17976931348623157e292,n[(a=e+24|0)>>3]=17976931348623157e292,n[e>>3]=-17976931348623157e292,n[(s=e+16|0)>>3]=-17976931348623157e292,!((0|t)<=0)){for(r=0|i[A+4>>2],p=17976931348623157e292,B=-17976931348623157e292,b=0,A=-1,c=17976931348623157e292,d=17976931348623157e292,w=-17976931348623157e292,l=-17976931348623157e292,v=0;u=+n[r+(v<<4)>>3],g=+n[r+(v<<4)+8>>3],h=+n[r+(((0|(A=A+2|0))==(0|t)?0:A)<<4)+8>>3],u>3]=u,c=u),g>3]=g,d=g),u>w?n[e>>3]=u:u=w,g>l&&(n[s>>3]=g,l=g),p=g>0&gB?g:B,b|=+f(+(g-h))>3.141592653589793,(0|(A=v+1|0))!=(0|t);)m=v,w=u,v=A,A=m;b&&(n[s>>3]=B,n[a>>3]=p)}}function ie(A,e){e|=0;var r,t=0,o=0,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,Q=0,y=0,E=0;if(B=0|i[(A|=0)>>2]){if(n[(b=e+8|0)>>3]=17976931348623157e292,n[(v=e+24|0)>>3]=17976931348623157e292,n[e>>3]=-17976931348623157e292,n[(m=e+16|0)>>3]=-17976931348623157e292,(0|B)>0){for(a=0|i[A+4>>2],w=17976931348623157e292,p=-17976931348623157e292,o=0,t=-1,h=17976931348623157e292,c=17976931348623157e292,g=-17976931348623157e292,u=-17976931348623157e292,k=0;s=+n[a+(k<<4)>>3],d=+n[a+(k<<4)+8>>3],l=+n[a+(((0|(y=t+2|0))==(0|B)?0:y)<<4)+8>>3],s>3]=s,h=s),d>3]=d,c=d),s>g?n[e>>3]=s:s=g,d>u&&(n[m>>3]=d,u=d),w=d>0&dp?d:p,o|=+f(+(d-l))>3.141592653589793,(0|(t=k+1|0))!=(0|B);)y=k,g=s,k=t,t=y;o&&(n[m>>3]=p,n[v>>3]=w)}}else i[e>>2]=0,i[e+4>>2]=0,i[e+8>>2]=0,i[e+12>>2]=0,i[e+16>>2]=0,i[e+20>>2]=0,i[e+24>>2]=0,i[e+28>>2]=0;if(!((0|(t=0|i[(y=A+8|0)>>2]))<=0)){r=A+12|0,Q=0;do{if(a=0|i[r>>2],o=Q,v=e+((Q=Q+1|0)<<5)|0,m=0|i[a+(o<<3)>>2]){if(n[(k=e+(Q<<5)+8|0)>>3]=17976931348623157e292,n[(A=e+(Q<<5)+24|0)>>3]=17976931348623157e292,n[v>>3]=-17976931348623157e292,n[(M=e+(Q<<5)+16|0)>>3]=-17976931348623157e292,(0|m)>0){for(B=0|i[a+(o<<3)+4>>2],w=17976931348623157e292,p=-17976931348623157e292,a=0,o=-1,b=0,h=17976931348623157e292,c=17976931348623157e292,d=-17976931348623157e292,u=-17976931348623157e292;s=+n[B+(b<<4)>>3],g=+n[B+(b<<4)+8>>3],l=+n[B+(((0|(o=o+2|0))==(0|m)?0:o)<<4)+8>>3],s>3]=s,h=s),g>3]=g,c=g),s>d?n[v>>3]=s:s=d,g>u&&(n[M>>3]=g,u=g),w=g>0&gp?g:p,a|=+f(+(g-l))>3.141592653589793,(0|(o=b+1|0))!=(0|m);)E=b,b=o,d=s,o=E;a&&(n[M>>3]=p,n[A>>3]=w)}}else i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0,i[v+16>>2]=0,i[v+20>>2]=0,i[v+24>>2]=0,i[v+28>>2]=0,t=0|i[y>>2]}while((0|Q)<(0|t))}}function ne(A,e,r){var t=0,n=0,o=0;if(!(0|re(A|=0,e|=0,r|=0)))return 0|(n=0);if((0|i[(n=A+8|0)>>2])<=0)return 0|(n=1);for(t=A+12|0,A=0;;){if(o=A,A=A+1|0,0|re((0|i[t>>2])+(o<<3)|0,e+(A<<5)|0,r)){A=0,t=6;break}if((0|A)>=(0|i[n>>2])){A=1,t=6;break}}return 6==(0|t)?0|A:0}function oe(A,e,r,t,i){e|=0,r|=0,t|=0,i|=0;var o,a,f,s,u,l,h,c=0;s=+n[(A|=0)>>3],f=+n[e>>3]-s,a=+n[A+8>>3],o=+n[e+8>>3]-a,l=+n[r>>3],c=((c=+n[t>>3]-l)*(a-(h=+n[r+8>>3]))-(s-l)*(u=+n[t+8>>3]-h))/(f*u-o*c),n[i>>3]=s+f*c,n[i+8>>3]=a+o*c}function ae(A,e){return e|=0,+n[(A|=0)>>3]!=+n[e>>3]?0|(e=0):0|(e=+n[A+8>>3]==+n[e+8>>3])}function fe(A,e){e|=0;var r,t,i;return+((i=+n[(A|=0)>>3]-+n[e>>3])*i+(t=+n[A+8>>3]-+n[e+8>>3])*t+(r=+n[A+16>>3]-+n[e+16>>3])*r)}function se(A,e,r){A|=0,r|=0;var t=0;(0|(e|=0))>0?(t=0|be(e,4),i[A>>2]=t,t||Q(23230,23253,40,23267)):i[A>>2]=0,i[A+4>>2]=e,i[A+8>>2]=0,i[A+12>>2]=r}function ue(A){var e,r,t,o=0,a=0,s=0,l=0;e=(A|=0)+4|0,r=A+12|0,t=A+8|0;A:for(;;){for(a=0|i[e>>2],o=0;;){if((0|o)>=(0|a))break A;if(s=0|i[A>>2],l=0|i[s+(o<<2)>>2])break;o=o+1|0}o=s+(~~(+f(+ +u(10,+ +(15-(0|i[r>>2])|0))*(+n[l>>3]+ +n[l+8>>3]))%+(0|a))>>>0<<2)|0,a=0|i[o>>2];e:do{if(0|a){if(s=l+32|0,(0|a)==(0|l))i[o>>2]=i[s>>2];else{if(!(o=0|i[(a=a+32|0)>>2]))break;for(;(0|o)!=(0|l);)if(!(o=0|i[(a=o+32|0)>>2]))break e;i[a>>2]=i[s>>2]}Be(l),i[t>>2]=(0|i[t>>2])-1}}while(0)}Be(0|i[A>>2])}function le(A){var e,r=0,t=0;for(e=0|i[(A|=0)+4>>2],t=0;;){if((0|t)>=(0|e)){r=0,t=4;break}if(r=0|i[(0|i[A>>2])+(t<<2)>>2]){t=4;break}t=t+1|0}return 4==(0|t)?0|r:0}function he(A,e){e|=0;var r=0,t=0,o=0,a=0;if(r=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,r=(0|i[A>>2])+(r<<2)|0,!(t=0|i[r>>2]))return 0|(a=1);a=e+32|0;do{if((0|t)!=(0|e)){if(!(r=0|i[t+32>>2]))return 0|(a=1);for(o=r;;){if((0|o)==(0|e)){o=8;break}if(!(r=0|i[o+32>>2])){r=1,o=10;break}t=o,o=r}if(8==(0|o)){i[t+32>>2]=i[a>>2];break}if(10==(0|o))return 0|r}else i[r>>2]=i[a>>2]}while(0);return Be(e),i[(a=A+8|0)>>2]=(0|i[a>>2])-1,0|(a=0)}function ce(A,e,r){A|=0,e|=0,r|=0;var t,o=0,a=0,s=0;(t=0|pe(40))||Q(23283,23253,98,23296),i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2],i[(a=t+16|0)>>2]=i[r>>2],i[a+4>>2]=i[r+4>>2],i[a+8>>2]=i[r+8>>2],i[a+12>>2]=i[r+12>>2],i[t+32>>2]=0,a=~~(+f(+ +u(10,+ +(15-(0|i[A+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,a=(0|i[A>>2])+(a<<2)|0,o=0|i[a>>2];do{if(o){for(;!(0|xA(o,e)&&0|xA(o+16|0,r));)if(a=0|i[o+32>>2],!(0|i[(o=0==(0|a)?o:a)+32>>2])){s=10;break}if(10==(0|s)){i[o+32>>2]=t;break}return Be(t),0|(s=o)}i[a>>2]=t}while(0);return i[(s=A+8|0)>>2]=1+(0|i[s>>2]),0|(s=t)}function de(A,e,r){e|=0,r|=0;var t=0,o=0;if(o=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,!(o=0|i[(0|i[A>>2])+(o<<2)>>2]))return 0|(r=0);if(!r){for(A=o;;){if(0|xA(A,e)){t=10;break}if(!(A=0|i[A+32>>2])){A=0,t=10;break}}if(10==(0|t))return 0|A}for(A=o;;){if(0|xA(A,e)&&0|xA(A+16|0,r)){t=10;break}if(!(A=0|i[A+32>>2])){A=0,t=10;break}}return 10==(0|t)?0|A:0}function ge(A,e){e|=0;var r=0;if(r=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,!(A=0|i[(0|i[A>>2])+(r<<2)>>2]))return 0|(r=0);for(;;){if(0|xA(A,e)){e=5;break}if(!(A=0|i[A+32>>2])){A=0,e=5;break}}return 5==(0|e)?0|A:0}function we(A){return 0|~~+function(A){return+ +Ie(+(A=+A))}(A=+A)}function pe(A){A|=0;var e,r=0,t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0;e=I,I=I+16|0,d=e;do{if(A>>>0<245){if(A=(l=A>>>0<11?16:A+11&-8)>>>3,3&(t=(c=0|i[5829])>>>A)|0)return n=0|i[(t=(A=23356+((r=(1&t^1)+A|0)<<1<<2)|0)+8|0)>>2],(0|(a=0|i[(o=n+8|0)>>2]))==(0|A)?i[5829]=c&~(1<>2]=A,i[t>>2]=a),k=r<<3,i[n+4>>2]=3|k,i[(k=n+k+4|0)>>2]=1|i[k>>2],I=e,0|(k=o);if(l>>>0>(h=0|i[5831])>>>0){if(0|t)return r=((r=t<>>=s=r>>>12&16)>>>5&8)|s|(a=(r>>>=t)>>>2&4)|(A=(r>>>=a)>>>1&2)|(n=(r>>>=A)>>>1&1))+(r>>>n)|0)<<1<<2)|0)+8|0)>>2],(0|(t=0|i[(s=a+8|0)>>2]))==(0|r)?(A=c&~(1<>2]=r,i[A>>2]=t,A=c),f=(k=n<<3)-l|0,i[a+4>>2]=3|l,i[(o=a+l|0)+4>>2]=1|f,i[a+k>>2]=f,0|h&&(n=0|i[5834],t=23356+((r=h>>>3)<<1<<2)|0,A&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=n,i[r+12>>2]=n,i[n+8>>2]=r,i[n+12>>2]=t),i[5831]=f,i[5834]=o,I=e,0|(k=s);if(a=0|i[5830]){for(t=(a&0-a)-1|0,t=u=0|i[23620+(((n=(t>>>=o=t>>>12&16)>>>5&8)|o|(f=(t>>>=n)>>>2&4)|(s=(t>>>=f)>>>1&2)|(u=(t>>>=s)>>>1&1))+(t>>>u)<<2)>>2],s=u,u=(-8&i[u+4>>2])-l|0;(A=0|i[t+16>>2])||(A=0|i[t+20>>2]);)t=A,s=(o=(f=(-8&i[A+4>>2])-l|0)>>>0>>0)?A:s,u=o?f:u;if((f=s+l|0)>>>0>s>>>0){o=0|i[s+24>>2],r=0|i[s+12>>2];do{if((0|r)==(0|s)){if(!(r=0|i[(A=s+20|0)>>2])&&!(r=0|i[(A=s+16|0)>>2])){t=0;break}for(;;)if(t=0|i[(n=r+20|0)>>2])r=t,A=n;else{if(!(t=0|i[(n=r+16|0)>>2]))break;r=t,A=n}i[A>>2]=0,t=r}else t=0|i[s+8>>2],i[t+12>>2]=r,i[r+8>>2]=t,t=r}while(0);do{if(0|o){if(r=0|i[s+28>>2],(0|s)==(0|i[(A=23620+(r<<2)|0)>>2])){if(i[A>>2]=t,!t){i[5830]=a&~(1<>2])==(0|s)?k:o+20|0)>>2]=t,!t)break;i[t+24>>2]=o,0|(r=0|i[s+16>>2])&&(i[t+16>>2]=r,i[r+24>>2]=t),0|(r=0|i[s+20>>2])&&(i[t+20>>2]=r,i[r+24>>2]=t)}}while(0);return u>>>0<16?(k=u+l|0,i[s+4>>2]=3|k,i[(k=s+k+4|0)>>2]=1|i[k>>2]):(i[s+4>>2]=3|l,i[f+4>>2]=1|u,i[f+u>>2]=u,0|h&&(n=0|i[5834],t=23356+((r=h>>>3)<<1<<2)|0,(r=1<>2]:(i[5829]=r|c,r=t,A=t+8|0),i[A>>2]=n,i[r+12>>2]=n,i[n+8>>2]=r,i[n+12>>2]=t),i[5831]=u,i[5834]=f),I=e,0|(k=s+8|0)}c=l}else c=l}else c=l}else if(A>>>0<=4294967231)if(l=-8&(A=A+11|0),n=0|i[5830]){o=0-l|0,u=(A>>>=8)?l>>>0>16777215?31:l>>>((u=14-((s=((p=A<<(c=(A+1048320|0)>>>16&8))+520192|0)>>>16&4)|c|(u=((p<<=s)+245760|0)>>>16&2))+(p<>>15)|0)+7|0)&1|u<<1:0,t=0|i[23620+(u<<2)>>2];A:do{if(t)for(A=0,s=l<<(31==(0|u)?0:25-(u>>>1)|0),a=0;;){if((f=(-8&i[t+4>>2])-l|0)>>>0>>0){if(!f){A=t,o=0,p=65;break A}A=t,o=f}if(a=0==(0|(p=0|i[t+20>>2]))|(0|p)==(0|(t=0|i[t+16+(s>>>31<<2)>>2]))?a:p,!t){t=a,p=61;break}s<<=1}else t=0,A=0,p=61}while(0);if(61==(0|p)){if(0==(0|t)&0==(0|A)){if(!(A=((A=2<>>=f=c>>>12&16)>>>5&8)|f|(s=(c>>>=a)>>>2&4)|(u=(c>>>=s)>>>1&2)|(t=(c>>>=u)>>>1&1))+(c>>>t)<<2)>>2]}t?p=65:(s=A,f=o)}if(65==(0|p))for(a=t;;){if(o=(t=(c=(-8&i[a+4>>2])-l|0)>>>0>>0)?c:o,A=t?a:A,(t=0|i[a+16>>2])||(t=0|i[a+20>>2]),!t){s=A,f=o;break}a=t}if(0!=(0|s)&&f>>>0<((0|i[5831])-l|0)>>>0&&(h=s+l|0)>>>0>s>>>0){a=0|i[s+24>>2],r=0|i[s+12>>2];do{if((0|r)==(0|s)){if(!(r=0|i[(A=s+20|0)>>2])&&!(r=0|i[(A=s+16|0)>>2])){r=0;break}for(;;)if(t=0|i[(o=r+20|0)>>2])r=t,A=o;else{if(!(t=0|i[(o=r+16|0)>>2]))break;r=t,A=o}i[A>>2]=0}else k=0|i[s+8>>2],i[k+12>>2]=r,i[r+8>>2]=k}while(0);do{if(a){if(A=0|i[s+28>>2],(0|s)==(0|i[(t=23620+(A<<2)|0)>>2])){if(i[t>>2]=r,!r){n&=~(1<>2])==(0|s)?k:a+20|0)>>2]=r,!r)break;i[r+24>>2]=a,0|(A=0|i[s+16>>2])&&(i[r+16>>2]=A,i[A+24>>2]=r),(A=0|i[s+20>>2])&&(i[r+20>>2]=A,i[A+24>>2]=r)}}while(0);A:do{if(f>>>0<16)k=f+l|0,i[s+4>>2]=3|k,i[(k=s+k+4|0)>>2]=1|i[k>>2];else{if(i[s+4>>2]=3|l,i[h+4>>2]=1|f,i[h+f>>2]=f,r=f>>>3,f>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=h,i[r+12>>2]=h,i[h+8>>2]=r,i[h+12>>2]=t;break}if(r=23620+((t=(r=f>>>8)?f>>>0>16777215?31:f>>>((t=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(t=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|t<<1:0)<<2)|0,i[h+28>>2]=t,i[(A=h+16|0)+4>>2]=0,i[A>>2]=0,!(n&(A=1<>2]=h,i[h+24>>2]=r,i[h+12>>2]=h,i[h+8>>2]=h;break}r=0|i[r>>2];e:do{if((-8&i[r+4>>2]|0)!=(0|f)){for(n=f<<(31==(0|t)?0:25-(t>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|f)){r=A;break e}n<<=1,r=A}i[t>>2]=h,i[h+24>>2]=r,i[h+12>>2]=h,i[h+8>>2]=h;break A}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=h,i[m>>2]=h,i[h+8>>2]=k,i[h+12>>2]=r,i[h+24>>2]=0}}while(0);return I=e,0|(k=s+8|0)}c=l}else c=l;else c=-1}while(0);if((t=0|i[5831])>>>0>=c>>>0)return r=t-c|0,A=0|i[5834],r>>>0>15?(k=A+c|0,i[5834]=k,i[5831]=r,i[k+4>>2]=1|r,i[A+t>>2]=r,i[A+4>>2]=3|c):(i[5831]=0,i[5834]=0,i[A+4>>2]=3|t,i[(k=A+t+4|0)>>2]=1|i[k>>2]),I=e,0|(k=A+8|0);if((f=0|i[5832])>>>0>c>>>0)return v=f-c|0,i[5832]=v,m=(k=0|i[5835])+c|0,i[5835]=m,i[m+4>>2]=1|v,i[k+4>>2]=3|c,I=e,0|(k=k+8|0);if(0|i[5947]?A=0|i[5949]:(i[5949]=4096,i[5948]=4096,i[5950]=-1,i[5951]=-1,i[5952]=0,i[5940]=0,i[5947]=-16&d^1431655768,A=4096),s=c+48|0,(l=(a=A+(u=c+47|0)|0)&(o=0-A|0))>>>0<=c>>>0)return I=e,0|(k=0);if(0|(A=0|i[5939])&&(d=(h=0|i[5937])+l|0)>>>0<=h>>>0|d>>>0>A>>>0)return I=e,0|(k=0);A:do{if(4&i[5940])r=0,p=143;else{t=0|i[5835];e:do{if(t){for(n=23764;!((d=0|i[n>>2])>>>0<=t>>>0&&(d+(0|i[n+4>>2])|0)>>>0>t>>>0);){if(!(A=0|i[n+8>>2])){p=128;break e}n=A}if((r=a-f&o)>>>0<2147483647)if((0|(A=0|Fe(0|r)))==((0|i[n>>2])+(0|i[n+4>>2])|0)){if(-1!=(0|A)){f=r,a=A,p=145;break A}}else n=A,p=136;else r=0}else p=128}while(0);do{if(128==(0|p))if(-1!=(0|(t=0|Fe(0)))&&(r=t,w=(r=(0==((w=(g=0|i[5948])+-1|0)&r|0)?0:(w+r&0-g)-r|0)+l|0)+(g=0|i[5937])|0,r>>>0>c>>>0&r>>>0<2147483647)){if(0|(d=0|i[5939])&&w>>>0<=g>>>0|w>>>0>d>>>0){r=0;break}if((0|(A=0|Fe(0|r)))==(0|t)){f=r,a=t,p=145;break A}n=A,p=136}else r=0}while(0);do{if(136==(0|p)){if(t=0-r|0,!(s>>>0>r>>>0&r>>>0<2147483647&-1!=(0|n))){if(-1==(0|n)){r=0;break}f=r,a=n,p=145;break A}if((A=u-r+(A=0|i[5949])&0-A)>>>0>=2147483647){f=r,a=n,p=145;break A}if(-1==(0|Fe(0|A))){Fe(0|t),r=0;break}f=A+r|0,a=n,p=145;break A}}while(0);i[5940]=4|i[5940],p=143}}while(0);if(143==(0|p)&&l>>>0<2147483647&&!(-1==(0|(v=0|Fe(0|l)))|1^(b=(B=(w=0|Fe(0))-v|0)>>>0>(c+40|0)>>>0)|v>>>0>>0&-1!=(0|v)&-1!=(0|w)^1)&&(f=b?B:r,a=v,p=145),145==(0|p)){r=(0|i[5937])+f|0,i[5937]=r,r>>>0>(0|i[5938])>>>0&&(i[5938]=r),u=0|i[5835];A:do{if(u){for(r=23764;;){if((0|a)==((A=0|i[r>>2])+(t=0|i[r+4>>2])|0)){p=154;break}if(!(n=0|i[r+8>>2]))break;r=n}if(154==(0|p)&&(m=r+4|0,0==(8&i[r+12>>2]|0))&&a>>>0>u>>>0&A>>>0<=u>>>0){i[m>>2]=t+f,m=u+(v=0==(7&(v=u+8|0)|0)?0:0-v&7)|0,v=(k=(0|i[5832])+f|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[u+k+4>>2]=40,i[5836]=i[5951];break}for(a>>>0<(0|i[5833])>>>0&&(i[5833]=a),t=a+f|0,r=23764;;){if((0|i[r>>2])==(0|t)){p=162;break}if(!(A=0|i[r+8>>2]))break;r=A}if(162==(0|p)&&0==(8&i[r+12>>2]|0)){i[r>>2]=a,i[(h=r+4|0)>>2]=(0|i[h>>2])+f,l=(h=a+(0==(7&(h=a+8|0)|0)?0:0-h&7)|0)+c|0,s=(r=t+(0==(7&(r=t+8|0)|0)?0:0-r&7)|0)-h-c|0,i[h+4>>2]=3|c;e:do{if((0|u)==(0|r))k=(0|i[5832])+s|0,i[5832]=k,i[5835]=l,i[l+4>>2]=1|k;else{if((0|i[5834])==(0|r)){k=(0|i[5831])+s|0,i[5831]=k,i[5834]=l,i[l+4>>2]=1|k,i[l+k>>2]=k;break}if(1==(3&(A=0|i[r+4>>2])|0)){f=-8&A,n=A>>>3;r:do{if(A>>>0<256){if(A=0|i[r+8>>2],(0|(t=0|i[r+12>>2]))==(0|A)){i[5829]=i[5829]&~(1<>2]=t,i[t+8>>2]=A;break}a=0|i[r+24>>2],A=0|i[r+12>>2];do{if((0|A)==(0|r)){if(A=0|i[(n=(t=r+16|0)+4|0)>>2])t=n;else if(!(A=0|i[t>>2])){A=0;break}for(;;)if(n=0|i[(o=A+20|0)>>2])A=n,t=o;else{if(!(n=0|i[(o=A+16|0)>>2]))break;A=n,t=o}i[t>>2]=0}else k=0|i[r+8>>2],i[k+12>>2]=A,i[A+8>>2]=k}while(0);if(!a)break;n=23620+((t=0|i[r+28>>2])<<2)|0;do{if((0|i[n>>2])==(0|r)){if(i[n>>2]=A,0|A)break;i[5830]=i[5830]&~(1<>2])==(0|r)?k:a+20|0)>>2]=A,!A)break r}while(0);if(i[A+24>>2]=a,0|(n=0|i[(t=r+16|0)>>2])&&(i[A+16>>2]=n,i[n+24>>2]=A),!(t=0|i[t+4>>2]))break;i[A+20>>2]=t,i[t+24>>2]=A}while(0);r=r+f|0,o=f+s|0}else o=s;if(i[(r=r+4|0)>>2]=-2&i[r>>2],i[l+4>>2]=1|o,i[l+o>>2]=o,r=o>>>3,o>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=l,i[r+12>>2]=l,i[l+8>>2]=r,i[l+12>>2]=t;break}r=o>>>8;do{if(r){if(o>>>0>16777215){n=31;break}n=o>>>((n=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(n=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|n<<1}else n=0}while(0);if(r=23620+(n<<2)|0,i[l+28>>2]=n,i[(A=l+16|0)+4>>2]=0,i[A>>2]=0,!((A=0|i[5830])&(t=1<>2]=l,i[l+24>>2]=r,i[l+12>>2]=l,i[l+8>>2]=l;break}r=0|i[r>>2];r:do{if((-8&i[r+4>>2]|0)!=(0|o)){for(n=o<<(31==(0|n)?0:25-(n>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|o)){r=A;break r}n<<=1,r=A}i[t>>2]=l,i[l+24>>2]=r,i[l+12>>2]=l,i[l+8>>2]=l;break e}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=l,i[m>>2]=l,i[l+8>>2]=k,i[l+12>>2]=r,i[l+24>>2]=0}}while(0);return I=e,0|(k=h+8|0)}for(r=23764;!((A=0|i[r>>2])>>>0<=u>>>0&&(k=A+(0|i[r+4>>2])|0)>>>0>u>>>0);)r=0|i[r+8>>2];r=(A=(A=(o=k+-47|0)+(0==(7&(A=o+8|0)|0)?0:0-A&7)|0)>>>0<(o=u+16|0)>>>0?u:A)+8|0,m=a+(v=0==(7&(v=a+8|0)|0)?0:0-v&7)|0,v=(t=f+-40|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[a+t+4>>2]=40,i[5836]=i[5951],i[(t=A+4|0)>>2]=27,i[r>>2]=i[5941],i[r+4>>2]=i[5942],i[r+8>>2]=i[5943],i[r+12>>2]=i[5944],i[5941]=a,i[5942]=f,i[5944]=0,i[5943]=r,r=A+24|0;do{m=r,i[(r=r+4|0)>>2]=7}while((m+8|0)>>>0>>0);if((0|A)!=(0|u)){if(a=A-u|0,i[t>>2]=-2&i[t>>2],i[u+4>>2]=1|a,i[A>>2]=a,r=a>>>3,a>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=u,i[r+12>>2]=u,i[u+8>>2]=r,i[u+12>>2]=t;break}if(t=23620+((n=(r=a>>>8)?a>>>0>16777215?31:a>>>((n=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(n=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|n<<1:0)<<2)|0,i[u+28>>2]=n,i[u+20>>2]=0,i[o>>2]=0,!((r=0|i[5830])&(A=1<>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break}r=0|i[t>>2];e:do{if((-8&i[r+4>>2]|0)!=(0|a)){for(n=a<<(31==(0|n)?0:25-(n>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|a)){r=A;break e}n<<=1,r=A}i[t>>2]=u,i[u+24>>2]=r,i[u+12>>2]=u,i[u+8>>2]=u;break A}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=u,i[m>>2]=u,i[u+8>>2]=k,i[u+12>>2]=r,i[u+24>>2]=0}}else 0==(0|(k=0|i[5833]))|a>>>0>>0&&(i[5833]=a),i[5941]=a,i[5942]=f,i[5944]=0,i[5838]=i[5947],i[5837]=-1,i[5842]=23356,i[5841]=23356,i[5844]=23364,i[5843]=23364,i[5846]=23372,i[5845]=23372,i[5848]=23380,i[5847]=23380,i[5850]=23388,i[5849]=23388,i[5852]=23396,i[5851]=23396,i[5854]=23404,i[5853]=23404,i[5856]=23412,i[5855]=23412,i[5858]=23420,i[5857]=23420,i[5860]=23428,i[5859]=23428,i[5862]=23436,i[5861]=23436,i[5864]=23444,i[5863]=23444,i[5866]=23452,i[5865]=23452,i[5868]=23460,i[5867]=23460,i[5870]=23468,i[5869]=23468,i[5872]=23476,i[5871]=23476,i[5874]=23484,i[5873]=23484,i[5876]=23492,i[5875]=23492,i[5878]=23500,i[5877]=23500,i[5880]=23508,i[5879]=23508,i[5882]=23516,i[5881]=23516,i[5884]=23524,i[5883]=23524,i[5886]=23532,i[5885]=23532,i[5888]=23540,i[5887]=23540,i[5890]=23548,i[5889]=23548,i[5892]=23556,i[5891]=23556,i[5894]=23564,i[5893]=23564,i[5896]=23572,i[5895]=23572,i[5898]=23580,i[5897]=23580,i[5900]=23588,i[5899]=23588,i[5902]=23596,i[5901]=23596,i[5904]=23604,i[5903]=23604,m=a+(v=0==(7&(v=a+8|0)|0)?0:0-v&7)|0,v=(k=f+-40|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[a+k+4>>2]=40,i[5836]=i[5951]}while(0);if((r=0|i[5832])>>>0>c>>>0)return v=r-c|0,i[5832]=v,m=(k=0|i[5835])+c|0,i[5835]=m,i[m+4>>2]=1|v,i[k+4>>2]=3|c,I=e,0|(k=k+8|0)}return i[(k=23312)>>2]=12,I=e,0|(k=0)}function Be(A){var e=0,r=0,t=0,n=0,o=0,a=0,f=0,s=0;if(A|=0){r=A+-8|0,n=0|i[5833],s=r+(e=-8&(A=0|i[A+-4>>2]))|0;do{if(1&A)f=r,a=r;else{if(t=0|i[r>>2],!(3&A))return;if(o=t+e|0,(a=r+(0-t)|0)>>>0>>0)return;if((0|i[5834])==(0|a)){if(3!=(3&(e=0|i[(A=s+4|0)>>2])|0)){f=a,e=o;break}return i[5831]=o,i[A>>2]=-2&e,i[a+4>>2]=1|o,void(i[a+o>>2]=o)}if(r=t>>>3,t>>>0<256){if(A=0|i[a+8>>2],(0|(e=0|i[a+12>>2]))==(0|A)){i[5829]=i[5829]&~(1<>2]=e,i[e+8>>2]=A,f=a,e=o;break}n=0|i[a+24>>2],A=0|i[a+12>>2];do{if((0|A)==(0|a)){if(A=0|i[(r=(e=a+16|0)+4|0)>>2])e=r;else if(!(A=0|i[e>>2])){A=0;break}for(;;)if(r=0|i[(t=A+20|0)>>2])A=r,e=t;else{if(!(r=0|i[(t=A+16|0)>>2]))break;A=r,e=t}i[e>>2]=0}else f=0|i[a+8>>2],i[f+12>>2]=A,i[A+8>>2]=f}while(0);if(n){if(e=0|i[a+28>>2],(0|i[(r=23620+(e<<2)|0)>>2])==(0|a)){if(i[r>>2]=A,!A){i[5830]=i[5830]&~(1<>2])==(0|a)?f:n+20|0)>>2]=A,!A){f=a,e=o;break}i[A+24>>2]=n,0|(r=0|i[(e=a+16|0)>>2])&&(i[A+16>>2]=r,i[r+24>>2]=A),(e=0|i[e+4>>2])?(i[A+20>>2]=e,i[e+24>>2]=A,f=a,e=o):(f=a,e=o)}else f=a,e=o}}while(0);if(!(a>>>0>=s>>>0)&&1&(t=0|i[(A=s+4|0)>>2])){if(2&t)i[A>>2]=-2&t,i[f+4>>2]=1|e,i[a+e>>2]=e,n=e;else{if((0|i[5835])==(0|s)){if(s=(0|i[5832])+e|0,i[5832]=s,i[5835]=f,i[f+4>>2]=1|s,(0|f)!=(0|i[5834]))return;return i[5834]=0,void(i[5831]=0)}if((0|i[5834])==(0|s))return s=(0|i[5831])+e|0,i[5831]=s,i[5834]=a,i[f+4>>2]=1|s,void(i[a+s>>2]=s);n=(-8&t)+e|0,r=t>>>3;do{if(t>>>0<256){if(e=0|i[s+8>>2],(0|(A=0|i[s+12>>2]))==(0|e)){i[5829]=i[5829]&~(1<>2]=A,i[A+8>>2]=e;break}o=0|i[s+24>>2],A=0|i[s+12>>2];do{if((0|A)==(0|s)){if(A=0|i[(r=(e=s+16|0)+4|0)>>2])e=r;else if(!(A=0|i[e>>2])){r=0;break}for(;;)if(r=0|i[(t=A+20|0)>>2])A=r,e=t;else{if(!(r=0|i[(t=A+16|0)>>2]))break;A=r,e=t}i[e>>2]=0,r=A}else r=0|i[s+8>>2],i[r+12>>2]=A,i[A+8>>2]=r,r=A}while(0);if(0|o){if(A=0|i[s+28>>2],(0|i[(e=23620+(A<<2)|0)>>2])==(0|s)){if(i[e>>2]=r,!r){i[5830]=i[5830]&~(1<>2])==(0|s)?t:o+20|0)>>2]=r,!r)break;i[r+24>>2]=o,0|(e=0|i[(A=s+16|0)>>2])&&(i[r+16>>2]=e,i[e+24>>2]=r),0|(A=0|i[A+4>>2])&&(i[r+20>>2]=A,i[A+24>>2]=r)}}while(0);if(i[f+4>>2]=1|n,i[a+n>>2]=n,(0|f)==(0|i[5834]))return void(i[5831]=n)}if(A=n>>>3,n>>>0<256)return r=23356+(A<<1<<2)|0,(e=0|i[5829])&(A=1<>2]:(i[5829]=e|A,A=r,e=r+8|0),i[e>>2]=f,i[A+12>>2]=f,i[f+8>>2]=A,void(i[f+12>>2]=r);A=23620+((t=(A=n>>>8)?n>>>0>16777215?31:n>>>((t=14-((o=((s=A<<(a=(A+1048320|0)>>>16&8))+520192|0)>>>16&4)|a|(t=((s<<=o)+245760|0)>>>16&2))+(s<>>15)|0)+7|0)&1|t<<1:0)<<2)|0,i[f+28>>2]=t,i[f+20>>2]=0,i[f+16>>2]=0,e=0|i[5830],r=1<>2];e:do{if((-8&i[A+4>>2]|0)!=(0|n)){for(t=n<<(31==(0|t)?0:25-(t>>>1)|0);e=0|i[(r=A+16+(t>>>31<<2)|0)>>2];){if((-8&i[e+4>>2]|0)==(0|n)){A=e;break e}t<<=1,A=e}i[r>>2]=f,i[f+24>>2]=A,i[f+12>>2]=f,i[f+8>>2]=f;break A}}while(0);s=0|i[(a=A+8|0)>>2],i[s+12>>2]=f,i[a>>2]=f,i[f+8>>2]=s,i[f+12>>2]=A,i[f+24>>2]=0}else i[5830]=e|r,i[A>>2]=f,i[f+24>>2]=A,i[f+12>>2]=f,i[f+8>>2]=f}while(0);if(s=(0|i[5837])-1|0,i[5837]=s,!(0|s)){for(A=23772;A=0|i[A>>2];)A=A+8|0;i[5837]=-1}}}}function be(A,e){e|=0;var r=0;return(A|=0)?(r=0|b(e,A),(e|A)>>>0>65535&&(r=(0|(r>>>0)/(A>>>0))==(0|e)?r:-1)):r=0,(A=0|pe(r))&&3&i[A+-4>>2]?(_e(0|A,0,0|r),0|A):0|A}function ve(A,e,r,t){return 0|(k(0|(t=(e|=0)-(t|=0)-((r|=0)>>>0>(A|=0)>>>0|0)>>>0)),A-r>>>0|0)}function me(A){return 0|((A|=0)?31-(0|m(A^A-1))|0:32)}function ke(A,e,r,t,n){n|=0;var o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0;if(l=A|=0,a=r|=0,f=c=t|=0,!(u=s=e|=0))return o=0!=(0|n),f?o?(i[n>>2]=0|A,i[n+4>>2]=0&e,n=0,0|(k(0|(c=0)),n)):(n=0,0|(k(0|(c=0)),n)):(o&&(i[n>>2]=(l>>>0)%(a>>>0),i[n+4>>2]=0),n=(l>>>0)/(a>>>0)>>>0,0|(k(0|(c=0)),n));o=0==(0|f);do{if(a){if(!o){if((o=(0|m(0|f))-(0|m(0|u))|0)>>>0<=31){a=h=o+1|0,A=l>>>(h>>>0)&(e=o-31>>31)|u<<(f=31-o|0),e&=u>>>(h>>>0),o=0,f=l<>2]=0|A,i[n+4>>2]=s|0&e,n=0,0|(k(0|(c=0)),n)):(n=0,0|(k(0|(c=0)),n))}if((o=a-1|0)&a|0){a=f=33+(0|m(0|a))-(0|m(0|u))|0,A=(h=32-f|0)-1>>31&u>>>((d=f-32|0)>>>0)|(u<>>(f>>>0))&(e=d>>31),e&=u>>>(f>>>0),o=l<<(g=64-f|0)&(s=h>>31),f=(u<>>(d>>>0))&s|l<>31;break}return 0|n&&(i[n>>2]=o&l,i[n+4>>2]=0),1==(0|a)?(g=0|A,0|(k(0|(d=s|0&e)),g)):(d=u>>>((g=0|me(0|a))>>>0)|0,g=u<<32-g|l>>>(g>>>0)|0,0|(k(0|d),g))}if(o)return 0|n&&(i[n>>2]=(u>>>0)%(a>>>0),i[n+4>>2]=0),g=(u>>>0)/(a>>>0)>>>0,0|(k(0|(d=0)),g);if(!l)return 0|n&&(i[n>>2]=0,i[n+4>>2]=(u>>>0)%(f>>>0)),g=(u>>>0)/(f>>>0)>>>0,0|(k(0|(d=0)),g);if(!((o=f-1|0)&f))return 0|n&&(i[n>>2]=0|A,i[n+4>>2]=o&u|0&e),d=0,g=u>>>((0|me(0|f))>>>0),0|(k(0|d),g);if((o=(0|m(0|f))-(0|m(0|u))|0)>>>0<=30){a=e=o+1|0,A=u<<(f=31-o|0)|l>>>(e>>>0),e=u>>>(e>>>0),o=0,f=l<>2]=0|A,i[n+4>>2]=s|0&e,g=0,0|(k(0|(d=0)),g)):(g=0,0|(k(0|(d=0)),g))}while(0);if(a){u=0|function(A,e,r,t){return 0|(k((e|=0)+(t|=0)+((r=(A|=0)+(r|=0)>>>0)>>>0>>0|0)>>>0|0),0|r)}(0|(h=0|r),0|(l=c|0&t),-1,-1),r=0|M(),s=f,f=0;do{t=s,s=o>>>31|s<<1,o=f|o<<1,ve(0|u,0|r,0|(t=A<<1|t>>>31|0),0|(c=A>>>31|e<<1|0)),f=1&(d=(g=0|M())>>31|((0|g)<0?-1:0)<<1),A=0|ve(0|t,0|c,d&h|0,(((0|g)<0?-1:0)>>31|((0|g)<0?-1:0)<<1)&l|0),e=0|M(),a=a-1|0}while(0!=(0|a));u=s,s=0}else u=f,s=0,f=0;return a=0,0|n&&(i[n>>2]=A,i[n+4>>2]=e),g=-2&(o<<1|0)|f,0|(k(0|(d=(0|o)>>>31|(u|a)<<1|0&(a<<1|o>>>31)|s)),g)}function Me(A,e,r,t){var n,o;return o=I,I=I+16|0,ke(A|=0,e|=0,r|=0,t|=0,n=0|o),I=o,0|(k(0|i[n+4>>2]),0|i[n>>2])}function Qe(A,e,r){return A|=0,e|=0,(0|(r|=0))<32?(k(e>>>r|0),A>>>r|(e&(1<>>r-32|0)}function ye(A,e,r){return A|=0,e|=0,(0|(r|=0))<32?(k(e<>>32-r|0),A<=0?+a(A+.5):+B(A-.5)}function De(A,e,r){A|=0,e|=0;var n,o,a=0;if((0|(r|=0))>=8192)return x(0|A,0|e,0|r),0|A;if(o=0|A,n=A+r|0,(3&A)==(3&e)){for(;3&A;){if(!r)return 0|o;t[A>>0]=0|t[e>>0],A=A+1|0,e=e+1|0,r=r-1|0}for(a=(r=-4&n|0)-64|0;(0|A)<=(0|a);)i[A>>2]=i[e>>2],i[A+4>>2]=i[e+4>>2],i[A+8>>2]=i[e+8>>2],i[A+12>>2]=i[e+12>>2],i[A+16>>2]=i[e+16>>2],i[A+20>>2]=i[e+20>>2],i[A+24>>2]=i[e+24>>2],i[A+28>>2]=i[e+28>>2],i[A+32>>2]=i[e+32>>2],i[A+36>>2]=i[e+36>>2],i[A+40>>2]=i[e+40>>2],i[A+44>>2]=i[e+44>>2],i[A+48>>2]=i[e+48>>2],i[A+52>>2]=i[e+52>>2],i[A+56>>2]=i[e+56>>2],i[A+60>>2]=i[e+60>>2],A=A+64|0,e=e+64|0;for(;(0|A)<(0|r);)i[A>>2]=i[e>>2],A=A+4|0,e=e+4|0}else for(r=n-4|0;(0|A)<(0|r);)t[A>>0]=0|t[e>>0],t[A+1>>0]=0|t[e+1>>0],t[A+2>>0]=0|t[e+2>>0],t[A+3>>0]=0|t[e+3>>0],A=A+4|0,e=e+4|0;for(;(0|A)<(0|n);)t[A>>0]=0|t[e>>0],A=A+1|0,e=e+1|0;return 0|o}function _e(A,e,r){e|=0;var n,o=0,a=0,f=0;if(n=(A|=0)+(r|=0)|0,e&=255,(0|r)>=67){for(;3&A;)t[A>>0]=e,A=A+1|0;for(f=e|e<<8|e<<16|e<<24,a=(o=-4&n|0)-64|0;(0|A)<=(0|a);)i[A>>2]=f,i[A+4>>2]=f,i[A+8>>2]=f,i[A+12>>2]=f,i[A+16>>2]=f,i[A+20>>2]=f,i[A+24>>2]=f,i[A+28>>2]=f,i[A+32>>2]=f,i[A+36>>2]=f,i[A+40>>2]=f,i[A+44>>2]=f,i[A+48>>2]=f,i[A+52>>2]=f,i[A+56>>2]=f,i[A+60>>2]=f,A=A+64|0;for(;(0|A)<(0|o);)i[A>>2]=f,A=A+4|0}for(;(0|A)<(0|n);)t[A>>0]=e,A=A+1|0;return n-r|0}function Ie(A){return(A=+A)>=0?+a(A+.5):+B(A-.5)}function Fe(A){A|=0;var e,r,t;return t=0|E(),(0|A)>0&(0|(e=(r=0|i[o>>2])+A|0))<(0|r)|(0|e)<0?(_(0|e),y(12),-1):(0|e)>(0|t)&&!(0|D(0|e))?(y(12),-1):(i[o>>2]=e,0|r)}return{___uremdi3:Me,_bitshift64Lshr:Qe,_bitshift64Shl:ye,_calloc:be,_cellAreaKm2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))>0){if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1!=(0|e)){A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e))}}else o=0;return I=n,6371.007180918475*o*6371.007180918475},_cellAreaM2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))>0){if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1!=(0|e)){A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e))}}else o=0;return I=n,6371.007180918475*o*6371.007180918475*1e3*1e3},_cellAreaRads2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))<=0)return I=n,+(o=0);if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1==(0|e))return I=n,+o;A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e));return I=n,+o},_compact:function(A,e,r){e|=0;var t,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,Q=0,y=0,E=0;if(!(r|=0))return 0|(y=0);if(n=0|i[(o=A|=0)>>2],!0&0==(15728640&(o=0|i[o+4>>2])|0)){if((0|r)<=0)return 0|(y=0);if(i[(y=e)>>2]=n,i[y+4>>2]=o,1==(0|r))return 0|(y=0);n=1;do{Q=0|i[(k=A+(n<<3)|0)+4>>2],i[(y=e+(n<<3)|0)>>2]=i[k>>2],i[y+4>>2]=Q,n=n+1|0}while((0|n)!=(0|r));return 0|(n=0)}if(!(Q=0|pe(k=r<<3)))return 0|(y=-3);if(De(0|Q,0|A,0|k),!(t=0|be(r,8)))return Be(Q),0|(y=-3);n=r;A:for(;;){v=0|Qe(0|(h=0|i[(f=Q)>>2]),0|(f=0|i[f+4>>2]),52),M(),m=(v&=15)+-1|0,b=(0|n)>0;e:do{if(b){if(B=((0|n)<0)<<31>>31,w=0|ye(0|m,0,52),p=0|M(),m>>>0>15)for(o=0,A=h,r=f;;){if(!(0==(0|A)&0==(0|r))){if(a=0|Qe(0|A,0|r,52),M(),s=(0|(a&=15))<(0|m),a=(0|a)==(0|m),r=0|Me(0|(l=s?0:a?A:0),0|(A=s?0:a?r:0),0|n,0|B),M(),0==(0|(u=0|i[(s=a=t+(r<<3)|0)>>2]))&0==(0|(s=0|i[s+4>>2])))r=l;else for(w=0,g=r,d=s,r=l;;){if((0|w)>(0|n)){y=41;break A}if((0|u)==(0|r)&(-117440513&d|0)==(0|A)){l=0|Qe(0|u,0|d,56),M(),c=(l&=7)+1|0,p=0|Qe(0|u,0|d,45),M();r:do{if(0|S(127&p)){if(u=0|Qe(0|u,0|d,52),M(),!(u&=15)){s=6;break}for(s=1;;){if(!(0==((p=0|ye(7,0,3*(15-s|0)|0))&r|0)&0==((0|M())&A|0))){s=7;break r}if(!(s>>>0>>0)){s=6;break}s=s+1|0}}else s=7}while(0);if((l+2|0)>>>0>s>>>0){y=51;break A}p=0|ye(0|c,0,56),A=0|M()|-117440513&A,i[(s=a)>>2]=0,i[s+4>>2]=0,s=g,r|=p}else s=(g+1|0)%(0|n)|0;if(0==(0|(u=0|i[(d=a=t+(s<<3)|0)>>2]))&0==(0|(d=0|i[d+4>>2])))break;w=w+1|0,g=s}i[(p=a)>>2]=r,i[p+4>>2]=A}if((0|(o=o+1|0))>=(0|n))break e;A=0|i[(r=Q+(o<<3)|0)>>2],r=0|i[r+4>>2]}for(o=0,A=h,r=f;;){if(!(0==(0|A)&0==(0|r))){if(s=0|Qe(0|A,0|r,52),M(),(0|(s&=15))>=(0|m)){if((0|s)!=(0|m)&&(A|=w,r=-15728641&r|p,s>>>0>=v>>>0)){a=m;do{g=0|ye(7,0,3*(14-a|0)|0),a=a+1|0,A|=g,r=0|M()|r}while(a>>>0>>0)}}else A=0,r=0;if(s=0|Me(0|A,0|r,0|n,0|B),M(),!(0==(0|(l=0|i[(u=a=t+(s<<3)|0)>>2]))&0==(0|(u=0|i[u+4>>2]))))for(g=0;;){if((0|g)>(0|n)){y=41;break A}if((0|l)==(0|A)&(-117440513&u|0)==(0|r)){c=0|Qe(0|l,0|u,56),M(),d=(c&=7)+1|0,E=0|Qe(0|l,0|u,45),M();r:do{if(0|S(127&E)){if(l=0|Qe(0|l,0|u,52),M(),!(l&=15)){u=6;break}for(u=1;;){if(!(0==((E=0|ye(7,0,3*(15-u|0)|0))&A|0)&0==((0|M())&r|0))){u=7;break r}if(!(u>>>0>>0)){u=6;break}u=u+1|0}}else u=7}while(0);if((c+2|0)>>>0>u>>>0){y=51;break A}E=0|ye(0|d,0,56),r=0|M()|-117440513&r,i[(d=a)>>2]=0,i[d+4>>2]=0,A|=E}else s=(s+1|0)%(0|n)|0;if(0==(0|(l=0|i[(u=a=t+(s<<3)|0)>>2]))&0==(0|(u=0|i[u+4>>2])))break;g=g+1|0}i[(E=a)>>2]=A,i[E+4>>2]=r}if((0|(o=o+1|0))>=(0|n))break e;A=0|i[(r=Q+(o<<3)|0)>>2],r=0|i[r+4>>2]}}}while(0);if((n+5|0)>>>0<11){y=99;break}if(!(p=0|be((0|n)/6|0,8))){y=58;break}e:do{if(b){g=0,d=0;do{if(!(0==(0|(o=0|i[(A=s=t+(g<<3)|0)>>2]))&0==(0|(A=0|i[A+4>>2])))){u=0|Qe(0|o,0|A,56),M(),r=(u&=7)+1|0,l=-117440513&A,E=0|Qe(0|o,0|A,45),M();r:do{if(0|S(127&E)){if(c=0|Qe(0|o,0|A,52),M(),0|(c&=15))for(a=1;;){if(!(0==(o&(E=0|ye(7,0,3*(15-a|0)|0))|0)&0==(l&(0|M())|0)))break r;if(!(a>>>0>>0))break;a=a+1|0}o|=A=0|ye(0|r,0,56),A=0|M()|l,i[(r=s)>>2]=o,i[r+4>>2]=A,r=u+2|0}}while(0);7==(0|r)&&(i[(E=p+(d<<3)|0)>>2]=o,i[E+4>>2]=-117440513&A,d=d+1|0)}g=g+1|0}while((0|g)!=(0|n));if(b){if(w=((0|n)<0)<<31>>31,c=0|ye(0|m,0,52),g=0|M(),m>>>0>15)for(A=0,o=0;;){do{if(!(0==(0|h)&0==(0|f))){for(u=0|Qe(0|h,0|f,52),M(),a=(0|(u&=15))<(0|m),u=(0|u)==(0|m),a=0|Me(0|(s=a?0:u?h:0),0|(u=a?0:u?f:0),0|n,0|w),M(),r=0;;){if((0|r)>(0|n)){y=98;break A}if((-117440513&(l=0|i[(E=t+(a<<3)|0)+4>>2])|0)==(0|u)&&(0|i[E>>2])==(0|s)){y=70;break}if((0|i[(E=t+((a=(a+1|0)%(0|n)|0)<<3)|0)>>2])==(0|s)&&(0|i[E+4>>2])==(0|u))break;r=r+1|0}if(70==(0|y)&&(y=0,!0&100663296==(117440512&l|0)))break;i[(E=e+(o<<3)|0)>>2]=h,i[E+4>>2]=f,o=o+1|0}}while(0);if((0|(A=A+1|0))>=(0|n)){n=d;break e}h=0|i[(f=Q+(A<<3)|0)>>2],f=0|i[f+4>>2]}for(A=0,o=0;;){do{if(!(0==(0|h)&0==(0|f))){if(u=0|Qe(0|h,0|f,52),M(),(0|(u&=15))>=(0|m))if((0|u)!=(0|m))if(r=h|c,a=-15728641&f|g,u>>>0>>0)u=a;else{s=m;do{E=0|ye(7,0,3*(14-s|0)|0),s=s+1|0,r|=E,a=0|M()|a}while(s>>>0>>0);u=a}else r=h,u=f;else r=0,u=0;for(s=0|Me(0|r,0|u,0|n,0|w),M(),a=0;;){if((0|a)>(0|n)){y=98;break A}if((-117440513&(l=0|i[(E=t+(s<<3)|0)+4>>2])|0)==(0|u)&&(0|i[E>>2])==(0|r)){y=93;break}if((0|i[(E=t+((s=(s+1|0)%(0|n)|0)<<3)|0)>>2])==(0|r)&&(0|i[E+4>>2])==(0|u))break;a=a+1|0}if(93==(0|y)&&(y=0,!0&100663296==(117440512&l|0)))break;i[(E=e+(o<<3)|0)>>2]=h,i[E+4>>2]=f,o=o+1|0}}while(0);if((0|(A=A+1|0))>=(0|n)){n=d;break e}h=0|i[(f=Q+(A<<3)|0)>>2],f=0|i[f+4>>2]}}else o=0,n=d}else o=0,n=0}while(0);if(_e(0|t,0,0|k),De(0|Q,0|p,n<<3|0),Be(p),!n)break;e=e+(o<<3)|0}return 41==(0|y)?(Be(Q),Be(t),0|(E=-1)):51==(0|y)?(Be(Q),Be(t),0|(E=-2)):58==(0|y)?(Be(Q),Be(t),0|(E=-3)):98==(0|y)?(Be(p),Be(Q),Be(t),0|(E=-1)):(99==(0|y)&&De(0|e,0|Q,n<<3|0),Be(Q),Be(t),0|(E=0))},_destroyLinkedPolygon:function(A){var e=0,r=0,t=0,n=0;if(A|=0)for(t=1;;){if(0|(e=0|i[A>>2]))do{if(0|(r=0|i[e>>2]))do{n=r,r=0|i[r+16>>2],Be(n)}while(0!=(0|r));n=e,e=0|i[e+8>>2],Be(n)}while(0!=(0|e));if(e=A,A=0|i[A+8>>2],t||Be(e),!A)break;t=0}},_edgeLengthKm:function(A){return+ +n[20752+((A|=0)<<3)>>3]},_edgeLengthM:function(A){return+ +n[20880+((A|=0)<<3)>>3]},_emscripten_replace_memory:function(A){return t=new Int8Array(A),new Uint8Array(A),i=new Int32Array(A),new Float32Array(A),n=new Float64Array(A),r=A,!0},_exactEdgeLengthKm:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+c)*+l(+a)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)!=(0|e));return I=t,+(d=6371.007180918475*o)},_exactEdgeLengthM:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+c)*+l(+a)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)!=(0|e));return I=t,+(d=6371.007180918475*o*1e3)},_exactEdgeLengthRads:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+a)*+l(+c)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)<(0|e));return I=t,+o},_experimentalH3ToLocalIj:function(A,e,r,t,i){var n,o;return i|=0,o=I,I=I+16|0,(A=0|$A(A|=0,e|=0,r|=0,t|=0,n=o))||(cA(n,i),A=0),I=o,0|A},_experimentalLocalIjToH3:function(A,e,r,t){var i,n;return A|=0,e|=0,t|=0,i=I,I=I+16|0,dA(r|=0,n=i),t=0|Ae(A,e,n,t),I=i,0|t},_free:Be,_geoToH3:LA,_getDestinationH3IndexFromUnidirectionalEdge:function(A,e){A|=0;var r,t,n=0;return r=I,I=I+16|0,n=r,!0&268435456==(2013265920&(e|=0)|0)?(t=0|Qe(0|A,0|e,56),M(),i[n>>2]=0,n=0|U(A,-2130706433&e|134217728,7&t,n),e=0|M(),k(0|e),I=r,0|n):(n=0,k(0|(e=0)),I=r,0|n)},_getH3IndexesFromUnidirectionalEdge:function(A,e,r){A|=0;var t,n,o,a,f=0;o=I,I=I+16|0,t=o,a=!0&268435456==(2013265920&(e|=0)|0),n=-2130706433&e|134217728,i[(f=r|=0)>>2]=a?A:0,i[f+4>>2]=a?n:0,a?(e=0|Qe(0|A,0|e,56),M(),i[t>>2]=0,A=0|U(A,n,7&e,t),e=0|M()):(A=0,e=0),i[(f=r+8|0)>>2]=A,i[f+4>>2]=e,I=o},_getH3UnidirectionalEdge:function(A,e,r,t){var n,o,a=0,f=0,s=0,u=0,l=0;if(o=I,I=I+16|0,n=o,!(0|ZA(A|=0,e|=0,r|=0,t|=0)))return u=0,k(0|(s=0)),I=o,0|u;for(s=-2130706433&e,a=(a=0==(0|UA(A,e)))?1:2;i[n>>2]=0,f=a+1|0,!((0|(l=0|U(A,e,a,n)))==(0|r)&(0|M())==(0|t));){if(!(f>>>0<7)){a=0,A=0,u=6;break}a=f}return 6==(0|u)?(k(0|a),I=o,0|A):(l=0|ye(0|a,0,56),u=0|s|M()|268435456,l|=A,k(0|u),I=o,0|l)},_getH3UnidirectionalEdgeBoundary:WA,_getH3UnidirectionalEdgesFromHexagon:function(A,e,r){r|=0;var t,n=0;t=0==(0|UA(A|=0,e|=0)),e&=-2130706433,i[(n=r)>>2]=t?A:0,i[n+4>>2]=t?285212672|e:0,i[(n=r+8|0)>>2]=A,i[n+4>>2]=301989888|e,i[(n=r+16|0)>>2]=A,i[n+4>>2]=318767104|e,i[(n=r+24|0)>>2]=A,i[n+4>>2]=335544320|e,i[(n=r+32|0)>>2]=A,i[n+4>>2]=352321536|e,i[(r=r+40|0)>>2]=A,i[r+4>>2]=369098752|e},_getOriginH3IndexFromUnidirectionalEdge:function(A,e){var r;return A|=0,k(0|((r=!0&268435456==(2013265920&(e|=0)|0))?-2130706433&e|134217728:0)),0|(r?A:0)},_getPentagonIndexes:NA,_getRes0Indexes:function(A){A|=0;var e=0,r=0,t=0;e=0;do{ye(0|e,0,45),t=134225919|M(),i[(r=A+(e<<3)|0)>>2]=-1,i[r+4>>2]=t,e=e+1|0}while(122!=(0|e))},_h3Distance:function(A,e,r,t){var i,n,o;return r|=0,t|=0,o=I,I=I+32|0,n=o,A=0==(0|$A(A|=0,e|=0,A,e,i=o+12|0))&&0==(0|$A(A,e,r,t,n))?0|hA(i,n):-1,I=o,0|A},_h3GetBaseCell:IA,_h3GetFaces:function A(e,r,t){t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0;n=I,I=I+128|0,h=n+112|0,f=n+96|0,c=n,a=0|Qe(0|(e|=0),0|(r|=0),52),M(),u=15&a,i[h>>2]=u,s=0|Qe(0|e,0|r,45),M(),s&=127;A:do{if(0|S(s)){if(0|u)for(o=1;;){if(!(0==((l=0|ye(7,0,3*(15-o|0)|0))&e|0)&0==((0|M())&r|0))){a=0;break A}if(!(o>>>0>>0))break;o=o+1|0}if(!(1&a))return l=0|ye(u+1|0,0,52),c=0|M()|-15728641&r,A((l|e)&~(h=0|ye(7,0,3*(14-u|0)|0)),c&~(0|M()),t),void(I=n);a=1}else a=0}while(0);YA(e,r,f),a?(mA(f,h,c),l=5):(yA(f,h,c),l=6);A:do{if(0|S(s))if(u)for(o=1;;){if(!(0==((s=0|ye(7,0,3*(15-o|0)|0))&e|0)&0==((0|M())&r|0))){o=8;break A}if(!(o>>>0>>0)){o=20;break}o=o+1|0}else o=20;else o=8}while(0);if(_e(0|t,-1,0|o),a){a=0;do{for(MA(f=c+(a<<4)|0,0|i[h>>2]),f=0|i[f>>2],o=0;!(-1==(0|(u=0|i[(s=t+(o<<2)|0)>>2]))|(0|u)==(0|f));)o=o+1|0;i[s>>2]=f,a=a+1|0}while((0|a)!=(0|l))}else{a=0;do{for(kA(f=c+(a<<4)|0,0|i[h>>2],0,1),f=0|i[f>>2],o=0;!(-1==(0|(u=0|i[(s=t+(o<<2)|0)>>2]))|(0|u)==(0|f));)o=o+1|0;i[s>>2]=f,a=a+1|0}while((0|a)!=(0|l))}I=n},_h3GetResolution:function(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),52),M(),15&e|0},_h3IndexesAreNeighbors:ZA,_h3IsPentagon:UA,_h3IsResClassIII:function(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),52),M(),1&e|0},_h3IsValid:FA,_h3Line:function(A,e,r,t,n){r|=0,t|=0,n|=0;var o,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,Q=0;if(o=I,I=I+48|0,s=o+12|0,M=o,0==(0|$A(A|=0,e|=0,A,e,a=o+24|0))&&0==(0|$A(A,e,r,t,s))){if((0|(k=0|hA(a,s)))<0)return I=o,0|(M=k);for(i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,i[s>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,$A(A,e,A,e,a),$A(A,e,r,t,s),gA(a),gA(s),k?(w=+(0|k),m=a,r=c=0|i[a>>2],t=d=0|i[(b=a+4|0)>>2],a=g=0|i[(v=a+8|0)>>2],p=+((0|i[s>>2])-c|0)/w,B=+((0|i[s+4>>2])-d|0)/w,w=+((0|i[s+8>>2])-g|0)/w):(b=t=a+4|0,v=g=a+8|0,m=a,r=0|i[a>>2],t=0|i[t>>2],a=0|i[g>>2],p=0,B=0,w=0),i[M>>2]=r,i[(g=M+4|0)>>2]=t,i[(d=M+8|0)>>2]=a,c=0;;){Q=p*(l=+(0|c))+ +(0|r),u=B*l+ +(0|i[b>>2]),l=w*l+ +(0|i[v>>2]),t=~~+xe(+Q),s=~~+xe(+u),r=~~+xe(+l),Q=+f(+(+(0|t)-Q)),u=+f(+(+(0|s)-u)),l=+f(+(+(0|r)-l));do{if(!(Q>u&Q>l)){if(h=0-t|0,u>l){a=h-r|0;break}a=s,r=h-s|0;break}t=0-(s+r)|0,a=s}while(0);if(i[M>>2]=t,i[g>>2]=a,i[d>>2]=r,wA(M),Ae(A,e,M,n+(c<<3)|0),(0|c)==(0|k))break;c=c+1|0,r=0|i[m>>2]}return I=o,0|(M=0)}return I=o,0|(M=-1)},_h3LineSize:function(A,e,r,t){var i,n,o;return r|=0,t|=0,o=I,I=I+32|0,n=o,A=0==(0|$A(A|=0,e|=0,A,e,i=o+12|0))&&0==(0|$A(A,e,r,t,n))?0|hA(i,n):-1,I=o,(A>>>31^1)+A|0},_h3SetToLinkedGeo:function(A,e,r){r|=0;var t,n,o,a=0;if(o=I,I=I+32|0,t=o,function(A,e,r){A|=0,r|=0;var t,n,o=0,a=0,f=0,s=0,u=0;if(n=I,I=I+176|0,t=n,(0|(e|=0))<1)return se(r,0,0),void(I=n);s=0|Qe(0|i[(s=A)>>2],0|i[s+4>>2],52),M(),se(r,(0|e)>6?e:6,15&s),s=0;do{if(jA(0|i[(o=A+(s<<3)|0)>>2],0|i[o+4>>2],t),(0|(o=0|i[t>>2]))>0){u=0;do{f=t+8+(u<<4)|0,(a=0|de(r,o=t+8+(((0|(u=u+1|0))%(0|o)|0)<<4)|0,f))?he(r,a):ce(r,f,o),o=0|i[t>>2]}while((0|u)<(0|o))}s=s+1|0}while((0|s)!=(0|e));I=n}(A|=0,e|=0,n=o+16|0),i[r>>2]=0,i[r+4>>2]=0,i[r+8>>2]=0,!(A=0|le(n)))return XA(r),ue(n),void(I=o);do{e=0|JA(r);do{KA(e,A),a=A+16|0,i[t>>2]=i[a>>2],i[t+4>>2]=i[a+4>>2],i[t+8>>2]=i[a+8>>2],i[t+12>>2]=i[a+12>>2],he(n,A),A=0|ge(n,t)}while(0!=(0|A));A=0|le(n)}while(0!=(0|A));XA(r),ue(n),I=o},_h3ToCenterChild:function(A,e,r){r|=0;var t=0,i=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(t&=15))<=(0|r)){if((0|t)!=(0|r)&&(A|=i=0|ye(0|r,0,52),e=0|M()|-15728641&e,(0|t)<(0|r)))do{i=0|ye(7,0,3*(14-t|0)|0),t=t+1|0,A&=~i,e&=~(0|M())}while((0|t)<(0|r))}else e=0,A=0;return k(0|e),0|A},_h3ToChildren:PA,_h3ToGeo:OA,_h3ToGeoBoundary:jA,_h3ToParent:CA,_h3UnidirectionalEdgeIsValid:function(A,e){var r=0;if(!(!0&268435456==(2013265920&(e|=0)|0)))return 0|(r=0);switch(r=0|Qe(0|(A|=0),0|e,56),M(),7&r){case 0:case 7:return 0|(r=0)}return!0&16777216==(117440512&e|0)&0!=(0|UA(A,r=-2130706433&e|134217728))?0|(r=0):0|(r=0|FA(A,r))},_hexAreaKm2:function(A){return+ +n[20496+((A|=0)<<3)>>3]},_hexAreaM2:function(A){return+ +n[20624+((A|=0)<<3)>>3]},_hexRing:function(A,e,r,t){A|=0,e|=0,t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0,h=0;if(n=I,I=I+16|0,h=n,!(r|=0))return i[(h=t)>>2]=A,i[h+4>>2]=e,I=n,0|(h=0);i[h>>2]=0;A:do{if(0|UA(A,e))A=1;else{if(a=(0|r)>0){o=0,l=A;do{if(0==(0|(l=0|U(l,e,4,h)))&0==(0|(e=0|M()))){A=2;break A}if(o=o+1|0,0|UA(l,e)){A=1;break A}}while((0|o)<(0|r));if(i[(u=t)>>2]=l,i[u+4>>2]=e,u=r+-1|0,a){a=0,f=1,o=l,A=e;do{if(0==(0|(o=0|U(o,A,2,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(f<<3)|0)>>2]=o,i[s+4>>2]=A,f=f+1|0,0|UA(o,A)){A=1;break A}a=a+1|0}while((0|a)<(0|r));s=0,a=f;do{if(0==(0|(o=0|U(o,A,3,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(f=t+(a<<3)|0)>>2]=o,i[f+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}s=s+1|0}while((0|s)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,1,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,5,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,4,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));for(f=0;;){if(0==(0|(o=0|U(o,A,6,h)))&0==(0|(A=0|M()))){A=2;break A}if((0|f)!=(0|u)){if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,0|UA(o,A)){A=1;break A}a=a+1|0}if((0|(f=f+1|0))>=(0|r)){f=l,a=e;break}}}else f=l,o=l,a=e,A=e}else i[(f=t)>>2]=A,i[f+4>>2]=e,f=A,o=A,a=e,A=e;A=1&((0|f)!=(0|o)|(0|a)!=(0|A))}}while(0);return I=n,0|(h=A)},_i64Subtract:ve,_kRing:F,_kRingDistances:function(A,e,r,t,i){var n;if(0|C(A|=0,e|=0,r|=0,t|=0,i|=0)){if(_e(0|t,0,(n=1+(0|b(3*r|0,r+1|0))|0)<<3|0),0|i)return _e(0|i,0,n<<2|0),void P(A,e,r,t,i,n,0);(i=0|be(n,4))&&(P(A,e,r,t,i,n,0),Be(i))}},_llvm_minnum_f64:Ee,_llvm_round_f64:xe,_malloc:pe,_maxFaceCount:function(A,e){var r=0,t=0;if(t=0|Qe(0|(A|=0),0|(e|=0),45),M(),!(0|S(127&t)))return 0|(t=2);if(t=0|Qe(0|A,0|e,52),M(),!(t&=15))return 0|(t=5);for(r=1;;){if(!(0==((0|ye(7,0,3*(15-r|0)|0))&A|0)&0==((0|M())&e|0))){r=2,A=6;break}if(!(r>>>0>>0)){r=5,A=6;break}r=r+1|0}return 6==(0|A)?0|r:0},_maxH3ToChildrenSize:function(A,e,r){return r|=0,A=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(A&=15))<=(0|r)?0|(r=0|ee(7,r-A|0)):0|(r=0)},_maxKringSize:function(A){return 1+(0|b(3*(A|=0)|0,A+1|0))|0},_maxPolyfillSize:function(A,e){e|=0;var r,t=0,n=0,o=0,a=0,f=0;if(r=I,I=I+48|0,o=r+8|0,n=r,a=0|i[(f=A|=0)+4>>2],i[(t=n)>>2]=i[f>>2],i[t+4>>2]=a,te(n,o),o=0|j(o,e),e=0|i[n>>2],(0|(n=0|i[A+8>>2]))<=0)return I=r,0|(f=(f=(a=(0|o)<(0|(f=e)))?f:o)+12|0);t=0|i[A+12>>2],A=0;do{e=(0|i[t+(A<<3)>>2])+e|0,A=A+1|0}while((0|A)<(0|n));return I=r,0|(f=(f=(f=(0|o)<(0|e))?e:o)+12|0)},_maxUncompactSize:function(A,e,r){A|=0,r|=0;var t=0,n=0,o=0,a=0;if((0|(e|=0))<=0)return 0|(r=0);if((0|r)>=16){for(t=0;;){if(!(0==(0|i[(a=A+(t<<3)|0)>>2])&0==(0|i[a+4>>2]))){t=-1,n=13;break}if((0|(t=t+1|0))>=(0|e)){t=0,n=13;break}}if(13==(0|n))return 0|t}t=0,a=0;A:for(;;){o=0|i[(n=A+(a<<3)|0)>>2],n=0|i[n+4>>2];do{if(!(0==(0|o)&0==(0|n))){if(n=0|Qe(0|o,0|n,52),M(),(0|(n&=15))>(0|r)){t=-1,n=13;break A}if((0|n)==(0|r)){t=t+1|0;break}t=(0|ee(7,r-n|0))+t|0;break}}while(0);if((0|(a=a+1|0))>=(0|e)){n=13;break}}return 13==(0|n)?0|t:0},_memcpy:De,_memset:_e,_numHexagons:function(A){var e;return A=0|i[(e=21008+((A|=0)<<3)|0)>>2],k(0|i[e+4>>2]),0|A},_pentagonIndexCount:function(){return 12},_pointDistKm:DA,_pointDistM:function(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))*6371.007180918475*1e3},_pointDistRads:function(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))},_polyfill:function(A,e,r){var t,n=0,o=0,a=0,f=0,s=0;if(t=I,I=I+48|0,n=t+8|0,o=t,0|function(A,e,r){e|=0,r|=0;var t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,y=0,E=0,x=0,D=0,_=0,F=0,U=0,S=0,T=0,V=0,H=0;H=I,I=I+112|0,U=H+80|0,s=H+72|0,S=H,T=H+56|0,(V=0|pe(32+(i[(u=(A=A|0)+8|0)>>2]<<5)|0))||Q(22848,22448,800,22456);if(ie(A,V),t=0|i[(o=A)+4>>2],i[(f=s)>>2]=i[o>>2],i[f+4>>2]=t,te(s,U),f=0|j(U,e),t=0|i[s>>2],(0|(o=0|i[u>>2]))>0){a=0|i[A+12>>2],n=0;do{t=(0|i[a+(n<<3)>>2])+t|0,n=n+1|0}while((0|n)!=(0|o))}if(n=0|be(F=(f=(0|f)<(0|t)?t:f)+12|0,8),l=0|be(F,8),i[U>>2]=0,_=0|i[(D=A)+4>>2],i[(t=s)>>2]=i[D>>2],i[t+4>>2]=_,0|(t=0|G(s,F,e,U,n,l)))return Be(n),Be(l),Be(V),I=H,0|(V=t);A:do{if((0|i[u>>2])>0){for(o=A+12|0,t=0;a=0|G((0|i[o>>2])+(t<<3)|0,F,e,U,n,l),t=t+1|0,!(0|a);)if((0|t)>=(0|i[u>>2]))break A;return Be(n),Be(l),Be(V),I=H,0|(V=a)}}while(0);(0|f)>-12&&_e(0|l,0,((0|F)>1?F:1)<<3|0);A:do{if((0|i[U>>2])>0){_=((0|F)<0)<<31>>31,m=n,k=l,y=n,E=n,x=l,D=n,t=n,p=n,B=l,b=l,v=l,n=l;e:for(;;){for(w=0|i[U>>2],d=0,g=0,o=0;;){f=(a=S)+56|0;do{i[a>>2]=0,a=a+4|0}while((0|a)<(0|f));if(0|C(s=0|i[(e=m+(d<<3)|0)>>2],e=0|i[e+4>>2],1,S,0)){f=(a=S)+56|0;do{i[a>>2]=0,a=a+4|0}while((0|a)<(0|f));0|(a=0|be(7,4))&&(P(s,e,1,S,a,7,0),Be(a))}c=0;do{l=0|i[(h=S+(c<<3)|0)>>2],h=0|i[h+4>>2];r:do{if(!(0==(0|l)&0==(0|h))){if(s=0|Me(0|l,0|h,0|F,0|_),M(),!(0==(0|(e=0|i[(f=a=r+(s<<3)|0)>>2]))&0==(0|(f=0|i[f+4>>2]))))for(u=0;;){if((0|u)>(0|F))break e;if((0|e)==(0|l)&(0|f)==(0|h))break r;if(0==(0|(e=0|i[(f=a=r+((s=(s+1|0)%(0|F)|0)<<3)|0)>>2]))&0==(0|(f=0|i[f+4>>2])))break;u=u+1|0}0==(0|l)&0==(0|h)||(OA(l,h,T),0|ne(A,V,T)&&(i[(u=a)>>2]=l,i[u+4>>2]=h,i[(u=k+(o<<3)|0)>>2]=l,i[u+4>>2]=h,o=o+1|0))}}while(0);c=c+1|0}while(c>>>0<7);if((0|(g=g+1|0))>=(0|w))break;d=d+1|0}if((0|w)>0&&_e(0|y,0,w<<3|0),i[U>>2]=o,!((0|o)>0))break A;l=n,h=v,c=D,d=b,g=B,w=k,n=p,v=t,b=E,B=y,p=l,t=h,D=x,x=c,E=d,y=g,k=m,m=w}return Be(E),Be(x),Be(V),I=H,0|(V=-1)}t=l}while(0);return Be(V),Be(n),Be(t),I=H,0|(V=0)}(A|=0,e|=0,r|=0)){if(a=0|i[(s=A)+4>>2],i[(f=o)>>2]=i[s>>2],i[f+4>>2]=a,te(o,n),f=0|j(n,e),e=0|i[o>>2],(0|(a=0|i[A+8>>2]))>0){o=0|i[A+12>>2],n=0;do{e=(0|i[o+(n<<3)>>2])+e|0,n=n+1|0}while((0|n)!=(0|a))}(0|(e=(0|f)<(0|e)?e:f))<=-12||_e(0|r,0,8+(((0|(s=e+11|0))>0?s:0)<<3)|0),I=t}else I=t},_res0IndexCount:function(){return 122},_round:Ie,_sbrk:Fe,_sizeOfCoordIJ:function(){return 8},_sizeOfGeoBoundary:function(){return 168},_sizeOfGeoCoord:function(){return 16},_sizeOfGeoPolygon:function(){return 16},_sizeOfGeofence:function(){return 8},_sizeOfH3Index:function(){return 8},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompact:function(A,e,r,t,n){A|=0,r|=0,t|=0,n|=0;var o=0,a=0,f=0,s=0,u=0,l=0;if((0|(e|=0))<=0)return 0|(n=0);if((0|n)>=16){for(o=0;;){if(!(0==(0|i[(l=A+(o<<3)|0)>>2])&0==(0|i[l+4>>2]))){o=14;break}if((0|(o=o+1|0))>=(0|e)){a=0,o=16;break}}if(14==(0|o))return 0|((0|t)>0?-2:-1);if(16==(0|o))return 0|a}o=0,l=0;A:for(;;){a=0|i[(f=u=A+(l<<3)|0)>>2],f=0|i[f+4>>2];do{if(!(0==(0|a)&0==(0|f))){if((0|o)>=(0|t)){a=-1,o=16;break A}if(s=0|Qe(0|a,0|f,52),M(),(0|(s&=15))>(0|n)){a=-2,o=16;break A}if((0|s)==(0|n)){i[(u=r+(o<<3)|0)>>2]=a,i[u+4>>2]=f,o=o+1|0;break}if((0|(a=(0|ee(7,n-s|0))+o|0))>(0|t)){a=-1,o=16;break A}PA(0|i[u>>2],0|i[u+4>>2],n,r+(o<<3)|0),o=a}}while(0);if((0|(l=l+1|0))>=(0|e)){a=0,o=16;break}}return 16==(0|o)?0|a:0},establishStackSpace:function(A,e){I=A|=0},stackAlloc:function(A){var e;return e=I,I=(I=I+(A|=0)|0)+15&-16,0|e},stackRestore:function(A){I=A|=0},stackSave:function(){return 0|I}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{a:fA,b:function(A){s=A},c:u,d:function(A,e,r,t){fA("Assertion failed: "+g(A)+", at: "+[e?g(e):"unknown filename",r,t?g(t):"unknown function"])},e:function(A){return r.___errno_location&&(v[r.___errno_location()>>2]=A),A},f:N,g:function(A,e,r){B.set(B.subarray(e,e+r),A)},h:function(A){var e=N(),r=16777216,t=2130706432;if(A>t)return!1;for(var i=Math.max(e,16777216);i>0]=e;break;case"i16":b[A>>1]=e;break;case"i32":v[A>>2]=e;break;case"i64":H=[e>>>0,(V=e,+F(V)>=1?V>0?(0|U(+P(V/4294967296),4294967295))>>>0:~~+C((V-+(~~V>>>0))/4294967296)>>>0:0)],v[A>>2]=H[0],v[A+4>>2]=H[1];break;case"float":m[A>>2]=e;break;case"double":k[A>>3]=e;break;default:fA("invalid type for setValue: "+r)}},r.getValue=function(A,e,r){switch("*"===(e=e||"i8").charAt(e.length-1)&&(e="i32"),e){case"i1":case"i8":return p[A>>0];case"i16":return b[A>>1];case"i32":case"i64":return v[A>>2];case"float":return m[A>>2];case"double":return k[A>>3];default:fA("invalid type for getValue: "+e)}return null},r.getTempRet0=u,R){z(R)||(K=R,R=r.locateFile?r.locateFile(K,o):o+K),G++,r.monitorRunDependencies&&r.monitorRunDependencies(G);var tA=function(A){A.byteLength&&(A=new Uint8Array(A)),B.set(A,8),r.memoryInitializerRequest&&delete r.memoryInitializerRequest.response,function(A){if(G--,r.monitorRunDependencies&&r.monitorRunDependencies(G),0==G&&(null!==S&&(clearInterval(S),S=null),T)){var e=T;T=null,e()}}()},iA=function(){i(R,tA,(function(){throw"could not load memory initializer "+R}))},nA=J(R);if(nA)tA(nA.buffer);else if(r.memoryInitializerRequest){var oA=function(){var A=r.memoryInitializerRequest,e=A.response;if(200!==A.status&&0!==A.status){var t=J(r.memoryInitializerRequestURL);if(!t)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+A.status+", retrying "+R),void iA();e=t.buffer}tA(e)};r.memoryInitializerRequest.response?setTimeout(oA,0):r.memoryInitializerRequest.addEventListener("load",oA)}else iA()}function aA(A){function e(){X||(X=!0,l||(E(D),E(_),r.onRuntimeInitialized&&r.onRuntimeInitialized(),function(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)A=r.postRun.shift(),I.unshift(A);var A;E(I)}()))}A=A||n,G>0||(!function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)A=r.preRun.shift(),x.unshift(A);var A;E(x)}(),G>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),e()}),1)):e()))}function fA(A){throw r.onAbort&&r.onAbort(A),a(A+=""),f(A),l=!0,"abort("+A+"). Build with -s ASSERTIONS=1 for more info."}if(T=function A(){X||aA(),X||(T=A)},r.run=aA,r.abort=fA,r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return aA(),A}("object"==typeof t?t:{}),i="number",n={};[["sizeOfH3Index",i],["sizeOfGeoCoord",i],["sizeOfGeoBoundary",i],["sizeOfGeoPolygon",i],["sizeOfGeofence",i],["sizeOfLinkedGeoPolygon",i],["sizeOfCoordIJ",i],["h3IsValid",i,[i,i]],["geoToH3",i,[i,i,i]],["h3ToGeo",null,[i,i,i]],["h3ToGeoBoundary",null,[i,i,i]],["maxKringSize",i,[i]],["kRing",null,[i,i,i,i]],["kRingDistances",null,[i,i,i,i,i]],["hexRing",null,[i,i,i,i]],["maxPolyfillSize",i,[i,i]],["polyfill",null,[i,i,i]],["h3SetToLinkedGeo",null,[i,i,i]],["destroyLinkedPolygon",null,[i]],["compact",i,[i,i,i]],["uncompact",i,[i,i,i,i,i]],["maxUncompactSize",i,[i,i,i]],["h3IsPentagon",i,[i,i]],["h3IsResClassIII",i,[i,i]],["h3GetBaseCell",i,[i,i]],["h3GetResolution",i,[i,i]],["maxFaceCount",i,[i,i]],["h3GetFaces",null,[i,i,i]],["h3ToParent",i,[i,i,i]],["h3ToChildren",null,[i,i,i,i]],["h3ToCenterChild",i,[i,i,i]],["maxH3ToChildrenSize",i,[i,i,i]],["h3IndexesAreNeighbors",i,[i,i,i,i]],["getH3UnidirectionalEdge",i,[i,i,i,i]],["getOriginH3IndexFromUnidirectionalEdge",i,[i,i]],["getDestinationH3IndexFromUnidirectionalEdge",i,[i,i]],["h3UnidirectionalEdgeIsValid",i,[i,i]],["getH3IndexesFromUnidirectionalEdge",null,[i,i,i]],["getH3UnidirectionalEdgesFromHexagon",null,[i,i,i]],["getH3UnidirectionalEdgeBoundary",null,[i,i,i]],["h3Distance",i,[i,i,i,i]],["h3Line",i,[i,i,i,i,i]],["h3LineSize",i,[i,i,i,i]],["experimentalH3ToLocalIj",i,[i,i,i,i,i]],["experimentalLocalIjToH3",i,[i,i,i,i]],["hexAreaM2",i,[i]],["hexAreaKm2",i,[i]],["edgeLengthM",i,[i]],["edgeLengthKm",i,[i]],["pointDistM",i,[i,i]],["pointDistKm",i,[i,i]],["pointDistRads",i,[i,i]],["cellAreaM2",i,[i,i]],["cellAreaKm2",i,[i,i]],["cellAreaRads2",i,[i,i]],["exactEdgeLengthM",i,[i,i]],["exactEdgeLengthKm",i,[i,i]],["exactEdgeLengthRads",i,[i,i]],["numHexagons",i,[i]],["getRes0Indexes",null,[i]],["res0IndexCount",i],["getPentagonIndexes",null,[i,i]],["pentagonIndexCount",i]].forEach((function(A){n[A[0]]=t.cwrap.apply(t,A)}));var o=16,a=n.sizeOfH3Index(),f=n.sizeOfGeoCoord(),s=n.sizeOfGeoBoundary(),u=n.sizeOfGeoPolygon(),l=n.sizeOfGeofence(),h=n.sizeOfLinkedGeoPolygon(),c=n.sizeOfCoordIJ(),d={m:"m",m2:"m2",km:"km",km2:"km2",rads:"rads",rads2:"rads2"};function g(A){if("number"!=typeof A||A<0||A>15||Math.floor(A)!==A)throw new Error("Invalid resolution: "+A)}var w=/[^0-9a-fA-F]/;function p(A){if(Array.isArray(A)&&2===A.length&&Number.isInteger(A[0])&&Number.isInteger(A[1]))return A;if("string"!=typeof A||w.test(A))return[0,0];var e=parseInt(A.substring(0,A.length-8),o);return[parseInt(A.substring(A.length-8),o),e]}function B(A){if(A>=0)return A.toString(o);var e=v(8,(A&=2147483647).toString(o));return e=(parseInt(e[0],o)+8).toString(o)+e.substring(1)}function b(A,e){return B(e)+v(8,B(A))}function v(A,e){for(var r=A-e.length,t="",i=0;i=0&&r.push(n)}return r}(a,o);return t._free(a),f},r.h3GetResolution=function(A){var e=p(A),r=e[0],t=e[1];return n.h3IsValid(r,t)?n.h3GetResolution(r,t):-1},r.geoToH3=function(A,e,r){var i=t._malloc(f);t.HEAPF64.set([A,e].map(U),i/8);var o=M(n.geoToH3(i,r));return t._free(i),o},r.h3ToGeo=function(A){var e=t._malloc(f),r=p(A),i=r[0],o=r[1];n.h3ToGeo(i,o,e);var a=I(e);return t._free(e),a},r.h3ToGeoBoundary=function(A,e){var r=t._malloc(s),i=p(A),o=i[0],a=i[1];n.h3ToGeoBoundary(o,a,r);var f=C(r,e,e);return t._free(r),f},r.h3ToParent=function(A,e){var r=p(A),t=r[0],i=r[1];return M(n.h3ToParent(t,i,e))},r.h3ToChildren=function(A,e){if(!P(A))return[];var r=p(A),i=r[0],o=r[1],f=n.maxH3ToChildrenSize(i,o,e),s=t._calloc(f,a);n.h3ToChildren(i,o,e,s);var u=E(s,f);return t._free(s),u},r.h3ToCenterChild=function(A,e){var r=p(A),t=r[0],i=r[1];return M(n.h3ToCenterChild(t,i,e))},r.kRing=function(A,e){var r=p(A),i=r[0],o=r[1],f=n.maxKringSize(e),s=t._calloc(f,a);n.kRing(i,o,e,s);var u=E(s,f);return t._free(s),u},r.kRingDistances=function(A,e){var r=p(A),i=r[0],o=r[1],f=n.maxKringSize(e),s=t._calloc(f,a),u=t._calloc(f,4);n.kRingDistances(i,o,e,s,u);for(var l=[],h=0;h0){r=t._calloc(i,l);for(var f=0;f0){for(var n=t.getValue(A+r,"i32"),o=0;o */ +r.read=function(A,e,r,t,i){var n,o,a=8*i-t-1,f=(1<>1,u=-7,l=r?i-1:0,h=r?-1:1,c=A[e+l];for(l+=h,n=c&(1<<-u)-1,c>>=-u,u+=a;u>0;n=256*n+A[e+l],l+=h,u-=8);for(o=n&(1<<-u)-1,n>>=-u,u+=t;u>0;o=256*o+A[e+l],l+=h,u-=8);if(0===n)n=1-s;else{if(n===f)return o?NaN:1/0*(c?-1:1);o+=Math.pow(2,t),n-=s}return(c?-1:1)*o*Math.pow(2,n-t)},r.write=function(A,e,r,t,i,n){var o,a,f,s=8*n-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,c=t?0:n-1,d=t?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),(e+=o+l>=1?h/f:h*Math.pow(2,1-l))*f>=2&&(o++,f/=2),o+l>=u?(a=0,o=u):o+l>=1?(a=(e*f-1)*Math.pow(2,i),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;A[r+c]=255&a,c+=d,a/=256,i-=8);for(o=o<0;A[r+c]=255&o,c+=d,o/=256,s-=8);A[r+c-d]|=128*g}},{}],9:[function(A,e,r){"use strict";e.exports=i;var t=A("ieee754");function i(A){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(A)?A:new Uint8Array(A||0),this.pos=0,this.type=0,this.length=this.buf.length}i.Varint=0,i.Fixed64=1,i.Bytes=2,i.Fixed32=5;var n=4294967296,o=1/n,a="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function f(A){return A.type===i.Bytes?A.readVarint()+A.pos:A.pos+1}function s(A,e,r){return r?4294967296*e+(A>>>0):4294967296*(e>>>0)+(A>>>0)}function u(A,e,r){var t=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(t);for(var i=r.pos-1;i>=A;i--)r.buf[i+t]=r.buf[i]}function l(A,e){for(var r=0;r>>8,A[r+2]=e>>>16,A[r+3]=e>>>24}function k(A,e){return(A[e]|A[e+1]<<8|A[e+2]<<16)+(A[e+3]<<24)}i.prototype={destroy:function(){this.buf=null},readFields:function(A,e,r){for(r=r||this.length;this.pos>3,n=this.pos;this.type=7&t,A(i,e,this),this.pos===n&&this.skip(t)}return e},readMessage:function(A,e){return this.readFields(A,e,this.readVarint()+this.pos)},readFixed32:function(){var A=v(this.buf,this.pos);return this.pos+=4,A},readSFixed32:function(){var A=k(this.buf,this.pos);return this.pos+=4,A},readFixed64:function(){var A=v(this.buf,this.pos)+v(this.buf,this.pos+4)*n;return this.pos+=8,A},readSFixed64:function(){var A=v(this.buf,this.pos)+k(this.buf,this.pos+4)*n;return this.pos+=8,A},readFloat:function(){var A=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,A},readDouble:function(){var A=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,A},readVarint:function(A){var e,r,t=this.buf;return e=127&(r=t[this.pos++]),r<128?e:(e|=(127&(r=t[this.pos++]))<<7,r<128?e:(e|=(127&(r=t[this.pos++]))<<14,r<128?e:(e|=(127&(r=t[this.pos++]))<<21,r<128?e:function(A,e,r){var t,i,n=r.buf;if(i=n[r.pos++],t=(112&i)>>4,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<3,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<10,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<17,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<24,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(1&i)<<31,i<128)return s(A,t,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=t[this.pos]))<<28,A,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var A=this.readVarint();return A%2==1?(A+1)/-2:A/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var A=this.readVarint()+this.pos,e=this.pos;return this.pos=A,A-e>=12&&a?function(A,e,r){return a.decode(A.subarray(e,r))}(this.buf,e,A):function(A,e,r){var t="",i=e;for(;i239?4:f>223?3:f>191?2:1;if(i+u>r)break;1===u?f<128&&(s=f):2===u?128==(192&(n=A[i+1]))&&(s=(31&f)<<6|63&n)<=127&&(s=null):3===u?(n=A[i+1],o=A[i+2],128==(192&n)&&128==(192&o)&&((s=(15&f)<<12|(63&n)<<6|63&o)<=2047||s>=55296&&s<=57343)&&(s=null)):4===u&&(n=A[i+1],o=A[i+2],a=A[i+3],128==(192&n)&&128==(192&o)&&128==(192&a)&&((s=(15&f)<<18|(63&n)<<12|(63&o)<<6|63&a)<=65535||s>=1114112)&&(s=null)),null===s?(s=65533,u=1):s>65535&&(s-=65536,t+=String.fromCharCode(s>>>10&1023|55296),s=56320|1023&s),t+=String.fromCharCode(s),i+=u}return t}(this.buf,e,A)},readBytes:function(){var A=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,A);return this.pos=A,e},readPackedVarint:function(A,e){if(this.type!==i.Bytes)return A.push(this.readVarint(e));var r=f(this);for(A=A||[];this.pos127;);else if(e===i.Bytes)this.pos=this.readVarint()+this.pos;else if(e===i.Fixed32)this.pos+=4;else{if(e!==i.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(A,e){this.writeVarint(A<<3|e)},realloc:function(A){for(var e=this.length||16;e268435455||A<0?function(A,e){var r,t;A>=0?(r=A%4294967296|0,t=A/4294967296|0):(t=~(-A/4294967296),4294967295^(r=~(-A%4294967296))?r=r+1|0:(r=0,t=t+1|0));if(A>=0x10000000000000000||A<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(A,e,r){r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos]=127&A}(r,0,e),function(A,e){var r=(7&A)<<4;if(e.buf[e.pos++]|=r|((A>>>=3)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;e.buf[e.pos++]=127&A}(t,e)}(A,this):(this.realloc(4),this.buf[this.pos++]=127&A|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=A>>>7&127))))},writeSVarint:function(A){this.writeVarint(A<0?2*-A-1:2*A)},writeBoolean:function(A){this.writeVarint(Boolean(A))},writeString:function(A){A=String(A),this.realloc(4*A.length),this.pos++;var e=this.pos;this.pos=function(A,e,r){for(var t,i,n=0;n55295&&t<57344){if(!i){t>56319||n+1===e.length?(A[r++]=239,A[r++]=191,A[r++]=189):i=t;continue}if(t<56320){A[r++]=239,A[r++]=191,A[r++]=189,i=t;continue}t=i-55296<<10|t-56320|65536,i=null}else i&&(A[r++]=239,A[r++]=191,A[r++]=189,i=null);t<128?A[r++]=t:(t<2048?A[r++]=t>>6|192:(t<65536?A[r++]=t>>12|224:(A[r++]=t>>18|240,A[r++]=t>>12&63|128),A[r++]=t>>6&63|128),A[r++]=63&t|128)}return r}(this.buf,A,this.pos);var r=this.pos-e;r>=128&&u(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(A){this.realloc(4),t.write(this.buf,A,this.pos,!0,23,4),this.pos+=4},writeDouble:function(A){this.realloc(8),t.write(this.buf,A,this.pos,!0,52,8),this.pos+=8},writeBytes:function(A){var e=A.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&u(r,t,this),this.pos=r-1,this.writeVarint(t),this.pos+=t},writeMessage:function(A,e,r){this.writeTag(A,i.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(A,e){e.length&&this.writeMessage(A,l,e)},writePackedSVarint:function(A,e){e.length&&this.writeMessage(A,h,e)},writePackedBoolean:function(A,e){e.length&&this.writeMessage(A,g,e)},writePackedFloat:function(A,e){e.length&&this.writeMessage(A,c,e)},writePackedDouble:function(A,e){e.length&&this.writeMessage(A,d,e)},writePackedFixed32:function(A,e){e.length&&this.writeMessage(A,w,e)},writePackedSFixed32:function(A,e){e.length&&this.writeMessage(A,p,e)},writePackedFixed64:function(A,e){e.length&&this.writeMessage(A,B,e)},writePackedSFixed64:function(A,e){e.length&&this.writeMessage(A,b,e)},writeBytesField:function(A,e){this.writeTag(A,i.Bytes),this.writeBytes(e)},writeFixed32Field:function(A,e){this.writeTag(A,i.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(A,e){this.writeTag(A,i.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(A,e){this.writeTag(A,i.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(A,e){this.writeTag(A,i.Fixed64),this.writeSFixed64(e)},writeVarintField:function(A,e){this.writeTag(A,i.Varint),this.writeVarint(e)},writeSVarintField:function(A,e){this.writeTag(A,i.Varint),this.writeSVarint(e)},writeStringField:function(A,e){this.writeTag(A,i.Bytes),this.writeString(e)},writeFloatField:function(A,e){this.writeTag(A,i.Fixed32),this.writeFloat(e)},writeDoubleField:function(A,e){this.writeTag(A,i.Fixed64),this.writeDouble(e)},writeBooleanField:function(A,e){this.writeVarintField(A,Boolean(e))}}},{ieee754:8}],10:[function(A,e,r){var t=A("pbf"),i=A("./lib/geojson_wrapper");function n(A){var e=new t;return function(A,e){for(var r in A.layers)e.writeMessage(3,o,A.layers[r])}(A,e),e.finish()}function o(A,e){var r;e.writeVarintField(15,A.version||1),e.writeStringField(1,A.name||""),e.writeVarintField(5,A.extent||4096);var t={keys:[],values:[],keycache:{},valuecache:{}};for(r=0;r>31}function l(A,e){for(var r=A.loadGeometry(),t=A.type,i=0,n=0,o=r.length,a=0;anew Promise(((r,t)=>{var i;r((i=e,{type:"FeatureCollection",features:A.cells.map((A=>{const e={properties:A,geometry:{type:i.geometry_type,coordinates:i.generate(A.h3id)}};return i.promoteID||(e.id=parseInt(A.h3id,16)),e}))}))})),a=A=>{const e=["type","data","maxzoom","attribution","buffer","filter","tolerance","cluster","clusterRadius","clusterMaxZoom","clusterMinPoints","clusterProperties","lineMetrics","generateId","promoteId"];return f(A,((A,r)=>e.includes(A)))},f=(A,e)=>Object.fromEntries(Object.entries(A).filter((([A,r])=>e(A,r))));t.Map.prototype.addH3TSource=function(A,e){const r=Object.assign({},n,e,{type:"vector",format:"pbf"});r.generate=A=>"Polygon"===r.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),r.promoteId&&(r.promoteId="h3id"),t.addProtocol("h3tiles",((A,e)=>{const t=`http${!1===r.https?"":"s"}://${A.url.split("://")[1]}`,n=A.url.split(/\/|\./i),a=n.length,f=n.slice(a-4,a-1).map((A=>1*A)),s=new AbortController,u=s.signal;let l;r.timeout>0&&setTimeout((()=>s.abort()),r.timeout),fetch(t,{signal:u}).then((A=>{if(A.ok)return l=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,r))).then((A=>{const t=i.tovt(A).getTile(...f),n={};n[r.sourcelayer]=t;const o=i.topbf.fromGeojsonVt(n,{version:2});r.debug&&console.log(`${f}: ${A.features.length} features, ${(performance.now()-l).toFixed(0)} ms`),e(null,o,null,null)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Tile .../${f.join("/")}.h3t is taking too long to fetch`),e(new Error(A))}))})),this.addSource(A,(A=>{const e=["type","url","tiles","bounds","scheme","minzoom","maxzoom","attribution","promoteId","volatile"];return f(A,((A,r)=>e.includes(A)))})(r))};t.Map.prototype.addH3JSource=function(A,e){const r=new AbortController,t=r.signal,f=Object.assign({},n,e,{type:"geojson"});let s;if(f.generate=A=>"Polygon"===f.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),f.promoteId&&(f.promoteId="h3id"),f.timeout>0&&setTimeout((()=>r.abort()),f.timeout),"string"==typeof f.data)return f.timeout>0&&setTimeout((()=>r.abort()),f.timeout),new Promise(((e,r)=>{fetch(f.data,{signal:t}).then((A=>{if(A.ok)return s=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,f))).then((r=>{f.data=r,this.addSource(A,a(f)),f.debug&&console.log(`${r.features.length} features, ${(performance.now()-s).toFixed(0)} ms`),e(this)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Source file ${f.data} is taking too long to fetch`),console.error(A.message)}))}));o(f.data,f).then((e=>(f.data=e,this.addSource(A,a(f)),new Promise(((A,e)=>A(this))))))};t.Map.prototype.setH3JData=function(A,e,r){const t=Object.assign({},n,r);t.generate=A=>"Polygon"===t.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),t.promoteId&&(t.promoteId="h3id");const a=new AbortController,f=a.signal,s=this.getSource(A);let u;"string"==typeof e?(t.timeout>0&&setTimeout((()=>a.abort()),t.timeout),fetch(e,{signal:f}).then((A=>{if(A.ok)return u=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,t))).then((A=>{s.setData(A),t.debug&&console.log(`${A.features.length} features, ${(performance.now()-u).toFixed(0)} ms`)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Data file ${e} is taking too long to fetch`),console.error(A.message)}))):o(e,t).then((A=>s.setData(A)))}},{"geojson-vt":6,"h3-js":7,"vt-pbf":10}]},{},[12])(12)})); \ No newline at end of file diff --git a/docs/articles/layers-overview_files/layers-control-1.0.0/filter-control.css b/docs/articles/layers-overview_files/layers-control-1.0.0/filter-control.css new file mode 100644 index 00000000..e6096c34 --- /dev/null +++ b/docs/articles/layers-overview_files/layers-control-1.0.0/filter-control.css @@ -0,0 +1,65 @@ +.filter-control { + background: #fff; + position: absolute; + z-index: 1; + border-radius: 3px; + width: 200px; + border: 1px solid rgba(0, 0, 0, 0.4); + font-family: 'Open Sans', sans-serif; + margin: 10px; + padding: 10px; +} + +.filter-control .filter-title { + font-weight: bold; + margin-bottom: 10px; + text-align: center; +} + +.filter-control input[type="range"] { + width: 100%; + margin: 10px 0; +} + +.filter-control .range-value { + text-align: center; + margin-top: 5px; +} + +.filter-control .checkbox-group { + display: flex; + flex-direction: column; + gap: 5px; +} + +.filter-control .checkbox-group label { + display: flex; + align-items: center; + gap: 5px; +} + +.filter-control .toggle-button { + background: darkgrey; + color: #ffffff; + text-align: center; + cursor: pointer; + padding: 5px 0; + border-radius: 3px 3px 0 0; + margin: -10px -10px 10px -10px; +} + +.filter-control .toggle-button:hover { + background: grey; +} + +.filter-control .filter-content { + display: block; +} + +.filter-control.collapsible .filter-content { + display: none; +} + +.filter-control.collapsible.open .filter-content { + display: block; +} \ No newline at end of file diff --git a/docs/articles/layers-overview_files/layers-control-1.0.0/layers-control.css b/docs/articles/layers-overview_files/layers-control-1.0.0/layers-control.css index 07ebdcc1..85512288 100644 --- a/docs/articles/layers-overview_files/layers-control-1.0.0/layers-control.css +++ b/docs/articles/layers-overview_files/layers-control-1.0.0/layers-control.css @@ -2,11 +2,14 @@ background: #fff; position: absolute; z-index: 1; - border-radius: 3px; + border-radius: 4px; width: 120px; - border: 1px solid rgba(0, 0, 0, 0.4); - font-family: 'Open Sans', sans-serif; - margin: 10px; + border: 1px solid rgba(0, 0, 0, 0.15); + font-family: "Open Sans", sans-serif; + margin: 0px; + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); + overflow: hidden; + transition: all 0.2s ease-in-out; } .layers-control a { @@ -14,11 +17,12 @@ color: #404040; display: block; margin: 0; - padding: 0; padding: 10px; text-decoration: none; - border-bottom: 1px solid rgba(0, 0, 0, 0.25); + border-bottom: 1px solid rgba(0, 0, 0, 0.1); text-align: center; + transition: all 0.15s ease-in-out; + font-weight: normal; } .layers-control a:last-child { @@ -27,32 +31,35 @@ .layers-control a:hover { background-color: #f8f8f8; - color: #404040; + color: #1a1a1a; } .layers-control a.active { - background-color: darkgrey; + background-color: #4a90e2; color: #ffffff; + font-weight: 500; } .layers-control a.active:hover { - background: grey; + background: #3b7ed2; } .layers-control .toggle-button { display: none; - background: darkgrey; + background: #4a90e2; color: #ffffff; text-align: center; cursor: pointer; - padding: 5px 0; - border-radius: 3px 3px 0 0; - + padding: 8px 0; + border-radius: 4px 4px 0 0; + font-weight: 500; + letter-spacing: 0.3px; + box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05) inset; + transition: all 0.15s ease-in-out; } - .layers-control .toggle-button:hover { - background: grey; + background: #3b7ed2; } .layers-control .layers-list { @@ -66,8 +73,51 @@ .layers-control.collapsible .layers-list { display: none; + opacity: 0; + max-height: 0; + transition: + opacity 0.25s ease, + max-height 0.25s ease; } .layers-control.collapsible.open .layers-list { display: block; + opacity: 1; + max-height: 500px; /* Large enough value to accommodate all content */ +} + +/* Compact icon styling */ +.layers-control.collapsible.icon-only { + width: auto; + min-width: 36px; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); + transform: translateZ( + 0 + ); /* Force hardware acceleration for smoother animations */ +} + +.layers-control.collapsible.icon-only .toggle-button { + border-radius: 4px; + padding: 8px; + width: 36px; + height: 36px; + box-sizing: border-box; + margin: 0; + border-bottom: none; + display: flex; + align-items: center; + justify-content: center; + box-shadow: none; +} + +.layers-control.collapsible.icon-only.open { + width: 120px; + box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25); +} + +.layers-control.collapsible.icon-only.open .toggle-button { + border-radius: 4px 4px 0 0; + border-bottom: 1px solid rgba(0, 0, 0, 0.1); + width: 100%; } diff --git a/docs/articles/layers-overview_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js b/docs/articles/layers-overview_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js new file mode 100644 index 00000000..510cfcca --- /dev/null +++ b/docs/articles/layers-overview_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js @@ -0,0 +1,1897 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js new file mode 100644 index 00000000..1a2fb15e --- /dev/null +++ b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js @@ -0,0 +1,2102 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/mapboxgl-binding-0.2.0/mapboxgl.js b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.0/mapboxgl.js new file mode 100644 index 00000000..510cfcca --- /dev/null +++ b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.0/mapboxgl.js @@ -0,0 +1,1897 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/mapboxgl-binding-0.2.1/mapboxgl.js b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.1/mapboxgl.js new file mode 100644 index 00000000..1a2fb15e --- /dev/null +++ b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.1/mapboxgl.js @@ -0,0 +1,2102 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js new file mode 100644 index 00000000..fc5462ee --- /dev/null +++ b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js @@ -0,0 +1,2684 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case 'get': + return properties[expression[1]]; + case 'concat': + return expression.slice(1).map(item => evaluateExpression(item, properties)).join(''); + case 'to-string': + return String(evaluateExpression(expression[1], properties)); + case 'to-number': + return Number(evaluateExpression(expression[1], properties)); + case 'number-format': + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || 'en-US'; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty('min-fraction-digits')) { + formatOptions.minimumFractionDigits = options['min-fraction-digits']; + } + if (options.hasOwnProperty('max-fraction-digits')) { + formatOptions.maximumFractionDigits = options['max-fraction-digits']; + } + if (options.hasOwnProperty('min-integer-digits')) { + formatOptions.minimumIntegerDigits = options['min-integer-digits']; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty('useGrouping')) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(tooltipProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + window._mapboxPopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layerId] === popup) { + delete window._mapboxPopups[layerId]; + } + }); +} + +// Helper function to generate draw styles based on parameters +function generateDrawStyles(styling) { + if (!styling) return null; + + return [ + // Point styles + { + 'id': 'gl-draw-point-active', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'true']], + 'paint': { + 'circle-radius': styling.vertex_radius + 2, + 'circle-color': styling.active_color + } + }, + { + 'id': 'gl-draw-point', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'false']], + 'paint': { + 'circle-radius': styling.vertex_radius, + 'circle-color': styling.point_color + } + }, + // Line styles + { + 'id': 'gl-draw-line', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'LineString']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Polygon fill + { + 'id': 'gl-draw-polygon-fill', + 'type': 'fill', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'paint': { + 'fill-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-outline-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-opacity': styling.fill_opacity + } + }, + // Polygon outline + { + 'id': 'gl-draw-polygon-stroke', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Midpoints + { + 'id': 'gl-draw-polygon-midpoint', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'midpoint']], + 'paint': { + 'circle-radius': 3, + 'circle-color': styling.active_color + } + }, + // Vertex point halos + { + 'id': 'gl-draw-vertex-halo-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 4, + styling.vertex_radius + 2 + ], + 'circle-color': '#FFF' + } + }, + // Vertex points + { + 'id': 'gl-draw-vertex-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 2, + styling.vertex_radius + ], + 'circle-color': styling.active_color + } + } + ]; +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, layer.popup, layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + // Set rain effect if provided + if (x.rain) { + map.setRain(x.rain); + } + + // Set snow effect if provided + if (x.snow) { + map.setSnow(x.snow); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + // Generate styles if styling parameters provided + if (x.draw_control.styling) { + const generatedStyles = generateDrawStyles(x.draw_control.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (x.draw_control.source) { + addSourceFeaturesToDraw(draw, x.draw_control.source, map); + } + + // Process any queued features + if (x.draw_features_queue) { + x.draw_features_queue.forEach(function(data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn('Source not found or has no data:', sourceId); + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + // Initialize with empty object, will be populated after map loads + let initialView = {}; + + // Capture the initial view after the map has loaded and all view operations are complete + map.once('load', function() { + initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + }); + + resetControl.onclick = function () { + // Only reset if we have captured the initial view + if (initialView.center) { + map.easeTo(initialView); + } + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDraw: function () { + return draw; // Return the draw instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + + // Helper function to update drawn features + function updateDrawnFeatures() { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + var drawnFeatures = drawControl.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(drawnFeatures) + ); + } + // Store drawn features in the widget's data + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, message.layer.popup, message.layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + if (window._mapboxPopups && window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer] + ) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll('style[data-mapgl-legend-css]'); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + // Identify user-added sources (those not in the original style) + // We'll assume any source that's not "composite", "mapbox", or starts with "mapbox-" is user-added + for (const sourceId in currentStyle.sources) { + if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") + ) { + userSourceIds.push(sourceId); + const source = currentStyle.sources[sourceId]; + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + } + + // Identify layers using user-added sources + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source)) { + userLayers.push(layer); + } + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + }); + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + // Create the draw control + var drawControl = new MapboxDraw(drawOptions); + map.addControl(drawControl, message.position); + map.controls.push(drawControl); + + // Store the draw control on the widget for later access + widget.drawControl = drawControl; + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(drawControl, message.source, map); + } + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + const features = drawControl.getAll(); + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + drawControl.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_features_to_draw") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + if (message.data.clear_existing) { + drawControl.deleteAll(); + } + addSourceFeaturesToDraw(drawControl, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn('Draw control not initialized'); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + // Remove all legend elements + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + + // Clean up any legend styles associated with this map + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => { + style.remove(); + }); + } + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_popup") { + const layerId = message.layer; + const newPopupProperty = message.popup; + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + delete window._mapboxPopups[layerId]; + } + + // Remove old click handler if any + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + delete window._mapboxClickHandlers[layerId]; + } + + // Remove old hover handlers for cursor change + map.off("mouseenter", layerId); + map.off("mouseleave", layerId); + + // Create new click handler + const clickHandler = function (e) { + onClickPopup(e, map, newPopupProperty, layerId); + }; + + // Add the new event handler + map.on("click", layerId, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_rain") { + if (message.rain) { + map.setRain(message.rain); + } else { + map.setRain(null); + } + } else if (message.type === "set_snow") { + if (message.snow) { + map.setSnow(message.snow); + } else { + map.setSnow(null); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/mapboxgl-binding-0.2.2/mapboxgl.js b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.2/mapboxgl.js new file mode 100644 index 00000000..faedbb1b --- /dev/null +++ b/docs/articles/layers-overview_files/mapboxgl-binding-0.2.2/mapboxgl.js @@ -0,0 +1,2367 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[layer.id]) { + window._mapboxPopups[layer.id].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layer.id] === popup) { + delete window._mapboxPopups[layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + // Set rain effect if provided + if (x.rain) { + map.setRain(x.rain); + } + + // Set snow effect if provided + if (x.snow) { + map.setSnow(x.snow); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[message.layer.popup]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[message.layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[message.layer.id] === popup) { + delete window._mapboxPopups[message.layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + if (window._mapboxPopups && window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer] + ) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll('style[data-mapgl-legend-css]'); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + // Identify user-added sources (those not in the original style) + // We'll assume any source that's not "composite", "mapbox", or starts with "mapbox-" is user-added + for (const sourceId in currentStyle.sources) { + if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") + ) { + userSourceIds.push(sourceId); + const source = currentStyle.sources[sourceId]; + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + } + + // Identify layers using user-added sources + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source)) { + userLayers.push(layer); + } + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + }); + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + // Remove all legend elements + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + + // Clean up any legend styles associated with this map + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => { + style.remove(); + }); + } + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_rain") { + if (message.rain) { + map.setRain(message.rain); + } else { + map.setRain(null); + } + } else if (message.type === "set_snow") { + if (message.snow) { + map.setSnow(message.snow); + } else { + map.setSnow(null); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.0.0/LICENSE.txt b/docs/articles/layers-overview_files/maplibre-gl-5.0.0/LICENSE.txt new file mode 100644 index 00000000..1e8acbb5 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.0.0/LICENSE.txt @@ -0,0 +1,116 @@ +Copyright (c) 2023, MapLibre contributors + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of MapLibre GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from mapbox-gl-js v1.13 and earlier + +Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license + +Copyright (c) 2020, Mapbox +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Mapbox GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from glfx.js + +Copyright (C) 2011 by Evan Wallace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +Contains a portion of d3-color https://github.com/d3/d3-color + +Copyright 2010-2016 Mike Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.0.0/maplibre-gl.css b/docs/articles/layers-overview_files/maplibre-gl-5.0.0/maplibre-gl.css new file mode 100644 index 00000000..f0162fd1 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.0.0/maplibre-gl.css @@ -0,0 +1 @@ +.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.0.0/maplibre-gl.js b/docs/articles/layers-overview_files/maplibre-gl-5.0.0/maplibre-gl.js new file mode 100644 index 00000000..f7f839bc --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.0.0/maplibre-gl.js @@ -0,0 +1,59 @@ +/** + * MapLibre GL JS + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.0.0/LICENSE.txt + */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); +})(this, (function () { 'use strict'; + +/* eslint-disable */ + +var maplibregl = {}; +var modules = {}; +function define(moduleName, _dependencies, moduleFactory) { + modules[moduleName] = moduleFactory; + + // to get the list of modules see generated dist/maplibre-gl-dev.js file (look for `define(` calls) + if (moduleName !== 'index') { + return; + } + + // we assume that when an index module is initializing then other modules are loaded already + var workerBundleString = 'var sharedModule = {}; (' + modules.shared + ')(sharedModule); (' + modules.worker + ')(sharedModule);' + + var sharedModule = {}; + // the order of arguments of a module factory depends on rollup (it decides who is whose dependency) + // to check the correct order, see dist/maplibre-gl-dev.js file (look for `define(` calls) + // we assume that for our 3 chunks it will generate 3 modules and their order is predefined like the following + modules.shared(sharedModule); + modules.index(maplibregl, sharedModule); + + if (typeof window !== 'undefined') { + maplibregl.setWorkerUrl(window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }))); + } + + return maplibregl; +}; + + + +define("shared",["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t));}catch(t){s(t);}}function o(t){try{l(n.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(a,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n,i;function s(){if(i)return n;function t(t,e){this.x=t,this.y=e;}return i=1,n=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},n}"function"==typeof SuppressedError&&SuppressedError;var a,o,l=r(s()),u=function(){if(o)return a;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return o=1,a=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},a}(),c=r(u);let h,p;function f(){return null==h&&(h="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),h}function d(){if(null==p&&(p=!1,f())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function B(t,e,r,n){const i=new c(t,e,r,n);return t=>i.solve(t)}const V=B(.25,.1,.25,1);function E(t,e,r){return Math.min(r,Math.max(e,t))}function T(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function F(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let $=1;function L(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function D(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function O(t){return Array.isArray(t)?t.map(O):"object"==typeof t&&t?L(t,O):t}const R={};function j(t){R[t]||("undefined"!=typeof console&&console.warn(t),R[t]=!0);}function N(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function U(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let q=null;function G(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const Z="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function X(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,r,n,i){const s=4*Math.max(-e,0),a=(Math.max(0,r)-r)*n*4+s,o=4*n,l=Math.max(0,e),u=Math.max(0,r);return {rect:{x:l,y:u,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-u},layout:[{offset:a,stride:o}]}}(t,r,n,i,s)),o)for(let t=0;tU(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,it=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=tt(t.url);if(e)return e(t,r);if(U(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:et},r)}if(!(/^file:/.test(n=t.url)||/^file:/.test(nt())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:nt(),signal:r.signal});let n,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e);}catch(e){throw new rt(0,e.message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new rt(n.status,n.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw W();return {data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(U(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:et},r)}var n;return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new rt(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),n(W());})),s.send(t.body);}))}(t,r)};function st(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function at(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function ot(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class lt{constructor(t,e={}){F(this,e),this.type=t;}}class ut extends lt{constructor(t,e={}){super("error",F({error:t},e));}}class ct{on(t,e){return this._listeners=this._listeners||{},at(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e);}}}off(t,e){return ot(t,e,this._listeners),ot(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},at(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new lt(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)ot(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(F(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof ut&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var ht={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const pt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ft(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return pt.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function dt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Nt=[It,zt,Pt,Ct,Bt,Vt,$t,Et,Rt(Tt),Lt,Dt,Ot];function Ut(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ut(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Nt)if(!Ut(t,e))return null}return `Expected ${jt(t)} but found ${jt(e)} instead.`}function qt(t,e){return e.some((e=>e.kind===t.kind))}function Gt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function Zt(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Xt=.96422,Kt=.82521,Ht=4/29,Yt=6/29,Jt=3*Yt*Yt,Wt=Yt*Yt*Yt,Qt=Math.PI/180,te=180/Math.PI;function ee(t){return (t%=360)<0&&(t+=360),t}function re([t,e,r,n]){let i,s;const a=ie((.2225045*(t=ne(t))+.7168786*(e=ne(e))+.0606169*(r=ne(r)))/1);t===e&&e===r?i=s=a:(i=ie((.4360747*t+.3850649*e+.1430804*r)/Xt),s=ie((.0139322*t+.0971045*e+.7141733*r)/Kt));const o=116*a-16;return [o<0?0:o,500*(i-a),200*(a-s),n]}function ne(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ie(t){return t>Wt?Math.pow(t,1/3):t/Jt+Ht}function se([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*oe(i),s=Xt*oe(s),a=Kt*oe(a),[ae(3.1338561*s-1.6168667*i-.4906146*a),ae(-.9787684*s+1.9161415*i+.033454*a),ae(.0719453*s-.2289914*i+1.4052427*a),n]}function ae(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function oe(t){return t>Yt?t*t*t:Jt*(t-Ht)}function le(t){return parseInt(t.padEnd(2,t),16)/255}function ue(t,e){return ce(e?t/100:t,0,1)}function ce(t,e,r){return Math.min(Math.max(e,t),r)}function he(t){return !t.some(Number.isNaN)}const pe={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function fe(t,e,r){return t+r*(e-t)}function de(t,e,r){return t.map(((t,n)=>fe(t,e[n],r)))}class ye{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof ye)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=pe[t];if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [le(t.slice(r,r+=e)),le(t.slice(r,r+=e)),le(t.slice(r,r+=e)),le(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[ce(+r/e,0,1),ce(+s/e,0,1),ce(+l/e,0,1),h?ue(+h,p):1];if(he(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,ce(+i,0,100),ce(+a,0,100),l?ue(+l,u):1];if(he(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=ee(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new ye(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=re(t),s=Math.sqrt(r*r+n*n);return [Math.round(1e4*s)?ee(Math.atan2(n,r)*te):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",re(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}static interpolate(t,e,r,n="rgb"){switch(n){case"rgb":{const[n,i,s,a]=de(t.rgb,e.rgb,r);return new ye(n,i,s,a,!1)}case"hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*Qt,se([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:fe(i,l,r),fe(s,u,r),fe(a,c,r)]);return new ye(f,d,y,m,!1)}case"lab":{const[n,i,s,a]=se(de(t.lab,e.lab,r));return new ye(n,i,s,a,!1)}}}}ye.black=new ye(0,0,0,1),ye.white=new ye(1,1,1,1),ye.transparent=new ye(0,0,0,0),ye.red=new ye(1,0,0,1);class me{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ge{constructor(t,e,r,n,i){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i;}}class xe{constructor(t){this.sections=t;}static fromString(t){return new xe([new ge(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof xe?t:xe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class ve{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof ve)return t;if("number"==typeof t)return new ve([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new ve(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new ve(de(t.values,e.values,r))}}class be{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}}const we=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class _e{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof _e)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Me(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Ae||t instanceof ye||t instanceof me||t instanceof xe||t instanceof ve||t instanceof _e||t instanceof Se)return !0;if(Array.isArray(t)){for(const e of t)if(!Me(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!Me(t[e]))return !1;return !0}return !1}function Ie(t){if(null===t)return It;if("string"==typeof t)return Pt;if("boolean"==typeof t)return Ct;if("number"==typeof t)return zt;if(t instanceof ye)return Bt;if(t instanceof Ae)return Vt;if(t instanceof me)return Ft;if(t instanceof xe)return $t;if(t instanceof ve)return Lt;if(t instanceof _e)return Ot;if(t instanceof Se)return Dt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=Ie(e);if(r){if(r===t)continue;r=Tt;break}r=t;}return Rt(r||Tt,e)}return Et}function ze(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ye||t instanceof Ae||t instanceof xe||t instanceof ve||t instanceof _e||t instanceof Se?t.toString():JSON.stringify(t)}class Pe{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Me(t[1]))return e.error("invalid value");const r=t[1];let n=Ie(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Pe(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}const Ce={string:Pt,number:zt,boolean:Ct,object:Et};class Be{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in Ce)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Ce[r],n++;}else i=Tt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=Rt(i,s);}else {if(!Ce[i])throw new Error(`Types doesn't contain name = ${i}`);r=Ce[i];}const s=[];for(;nt.outputDefined()))}}const Ve={"to-boolean":Ct,"to-color":Bt,"to-number":zt,"to-string":Pt};class Ee{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!Ve[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=Ve[r],i=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ke(e[0],e[1],e[2],e[3]),!r))return new ye(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new be(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=ve.parse(e);if(n)return n}throw new be(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=_e.parse(e);if(n)return n}throw new be(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new be(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return xe.fromString(ze(this.args[0].evaluate(t)));case"resolvedImage":return Se.fromString(ze(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return ze(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function Te(t,e,r=0,n=t.length-1,i=$e){for(;n>r;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Te(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(Fe(t,r,e),i(t[n],s)>0&&Fe(t,r,n);a0;)o--;}0===i(t[r],s)?Fe(t,r,o):(o++,Fe(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function Fe(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function $e(t,e){return te?1:0}function Le(t,e){if(t.length<=1)return [t];const r=[];let n,i;for(const e of t){const t=Oe(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e));}if(n&&r.push(n),e>1)for(let t=0;t`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new Be(e,[t]):"coerce"===r?new Ee(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("projectionDefinition"!==t.kind||"string"!==i.kind&&"array"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind)if("padding"!==t.kind||"value"!==i.kind&&"number"!==i.kind&&"array"!==i.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==i.kind&&"array"!==i.kind){if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof Pe)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Ne;try{n=new Pe(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new Ue(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new kt(r,t));}checkSubtype(t,e){const r=Ut(t,e);return r&&this.error(r),r}}class qe{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new be(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new be(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class Xe{constructor(t,e){this.type=Ct,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Tt),n=e.parse(t[2],2,Tt);return r&&n?qt(r.type,[Ct,Pt,zt,It,Tt])?new Xe(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${jt(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!Gt(e,["boolean","string","number","null"]))throw new be(`Expected first argument to be of type boolean, string, number or null, but found ${jt(Ie(e))} instead.`);if(!Gt(r,["string","array"]))throw new be(`Expected second argument to be of type array or string, but found ${jt(Ie(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class Ke{constructor(t,e,r){this.type=zt,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Tt),n=e.parse(t[2],2,Tt);if(!r||!n)return null;if(!qt(r.type,[Ct,Pt,zt,It,Tt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${jt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,zt);return i?new Ke(r,n,i):null}return new Ke(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Gt(e,["boolean","string","number","null"]))throw new be(`Expected first argument to be of type boolean, string, number or null, but found ${jt(Ie(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),Gt(r,["string"])){const t=r.indexOf(e,n);return -1===t?-1:[...r.slice(0,t)].length}if(Gt(r,["array"]))return r.indexOf(e,n);throw new be(`Expected second argument to be of type array or string, but found ${jt(Ie(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class He{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,Ie(t)))return null}else r=Ie(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,Tt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new He(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (Ie(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class Ye{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class Je{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Tt),n=e.parse(t[2],2,zt);if(!r||!n)return null;if(!qt(r.type,[Rt(Tt),Pt,Tt]))return e.error(`Expected first argument to be of type array or string, but found ${jt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,zt);return i?new Je(r.type,r,n,i):null}return new Je(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),Gt(e,["string"]))return [...e].slice(r,n).join("");if(Gt(e,["array"]))return e.slice(r,n);throw new be(`Expected first argument to be of type array or string, but found ${jt(Ie(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function We(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new be("Input is not a number.");a=o-1;}return 0}class Qe{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,zt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Qe(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[We(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function tr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var er,rr,nr=function(){if(rr)return er;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return rr=1,er=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},er}(),ir=tr(nr);class sr{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=ar(e,t.base,r,n);else if("linear"===t.name)i=ar(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new ir(s[0],s[1],s[2],s[3]).solve(ar(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,zt),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Bt:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return Zt(o,zt)||Zt(o,Vt)||Zt(o,Bt)||Zt(o,Lt)||Zt(o,Ot)||Zt(o,Rt(zt))?new sr(o,r,n,i,a):e.error(`Type ${jt(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=We(e,n),a=sr.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return fe(o,l,a);case"color":return ye.interpolate(o,l,a);case"padding":return ve.interpolate(o,l,a);case"variableAnchorOffsetCollection":return _e.interpolate(o,l,a);case"array":return de(o,l,a);case"projectionDefinition":return Ae.interpolate(o,l,a)}case"interpolate-hcl":return ye.interpolate(o,l,a,"hcl");case"interpolate-lab":return ye.interpolate(o,l,a,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function ar(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}const or={color:ye.interpolate,number:fe,padding:ve.interpolate,variableAnchorOffsetCollection:_e.interpolate,array:de};class lr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const s=n&&i.some((t=>Ut(n,t.type)));return new lr(s?Tt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof Se&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function ur(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function cr(t,e,r,n){return 0===n.compare(e,r)}function hr(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=Ct,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,Tt);if(!s)return null;if(!ur(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${jt(s.type)}'.`);let a=e.parse(t[2],2,Tt);if(!a)return null;if(!ur(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${jt(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${jt(s.type)}' and '${jt(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new Be(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new Be(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ft),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=Ie(s),r=Ie(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new be(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=Ie(s),r=Ie(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const pr=hr("==",(function(t,e,r){return e===r}),cr),fr=hr("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !cr(0,e,r,n)})),dr=hr("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),mr=hr("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),gr=hr(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class xr{constructor(t,e,r){this.type=Ft,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,Ct);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Ct);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,Pt),!s)?null:new xr(n,i,s)}evaluate(t){return new me(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class vr{constructor(t,e,r,n,i){this.type=Pt,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,zt);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,Pt),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Pt),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,zt),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,zt),!o)?null:new vr(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class br{constructor(t){this.type=$t,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,zt),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,Rt(Pt)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,Bt),!a))return null;const o=n[n.length-1];o.scale=t,o.font=r,o.textColor=a;}else {const s=e.parse(t[r],1,Tt);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new br(n)}evaluate(t){return new xe(this.sections.map((e=>{const r=e.content.evaluate(t);return Ie(r)===Dt?new ge("",r,null,null,null):new ge(ze(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor);}outputDefined(){return !1}}class wr{constructor(t){this.type=Dt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Pt);return r?new wr(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=Se.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class _r{constructor(t){this.type=zt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${jt(r.type)} instead.`):new _r(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new be(`Expected value to be of type string or array, but found ${jt(Ie(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const Sr=8192;function Ar(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*Sr),Math.round(n*i*Sr)]}function kr(t,e){const r=Math.pow(2,e.z);return [(i=(t[0]/Sr+e.x)/r,360*i-180),(n=(t[1]/Sr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i;}function Mr(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function Ir(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function zr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Pr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Fr(t,e,r,n)||!Fr(r,n,t,e));var i,s;}function Cr(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(a=o[e+1])[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}var i,s,a;return n}function Vr(t,e){for(const r of e)if(Br(t,r))return !0;return !1}function Er(t,e){for(const r of t)if(!Br(r,e))return !1;for(let r=0;r0&&o<0||a<0&&o>0}function $r(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Mr(e,t);}function Or(t,e,r,n){const i=Math.pow(2,n.z)*Sr,s=[n.x*Sr,n.y*Sr],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Dr(n,e,r,i),a.push(n);}return a}function Rr(t,e,r,n){const i=Math.pow(2,n.z)*Sr,s=[n.x*Sr,n.y*Sr],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Mr(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)Dr(n,e,r,i);}var o;return a}class jr{constructor(t,e){this.type=Ct,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Me(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n);}if(t.length)return new jr(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new jr(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new jr(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryDollarType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=$r(e.coordinates,n,i),a=Or(t.geometry(),r,n,i);if(!Ir(r,n))return !1;for(const t of a)if(!Br(t,s))return !1}if("MultiPolygon"===e.type){const s=Lr(e.coordinates,n,i),a=Or(t.geometry(),r,n,i);if(!Ir(r,n))return !1;for(const t of a)if(!Vr(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryDollarType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=$r(e.coordinates,n,i),a=Rr(t.geometry(),r,n,i);if(!Ir(r,n))return !1;for(const t of a)if(!Er(t,s))return !1}if("MultiPolygon"===e.type){const s=Lr(e.coordinates,n,i),a=Rr(t.geometry(),r,n,i);if(!Ir(r,n))return !1;for(const t of a)if(!Tr(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let Nr=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}};const Ur=1/298.257223563,qr=Ur*(2-Ur),Gr=Math.PI/180;class Zr{constructor(t){const e=6378.137*Gr*1e3,r=Math.cos(t*Gr),n=1/(1-qr*(1-r*r)),i=Math.sqrt(n);this.kx=e*i*r,this.ky=e*i*n*(1-qr);}distance(t,e){const r=this.wrap(t[0]-e[0])*this.kx,n=(t[1]-e[1])*this.ky;return Math.sqrt(r*r+n*n)}pointOnLine(t,e){let r,n,i,s,a=1/0;for(let o=0;o1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function Xr(t,e){return e[0]-t[0]}function Kr(t){return t[1]-t[0]+1}function Hr(t,e){return t[1]>=t[0]&&t[1]t[1])return [null,null];const r=Kr(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return [t,null];const n=Math.floor(r/2)-1;return [[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function Jr(t,e){if(!Hr(e,t.length))return [1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)Mr(r,t[n]);return r}function Wr(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)Mr(e,t);return e}function Qr(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function tn(t,e,r){if(!Qr(t)||!Qr(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Ir(i,s)){if(ln(t,e))return 0}else if(ln(e,t))return 0;let a=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=a.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(Kr(l)<=u){if(!Hr(l,t.length))return NaN;if(e){const e=on(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=an(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else {const r=Yr(l,e);cn(a,s,n,t,o,r[0]),cn(a,s,n,t,o,r[1]);}}return s}function fn(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new Nr([[0,[0,t.length-1],[0,r.length-1]]],Xr);for(;o.length>0;){const s=o.pop();if(s[0]>=a)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(Kr(l)<=c&&Kr(u)<=h){if(!Hr(l,t.length)&&Hr(u,r.length))return NaN;let s;if(e&&n)s=nn(t,l,r,u,i),a=Math.min(a,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=en(r[t],e,i),a=Math.min(a,s),0===a)return a}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=en(t[r],e,i),a=Math.min(a,s),0===a)return a}else s=sn(t,l,r,u,i),a=Math.min(a,s);}else {const s=Yr(l,e),c=Yr(u,n);hn(o,a,i,t,r,s[0],c[0]),hn(o,a,i,t,r,s[0],c[1]),hn(o,a,i,t,r,s[1],c[0]),hn(o,a,i,t,r,s[1],c[1]);}}return a}function dn(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class yn{constructor(t,e){this.type=zt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Me(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new yn(e,e.features.map((t=>dn(t.geometry))).flat());if("Feature"===e.type)return new yn(e,dn(e.geometry));if("type"in e&&"coordinates"in e)return new yn(e,dn(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>kr([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Zr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,fn(n,!1,[t.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,fn(n,!1,t.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,pn(n,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>kr([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Zr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,fn(n,!0,[t.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,fn(n,!0,t.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,pn(n,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Le(r,0).map((e=>e.map((e=>e.map((e=>kr([e.x,e.y],t.canonical))))))),i=new Zr(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case"Point":s=Math.min(s,pn([t.coordinates],!1,e,i,s));break;case"LineString":s=Math.min(s,pn(t.coordinates,!0,e,i,s));break;case"Polygon":s=Math.min(s,un(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}const mn={"==":pr,"!=":fr,">":yr,"<":dr,">=":gr,"<=":mr,array:Be,at:Ze,boolean:Be,case:Ye,coalesce:lr,collator:xr,format:br,image:wr,in:Xe,"index-of":Ke,interpolate:sr,"interpolate-hcl":sr,"interpolate-lab":sr,length:_r,let:qe,literal:Pe,match:He,number:Be,"number-format":vr,object:Be,slice:Je,step:Qe,string:Be,"to-boolean":Ee,"to-color":Ee,"to-number":Ee,"to-string":Ee,var:Ge,within:jr,distance:yn};class gn{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const r=t[0],n=gn.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new Ue(e.registry,_n,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(jt).join(", ")})`:`(${jt(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&_n(t):r&&t instanceof Pe;})),!!r&&Sn(t)&&kn(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Sn(t){if(t instanceof gn){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof jr)return !1;if(t instanceof yn)return !1;let e=!0;return t.eachChild((t=>{e&&!Sn(t)&&(e=!1);})),e}function An(t){if(t instanceof gn&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!An(t)&&(e=!1);})),e}function kn(t,e){if(t instanceof gn&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!kn(t,e)&&(r=!1);})),r}function Mn(t){return {result:"success",value:t}}function In(t){return {result:"error",value:t}}function zn(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Pn(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Cn(t){return !!t.expression&&t.expression.interpolated}function Bn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Vn(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function En(t){return t}function Tn(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(Cn(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?ye.parse:ve.parse;(t=At({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default);}if(t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;let o,l,u;if("exponential"===s)o=Dn;else if("interval"===s)o=Ln;else if("categorical"===s){o=$n,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=On;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Dn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:sr.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Fn(t.default,e.default):o(t,e,i,l,u)}}}function Fn(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function $n(t,e,r,n,i){return Fn(typeof r===i?n[r]:void 0,t.default,e.default)}function Ln(t,e,r){if("number"!==Bn(r))return Fn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=We(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Dn(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Bn(r))return Fn(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=We(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=or[e.type]||En;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function On(t,e,r){switch(e.type){case"color":r=ye.parse(r);break;case"formatted":r=xe.fromString(r.toString());break;case"resolvedImage":r=Se.fromString(r.toString());break;case"padding":r=ve.parse(r);break;default:Bn(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return Fn(r,t.default,e.default)}gn.register(mn,{error:[{kind:"error"},[Pt],(t,[e])=>{throw new be(e.evaluate(t))}],typeof:[Pt,[Tt],(t,[e])=>jt(Ie(e.evaluate(t)))],"to-rgba":[Rt(zt,4),[Bt],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return [255*r,255*n,255*i,s]}],rgb:[Bt,[zt,zt,zt],xn],rgba:[Bt,[zt,zt,zt,zt],xn],has:{type:Ct,overloads:[[[Pt],(t,[e])=>vn(e.evaluate(t),t.properties())],[[Pt,Et],(t,[e,r])=>vn(e.evaluate(t),r.evaluate(t))]]},get:{type:Tt,overloads:[[[Pt],(t,[e])=>bn(e.evaluate(t),t.properties())],[[Pt,Et],(t,[e,r])=>bn(e.evaluate(t),r.evaluate(t))]]},"feature-state":[Tt,[Pt],(t,[e])=>bn(e.evaluate(t),t.featureState||{})],properties:[Et,[],t=>t.properties()],"geometry-type":[Pt,[],t=>t.geometryType()],id:[Tt,[],t=>t.id()],zoom:[zt,[],t=>t.globals.zoom],"heatmap-density":[zt,[],t=>t.globals.heatmapDensity||0],"line-progress":[zt,[],t=>t.globals.lineProgress||0],accumulated:[Tt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[zt,wn(zt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[zt,wn(zt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:zt,overloads:[[[zt,zt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[zt],(t,[e])=>-e.evaluate(t)]]},"/":[zt,[zt,zt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[zt,[zt,zt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[zt,[],()=>Math.LN2],pi:[zt,[],()=>Math.PI],e:[zt,[],()=>Math.E],"^":[zt,[zt,zt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[zt,[zt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[zt,[zt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[zt,[zt],(t,[e])=>Math.log(e.evaluate(t))],log2:[zt,[zt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[zt,[zt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[zt,[zt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[zt,[zt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[zt,[zt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[zt,[zt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[zt,[zt],(t,[e])=>Math.atan(e.evaluate(t))],min:[zt,wn(zt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[zt,wn(zt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[zt,[zt],(t,[e])=>Math.abs(e.evaluate(t))],round:[zt,[zt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[zt,[zt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[zt,[zt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Ct,[Pt,Tt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[Ct,[Tt],(t,[e])=>t.id()===e.value],"filter-type-==":[Ct,[Pt],(t,[e])=>t.geometryDollarType()===e.value],"filter-<":[Ct,[Pt,Tt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[Ct,[Pt,Tt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Ct,[Tt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Ct,[Pt,Tt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Ct,[Tt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Ct,[Pt,Tt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Ct,[Tt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Ct,[Tt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Ct,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Ct,[Rt(Pt)],(t,[e])=>e.value.indexOf(t.geometryDollarType())>=0],"filter-id-in":[Ct,[Rt(Tt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Ct,[Pt,Rt(Tt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Ct,[Pt,Rt(Tt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Ct,overloads:[[[Ct,Ct],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[wn(Ct),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:Ct,overloads:[[[Ct,Ct],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[wn(Ct),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[Ct,[Ct],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Ct,[Pt],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Pt,[Pt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Pt,[Pt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Pt,wn(Tt),(t,e)=>e.map((e=>ze(e.evaluate(t)))).join("")],"resolved-locale":[Pt,[Ft],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Rn{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new Ne,this._defaultValue=e?"color"===(r=e).type&&Vn(r.default)?new ye(0,0,0,0):"color"===r.type?ye.parse(r.default)||null:"padding"===r.type?ve.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?_e.parse(r.default)||null:"projectionDefinition"===r.type?Ae.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new be(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function jn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in mn}function Nn(t,e){const r=new Ue(mn,_n,[],e?function(t){const e={color:Bt,string:Pt,number:zt,enum:Pt,boolean:Ct,formatted:$t,padding:Lt,projectionDefinition:Vt,resolvedImage:Dt,variableAnchorOffsetCollection:Ot};return "array"===t.type?Rt(e[t.value]||Tt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Mn(new Rn(n,e)):In(r.errors)}class Un{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!An(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class qn{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!An(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?sr.interpolationFactor(this.interpolationType,t,e,r):0}}function Gn(t,e){const r=Nn(t,e);if("error"===r.result)return r;const n=r.value.expression,i=Sn(n);if(!i&&!zn(e))return In([new kt("","data expressions not supported")]);const s=kn(n,["zoom"]);if(!s&&!Pn(e))return In([new kt("","zoom expressions not supported")]);const a=Xn(n);return a||s?a instanceof kt?In([a]):a instanceof sr&&!Cn(e)?In([new kt("",'"interpolate" expressions cannot be used with this property')]):Mn(a?new qn(i?"camera":"composite",r.value,a.labels,a instanceof sr?a.interpolation:void 0):new Un(i?"constant":"source",r.value)):In([new kt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Zn{constructor(t,e){this._parameters=t,this._specification=e,At(this,Tn(this._parameters,this._specification));}static deserialize(t){return new Zn(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function Xn(t){let e=null;if(t instanceof qe)e=Xn(t.result);else if(t instanceof lr){for(const r of t.args)if(e=Xn(r),e)break}else (t instanceof Qe||t instanceof sr)&&t.input instanceof gn&&"zoom"===t.input.name&&(e=t);return e instanceof kt||t.eachChild((t=>{const r=Xn(t);r instanceof kt?e=r:!e&&r?e=new kt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new kt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function Kn(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Kn(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const Hn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Yn(t){if(null==t)return {filter:()=>!0,needGeometry:!1};Kn(t)||(t=Qn(t));const e=Nn(t,Hn);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:Wn(t)}}function Jn(t,e){return te?1:0}function Wn(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0]||"geometry-type"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?ti(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(Qn))):"all"===e?["all"].concat(t.slice(1).map(Qn)):"none"===e?["all"].concat(t.slice(1).map(Qn).map(ni)):"in"===e?ei(t[1],t.slice(2)):"!in"===e?ni(ei(t[1],t.slice(2))):"has"===e?ri(t[1]):"!has"!==e||ni(ri(t[1]));var r;}function ti(t,e,r){switch(t){case"$type":return [`filter-type-${r}`,e];case"$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function ei(t,e){if(0===e.length)return !1;switch(t){case"$type":return ["filter-type-in",["literal",e]];case"$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(Jn)]]:["filter-in-small",t,["literal",e]]}}function ri(t){switch(t){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",t]}}function ni(t){return ["!",t]}function ii(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${ii(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new St(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function pi(t){const e=t.valueSpec,r=oi(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===Bn(t.value.stops)&&"array"===Bn(t.value.stops[0])&&"object"===Bn(t.value.stops[0][0]),c=ui({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new St(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(ci({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Bn(n)&&0===n.length&&e.push(new St(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new St(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new St(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!Cn(t.valueSpec)&&c.push(new St(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!zn(t.valueSpec)?c.push(new St(t.key,t.value,"property functions not supported")):o&&!Pn(t.valueSpec)&&c.push(new St(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new St(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==Bn(n))return [new St(o,n,`array expected, ${Bn(n)} found`)];if(2!==n.length)return [new St(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==Bn(n[0]))return [new St(o,n,`object expected, ${Bn(n[0])} found`)];if(void 0===n[0].zoom)return [new St(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new St(o,n,"object stop key must have value")];if(s&&s>oi(n[0].zoom))return [new St(o,n[0].zoom,"stop zoom values must appear in ascending order")];oi(n[0].zoom)!==s&&(s=oi(n[0].zoom),i=void 0,a={}),r=r.concat(ui({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:hi,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return jn(li(n[1]))?r.concat([new St(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=Bn(t.value),l=oi(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return [new St(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new St(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return zn(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new St(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew St(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new St(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!An(r))return [new St(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!An(r))return [new St(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!kn(r,["zoom","feature-state"]))return [new St(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Sn(r))return [new St(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function di(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(oi(r))&&i.push(new St(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(oi(r))&&i.push(new St(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function yi(t){return Kn(li(t.value))?fi(At({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):mi(t)}function mi(t){const e=t.value,r=t.key;if("array"!==Bn(e))return [new St(r,e,`array expected, ${Bn(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return [new St(r,e,"filter array must have at least 1 element")];switch(s=s.concat(di({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),oi(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===oi(e[1])&&s.push(new St(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new St(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=Bn(e[1]),"string"!==i&&s.push(new St(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new St(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{oi(e.id)===o&&(t=e);})),t?t.ref?e.push(new St(n,r.ref,"ref cannot reference another ref layer")):a=oi(t.type):e.push(new St(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&oi(t.type);t?"vector"===s&&"raster"===a?e.push(new St(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new St(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new St(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new St(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new St(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new St(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new St(n,r.source,`source "${r.source}" not found`));}else e.push(new St(n,r,'missing required property "source"'));return e=e.concat(ui({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:yi,layout:t=>ui({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>vi(At({layerType:a},t))}}),paint:t=>ui({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>xi(At({layerType:a},t))}})}})),e}function wi(t){const e=t.value,r=t.key,n=Bn(e);return "string"!==n?[new St(r,e,`string expected, ${n} found`)]:[]}const _i={promoteId:function({key:t,value:e}){if("string"===Bn(e))return wi({key:t,value:e});{const r=[];for(const n in e)r.push(...wi({key:`${t}.${n}`,value:e[n]}));return r}}};function Si(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new St(r,e,'"type" is required')];const a=oi(e.type);let o;switch(a){case"vector":case"raster":return o=ui({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:_i,validateSpec:s}),o;case"raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=Bn(n);if(void 0===n)return o;if("object"!==l)return o.push(new St("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===oi(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new St(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new St(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case"geojson":if(o=ui({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:_i}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],a="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...fi({key:`${r}.${t}.map`,value:i,validateSpec:s,expressionContext:"cluster-map"})),o.push(...fi({key:`${r}.${t}.reduce`,value:a,validateSpec:s,expressionContext:"cluster-reduce"}));}return o;case"video":return ui({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case"image":return ui({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case"canvas":return [new St(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return di({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:s,styleSpec:n})}}function Ai(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=Bn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new St("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new St(a,e[a],`unknown property "${a}"`)]);}return s}function ki(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=Bn(e);if(void 0===e)return [];if("object"!==s)return [new St("sky",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new St(s,e[s],`unknown property "${s}"`)]);return a}function Mi(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=Bn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new St("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new St(a,e[a],`unknown property "${a}"`)]);return s}function Ii(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new St(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new St(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(ui({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return wi({key:n,value:r})}const zi={"*":()=>[],array:ci,boolean:function(t){const e=t.value,r=t.key,n=Bn(e);return "boolean"!==n?[new St(r,e,`boolean expected, ${n} found`)]:[]},number:hi,color:function(t){const e=t.key,r=t.value,n=Bn(r);return "string"!==n?[new St(e,r,`color expected, ${n} found`)]:ye.parse(String(r))?[]:[new St(e,r,`color expected, "${r}" found`)]},constants:ai,enum:di,filter:yi,function:pi,layer:bi,object:ui,source:Si,light:Ai,sky:ki,terrain:Mi,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=Bn(e);if(void 0===e)return [];if("object"!==s)return [new St("projection",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new St(s,e[s],`unknown property "${s}"`)]);return a},projectionDefinition:function(t){const e=t.key;let r=t.value;r=r instanceof String?r.valueOf():r;const n=Bn(r);return "array"!==n||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(r)||function(t){return !!["interpolate","step","literal"].includes(t[0])}(r)?["array","string"].includes(n)?[]:[new St(e,r,`projection expected, invalid type "${n}" found`)]:[new St(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:wi,formatted:function(t){return 0===wi(t).length?[]:fi(t)},resolvedImage:function(t){return 0===wi(t).length?[]:fi(t)},padding:function(t){const e=t.key,r=t.value;if("array"===Bn(r)){if(r.length<1||r.length>4)return [new St(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(ai({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:Pi}))),Ei(r)}function Vi(t){return function(e){return t({...e,validateSpec:Pi})}}function Ei(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function Ti(t){return function(...e){return Ei(t.apply(this,e))}}Bi.source=Ti(Vi(Si)),Bi.sprite=Ti(Vi(Ii)),Bi.glyphs=Ti(Vi(Ci)),Bi.light=Ti(Vi(Ai)),Bi.sky=Ti(Vi(ki)),Bi.terrain=Ti(Vi(Mi)),Bi.layer=Ti(Vi(bi)),Bi.filter=Ti(Vi(yi)),Bi.paintProperty=Ti(Vi(xi)),Bi.layoutProperty=Ti(Vi(vi));const Fi=Bi,$i=Fi.light,Li=Fi.sky,Di=Fi.paintProperty,Oi=Fi.layoutProperty;function Ri(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new ut(new Error(n.message))),r=!0;return r}class ji{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1;}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const s=t[n];i[n]=Ni[r].shallow.indexOf(n)>=0?s:Xi(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(i.$name=r),i}function Ki(t){if(Zi(t))return t;if(Array.isArray(t))return t.map(Ki);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=Gi(t)||"Object";if(!Ni[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Ni[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=Ni[e].shallow.indexOf(r)>=0?i:Ki(i);}return n}class Hi{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function Ji(t){for(const e of t)if(ns(e.charCodeAt(0)))return !0;return !1}function Wi(t){for(const e of t)if(!es(e.charCodeAt(0)))return !1;return !0}function Qi(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const ts=Qi(["Arab","Dupl","Mong","Ougr","Syrc"]);function es(t){return !ts.test(String.fromCodePoint(t))}const rs=Qi(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function ns(t){return !(746!==t&&747!==t&&(t<4352||!(Yi["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Yi["CJK Compatibility"](t)||Yi["CJK Strokes"](t)||!(!Yi["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Yi["Enclosed CJK Letters and Months"](t)||Yi["Ideographic Description Characters"](t)||Yi.Kanbun(t)||Yi.Katakana(t)&&12540!==t||!(!Yi["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Yi["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Yi["Vertical Forms"](t)||Yi["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||rs.test(String.fromCodePoint(t)))))}function is(t){return !(ns(t)||function(t){return !!(Yi["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Yi["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||Yi["Letterlike Symbols"](t)||Yi["Number Forms"](t)||Yi["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||Yi["Control Pictures"](t)&&9251!==t||Yi["Optical Character Recognition"](t)||Yi["Enclosed Alphanumerics"](t)||Yi["Geometric Shapes"](t)||Yi["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Yi["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Yi["CJK Symbols and Punctuation"](t)||Yi.Katakana(t)||Yi["Private Use Area"](t)||Yi["CJK Compatibility Forms"](t)||Yi["Small Form Variants"](t)||Yi["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const ss=Qi(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function as(t){return ss.test(String.fromCodePoint(t))}function os(t,e){return !(!e&&as(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Yi.Khmer(t))}function ls(t){for(const e of t)if(as(e.charCodeAt(0)))return !0;return !1}const us=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{};}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(us.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve();}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,r){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((t=>{this.loadScriptResolve=t;}));r(e);const i=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([n,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class cs{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Hi,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!os(r.charCodeAt(0),e))return !1;return !0}(t,"loaded"===us.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class hs{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Vn(t))return new Zn(t,e);if(jn(t)){const r=Gn(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=ye.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?r=_e.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(r=Ae.parse(t)):r=ve.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class ps{constructor(t){this.property=t,this.value=new hs(t,void 0);}transitioned(t,e){return new ds(this.property,this.value,e,F({},t.transition,this.transition),t.now)}untransitioned(){return new ds(this.property,this.value,null,{},0)}}class fs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return O(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ps(this._values[t].property)),this._values[t].value=new hs(this._values[t].property,null===e?void 0:O(e));}getTransition(t){return O(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ps(this._values[t].property)),this._values[t].transition=O(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new ys(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new ys(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class ds{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(nn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class _s{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new cs(Math.floor(e.zoom-1),e)),t.expression.evaluate(new cs(Math.floor(e.zoom),e)),t.expression.evaluate(new cs(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Ss{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class As{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new hs(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new ps(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}Ui("DataDrivenProperty",bs),Ui("DataConstantProperty",vs),Ui("CrossFadedDataDrivenProperty",ws),Ui("CrossFadedProperty",_s),Ui("ColorRampProperty",Ss);const ks="-transition";class Ms extends ct{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new ms(e.layout)),e.paint)){this._transitionablePaint=new fs(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new xs(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(Oi,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(ks)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(Di,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(ks))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),D(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&Ri(this,t.call(Fi,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:ht,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof gs&&zn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const Is={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class zs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class Ps{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Cs(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=Is[t.type].BYTES_PER_ELEMENT,s=r=Bs(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Bs(r,Math.max(n,e)),alignment:e}}function Bs(t,e){return Math.ceil(t/e)*e}class Vs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Vs.prototype.bytesPerElement=4,Ui("StructArrayLayout2i4",Vs);class Es extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}Es.prototype.bytesPerElement=6,Ui("StructArrayLayout3i6",Es);class Ts extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Ts.prototype.bytesPerElement=8,Ui("StructArrayLayout4i8",Ts);class Fs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Fs.prototype.bytesPerElement=12,Ui("StructArrayLayout2i4i12",Fs);class $s extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}$s.prototype.bytesPerElement=8,Ui("StructArrayLayout2i4ub8",$s);class Ls extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Ls.prototype.bytesPerElement=8,Ui("StructArrayLayout2f8",Ls);class Ds extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}Ds.prototype.bytesPerElement=20,Ui("StructArrayLayout10ui20",Ds);class Os extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}Os.prototype.bytesPerElement=24,Ui("StructArrayLayout4i4ui4i24",Os);class Rs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Rs.prototype.bytesPerElement=12,Ui("StructArrayLayout3f12",Rs);class js extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}js.prototype.bytesPerElement=4,Ui("StructArrayLayout1ul4",js);class Ns extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}Ns.prototype.bytesPerElement=20,Ui("StructArrayLayout6i1ul2ui20",Ns);class Us extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Us.prototype.bytesPerElement=12,Ui("StructArrayLayout2i2i2i12",Us);class qs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}qs.prototype.bytesPerElement=16,Ui("StructArrayLayout2f1f2i16",qs);class Gs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=16*t,l=4*t,u=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=a,t}}Gs.prototype.bytesPerElement=16,Ui("StructArrayLayout2ub2f2i16",Gs);class Zs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Zs.prototype.bytesPerElement=6,Ui("StructArrayLayout3ui6",Zs);class Xs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}Xs.prototype.bytesPerElement=48,Ui("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Xs);class Ks extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=S,this.uint32[C+12]=A,this.float32[C+13]=k,this.float32[C+14]=M,this.uint16[P+30]=I,this.uint16[P+31]=z,t}}Ks.prototype.bytesPerElement=64,Ui("StructArrayLayout8i15ui1ul2f2ui64",Ks);class Hs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Hs.prototype.bytesPerElement=4,Ui("StructArrayLayout1f4",Hs);class Ys extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Ys.prototype.bytesPerElement=12,Ui("StructArrayLayout1ui2f12",Ys);class Js extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}Js.prototype.bytesPerElement=8,Ui("StructArrayLayout1ul2ui8",Js);class Ws extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}Ws.prototype.bytesPerElement=4,Ui("StructArrayLayout2ui4",Ws);class Qs extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Qs.prototype.bytesPerElement=2,Ui("StructArrayLayout1ui2",Qs);class ta extends Ps{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}ta.prototype.bytesPerElement=16,Ui("StructArrayLayout4f16",ta);class ea extends zs{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}ea.prototype.size=20;class ra extends Ns{get(t){return new ea(this,t)}}Ui("CollisionBoxArray",ra);class na extends zs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}na.prototype.size=48;class ia extends Xs{get(t){return new na(this,t)}}Ui("PlacedSymbolArray",ia);class sa extends zs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}sa.prototype.size=64;class aa extends Ks{get(t){return new sa(this,t)}}Ui("SymbolInstanceArray",aa);class oa extends Hs{getoffsetX(t){return this.float32[1*t+0]}}Ui("GlyphOffsetArray",oa);class la extends Es{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Ui("SymbolLineVertexArray",la);class ua extends zs{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}ua.prototype.size=12;class ca extends Ys{get(t){return new ua(this,t)}}Ui("TextAnchorOffsetArray",ca);class ha extends zs{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}ha.prototype.size=8;class pa extends Js{get(t){return new ha(this,t)}}Ui("FeatureIndexArray",pa);class fa extends Vs{}class da extends Vs{}class ya extends Vs{}class ma extends Fs{}class ga extends $s{}class xa extends Ls{}class va extends Ds{}class ba extends Os{}class wa extends Rs{}class _a extends js{}class Sa extends Us{}class Aa extends Gs{}class ka extends Zs{}class Ma extends Ws{}const Ia=Cs([{name:"a_pos",components:2,type:"Int16"}],4),{members:za}=Ia;class Pa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t;}prepareSegment(t,e,r,n){const i=this.segments[this.segments.length-1];return t>Pa.MAX_VERTEX_ARRAY_LENGTH&&j(`Max vertices per segment is ${Pa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Pa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+t>Pa.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n?this.createNewSegment(e,r,n):i}createNewSegment(t,e,r){const n={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==r&&(n.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(t,e,r){return this.prepareSegment(0,t,e,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0;}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new Pa([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ca(t,e){return 256*(t=E(Math.floor(t),0,255))+E(Math.floor(e),0,255)}Pa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ui("SegmentVector",Pa);const Ba=Cs([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Va,Ea,Ta,Fa={exports:{}},$a={exports:{}},La={exports:{}},Da=function(){if(Ta)return Fa.exports;Ta=1;var t=(Va||(Va=1,$a.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),$a.exports),e=(Ea||(Ea=1,La.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),La.exports);return Fa.exports=t,Fa.exports.murmur3=t,Fa.exports.murmur2=e,Fa.exports}(),Oa=r(Da);class Ra{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(ja(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=ja(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Na(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new Ra;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function ja(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Oa(String(t))}function Na(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;Ua(t,s,a),Ua(e,3*s,3*a),Ua(e,3*s+1,3*a+1),Ua(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new Xa(t,e):new Ga(t,e)}}class Ja{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new Za(t,e):new Ga(t,e)}}class Wa{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new cs(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=Ha(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new cs(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new cs(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Ha(r),s=Ha(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Wa||r instanceof Qa)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new eo(n,e,r);this.needsUpload=!1,this._featureMap=new Ra,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function no(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function io(t,e,r){const n={color:{source:Ls,composite:ta},number:{source:Hs,composite:Ls}},i=function(t){return {"line-pattern":{source:va,composite:va},"fill-pattern":{source:va,composite:va},"fill-extrusion-pattern":{source:va,composite:va}}[t]}(t);return i&&i[r]||n[e][r]}Ui("ConstantBinder",Ya),Ui("CrossFadedConstantBinder",Ja),Ui("SourceExpressionBinder",Wa),Ui("CrossFadedCompositeBinder",to),Ui("CompositeExpressionBinder",Qa),Ui("ProgramConfiguration",eo,{omit:["_buffers"]}),Ui("ProgramConfigurationSet",ro);const so=Math.pow(2,14)-1,ao=-so-1;function oo(t){const e=M/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&j("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function lo(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?oo(t):[]}}const uo=-32768;function co(t,e,r,n,i){t.emplaceBack(uo+8*e+n,uo+8*r+i);}class ho{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new da,this.indexArray=new ka,this.segments=new Pa,this.programConfigurations=new ro(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1,o="heatmap"===n.type;if("circle"===n.type){const t=n;s=t.layout.get("circle-sort-key"),a=!s.isConstant(),o=o||"map"===t.paint.get("circle-pitch-alignment");}const l=o?e.subdivisionGranularity.circle:1;for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=lo(e,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:oo(e),patterns:{},sortKey:c};i.push(h);}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r,l),e.featureIndex.insert(o,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,za),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const a=s.length;for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=M||n<0||n>=M)continue;const i=this.segments.prepareSegment(a*a,this.layoutVertexArray,this.indexArray,t.sortKey),o=i.vertexLength;for(let t=0;t1){if(go(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function wo(t,e){let r,n,i,s=!1;for(let a=0;ae.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function _o(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function So(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=N(t,e,r[0]);return s!==N(t,e,r[1])||s!==N(t,e,r[2])||s!==N(t,e,r[3])}function Ao(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function ko(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Mo(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=l.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let e=0;eBo(t,e)))}(o,a),h=u?l*s:l;for(const t of n)for(const e of t){const t=u?e:Bo(e,a);let r=h;const n=_([],[e.x,e.y,0,1],a);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n[3]/i.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=i.cameraToCenterDistance/n[3]),fo(c,t,r))return !0}return !1}}function Bo(t,e){const r=_([],[t.x,t.y,0,1],e);return new l(r[0]/r[3],r[1]/r[3])}class Vo extends ho{}let Eo;Ui("HeatmapBucket",Vo,{omit:["layers"]});var To={get paint(){return Eo=Eo||new As({"heatmap-radius":new bs(ht.paint_heatmap["heatmap-radius"]),"heatmap-weight":new bs(ht.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new vs(ht.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ss(ht.paint_heatmap["heatmap-color"]),"heatmap-opacity":new vs(ht.paint_heatmap["heatmap-opacity"])})}};function Fo(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function $o(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Fo({},{width:e,height:r},n);Lo(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function Lo(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a);};if(t.clips)for(let e=0,i=0;e0)for(let i=e;i=e;i-=n)s=xl(i/n|0,t[i],t[i+1],s);return s&&pl(s,s.next)&&(vl(s),s=s.next),s}function Jo(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!pl(n,n.next)&&0!==hl(n.prev,n,n.next))n=n.next;else {if(vl(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function Wo(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=al(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?tl(t,n,i,s):Qo(t))e.push(l.i,t.i,u.i),vl(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?Wo(t=el(Jo(t),e),e,r,n,i,s,2):2===a&&rl(t,e,r,n,i,s):Wo(Jo(t),e,r,n,i,s,1);break}}}function Qo(t){const e=t.prev,r=t,n=t.next;if(hl(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),p=Math.max(i,s,a),f=Math.max(o,l,u);let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&ul(i,o,s,l,a,u,d.x,d.y)&&hl(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function tl(t,e,r,n){const i=t.prev,s=t,a=t.next;if(hl(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=Math.min(o,l,u),d=Math.min(c,h,p),y=Math.max(o,l,u),m=Math.max(c,h,p),g=al(f,d,e,r,n),x=al(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&ul(o,c,l,h,u,p,v.x,v.y)&&hl(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&ul(o,c,l,h,u,p,b.x,b.y)&&hl(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&ul(o,c,l,h,u,p,v.x,v.y)&&hl(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&ul(o,c,l,h,u,p,b.x,b.y)&&hl(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function el(t,e){let r=t;do{const n=r.prev,i=r.next.next;!pl(n,i)&&fl(n,r,r.next,i)&&ml(n,i)&&ml(i,n)&&(e.push(n.i,r.i,i.i),vl(r),vl(r.next),r=t=i),r=r.next;}while(r!==t);return Jo(r)}function rl(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&cl(a,t)){let o=gl(a,t);return a=Jo(a,a.next),o=Jo(o,o.next),Wo(a,e,r,n,i,s,0),void Wo(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function nl(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function il(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;if(pl(t,r))return r;do{if(pl(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&ll(is.x||r.x===s.x&&sl(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=gl(r,t);return Jo(n,n.next),Jo(r,r.next)}function sl(t,e){return hl(t.prev,t,e.prev)<0&&hl(e.next,t,t.next)<0}function al(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ol(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function ul(t,e,r,n,i,s,a,o){return !(t===a&&e===o)&&ll(t,e,r,n,i,s,a,o)}function cl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&fl(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(ml(t,e)&&ml(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(hl(t.prev,t,e.prev)||hl(t,e.prev,e))||pl(t,e)&&hl(t.prev,t,t.next)>0&&hl(e.prev,e,e.next)>0)}function hl(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function pl(t,e){return t.x===e.x&&t.y===e.y}function fl(t,e,r,n){const i=yl(hl(t,e,r)),s=yl(hl(t,e,n)),a=yl(hl(r,n,t)),o=yl(hl(r,n,e));return i!==s&&a!==o||!(0!==i||!dl(t,r,e))||!(0!==s||!dl(t,n,e))||!(0!==a||!dl(r,t,n))||!(0!==o||!dl(r,e,n))}function dl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function yl(t){return t>0?1:t<0?-1:0}function ml(t,e){return hl(t.prev,t,t.next)<0?hl(t,e,t.next)>=0&&hl(t,t.prev,e)>=0:hl(t,e,t.prev)<0||hl(t,t.next,e)<0}function gl(t,e){const r=bl(t.i,t.x,t.y),n=bl(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function xl(t,e,r,n){const i=bl(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function vl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function bl(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class wl{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e;}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const r=0|Math.round(t),n=0|Math.round(e),i=this._getKey(r,n);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(r,n),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const r=[];for(let n=0;n0?(r.push(i),r.push(a),r.push(s)):(r.push(i),r.push(s),r.push(a));}return r}(this._vertexBuffer,t);const e=[],r=t.length;for(let n=0;n=1||v<=0)||y&&(oi)){u>=n&&u<=i&&s.push(r[(t+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(a+p*x,o+f*x));const b=a+p*Math.max(x,0),w=a+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,a,o,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(a+p*v,o+f*v)),(y||u>=n&&u<=i)&&s.push(r[(t+1)%3]),!y&&(u<=n||u>=i)&&this._generateInterEdgeVertices(s,a,o,l,u,c,h,w,n,i);}return s}_generateIntraEdgeVertices(t,e,r,n,i,s,a){const o=n-e,l=i-r,u=0===l,c=u?Math.min(e,n):Math.min(s,a),h=u?Math.max(e,n):Math.max(s,a),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?e=p;n--){const i=n*this._granularityCellSize;t.push(this._vertexToIndex(i,r+l*(i-e)/o));}}_generateInterEdgeVertices(t,e,r,n,i,s,a,o,l,u){const c=i-r,h=s-n,p=a-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=n+h*y;let x=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,b=o=1||m<=0){const t=r-a,n=s+(e-s)*Math.min((l-a)/t,(u-a)/t);x=Math.floor(Math.min(n,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,o)/this._granularityCellSize)-1,b=o0?u:l;if(b)for(let e=x;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,_));else for(let e=v;e>=x;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,_));}_generateOutline(t){const e=[];for(const r of t){const t=Il(r,this._granularity,!0),n=this._pointArrayToIndices(t),i=[];for(let t=1;ti!=(s===Sl)?(t.push(e),t.push(r),t.push(this._vertexToIndex(n,s)),t.push(r),t.push(this._vertexToIndex(i,s)),t.push(this._vertexToIndex(n,s))):(t.push(r),t.push(e),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(i,s)),t.push(r),t.push(this._vertexToIndex(n,s)));}_fillPoles(t,e,r){const n=this._vertexBuffer,i=M,s=t.length;for(let a=2;a80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return Wo(s,a,r,o,l,u,0),a}(r,n),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e);}catch(t){console.error(t);}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(t,e){const r=[];for(let n=0;n0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,e=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(x-t),n=Math.abs(v-e),i=Math.abs(x-c),s=Math.abs(v-h),u=p?r/m:Number.POSITIVE_INFINITY,b=f?n/g:Number.POSITIVE_INFINITY;if((i<=r||!p)&&(s<=n||!f))break;if(u=0?a-1:s-1,i=(o+1)%s,l=t[2*e[n]],u=t[2*e[i]],c=t[2*e[a]],h=t[2*e[a]+1],p=t[2*e[o]+1];let f=!1;if(lu)f=!1;else {const r=p-h,s=-(t[2*e[o]]-c),a=h((u-c)*r+(t[2*e[i]+1]-h)*s)*a&&(f=!0);}if(f){const t=e[n],i=e[a],l=e[o];t!==i&&t!==l&&i!==l&&r.push(l,i,t),a--,a<0&&(a=s-1);}else {const t=e[i],n=e[a],l=e[o];t!==n&&t!==l&&n!==l&&r.push(l,n,t),o++,o>=s&&(o=0);}if(n===i)break}}function Pl(t,e,r,n,i,s,a,o,l){const u=i.length/2,c=a&&o&&l;if(uPa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,g=!0,c=0);const x=Cl(a,n,s,o,p,y,u),v=Cl(a,n,s,o,f,m,u),b=Cl(a,n,s,o,d,g,u);r.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++;}}(e,r,n,i,s,t),c&&function(t,e,r,n,i,s){const a=[];for(let t=0;tPa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,d=!0,y=!0,c=0);const m=Cl(a,n,s,o,i,d,u),g=Cl(a,n,s,o,h,y,u);r.emplaceBack(c+m-l,c+g-l),u.primitiveLength++;}}}(a,r,o,i,l,t),e.forceNewSegmentOnNextPrepare(),null==a||a.forceNewSegmentOnNextPrepare();}function Cl(t,e,r,n,i,s,a){if(s){const s=n.count;return r(e[2*i],e[2*i+1]),t[i]=n.count,n.count++,a.vertexLength++,s}return t[i]}class Bl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ya,this.indexArray=new ka,this.indexArray2=new Ma,this.programConfigurations=new ro(t.layers,t.zoom),this.segments=new Pa,this.segments2=new Pa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Ko("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=lo(a,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:oo(a),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Ho("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Xo),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s){for(const t of Le(e,500)){const e=Ml(t,n,s.fill.getGranularityForZoomLevel(n.z)),r=this.layoutVertexArray;Pl(((t,e)=>{r.emplaceBack(t,e);}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}}let Vl,El;Ui("FillBucket",Bl,{omit:["layers","patternFeatures"]});var Tl={get paint(){return El=El||new As({"fill-antialias":new vs(ht.paint_fill["fill-antialias"]),"fill-opacity":new bs(ht.paint_fill["fill-opacity"]),"fill-color":new bs(ht.paint_fill["fill-color"]),"fill-outline-color":new bs(ht.paint_fill["fill-outline-color"]),"fill-translate":new vs(ht.paint_fill["fill-translate"]),"fill-translate-anchor":new vs(ht.paint_fill["fill-translate-anchor"]),"fill-pattern":new ws(ht.paint_fill["fill-pattern"])})},get layout(){return Vl=Vl||new As({"fill-sort-key":new bs(ht.layout_fill["fill-sort-key"])})}};class Fl extends Ms{constructor(t){super(t,Tl);}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Bl(t)}queryRadius(){return ko(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:r,pixelsToTileUnits:n}){return yo(Mo(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,n),e)}isTileClipped(){return !0}}const $l=Cs([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ll=Cs([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Dl}=$l;var Ol,Rl,jl,Nl,Ul,ql,Gl,Zl={};function Xl(){if(Rl)return Ol;Rl=1;var t=s();function e(t,e,n,i,s){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=s,t.readFields(r,this,e);}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){for(var r=t.readVarint()+t.pos;t.pos>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(a,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var s,a,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return jl=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},jl}function Hl(){return Gl||(Gl=1,Zl.VectorTile=function(){if(ql)return Ul;ql=1;var t=Kl();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return Ul=function(t,r){this.layers=t.readFields(e,{},r);},Ul}(),Zl.VectorTileFeature=Xl(),Zl.VectorTileLayer=Kl()),Zl}var Yl=r(Hl());const Jl=Yl.VectorTileFeature.types,Wl=Math.pow(2,13);function Ql(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*Wl)+a,i*Wl*2,s*Wl*2,Math.round(o));}class tu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ma,this.centroidVertexArray=new fa,this.indexArray=new ka,this.programConfigurations=new ro(t.layers,t.zoom),this.segments=new Pa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=Ko("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=lo(n,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:oo(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Ho("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{},e.subdivisionGranularity),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0);}}addFeatures(t,e,r){for(const n of this.features){const{geometry:i}=n;this.addFeature(n,i,n.index,e,r,t.subdivisionGranularity);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Dl),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Ll.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i,s){for(const r of Le(e,500)){const e={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(e,n,t,r,s);const a=this.layoutVertexArray.length-i,o=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t{Ql(u,t,e,0,0,1,1,0);}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles);}_generateSideFaces(t,e){let r=0;for(let n=1;nPa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const a=i.sub(s)._perp()._unit(),o=s.dist(i);r+o>32768&&(r=0),Ql(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,0,r),Ql(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,1,r),r+=o,Ql(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,0,r),Ql(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,1,r);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2;}}}function eu(t,e){for(let r=0;rM)||t.y===e.y&&(t.y<0||t.y>M)}function nu(t){return t.every((t=>t.x<0))||t.every((t=>t.x>M))||t.every((t=>t.y<0))||t.every((t=>t.y>M))}let iu;Ui("FillExtrusionBucket",tu,{omit:["layers","features"]});var su={get paint(){return iu=iu||new As({"fill-extrusion-opacity":new vs(ht["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new bs(ht["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new vs(ht["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new vs(ht["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ws(ht["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new bs(ht["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new bs(ht["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new vs(ht["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class au extends Ms{constructor(t){super(t,su);}createBucket(t){return new tu(t)}queryRadius(){return ko(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s,pixelPosMatrix:a}){const o=Mo(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-i.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(e,r),c=this.paint.get("fill-extrusion-base").evaluate(e,r),h=function(t,e,r){const n=[];for(const r of t){const t=[r.x,r.y,0,1];_(t,t,e),n.push(new l(t[0]/t[3],t[1]/t[3]));}return n}(o,a),p=function(t,e,r,n){const i=[],s=[],a=n[8]*e,o=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,s=i.y,y=n[0]*e+n[4]*s+n[12],m=n[1]*e+n[5]*s+n[13],g=n[2]*e+n[6]*s+n[14],x=n[3]*e+n[7]*s+n[15],v=g+u,b=x+c,w=y+h,_=m+p,S=g+f,A=x+d,k=new l((y+a)/b,(m+o)/b);k.z=v/b,t.push(k);const M=new l(w/A,_/A);M.z=S/A,r.push(M);}i.push(t),s.push(r);}return [i,s]}(n,c,u,a);return function(t,e,r){let n=1/0;yo(r,e)&&(n=lu(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new ga,this.layoutVertexArray2=new xa,this.indexArray=new ka,this.programConfigurations=new ro(t.layers,t.zoom),this.segments=new Pa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Ko("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=lo(e,t);if(!this.layers[0]._featureFilter.filter(new cs(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:oo(e),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Ho("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,pu)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,cu),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),l=a.get("line-cap"),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,s,a,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Il(t,a?o.line.getGranularityForZoomLevel(a.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c0;if(w&&e>c){const t=f.dist(d);if(t>2*h){const e=f.sub(f.sub(d)._mult(h/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,m,0,0,p),d=e;}}const S=d&&y;let A=S?r:l?"butt":n;if(S&&"round"===A&&(vi&&(A="bevel"),"bevel"===A&&(v>2&&(A="flipbevel"),v100)a=g.mult(-1);else {const t=v*m.add(g).mag()/m.sub(g).mag();a._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(f,a,0,0,p),this.addCurrentVertex(f,a.mult(-1),0,0,p);}else if("bevel"===A||"fakeround"===A){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(d&&this.addCurrentVertex(f,m,e,r,p),"fakeround"===A){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*h){const e=f.add(y.sub(f)._mult(h/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,p),f=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>yu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s));}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(yu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let gu,xu;Ui("LineBucket",mu,{omit:["layers","patternFeatures"]});var vu={get paint(){return xu=xu||new As({"line-opacity":new bs(ht.paint_line["line-opacity"]),"line-color":new bs(ht.paint_line["line-color"]),"line-translate":new vs(ht.paint_line["line-translate"]),"line-translate-anchor":new vs(ht.paint_line["line-translate-anchor"]),"line-width":new bs(ht.paint_line["line-width"]),"line-gap-width":new bs(ht.paint_line["line-gap-width"]),"line-offset":new bs(ht.paint_line["line-offset"]),"line-blur":new bs(ht.paint_line["line-blur"]),"line-dasharray":new _s(ht.paint_line["line-dasharray"]),"line-pattern":new ws(ht.paint_line["line-pattern"]),"line-gradient":new Ss(ht.paint_line["line-gradient"])})},get layout(){return gu=gu||new As({"line-cap":new vs(ht.layout_line["line-cap"]),"line-join":new bs(ht.layout_line["line-join"]),"line-miter-limit":new vs(ht.layout_line["line-miter-limit"]),"line-round-limit":new vs(ht.layout_line["line-round-limit"]),"line-sort-key":new bs(ht.layout_line["line-sort-key"])})}};class bu extends bs{possiblyEvaluate(t,e){return e=new cs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=F({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let wu;class _u extends Ms{constructor(t){super(t,vu),this.gradientVersion=0,wu||(wu=new bu(vu.paint.properties["line-width"].specification),wu.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Qe,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=wu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new mu(t)}queryRadius(t){const e=t,r=Su(Ao("line-width",this,e),Ao("line-gap-width",this,e)),n=Ao("line-offset",this,e);return r/2+Math.abs(n)+ko(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s}){const a=Mo(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-i.bearingInRadians,s),o=s/2*Su(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Au=Cs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ku=Cs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Cs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Mu=Cs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Cs([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Iu=Cs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),zu=Cs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Pu(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),us.applyArabicShaping&&(t=us.applyArabicShaping(t)),t}(t.text,e,r);})),t}Cs([{name:"triangle",components:3,type:"Uint16"}]),Cs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Cs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Cs([{type:"Float32",name:"offsetX"}]),Cs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Cs([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Cu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Bu,Vu,Eu,Tu=24,Fu={};function $u(){return Bu||(Bu=1,Fu.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},Fu.write=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;}),Fu}function Lu(){if(Eu)return Vu;Eu=1,Vu=e;var t=$u();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function v(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return a(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=s(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},Vu}var Du=r(Lu());const Ou=3;function Ru(t,e,r){1===t&&r.readMessage(ju,e);}function ju(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(Nu,{});e.push({id:t,bitmap:new Do({width:i+2*Ou,height:s+2*Ou},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}}function Nu(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const Uu=Ou;function qu(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&Qu[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new Ju;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yu.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Wu(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=Ju.fromFeature(e,s);let g;p===t.ai.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=us;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),oc(m,c,a,r,i,d));for(const e of t){const t=new Ju;t.text=e,t.sections=m.sections;for(let r=0;r0&&n>_&&(_=n);}else {const t=n[y.fontStack],e=t&&t[g];if(e&&e.rect)S=e.rect,b=e.metrics;else {const t=r[y.fontStack],e=t&&t[g];if(!e)continue;b=e.metrics;}x=(s-y.scale)*Tu;}M?(e.verticalizable=!0,w.push({glyph:g,imageName:A,x:f,y:d+x,vertical:M,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:b,rect:S}),f+=k*y.scale+c):(w.push({glyph:g,imageName:A,x:f,y:d+x,vertical:M,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:b,rect:S}),f+=b.advance*y.scale+c);}0!==w.length&&(y=Math.max(f-c,y),uc(w,0,w.length-1,g,_)),f=0;const S=a*s+_;b.lineOffset=Math.max(_,l),d+=S,m=Math.max(S,m),++x;}var v;const b=d-Hu,{horizontalAlign:w,verticalAlign:_}=lc(o);((function(t,e,r,n,i,s,a,o,l){const u=(e-r)*i;let c=0;c=s!==a?-o*n-Hu:(-n*l+.5)*a;for(const e of t)for(const t of e.positionedGlyphs)t.x+=u,t.y+=c;}))(e.positionedLines,g,w,_,y,m,a,b,s.length),e.top+=-_*b,e.bottom=e.top+b,e.left+=-w*y,e.right=e.left+y;}(w,r,n,i,g,o,l,u,p,c,f,y),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return !1;return !0}(b)&&w}const Qu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},tc={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},ec={40:!0};function rc(t,e,r,n,i,s){if(e.imageName){const t=n[e.imageName];return t?t.displaySize[0]*e.scale*Tu/s+i:0}{const n=r[e.fontStack],s=n&&n[t];return s?s.metrics.advance*e.scale+i:0}}function nc(t,e,r,n){const i=Math.pow(t-e,2);return n?t=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/a,a=t;}return {x1:n,y1:i,x2:n+s,y2:i+a}}function pc(t,e,r,n,i,s){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-a.displaySize[1])/2,p=c+a.displaySize[1]),{image:a,top:c,right:h,bottom:p,left:f,collisionPadding:o}}const fc=255,dc=128,yc=fc*dc;function mc(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new cs(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=mc(this.zoom,r["text-size"]),this.iconSizeData=mc(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap="never"!==gc(n,"text-overlap","text-allow-overlap")||"never"!==gc(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ai[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Sc(new ro(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Sc(new ro(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new oa,this.lineVertexArray=new la,this.symbolInstances=new aa,this.textAnchorOffsets=new ca;}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new cs(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=lo(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=oo(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=xe.factory(t),r=this.hasRTLText=this.hasRTLText||_c(e);(!r||"unavailable"===us.getRTLTextPluginStatus()||r&&us.isParsed())&&(x=Pu(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof Se?t:Se.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:xc[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=a.evaluate(g,{},n).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ai.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=Ji(x.toString()),i=t.fontStack||e,s=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,s,r,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Mc,Ic;Ui("SymbolBucket",kc,{omit:["layers","collisionBoxArray","features","compareText"]}),kc.MAX_GLYPHS=65535,kc.addDynamicAttributes=wc;var zc={get paint(){return Ic=Ic||new As({"icon-opacity":new bs(ht.paint_symbol["icon-opacity"]),"icon-color":new bs(ht.paint_symbol["icon-color"]),"icon-halo-color":new bs(ht.paint_symbol["icon-halo-color"]),"icon-halo-width":new bs(ht.paint_symbol["icon-halo-width"]),"icon-halo-blur":new bs(ht.paint_symbol["icon-halo-blur"]),"icon-translate":new vs(ht.paint_symbol["icon-translate"]),"icon-translate-anchor":new vs(ht.paint_symbol["icon-translate-anchor"]),"text-opacity":new bs(ht.paint_symbol["text-opacity"]),"text-color":new bs(ht.paint_symbol["text-color"],{runtimeType:Bt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new bs(ht.paint_symbol["text-halo-color"]),"text-halo-width":new bs(ht.paint_symbol["text-halo-width"]),"text-halo-blur":new bs(ht.paint_symbol["text-halo-blur"]),"text-translate":new vs(ht.paint_symbol["text-translate"]),"text-translate-anchor":new vs(ht.paint_symbol["text-translate-anchor"])})},get layout(){return Mc=Mc||new As({"symbol-placement":new vs(ht.layout_symbol["symbol-placement"]),"symbol-spacing":new vs(ht.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new vs(ht.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new bs(ht.layout_symbol["symbol-sort-key"]),"symbol-z-order":new vs(ht.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new vs(ht.layout_symbol["icon-allow-overlap"]),"icon-overlap":new vs(ht.layout_symbol["icon-overlap"]),"icon-ignore-placement":new vs(ht.layout_symbol["icon-ignore-placement"]),"icon-optional":new vs(ht.layout_symbol["icon-optional"]),"icon-rotation-alignment":new vs(ht.layout_symbol["icon-rotation-alignment"]),"icon-size":new bs(ht.layout_symbol["icon-size"]),"icon-text-fit":new vs(ht.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new vs(ht.layout_symbol["icon-text-fit-padding"]),"icon-image":new bs(ht.layout_symbol["icon-image"]),"icon-rotate":new bs(ht.layout_symbol["icon-rotate"]),"icon-padding":new bs(ht.layout_symbol["icon-padding"]),"icon-keep-upright":new vs(ht.layout_symbol["icon-keep-upright"]),"icon-offset":new bs(ht.layout_symbol["icon-offset"]),"icon-anchor":new bs(ht.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new vs(ht.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new vs(ht.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new vs(ht.layout_symbol["text-rotation-alignment"]),"text-field":new bs(ht.layout_symbol["text-field"]),"text-font":new bs(ht.layout_symbol["text-font"]),"text-size":new bs(ht.layout_symbol["text-size"]),"text-max-width":new bs(ht.layout_symbol["text-max-width"]),"text-line-height":new vs(ht.layout_symbol["text-line-height"]),"text-letter-spacing":new bs(ht.layout_symbol["text-letter-spacing"]),"text-justify":new bs(ht.layout_symbol["text-justify"]),"text-radial-offset":new bs(ht.layout_symbol["text-radial-offset"]),"text-variable-anchor":new vs(ht.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new bs(ht.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new bs(ht.layout_symbol["text-anchor"]),"text-max-angle":new vs(ht.layout_symbol["text-max-angle"]),"text-writing-mode":new vs(ht.layout_symbol["text-writing-mode"]),"text-rotate":new bs(ht.layout_symbol["text-rotate"]),"text-padding":new vs(ht.layout_symbol["text-padding"]),"text-keep-upright":new vs(ht.layout_symbol["text-keep-upright"]),"text-transform":new bs(ht.layout_symbol["text-transform"]),"text-offset":new bs(ht.layout_symbol["text-offset"]),"text-allow-overlap":new vs(ht.layout_symbol["text-allow-overlap"]),"text-overlap":new vs(ht.layout_symbol["text-overlap"]),"text-ignore-placement":new vs(ht.layout_symbol["text-ignore-placement"]),"text-optional":new vs(ht.layout_symbol["text-optional"])})}};class Pc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:It,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Ui("FormatSectionOverride",Pc,{omit:["defaultValue"]});class Cc extends Ms{constructor(t){super(t,zc);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||jn(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new kc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of zc.paint.overridableProperties){if(!Cc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Pc(e),n=new Rn(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Un("source",n):new qn("composite",n,e.value.zoomStops),this.paint._values[t]=new gs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&Cc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=zc.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof xe)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof Pe&&Ie(e.value)===$t?s(e.value.sections):e instanceof br?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Bc;var Vc={get paint(){return Bc=Bc||new As({"background-color":new vs(ht.paint_background["background-color"]),"background-pattern":new _s(ht.paint_background["background-pattern"]),"background-opacity":new vs(ht.paint_background["background-opacity"])})}};class Ec extends Ms{constructor(t){super(t,Vc);}}let Tc;var Fc={get paint(){return Tc=Tc||new As({"raster-opacity":new vs(ht.paint_raster["raster-opacity"]),"raster-hue-rotate":new vs(ht.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new vs(ht.paint_raster["raster-brightness-min"]),"raster-brightness-max":new vs(ht.paint_raster["raster-brightness-max"]),"raster-saturation":new vs(ht.paint_raster["raster-saturation"]),"raster-contrast":new vs(ht.paint_raster["raster-contrast"]),"raster-resampling":new vs(ht.paint_raster["raster-resampling"]),"raster-fade-duration":new vs(ht.paint_raster["raster-fade-duration"])})}};class $c extends Ms{constructor(t){super(t,Fc);}}class Lc extends Ms{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Dc{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle();}),0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const Oc=6371008.8;class Rc{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Rc(T(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Oc*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof Rc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Rc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Rc(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const jc=2*Math.PI*Oc;function Nc(t){return jc*Math.cos(t*Math.PI/180)}function Uc(t){return (180+t)/360}function qc(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Gc(t,e){return t/Nc(e)}function Zc(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Xc(t,e){return t*Nc(Zc(e))}class Kc{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=Rc.convert(t);return new Kc(Uc(r.lng),qc(r.lat),Gc(e,r.lat))}toLngLat(){return new Rc(360*this.x-180,Zc(this.y))}toAltitude(){return Xc(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/jc*(t=Zc(this.y),1/Math.cos(t*Math.PI/180));var t;}}function Hc(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Yc{constructor(t,e,r){if(!function(t,e,r){return !(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=Qc(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=Hc(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=Hc(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*M,(t.y*e-this.y)*M)}toString(){return `${this.z}/${this.x}/${this.y}`}}class Jc{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Qc(t,e.z,e.z,e.x,e.y);}}class Wc{constructor(t,e,r,n,i){if(this.terrainRttPosMatrix32f=null,t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Yc(r,+n,+i),this.key=Qc(e,t,r,n,i);}clone(){return new Wc(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new Wc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Wc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?Qc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Qc(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new Wc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new Wc(e,this.wrap,e,r,n),new Wc(e,this.wrap,e,r+1,n),new Wc(e,this.wrap,e,r,n+1),new Wc(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new Oo({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class rh{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class nh{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new ji(M,16,0),this.grid3D=new ji(M,16,0),this.featureIndexArray=new pa,this.promoteId=e;}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Yl.VectorTile(new Du(this.rawTileData)).layers,this.sourceLayerCoder=new eh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params,s=M/t.tileSize/t.scale,a=Yn(i.filter),o=t.queryGeometry,u=t.queryPadding*s,c=sh(o),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=sh(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new l(e,r),new l(e,i),new l(n,i),new l(n,r)];if(t.length>2)for(const e of s)if(_o(t,e))return !0;for(let e=0;e(p||(p=oo(e)),r.queryIntersectsFeature({queryGeometry:o,feature:e,featureState:n,geometry:p,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix}))));}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!h.some((t=>s.has(t))))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=lo(f,!0);if(!i.filter(new cs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new cs(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const a=e instanceof xs?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function sh(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {minX:e,minY:r,maxX:n,maxY:i}}function ah(t,e){return e-t}function oh(t,e,r,n,i){const s=[];for(let a=0;a=n&&c.x>=n||(a.x>=n?a=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=n&&(c=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=i&&c.y>=i||(a.y>=i?a=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y>=i&&(c=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),u&&a.equals(u[u.length-1])||(u=[a],s.push(u)),u.push(c)))));}}return s}Ui("FeatureIndex",nh,{omit:["rawTileData","sourceLayerCoder"]});class lh extends l{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new lh(this.x,this.y,this.angle,this.segment)}}function uh(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function ch(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=or.number(n.x,i.x,c),p=or.number(n.y,i.y,c),f=new lh(h,p,i.angleTo(n),r);return f._round(),!a||uh(t,f,o,a,e)?f:void 0}l+=s;}}function dh(t,e,r,n,i,s,a,o,l){const u=hh(n,s,a),c=ph(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new lh(g,x,y,e);r._round(),n&&!uh(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=yh(t,h/2,r,n,i,s,a,!0,l)),f}Ui("Anchor",lh);const mh=Gu;function gh(t,e,r,n){const i=[],s=t.image,a=s.pixelRatio,o=s.paddedRect.w-2*mh,u=s.paddedRect.h-2*mh;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=s.stretchX||[[0,o]],p=s.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=o-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,S=m,A=0,k=g;if(s.content&&n){const e=s.content,r=e[2]-e[0],n=e[3]-e[1];(s.textFitWidth||s.textFitHeight)&&(c=hc(t)),x=xh(h,0,e[0]),b=xh(p,0,e[1]),v=xh(h,e[0],e[2]),w=xh(p,e[1],e[3]),_=e[0]-x,A=e[1]-b,S=r-v,k=n-w;}const M=c.x1,I=c.y1,z=c.x2-M,P=c.y2-I,C=(t,n,i,o)=>{const u=bh(t.stretch-x,v,z,M),c=wh(t.fixed-_,S,t.stretch,d),h=bh(n.stretch-b,w,P,I),p=wh(n.fixed-A,k,n.stretch,y),f=bh(i.stretch-x,v,z,M),m=wh(i.fixed-_,S,i.stretch,d),g=bh(o.stretch-b,w,P,I),C=wh(o.fixed-A,k,o.stretch,y),B=new l(u,h),V=new l(f,h),E=new l(f,g),T=new l(u,g),F=new l(c/a,p/a),$=new l(m/a,C/a),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),r=[e,-t,t,e];B._matMult(r),V._matMult(r),T._matMult(r),E._matMult(r);}const D=t.stretch+t.fixed,O=n.stretch+n.fixed;return {tl:B,tr:V,bl:T,br:E,tex:{x:s.paddedRect.x+mh+D,y:s.paddedRect.y+mh+O,w:i.stretch+i.fixed-D,h:o.stretch+o.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:$,minFontScaleX:S/a/z,minFontScaleY:k/a/P,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=vh(h,m,d),e=vh(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {const u=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?hc(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};u.y1=u.y1*a-o[0],u.y2=u.y2*a+o[2],u.x1=u.x1*a-o[3],u.x2=u.x2*a+o[1];const p=s.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const t=new l(u.x1,u.y1),e=new l(u.x2,u.y1),r=new l(u.x1,u.y2),n=new l(u.x2,u.y2),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,i);}this.boxEndIndex=t.length;}}class Sh{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}function Ah(t,e=1,r=!1){let n=1/0,i=1/0,s=-1/0,a=-1/0;const o=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const u=Math.min(s-n,a-i);let c=u/2;const h=new Sh([],kh);if(0===u)return new l(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Mh(n.p.x-c,n.p.y-c,c,t)),h.push(new Mh(n.p.x+c,n.p.y-c,c,t)),h.push(new Mh(n.p.x-c,n.p.y+c,c,t)),h.push(new Mh(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function kh(t,e){return e.max-t.max}function Mh(t,e,r,n){this.p=new l(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,bo(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var Ih;t.av=void 0,(Ih=t.av||(t.av={}))[Ih.center=1]="center",Ih[Ih.left=2]="left",Ih[Ih.right=3]="right",Ih[Ih.top=4]="top",Ih[Ih.bottom=5]="bottom",Ih[Ih["top-left"]=6]="top-left",Ih[Ih["top-right"]=7]="top-right",Ih[Ih["bottom-left"]=8]="bottom-left",Ih[Ih["bottom-right"]=9]="bottom-right";const zh=7,Ph=Number.POSITIVE_INFINITY;function Ch(t,e){return e[1]!==Ph?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-zh;break;case"bottom-right":case"bottom-left":case"bottom":i=-r+zh;}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case"top-right":case"top-left":n=i-zh;break;case"bottom-right":case"bottom-left":n=-i+zh;break;case"bottom":n=-e+zh;break;case"top":n=e-zh;}switch(t){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=e;break;case"right":r=-e;}return [r,n]}(t,e[0])}function Bh(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*Tu));n.startsWith("top")?i[1]-=zh:n.startsWith("bottom")&&(i[1]+=zh),e[r+1]=i;}return new _e(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Tu,Ph]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Tu));const s=[];for(const t of a)s.push(t,Ch(t,n));return new _e(s)}return null}function Vh(t){switch(t){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function Eh(e,r,n,i,s,a,o,l,u,c,h,p){let f=a.textMaxSize.evaluate(r,{});void 0===f&&(f=o);const d=e.layers[0].layout,y=d.get("icon-offset").evaluate(r,{},h),m=Fh(n.horizontal),g=o/24,x=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*d.get("symbol-spacing"),_=d.get("text-padding")*e.tilePixelRatio,S=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),s=i&&i.values;return [s[0]*n,s[1]*n,s[2]*n,s[3]*n]}(d,r,h,e.tilePixelRatio),A=d.get("text-max-angle")/180*Math.PI,k="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),I="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),z=d.get("symbol-placement"),P=w/2,C=d.get("icon-text-fit");let B;i&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(B=pc(i,n.vertical,C,d.get("icon-text-fit-padding"),y,g)),m&&(i=pc(i,m,C,d.get("icon-text-fit-padding"),y,g)));const V=h?p.line.getGranularityForZoomLevel(h.z):1,E=(l,p)=>{p.x<0||p.x>=M||p.y<0||p.y>=M||function(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k){const M=e.addToLineVertexArray(r,n);let I,z,P,C,B=0,V=0,E=0,T=0,F=-1,$=-1;const L={};let D=Oa("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},A)+90;P=new _h(u,r,c,h,p,i.vertical,f,d,y,t),o&&(C=new _h(u,r,c,h,p,o,g,x,y,t));}if(s){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),a=gh(s,n,S,i),f=o?gh(o,n,S,i):void 0;z=new _h(u,r,c,h,p,s,g,x,!1,n),B=4*a.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[dc*l.layout.get("icon-size").evaluate(w,{})],y[0]>yc&&j(`${e.layerIds[0]}: Value for "icon-size" is >= ${fc}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[dc*_.compositeIconSizes[0].evaluate(w,{},A),dc*_.compositeIconSizes[1].evaluate(w,{},A)],(y[0]>yc||y[1]>yc)&&j(`${e.layerIds[0]}: Value for "icon-size" is >= ${fc}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,y,b,v,w,t.ai.none,r,M.lineStartIndex,M.lineLength,-1,A),F=e.icon.placedSymbolArray.length-1,f&&(V=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.ai.vertical,r,M.lineStartIndex,M.lineLength,-1,A),$=e.icon.placedSymbolArray.length-1);}const O=Object.keys(i.horizontal);for(const n of O){const s=i.horizontal[n];if(!I){D=Oa(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},A);I=new _h(u,r,c,h,p,s,f,d,y,t);}const o=1===s.positionedLines.length;if(E+=Th(e,r,s,a,l,y,w,m,M,i.vertical?t.ai.horizontal:t.ai.horizontalOnly,o?O:[n],L,F,_,A),o)break}i.vertical&&(T+=Th(e,r,i.vertical,a,l,y,w,m,M,t.ai.vertical,["vertical"],L,$,_,A));const R=I?I.boxStartIndex:e.collisionBoxArray.length,N=I?I.boxEndIndex:e.collisionBoxArray.length,U=P?P.boxStartIndex:e.collisionBoxArray.length,q=P?P.boxEndIndex:e.collisionBoxArray.length,G=z?z.boxStartIndex:e.collisionBoxArray.length,Z=z?z.boxEndIndex:e.collisionBoxArray.length,X=C?C.boxStartIndex:e.collisionBoxArray.length,K=C?C.boxEndIndex:e.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(I,H),H=Y(P,H),H=Y(z,H),H=Y(C,H);const J=H>-1?1:0;J&&(H*=k/Tu),e.glyphOffsetArray.length>=kc.MAX_GLYPHS&&j("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=Bh(l,w,A),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,F,$,D,R,N,U,q,G,Z,X,K,c,E,T,B,V,J,0,f,H,Q,tt);}(e,p,l,n,i,s,B,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,x,[_,_,_,_],k,u,b,S,I,y,r,a,c,h,o);};if("line"===z)for(const t of oh(r.geometry,0,0,M,M)){const r=Il(t,V),s=dh(r,w,A,n.vertical||m,i,24,v,e.overscaling,M);for(const t of s)m&&$h(e,m.text,P,t)||E(r,t);}else if("line-center"===z){for(const t of r.geometry)if(t.length>1){const e=Il(t,V),r=fh(e,A,n.vertical||m,i,24,v);r&&E(e,r);}}else if("Polygon"===r.type)for(const t of Le(r.geometry,0)){const e=Ah(t,16);E(Il(t[0],V,!0),new lh(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry){const e=Il(t,V);E(e,new lh(e[0].x,e[0].y,0));}else if("Point"===r.type)for(const t of r.geometry)for(const e of t)E([e],new lh(e.x,e.y,0));}function Th(t,e,r,n,i,s,a,o,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,s,a,o){const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=Uu+1,p=!0,f=1,d=0;const y=(i||o)&&n.vertical,m=n.metrics.advance*n.scale/2;if(o&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Tu-n.metrics.width*n.scale)/2:(n.scale-1)*Tu)),n.imageName){const t=a[n.imageName];p=t.sdf,f=t.pixelRatio,h=Gu/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],S=w+s.w/b*n.scale/f,A=_+s.h/b*n.scale/f,k=new l(w,_),M=new l(S,_),I=new l(w,A),z=new l(S,A);if(y){const t=new l(-m,m-Hu),e=-Math.PI/2,r=Tu/2-m,i=new l(5-Hu-r,-(n.imageName?r:0)),s=new l(...v);k._rotateAround(e,t)._add(i)._add(s),M._rotateAround(e,t)._add(i)._add(s),I._rotateAround(e,t)._add(i)._add(s),z._rotateAround(e,t)._add(i)._add(s);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),M._matMult(r),I._matMult(r),z._matMult(r);}const P=new l(0,0),C=new l(0,0);c.push({tl:k,tr:M,bl:I,br:z,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,o,i,s,a,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[dc*i.layout.get("text-size").evaluate(a,{})],x[0]>yc&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${fc}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[dc*d.compositeTextSizes[0].evaluate(a,{},y),dc*d.compositeTextSizes[1].evaluate(a,{},y)],(x[0]>yc||x[1]>yc)&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${fc}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,o,s,a,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function Fh(t){for(const e in t)return t[e];return null}function $h(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=Lh[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Dh(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Lh.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Oh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)Uh(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Uh(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function Oh(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;Rh(t,e,a,n,i,s),Oh(t,e,r,n,a-1,1-s),Oh(t,e,r,a+1,i,1-s);}function Rh(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);Rh(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(jh(t,e,n,r),e[2*i+s]>a&&jh(t,e,n,i);oa;)l--;}e[2*n+s]===a?jh(t,e,n,l):(l++,jh(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function jh(t,e,r,n){Nh(t,r,n),Nh(e,2*r,2*n),Nh(e,2*r+1,2*n+1);}function Nh(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Uh(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}var qh;t.ce=void 0,(qh=t.ce||(t.ce={})).create="create",qh.load="load",qh.fullLoad="fullLoad";let Gh=null,Zh=[];const Xh=1e3/60,Kh="loadTime",Hh="fullLoadTime",Yh={mark(t){performance.mark(t);},frame(t){const e=t;null!=Gh&&Zh.push(e-Gh),Gh=e;},clearMetrics(){Gh=null,Zh=[],performance.clearMeasures(Kh),performance.clearMeasures(Hh);for(const e in t.ce)performance.clearMarks(t.ce[e]);},getPerformanceMetrics(){performance.measure(Kh,t.ce.create,t.ce.load),performance.measure(Hh,t.ce.create,t.ce.fullLoad);const e=performance.getEntriesByName(Kh)[0].duration,r=performance.getEntriesByName(Hh)[0].duration,n=Zh.length,i=1/(Zh.reduce(((t,e)=>t+e),0)/n/1e3),s=Zh.filter((t=>t>Xh)).reduce(((t,e)=>t+(e-Xh)/Xh),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:s/(n+s)*100,totalFrames:n}}};t.$=St,t.A=g,t.B=Li,t.C=function(t){if(null==q){const e=t.navigator?t.navigator.userAgent:null;q=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return q},t.D=vs,t.E=ct,t.F=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Dc((()=>this.process())),this.subscription=function(t,e,r,n){return t.addEventListener(e,r,!1),{unsubscribe:()=>{t.removeEventListener(e,r,!1);}}}(this.target,"message",(t=>this.receive(t))),this.globalScope=U(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[i]={resolve:r,reject:n},e&&e.signal.addEventListener("abort",(()=>{delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),{once:!0});const s=[],a=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:Xi(t.data,s)});this.target.postMessage(a,{transfer:s});}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(U(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(Ki(r.error)):e.resolve(Ki(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=Ki(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i);}catch(e){this.completeTask(t,e);}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?Xi(e):null,data:Xi(r,n)};this.target.postMessage(i,{transfer:n});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.G=et,t.H=function(){var t=new g(16);return g!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.I=Zu,t.J=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=a*y+c*m+d*g+e[15]),t},t.K=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.L=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*o+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*s+b*u+w*f+_*g,t[3]=v*a+b*c+w*d+_*x,t[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*s+b*u+w*f+_*g,t[7]=v*a+b*c+w*d+_*x,t[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*s+b*u+w*f+_*g,t[11]=v*a+b*c+w*d+_*x,t[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*s+b*u+w*f+_*g,t[15]=v*a+b*c+w*d+_*x,t},t.M=function(t,e){const r={};for(let n=0;n{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e);};for(const r of t){const t=window.document.createElement("source");st(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t);}}))},t.a1=function(){return $++},t.a2=ra,t.a3=kc,t.a4=Yn,t.a5=lo,t.a6=rh,t.a7=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.a8=function(t){return Math.log(t)/Math.LN2},t.a9=function(t){var e=t[0],r=t[1];return e*e+r*r},t.aA=Cs,t.aB=_l,t.aC=fa,t.aD=Pa,t.aE=ka,t.aF=85.051129,t.aG=function(t){return Math.pow(2,t)},t.aH=Gc,t.aI=T,t.aJ=Y,t.aK=Xc,t.aL=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},t.aM=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},t.aN=function(t){var e=new g(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aO=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},t.aP=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},t.aQ=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.aR=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},t.aS=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aT=Jc,t.aU=Qc,t.aV=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.aW=function(t){var e=new g(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.aX=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.aY=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[4],a=e[5],o=e[6],l=e[7],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*i+u*n,t[5]=a*i+c*n,t[6]=o*i+h*n,t[7]=l*i+p*n,t[8]=u*i-s*n,t[9]=c*i-a*n,t[10]=h*i-o*n,t[11]=p*i-l*n,t},t.aZ=function(){const t=new Float32Array(16);return v(t),t},t.a_=function(){const t=new Float64Array(16);return v(t),t},t.aa=function(t){return t*Math.PI/180},t.ab=E,t.ac=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ad=A,t.ae=function(t){return Math.hypot(t[0],t[1])},t.af=function(t){return t[0]=0,t[1]=0,t},t.ag=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},t.ah=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:a}=t,o=i?E(sr.interpolationFactor(i,e,s,a),0,1):0;"camera"===t.kind?n=or.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.aj=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/dc:"composite"===t.kind?or.number(n/dc,i/dc,r):e},t.ak=wc,t.al=_,t.am=function(t,e,r,n){const i=e.y-t.y,s=e.x-t.x,a=n.y-r.y,o=n.x-r.x,u=a*s-o*i;if(0===u)return null;const c=(o*(t.y-r.y)-a*(t.x-r.x))/u;return new l(t.x+c*s,t.y+c*i)},t.an=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,S=i*u-s*l,A=c*y-h*d,k=c*m-p*d,M=c*g-f*d,I=h*m-p*y,z=h*g-f*y,P=p*g-f*m,C=x*P-v*z+b*I+w*M-_*k+S*A;return C?(t[0]=(o*P-l*z+u*I)*(C=1/C),t[1]=(i*z-n*P-s*I)*C,t[2]=(y*S-m*_+g*w)*C,t[3]=(p*_-h*S-f*w)*C,t[4]=(l*M-a*P-u*k)*C,t[5]=(r*P-i*M+s*k)*C,t[6]=(m*b-d*S-g*v)*C,t[7]=(c*S-p*b+f*v)*C,t[8]=(a*z-o*M+u*A)*C,t[9]=(n*M-r*z-s*A)*C,t[10]=(d*_-y*b+g*x)*C,t[11]=(h*b-c*_-f*x)*C,t[12]=(o*k-a*I-l*A)*C,t[13]=(r*I-n*k+i*A)*C,t[14]=(y*v-d*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null},t.ao=oh,t.ap=po,t.aq=v,t.ar=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return [e,r,n,i]},t.as=Tu,t.at=I,t.au=function(t,e,r,n,i=!1){if(!r[0]&&!r[1])return [0,0];const s=i?"map"===n?-t.bearingInRadians:0:"viewport"===n?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e];}return [i?r[0]:I(e,r[0],t.zoom),i?r[1]:I(e,r[1],t.zoom)]},t.aw=gc,t.ax=Vh,t.ay=lc,t.az=Dh,t.b=G,t.b$=t=>"line"===t.type,t.b0=function(t,e,r){const n=new Float64Array(4);return function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u;}(n,t,e-90,r),n},t.b1=function(t,e,r,n){var i,s,a,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],y=r[2],g=r[3];return (s=u*f+c*d+h*y+p*g)<0&&(s=-s,f=-f,d=-d,y=-y,g=-g),1-s>m?(i=Math.acos(s),a=Math.sin(i),o=Math.sin((1-n)*i)/a,l=Math.sin(n*i)/a):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*y,t[3]=o*p+l*g,t},t.b2=function(t){const e=new Float64Array(9);var r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v;h=(i=(n=t)[0])*(l=i+i),p=(s=n[1])*l,d=(a=n[2])*l,y=a*(u=s+s),g=(o=n[3])*l,x=o*u,v=o*(c=a+a),(r=e)[0]=1-(f=s*u)-(m=a*c),r[3]=p-v,r[6]=d+x,r[1]=p+v,r[4]=1-h-m,r[7]=y-g,r[2]=d-x,r[5]=y+g,r[8]=1-h-f;const b=Y(-Math.asin(E(e[2],-1,1)));let w,_;return Math.hypot(e[5],e[8])<.001?(w=0,_=-Y(Math.atan2(e[3],e[4]))):(w=Y(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),_=Y(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:w,pitch:b+90,bearing:_}},t.b3=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b4=ye,t.b5=Ga,t.b6=Sl,t.b7=Al,t.b8=wl,t.b9=P,t.bA=L,t.bB=D,t.bC=class extends qa{constructor(t,e){super(t,e),this.current=0;}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t));}},t.bD=class extends qa{constructor(t,e){super(t,e),this.current=Ka;}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.bE=Za,t.bF=Xa,t.bG=class extends qa{constructor(t,e){super(t,e),this.current=[0,0,0];}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]));}},t.bH=class extends qa{constructor(t,e){super(t,e),this.current=[0,0];}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]));}},t.bI=x,t.bJ=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.bK=function(t,e,r){var n=e[0],i=e[1],s=e[2];return t[0]=n*r[0]+i*r[3]+s*r[6],t[1]=n*r[1]+i*r[4]+s*r[7],t[2]=n*r[2]+i*r[5]+s*r[8],t},t.bL=function(t,e,r,n,i,s,a){var o=1/(e-r),l=1/(n-i),u=1/(s-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=(a+s)*u,t[15]=1,t},t.bM=class extends qs{},t.bN=zu,t.bO=class extends Zs{},t.bP=jo,t.bQ=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.bR=Ro,t.bS=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[3]*n+r[7]*i+r[11]*s+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/a,t},t.bT=class extends Ts{},t.bU=class extends Qs{},t.bV=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},t.bW=function(t,e){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],p=t[10],f=t[11],d=t[12],y=t[13],g=t[14],x=t[15],v=e[0],b=e[1],w=e[2],_=e[3],S=e[4],A=e[5],k=e[6],M=e[7],I=e[8],z=e[9],P=e[10],C=e[11],B=e[12],V=e[13],E=e[14],T=e[15];return Math.abs(r-v)<=m*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-b)<=m*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(i-w)<=m*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(s-_)<=m*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(a-S)<=m*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(o-A)<=m*Math.max(1,Math.abs(o),Math.abs(A))&&Math.abs(l-k)<=m*Math.max(1,Math.abs(l),Math.abs(k))&&Math.abs(u-M)<=m*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(c-I)<=m*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-z)<=m*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(p-P)<=m*Math.max(1,Math.abs(p),Math.abs(P))&&Math.abs(f-C)<=m*Math.max(1,Math.abs(f),Math.abs(C))&&Math.abs(d-B)<=m*Math.max(1,Math.abs(d),Math.abs(B))&&Math.abs(y-V)<=m*Math.max(1,Math.abs(y),Math.abs(V))&&Math.abs(g-E)<=m*Math.max(1,Math.abs(g),Math.abs(E))&&Math.abs(x-T)<=m*Math.max(1,Math.abs(x),Math.abs(T))},t.bX=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.bY=t=>"symbol"===t.type,t.bZ=t=>"circle"===t.type,t.b_=t=>"heatmap"===t.type,t.ba=C,t.bb=Ae,t.bc=function(t,e,r,n,i){return P(n,i,E((t-e)/(r-e),0,1))},t.bd=z,t.be=function(){return new Float64Array(4)},t.bf=function(){return new Float64Array(3)},t.bg=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),s[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),s[2]=i[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},t.bh=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[0],s[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),s[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},t.bi=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),s[1]=i[1],s[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},t.bj=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i-u*n,t[1]=a*i-c*n,t[2]=o*i-h*n,t[3]=l*i-p*n,t[8]=s*n+u*i,t[9]=a*n+c*i,t[10]=o*n+h*i,t[11]=l*n+p*i,t},t.bk=function(t,e){const r=z(t,360),n=z(e,360),i=n-r,s=n>r?i-360:i+360;return Math.abs(i)0?a:-a},t.bn=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bo=Oc,t.bp=function(t,e){const r=z(t,2*Math.PI),n=z(e,2*Math.PI);return Math.min(Math.abs(r-n),Math.abs(r-n+2*Math.PI),Math.abs(r-n-2*Math.PI))},t.bq=function(t){return Math.hypot(t[0],t[1],t[2])},t.br=function(){const t={},e=ht.$version;for(const r in ht.$root){const n=ht.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.bs=Hi,t.bt=nt,t.bu=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):s.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(wt),i=e.map(wt),s=t.reduce(_t,{}),a=e.reduce(_t,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;t"fill"===t.type,t.c1=t=>"fill-extrusion"===t.type,t.c2=t=>"hillshade"===t.type,t.c3=t=>"raster"===t.type,t.c4=t=>"background"===t.type,t.c5=t=>"custom"===t.type,t.c6=B,t.c7=function(t,e,r){const n=k(e.x-r.x,e.y-r.y),i=k(t.x-r.x,t.y-r.y);var s,a;return Y(Math.atan2(n[0]*i[1]-n[1]*i[0],(s=n)[0]*(a=i)[0]+s[1]*a[1]))},t.c8=V,t.c9=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},t.cA=Lu,t.cB=Nn,t.cC=us,t.ca=function(t,e){const{x:r,y:n}=Kc.fromLngLat(e);return !(t<0||t>25||n<0||n>=1||r<0||r>=1)},t.cb=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cc=class extends Es{},t.cd=Yh,t.cf=function(t){return t.message===J},t.cg=rt,t.ch=function(t,e){Q.REGISTERED_PROTOCOLS[t]=e;},t.ci=function(t){delete Q.REGISTERED_PROTOCOLS[t];},t.cj=function(t,e){const r={};for(let n=0;nt*Tu));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(i,{},e.canonical)*Tu:1/0,w=()=>{e.bucket.allowVerticalPlacement&&Ji(s)&&(d.vertical=Wu(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,b,a,m,"left",f,g,t.ai.vertical,!0,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.e=F,t.f=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=Z;}));},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):Z;})),t.g=tt,t.h=(t,e)=>it(F(t,{type:"json"}),e),t.i=U,t.j=ut,t.k=lt,t.l=(t,e)=>it(F(t,{type:"arrayBuffer"}),e),t.m=it,t.n=function(t){return new Du(t).readFields(Ru,[])},t.o=Do,t.p=qu,t.q=As,t.r=$i,t.s=st,t.t=Ri,t.u=Fi,t.v=ht,t.w=j,t.x=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}},t.y=or,t.z=cs;})); + +define("worker",["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const o of t){this._layerConfigs[o.id]=o;const t=this._layers[o.id]=e.bv(o);t._featureFilter=e.a4(t.filter),this.keyCache[o.id]&&delete this.keyCache[o.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=e.cj(Object.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let r=this.familiesBySource[i];r||(r=this.familiesBySource[i]={});const s=o.sourceLayer||"_geojsonTileLayer";let n=r[s];n||(n=r[s]=[]),n.push(t);}}}class o{constructor(t){const o={},i=[];for(const e in t){const r=t[e],s=o[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};i.push(o),s[e]={rect:o,metrics:t.metrics};}}const{w:r,h:s}=e.p(i),n=new e.o({width:r||1,height:s||1});for(const i in t){const r=t[i];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=o[i][t].rect;e.o.copy(s.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap);}}this.image=n,this.positions=o;}}e.ck("GlyphAtlas",o);class i{constructor(t){this.tileID=new e.S(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,i,s,n,a){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a2;const l=new e.cl(Object.keys(t.layers).sort()),c=new e.cm(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:s,subdivisionGranularity:a},d=i.familiesBySource[this.source];for(const o in d){const i=t.layers[o];if(!i)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(o),a=[];for(let e=0;e=o.maxzoom||"none"!==o.visibility&&(r(t,this.zoom,s),(u[o.id]=o.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}const f=e.bA(h.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let g=Promise.resolve({});if(Object.keys(f).length){const e=new AbortController;this.inFlightDependencies.push(e),g=n.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const p=Object.keys(h.iconDependencies);let m=Promise.resolve({});if(p.length){const e=new AbortController;this.inFlightDependencies.push(e),m=n.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},e);}const y=Object.keys(h.patternDependencies);let v=Promise.resolve({});if(y.length){const e=new AbortController;this.inFlightDependencies.push(e),v=n.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const[w,x,_]=yield Promise.all([g,m,v]),b=new o(w),M=new e.cn(x,_);for(const t in u){const o=u[t];o instanceof e.a3?(r(o.layers,this.zoom,s),e.co({bucket:o,glyphMap:w,glyphPositions:b.positions,imageMap:x,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):o.hasPattern&&(o instanceof e.cp||o instanceof e.cq||o instanceof e.cr)&&(r(o.layers,this.zoom,s),o.addFeatures(h,this.tileID.canonical,M.patternPositions));}return this.status="done",{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:M,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function r(t,o,i){const r=new e.z(o);for(const e of t)e.recalculate(r,i);}class s{constructor(e,t,o){this.actor=e,this.layerIndex=t,this.availableImages=o,this.fetching={},this.loading={},this.loaded={};}loadVectorTile(t,o){return e._(this,void 0,void 0,(function*(){const i=yield e.l(t.request,o);try{return {vectorTile:new e.cs.VectorTile(new e.ct(i.data)),rawData:i.data,cacheControl:i.cacheControl,expires:i.expires}}catch(e){const o=new Uint8Array(i.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cu(t.request),s=new i(t);this.loading[o]=s;const n=new AbortController;s.abort=n;try{const i=yield this.loadVectorTile(t,n);if(delete this.loading[o],!i)return null;const a=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}s.vectorTile=i.vectorTile;const u=s.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[o]=s,this.fetching[o]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[o];}}catch(e){throw delete this.loading[o],s.status="done",this.loaded[o]=s,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid;if(!this.loaded||!this.loaded[o])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const i=this.loaded[o];if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=yield i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let s;if(this.fetching[o]){const{rawTileData:t,cacheControl:i,resourceTiming:n}=this.fetching[o];delete this.fetching[o],s=e.e({rawTileData:t.slice(0)},r,i,n);}else s=r;return s}if("done"===i.status&&i.vectorTile)return i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){const e=this.loading,o=t.uid;e&&e[o]&&e[o].abort&&(e[o].abort.abort(),delete e[o]);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid];}))}}class n{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:i,rawImageData:r,redFactor:s,greenFactor:n,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cv(r,-1,-1,c,u)):r,d=new e.cw(o,h,i,s,n,a,l);return this.loaded=this.loaded||{},this.loaded[o]=d,d}))}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}var a,l,c=function(){if(l)return a;function e(e,o){if(0!==e.length){t(e[0],o);for(var i=1;i=Math.abs(a)?o-l+a:a-l+o,o=l;}o+i>=0!=!!t&&e.reverse();}return l=1,a=function t(o,i){var r,s=o&&o.type;if("FeatureCollection"===s)for(r=0;r>31}function c(e,t){for(var o=e.loadGeometry(),i=e.type,r=0,s=0,n=o.length,c=0;ce},_=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;const M=3,S=5,I=6;class P{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const s=[];for(let t=0;t=o;e--){const o=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,r=180;else if(o>r){const e=this.getClusters([o,i,180,s],t),n=this.getClusters([-180,i,r,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(D(o),C(s),D(r),C(i)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+S]>1?k(l,t,this.clusterProps):this.points[l[t+M]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(i);const s=r.data;if(t*this.stride>=s.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const o=t*this.stride;s[o+4]===e&&l.push(s[o+S]>1?k(s,o,this.clusterProps):this.points[s[o+M]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(o-a)/r,c=(o+1+a)/r,u={features:[]};return this._addTileFeatures(i.range((t-a)/r,l,(t+1+a)/r,c),i.data,t,o,r,u),0===t&&this._addTileFeatures(i.range(1-a/r,l,1,c),i.data,r,o,r,u),t===r-1&&this._addTileFeatures(i.range(0,l,a/r,c),i.data,-1,o,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=i?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,o,i,r):r1;let l,c,u;if(a)l=T(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+M]];l=o.properties;const[i,r]=o.geometry.coordinates;c=D(i),u=C(r);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-o)),Math.round(this.options.extent*(u*r-i))]],tags:l};let d;d=a||this.options.generateId?t[e+M]:this.points[t[e+M]].id,void 0!==d&&(h.id=d),s.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:r,minPoints:s}=this.options,n=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+S]);}if(f>d&&f>=s){let e,s=i*d,n=u*d,g=-1;const p=((o/c|0)<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+S];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=p,r&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)));}a[o+4]=p,l.push(s/f,n/f,1/0,p,-1,f),r&&l.push(g);}else {for(let e=0;e1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+S]>1){const i=this.clusterProps[e[t+I]];return o?Object.assign({},i):i}const i=this.points[e[t+M]].properties,r=this.options.map(i);return o&&r===i?Object.assign({},r):r}}function k(e,t,o){return {type:"Feature",id:e[t+M],properties:T(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),O(e[t+1])]}};var i;}function T(e,t,o){const i=e[t+S],r=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,s=e[t+I],n=-1===s?{}:Object.assign({},o[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+M],point_count:i,point_count_abbreviated:r})}function D(e){return e/360+.5}function C(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function O(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function L(e,t,o,i){let r=i;const s=t+(o-t>>1);let n,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;ir)n=i,r=t;else if(t===r){const e=Math.abs(i-s);ei&&(n-t>3&&L(e,t,n,i),e[n+2]=r,o-n>3&&L(e,n,o,i));}function F(e,t,o,i,r,s){let n=r-o,a=s-i;if(0!==n||0!==a){const l=((e-o)*n+(t-i)*a)/(n*n+a*a);l>1?(o=r,i=s):l>0&&(o+=n*l,i+=a*l);}return n=e-o,a=t-i,n*n+a*a}function z(e,t,o,i){const r={id:null==e?null:e,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)G(r,o);else if("Polygon"===t)G(r,o[0]);else if("MultiLineString"===t)for(const e of o)G(r,e);else if("MultiPolygon"===t)for(const e of o)G(r,e[0]);return r}function G(e,t){for(let o=0;o0&&(n+=i?(r*l-a*s)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-s,2))),r=a,s=l;}const a=t.length-3;t[2]=1,L(t,0,a,o),t[a+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function Z(e,t,o,i){for(let r=0;r1?1:o}function W(e,t,o,i,r,s,n,a){if(i/=t,s>=(o/=t)&&n=i)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const n=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(n>=o&&c=i)continue;let u=[];if("Point"===s||"MultiPoint"===s)R(e,u,o,i,r);else if("LineString"===s)Y(e,u,o,i,r,!1,a.lineMetrics);else if("MultiLineString"===s)X(e,u,o,i,r,!1);else if("Polygon"===s)X(e,u,o,i,r,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];X(t,e,o,i,r,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(z(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(z(t.id,s,u,t.tags));}}return l.length?l:null}function R(e,t,o,i,r){for(let s=0;s=o&&n<=i&&q(t,e[s],e[s+1],e[s+2]);}}function Y(e,t,o,i,r,s,n){let a=V(e);const l=0===r?B:H;let c,u,h=e.start;for(let d=0;do&&(u=l(a,f,g,m,y,o),n&&(a.start=h+c*u)):v>i?w=o&&(u=l(a,f,g,m,y,o),x=!0),w>i&&v<=i&&(u=l(a,f,g,m,y,i),x=!0),!s&&x&&(n&&(a.end=h+c*u),t.push(a),a=V(e)),n&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===r?f:g;p>=o&&p<=i&&q(a,f,g,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&q(a,a[0],a[1],a[2]),a.length&&t.push(a);}function V(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function X(e,t,o,i,r,s){for(const n of e)Y(n,t,o,i,r,s,!1);}function q(e,t,o,i){e.push(t,o,i);}function B(e,t,o,i,r,s){const n=(s-t)/(i-t);return q(e,s,o+(r-o)*n,1),n}function H(e,t,o,i,r,s){const n=(s-o)/(r-o);return q(e,t+(i-t)*n,s,1),n}function $(e,t){const o=[];for(let i=0;i0&&t.size<(r?n:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;en)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;r&&function(e,t){let o=0;for(let t=0,i=e.length,r=i-2;t0===t)for(let t=0,o=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=ee(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(o!==s>>e||i!==n>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,v=null,w=null,x=null,_=W(e,u,o-f,o+p,0,d.minX,d.maxX,l),b=W(e,u,o+g,o+m,0,d.minX,d.maxX,l);e=null,_&&(y=W(_,u,i-f,i+p,1,d.minY,d.maxY,l),v=W(_,u,i+g,i+m,1,d.minY,d.maxY,l),_=null),b&&(w=W(b,u,i-f,i+p,1,d.minY,d.maxY,l),x=W(b,u,i+g,i+m,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(v||[],t+1,2*o,2*i+1),a.push(w||[],t+1,2*o+1,2*i),a.push(x||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:r,debug:s}=i;if(e<0||e>24)return null;const n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[se(c,u,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),s>1&&console.timeEnd("drilling down"),this.tiles[a]?K(this.tiles[a],r):null):null}}function se(e,t,o){return 32*((1<{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,n);},t}(t)).load((yield this._pendingData).features):(r=yield this._pendingData,new re(r,t.geojsonVtOptions)),this.loaded={};const o={};if(i){const e=i.finish();e&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}return o}catch(t){if(delete this._pendingRequest,e.cf(t))return {abandoned:!0};throw t}var r;}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){let i=yield this.loadGeoJSON(t,o);if(delete this._pendingRequest,"object"!=typeof i)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(i,!0),t.filter){const o=e.cB(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const r=i.features.filter((e=>o.value.evaluate({zoom:0},e)));i={type:"FeatureCollection",features:r};}return i}))}loadGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){const{promoteId:i}=t;if(t.request){const r=yield e.h(t.request,o);return this._dataUpdateable=ae(r.data,i)?le(r.data,i):void 0,r.data}if("string"==typeof t.data)try{const e=JSON.parse(t.data);return this._dataUpdateable=ae(e,i)?le(e,i):void 0,e}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return function(e,t,o){var i,r,s,n;if(t.removeAll&&e.clear(),t.remove)for(const o of t.remove)e.delete(o);if(t.add)for(const i of t.add){const t=ne(i,o);null!=t&&e.set(t,i);}if(t.update)for(const o of t.update){let t=e.get(o.id);if(null==t)continue;const a=!o.removeAllProperties&&((null===(i=o.removeProperties)||void 0===i?void 0:i.length)>0||(null===(r=o.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((o.newGeometry||o.removeAllProperties||a)&&(t=Object.assign({},t),e.set(o.id,t),a&&(t.properties=Object.assign({},t.properties))),o.newGeometry&&(t.geometry=o.newGeometry),o.removeAllProperties)t.properties={};else if((null===(s=o.removeProperties)||void 0===s?void 0:s.length)>0)for(const e of o.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:i}of o.addOrUpdateProperties)t.properties[e]=i;}}(this._dataUpdateable,t.dataDiff,i),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class ue{constructor(t){this.self=t,this.actor=new e.F(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.ch,this.self.removeProtocol=e.ci,this.self.registerRTLTextPlugin=t=>{e.cC.setMethods(t);},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,o)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,o.source).removeTile(o);})))),this.actor.registerMessageHandler("GCEZ",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterExpansionZoom(o)})))),this.actor.registerMessageHandler("GCC",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterChildren(o)})))),this.actor.registerMessageHandler("GCL",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterLeaves(o)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,o)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][o.type]||!this.workerSources[t][o.type][o.source])return;const e=this.workerSources[t][o.type][o.source];delete this.workerSources[t][o.type][o.source],void 0!==e.removeSource&&e.removeSource(o);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t];})))),this.actor.registerMessageHandler("SR",((t,o)=>e._(this,void 0,void 0,(function*(){this.referrer=o;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,o)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(o);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(o.layers,o.removedIds);})))),this.actor.registerMessageHandler("SL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(o);}))));}_setImages(t,o){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=o;for(const e in this.workerSources[t]){const i=this.workerSources[t][e];for(const e in i)i[e].availableImages=o;}}))}_syncRTLPluginState(t,o){return e._(this,void 0,void 0,(function*(){return yield e.cC.syncState(o,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let o=this.layerIndexes[e];return o||(o=this.layerIndexes[e]=new t),o}_getWorkerSource(e,t,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][o]){const i={sendAsync:(t,o)=>(t.targetMapId=e,this.actor.sendAsync(t,o))};switch(t){case"vector":this.workerSources[e][t][o]=new s(i,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][o]=new ce(i,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][o]=new this.externalWorkerSourceTypes[t](i,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][o]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue})); + +define("index",["exports","./shared"],(function(e,t){"use strict";var i="5.0.0";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let o,s;const a={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:e=>new Promise(((i,r)=>{const o=requestAnimationFrame(i);e.signal.addEventListener("abort",(()=>{cancelAnimationFrame(o),r(t.c());}));})),getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(o||(o=document.createElement("a")),o.href=e,o.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==s&&(s=matchMedia("(prefers-reduced-motion: reduce)")),s.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",n.suppressClickInternal,!0);}),0);}static getScale(e){const t=e.getBoundingClientRect();return {x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const o=i.boundingClientRect;return new t.P((r.clientX-o.left)/i.x-e.clientLeft,(r.clientY-o.top)/i.y-e.clientTop)}static mousePos(e,t){const i=n.getScale(e);return n.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=n.getScale(e);for(let o=0;o{c&&_(c),c=null,d=!0;},h.onerror=()=>{u=!0,c=null;},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,r,o,s;e.resetRequestQueue=()=>{i=[],r=0,o=0,s={};},e.addThrottleControl=e=>{const t=o++;return s[t]=e,t},e.removeThrottleControl=e=>{delete s[e],n();},e.getImage=(e,r,o=!0)=>new Promise(((s,a)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:o,state:"queued",onError:e=>{a(e);},onSuccess:e=>{s(e);}}),n();}));const a=e=>t._(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:i,supportImageRefresh:o,onError:s,onSuccess:a,abortController:l}=e,h=!1===o&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((e,t)=>e&&"accept"===t),!0));r++;const u=h?c(i,l):t.m(i,l);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?a(i):i.data&&a({data:yield(d=i.data,"function"==typeof createImageBitmap?t.d(d):t.f(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(t){delete e.abortController,s(t);}finally{r--,n();}var d;})),n=()=>{const e=(()=>{for(const e of Object.keys(s))if(s[e]())return !0;return !1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:a(e);}},c=(e,i)=>new Promise(((r,o)=>{const s=new Image,a=e.url,n=e.credentials;n&&"include"===n?s.crossOrigin="use-credentials":(n&&"same-origin"===n||!t.s(a))&&(s.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{s.src="",o(t.c());})),s.fetchPriority="high",s.onload=()=>{s.onerror=s.onload=null,r({data:s});},s.onerror=()=>{s.onerror=s.onload=null,i.signal.aborted||o(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},s.src=a;}));}(p||(p={})),p.resetRequestQueue();class m{constructor(e){this._transformRequestFn=e;}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e;}}function f(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:o}of e){const e=`${r}${o}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:o}));}}return t}function g(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}class v{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:o,height:s}=e,a=!(this.size&&this.size[0]===o&&this.size[1]===s||r),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),a)this.size=[o,s],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,o,s,0,this.format,l.UNSIGNED_BYTE,e.data);else {const{x:i,y:a}=r||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,a,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,a,o,s,l.RGBA,l.UNSIGNED_BYTE,e.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D);}bind(e,t,i){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),i!==o.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=o.LINEAR),e!==this.filter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,t),this.wrap=t);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t);}_validate(e,i){let r=!0;const o=i.data||i.spriteData;return this._validateStretch(i.stretchX,o&&o.width)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,o&&o.height)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.j(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return !0;let i=0;for(const r of e){if(r[0]{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t});}))}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.k("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return {width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else {const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},o=new t.I(i,r);this.patterns[e]={bin:i,position:o};}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new v(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE);}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),o=this.atlasImage;o.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,s=i.y+1,a=this.getImage(e).data,n=a.width,l=a.height;t.R.copy(a,o,{x:0,y:0},{x:r,y:s},{width:n,height:l}),t.R.copy(a,o,{x:0,y:l-1},{x:r,y:s-1},{width:n,height:1}),t.R.copy(a,o,{x:0,y:0},{x:r,y:s+l},{width:n,height:1}),t.R.copy(a,o,{x:n-1,y:0},{x:r-1,y:s},{width:1,height:l}),t.R.copy(a,o,{x:0,y:0},{x:r+n,y:s},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e);}}}const y=1e20;function w(e,t,i,r,o,s,a,n,l){for(let c=t;c-1);l++,s[l]=n,a[l]=c,a[l+1]=y;}for(let n=0,l=0;n65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[o])return {stack:e,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[o]){const i=P.loadGlyphRange(e,o,this.url,this.requestManager);t.requests[o]=i;}const s=yield t.requests[o];for(const e in s)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=s[+e]);return t.ranges[o]=!0,{stack:e,id:i,glyph:s[i]||null}}))}_doesCharSupportLocalGlyph(e){return !!this.localIdeographFontFamily&&/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))}_tinySDF(e,i,r){const o=this.localIdeographFontFamily;if(!o)return;if(!this._doesCharSupportLocalGlyph(r))return;let s=e.tinySDF;if(!s){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),s=e.tinySDF=new P.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:t});}const a=s.draw(String.fromCharCode(r));return {id:r,bitmap:new t.o({width:a.width||60,height:a.height||60},a.data),metrics:{width:a.glyphWidth/2||24,height:a.glyphHeight/2||24,left:a.glyphLeft/2+.5||0,top:a.glyphTop/2-27.5||-8,advance:a.glyphAdvance/2||24,isDoubleResolution:!0}}}}P.loadGlyphRange=function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const s=256*i,a=s+255,n=o.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${s}-${a}`),"Glyphs"),l=yield t.l(n,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${s}-${a}`);const c={};for(const e of t.n(l.data))c[e.id]=e;return c}))},P.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:s="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const n=this.size=e+4*t,l=this._createCanvas(n),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${s} ${e}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:s}=this.ctx.measureText(e),a=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-o))),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=n+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),_={data:d,width:c,height:h,glyphWidth:n,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(e,m,m+a);const v=p.getImageData(m,m,n,l);g.fill(y,0,u),f.fill(0,0,u);for(let e=0;e0?e*e:0,f[r]=e<0?e*e:0;}}w(g,0,0,c,h,c,this.f,this.v,this.z),w(f,m,m,n,l,c,this.f,this.v,this.z);for(let e=0;e1&&(a=e[++s]);const l=Math.abs(n-a.left),c=Math.abs(n-a.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(a.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.data[o+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let o=0,s=e[o];for(let t=0;t1&&(s=e[++o]);const i=Math.abs(t-s.left),a=Math.abs(t-s.right),n=Math.min(i,a);this.data[r+t]=Math.max(0,Math.min(255,(s.isDash?n:-n)+128));}}addDash(e,i){const r=i?7:0,o=2*r+1;if(this.nextRow+o>this.height)return t.w("LineAtlas out of space"),null;let s=0;for(let t=0;t{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[D]}numActive(){return Object.keys(this.active).length}}const A=Math.floor(a.hardwareConcurrency/2);let L,k;function F(){return L||(L=new z),L}z.workerCount=t.C(globalThis)?Math.max(Math.min(A,3),1):1;class B{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let e=0;e{e.remove();})),this.actors=[],e&&this.workerPool.release(this.id);}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t);}}function j(){return k||(k=new B(F(),t.G),k.registerMessageHandler("GR",((e,i,r)=>t.m(i,r)))),k}function O(e,i){const r=t.H();return t.J(r,r,[1,1,0]),t.K(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.L(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function N(e,t,i,r,o,s){var a;const n=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return !0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return !0}return !1}(null!==(a=null==o?void 0:o.layers)&&void 0!==a?a:null,t,e.id),l=s.maxPitchScaleFactor(),c=e.tilesIn(r,l,n);c.sort(Z);const h=[];for(const r of c)h.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,o,s,l,O(e.transform,r.tileID))});return function(e,t){for(const i in e)for(const r of e[i])G(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,o=r.wrappedTileID,s=i[o]=i[o]||{};for(const i in e){const r=e[i],o=s[i]=s[i]||{},a=t[i]=t[i]||[];for(const e of r)o[e.featureIndex]||(o[e.featureIndex]=!0,a.push(e));}}return t}(h),e)}function Z(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function G(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r;}function U(e,i,r){return t._(this,void 0,void 0,(function*(){let o=e;if(e.url?o=(yield t.h(i.transformRequest(e.url,"Source"),r)).data:yield a.frameAsync(r),!o)return null;const s=t.M(t.e(o,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in o&&o.vector_layers&&(s.vectorLayerIds=o.vector_layers.map((e=>e.id))),s}))}class V{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])));}setNorthEast(e){return this._ne=e instanceof t.N?new t.N(e.lng,e.lat):t.N.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.N?new t.N(e.lng,e.lat):t.N.convert(e),this}extend(e){const i=this._sw,r=this._ne;let o,s;if(e instanceof t.N)o=e,s=e;else {if(!(e instanceof V))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(V.convert(e)):this.extend(t.N.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.N.convert(e)):this;if(o=e._sw,s=e._ne,!o||!s)return this}return i||r?(i.lng=Math.min(o.lng,i.lng),i.lat=Math.min(o.lat,i.lat),r.lng=Math.max(s.lng,r.lng),r.lat=Math.max(s.lat,r.lat)):(this._sw=new t.N(o.lng,o.lat),this._ne=new t.N(s.lng,s.lat)),this}getCenter(){return new t.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.N(this.getWest(),this.getNorth())}getSouthEast(){return new t.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:r}=t.N.convert(e);let o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&o}static convert(e){return e instanceof V?e:e?new V(e):e}static fromLngLat(e,i=0){const r=360*i/40075017,o=r/Math.cos(Math.PI/180*e.lat);return new V(new t.N(e.lng-o,e.lat-r),new t.N(e.lng+o,e.lat+r))}adjustAntiMeridian(){const e=new t.N(this._sw.lng,this._sw.lat),i=new t.N(this._ne.lng,this._ne.lat);return new V(e,e.lng>i.lng?new t.N(i.lng+360,i.lat):i)}}class q{constructor(e,t,i){this.bounds=V.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.O(this.bounds.getWest())*i),o=Math.floor(t.Q(this.bounds.getNorth())*i),s=Math.ceil(t.O(this.bounds.getEast())*i),a=Math.ceil(t.Q(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((t,i)=>{e.reloadPromise={resolve:t,reject:i};}))}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null);}}))}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject);}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class W extends t.E{constructor(e,i,r,o){super(),this.id=e,this.dispatcher=r,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.M(i,["url","scheme","tileSize"]));}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield U(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.k("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this.fire(new t.j(e));}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}serialize(){return t.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const i=yield p.getImage(this.map._requestManager.transformRequest(t,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const t=this.map.painter.context,r=t.gl,o=i.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new v(t,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController);}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture);}))}hasTransition(){return !1}}class X extends W{constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield p.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const o=t.b(r)&&t.U()?r:yield this.readImageNow(r),s={type:this.type,uid:e.uid,source:this.id,rawImageData:o,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:s});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded";}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.V()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.W(e,-1,-1,i,r))}catch(e){}}return a.getImageData(e,1)}))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,s=0===i.x?e.wrap-1:e.wrap,a=(i.x+1+r)%r,n=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.S(e.overscaledZ,s,i.z,o,i.y).key]={backfilled:!1},l[new t.S(e.overscaledZ,n,i.z,a,i.y).key]={backfilled:!1},i.y>0&&(l[new t.S(e.overscaledZ,s,i.z,o,i.y-1).key]={backfilled:!1},l[new t.S(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.S(e.overscaledZ,n,i.z,a,i.y-1).key]={backfilled:!1}),i.y+10&&t.e(o,{resourceTiming:r}),this.fire(new t.k("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.k("data",Object.assign(Object.assign({},o),{sourceDataType:"content"})));}catch(e){if(this._pendingLoads--,this._removed)return void this.fire(new t.k("dataabort",{dataType:"source"}));this.fire(new t.j(e));}}))}loaded(){return 0===this._pendingLoads}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t);}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0;}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}}class K extends t.E{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t;}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield p.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading());}catch(e){this._request=null,this._loaded=!0,this.fire(new t.j(e));}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.k("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.Y.fromLngLat);var r;return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,s=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y);const a=Math.max(o-i,s-r),n=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,n);return new t.Z(n,Math.floor((i+o)/2*l),Math.floor((r+s)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new v(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}}class Y extends K{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a0(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading();}catch(e){this.fire(new t.j(e));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.j(new t.$(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new v(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class J extends K{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new t.j(new t.$(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.j(new t.$(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.j(new t.$(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.j(new t.$(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.j(new t.$(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new v(i,this.canvas,r.RGBA,{premultiply:!0});let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}}const Q={},ee=e=>{switch(e){case"geojson":return $;case"image":return K;case"raster":return W;case"raster-dem":return X;case"vector":return H;case"video":return Y;case"canvas":return J}return Q[e]},te="RTLPluginLoaded";class ie extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=j();}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.k(te));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let re=null;function oe(){return re||(re=new ie),re}class se{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a1(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r;}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a3){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a3&&i.hasRTLText){this.hasRTLText=!0,oe().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage);}else this.collisionBoxArray=new t.a2;}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new v(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new v(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null);}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture);}queryRenderedFeatures(e,t,i,r,o,s,a,n,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:o,scale:s,tileSize:this.tileSize,pixelPosMatrix:c,transform:n,params:a,queryPadding:this.queryPadding*l},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const o=r.loadVTLayers(),s=i&&i.sourceLayer?i.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const n=t.a4(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,o);}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class ne{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,i,r){const o=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},t.e(this.stateChanges[e][o],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null);}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,i){const r=String(i),o=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete o[e];}return o}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,i){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}r[e]=r[e]||{},t.e(r[e],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i);}}function le(e,t,i){const r=t.intersectsFrustum(e);if(!i)return r;const o=t.intersectsPlane(i);return 0===r||0===o?0:2===r&&2===o?2:1}function ce(e,i,r,o,s){let a=e;const n=Math.atan(i/r),l=Math.hypot(i,r);return a=e+t.a8(o/l/Math.max(.5,Math.cos(t.aa(s/2)))),a+=1*t.a8(Math.cos(n))/2,a+=t.ab(e-a,-0,0),a}function he(e,i){const r=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.a8(e.tileSize/i.tileSize));return Math.max(0,r)}function ue(e,i){const r=e.getCameraFrustum(),o=e.getClippingPlane(),s=e.screenPointToMercatorCoordinate(e.getCameraPoint()),a=t.Y.fromLngLat(e.center,e.elevation);s.z=a.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const n=e.getCoveringTilesDetailsProvider(),l=n.allowVariableZoom(e,i),c=he(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),_=Math.pow(2,d),p=[_*s.x,_*s.y,0],m=[_*a.x,_*a.y,0],f=Math.hypot(a.x-s.x,a.y-s.y),g=Math.abs(a.z-s.z),v=Math.hypot(f,g),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],y=[];if(e.renderWorldCopies&&n.allowWorldCopies())for(let e=1;e<=3;e++)b.push(x(-e)),b.push(x(e));for(b.push(x(0));b.length>0;){const _=b.pop(),f=_.x,x=_.y;let w=_.fullyVisible;const T={x:f,y:x,z:_.zoom},P=n.getTileAABB(T,_.wrap,e.elevation,i);if(!w){const e=le(r,P,o);if(0===e)continue;w=2===e;}const C=n.distanceToTile2d(s.x,s.y,T,P);let I=c;l&&(I=(i.calculateTileZoom||ce)(e.zoom+t.a8(e.tileSize/i.tileSize),C,g,v,e.fov)),I=(i.roundZoom?Math.round:Math.floor)(I),I=Math.max(0,I);const E=Math.min(I,u);if(_.wrap=n.getWrap(a,T,_.wrap),_.zoom>=E){if(_.zoom>1),wrap:_.wrap,fullyVisible:w});}return y.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}class de extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((e,t,i,r)=>{const o=new(ee(t.type))(e,t,i,r);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return o})(e,t,i,this),this._tiles={},this._cache=new ae(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ne,this._didEmitContent=!1,this._updated=!1;}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e);}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(e,i,r){return t._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,r);}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.j(i,{tile:e})):this.update(this.transform,this.terrain);}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e);}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.k("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(_e).map((e=>e.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,o=i.tileID,s=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),a=new t.P(o.canonical.x,o.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(_e).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)(e||"errored"!==this._tiles[t].state)&&this._reloadTile(t,"reloading");}}_reloadTile(e,i){return t._(this,void 0,void 0,(function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i));}))}_tileLoaded(e,i,r){e.timeAdded=a.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.k("data",{dataType:"source",tile:e,coord:e.tileID}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[s]&&(e.neighboringTiles[s].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const o in this._tiles){let s=this._tiles[o];if(r[o]||!s.hasData()||s.tileID.overscaledZ<=t||s.tileID.overscaledZ>i)continue;let a=s.tileID;for(;s&&s.tileID.overscaledZ>t+1;){const e=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[e.key],s&&s.hasData()&&(a=e);}let n=a;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]||e[n.canonical.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e]);}}_updateCoveredAndRetainedTiles(e,t,i,r,o,s){const n={},l={},c=Object.keys(e),h=a.now();for(const i of c){const r=e[i],o=this._tiles[i];if(!o||0!==o.fadeEndTime&&o.fadeEndTime<=h)continue;const s=this.findLoadedParent(r,t),a=this.findLoadedSibling(r),c=s||a||null;c&&(this._addTile(c.tileID),n[c.tileID.key]=c.tileID),l[i]=r;}this._retainLoadedChildren(l,r,i,e);for(const t in n)e[t]||(this._coveredTiles[t]=!0,e[t]=n[t]);if(s){const t={},i={};for(const e of o)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const r in i){const o=i[r].children(this._source.maxzoom);this._tiles[o[0].key]&&this._tiles[o[1].key]&&this._tiles[o[2].key]&&this._tiles[o[3].key]&&(t[o[0].key]=e[o[0].key]=o[0],t[o[1].key]=e[o[1].key]=o[1],t[o[2].key]=e[o[2].key]=o[2],t[o[3].key]=e[o[3].key]=o[3],delete i[r]);}for(const r in i){const o=i[r],s=this.findLoadedParent(o,this._source.minzoom),a=this.findLoadedSibling(o),n=s||a||null;if(n){t[n.tileID.key]=e[n.tileID.key]=n.tileID;for(const e in t)t[e].isChildOf(n.tileID)&&delete t[e];}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0);}}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.S(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=ue(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const o=he(e,this._source),s=Math.max(o-de.maxOverzooming,this._source.minzoom),a=Math.max(o+de.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of r)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const r=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[r.key]=r;}r=r.concat(Object.values(e));}const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,o);pe(this._source.type)&&this._updateCoveredAndRetainedTiles(l,s,a,o,r,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.ac(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e);}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e);}_updateRetainedTiles(e,t){var i;const r={},o={},s=Math.max(t-de.maxOverzooming,this._source.minzoom),a=Math.max(t+de.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);r[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=a.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){r[e.key]=e;continue}}else {const e=a.children(this._source.maxzoom);if(r[e[0].key]&&r[e[1].key]&&r[e[2].key]&&r[e[3].key])continue}let n=e.wasRequested();for(let t=a.overscaledZ-1;t>=s;--t){const s=a.scaledTo(t);if(o[s.key])break;if(o[s.key]=!0,e=this.getTile(s),!e&&n&&(e=this._addTile(s)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[s.key]=s),n=e.wasRequested(),t)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i;}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new se(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.k("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset();}tilesIn(e,i,r){const o=[],s=this.transform;if(!s)return o;const a=r?s.getCameraQueryGeometry(e):e,n=e.map((e=>s.screenPointToMercatorCoordinate(e,this.terrain))),l=a.map((e=>s.screenPointToMercatorCoordinate(e,this.terrain))),c=this.getIds();let h=1/0,u=1/0,d=-1/0,_=-1/0;for(const e of l)h=Math.min(h,e.x),u=Math.min(u,e.y),d=Math.max(d,e.x),_=Math.max(_,e.y);for(let e=0;e=0&&f[1].y+m>=0){const e=n.map((e=>a.getTilePoint(e))),t=l.map((e=>a.getTilePoint(e)));o.push({tile:r,tileID:a,queryGeometry:e,cameraQueryGeometry:t,scale:p});}}return o}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return !0;if(pe(this._source.type)){const e=a.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}}function _e(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function pe(e){return "raster"===e||"image"===e||"video"===e}de.maxOverzooming=10,de.maxUnderzooming=3;class me{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(o-a)/n:0;return this.points[s].mult(1-l).add(this.points[i].mult(l))}}function fe(e,t){let i=!0;return "always"===e||"never"!==e&&"never"!==t||(i=!1),i}class ge{constructor(e,t,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return [];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(o)return [{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e0}hitTestCircle(e,t,i,r,o){const s=e-i,a=e+i,n=t-i,l=t+i;if(a<0||s>this.width||l<0||n>this.height)return !1;const c=[];return this._forEachCell(s,n,a,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},o),c.length>0}_queryCell(e,t,i,r,o,s,a,n){const{seenUids:l,hitTest:c,overlapMode:h}=a,u=this.boxCells[o];if(null!==u){const o=this.bboxes;for(const a of u)if(!l.box[a]){l.box[a]=!0;const u=4*a,d=this.boxKeys[a];if(e<=o[u+2]&&t<=o[u+3]&&i>=o[u+0]&&r>=o[u+1]&&(!n||n(d))&&(!c||!fe(h,d.overlapMode))&&(s.push({key:d,x1:o[u],y1:o[u+1],x2:o[u+2],y2:o[u+3]}),c))return !0}}const d=this.circleCells[o];if(null!==d){const o=this.circles;for(const a of d)if(!l.circle[a]){l.circle[a]=!0;const u=3*a,d=this.circleKeys[a];if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],e,t,i,r)&&(!n||n(d))&&(!c||!fe(h,d.overlapMode))){const e=o[u],t=o[u+1],i=o[u+2];if(s.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return !0}}}return !1}_queryCellCircle(e,t,i,r,o,s,a,n){const{circle:l,seenUids:c,overlapMode:h}=a,u=this.boxCells[o];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(r))&&!fe(h,r.overlapMode))return s.push(!0),!0}}const d=this.circleCells[o];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!n||n(r))&&!fe(h,r.overlapMode))return s.push(!0),!0}}}_forEachCell(e,t,i,r,o,s,a,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(o.call(this,e,t,i,r,this.xCellCount*l+d,s,a,n))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,o,s){const a=r-e,n=o-t,l=i+s;return l*l>a*a+n*n}_circleAndRectCollide(e,t,i,r,o,s,a){const n=(s-r)/2,l=Math.abs(e-(r+n));if(l>n+i)return !1;const c=(a-o)/2,h=Math.abs(t-(o+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}function ve(e,i,o){const s=t.H();if(!e){const{vecSouth:e,vecEast:t}=be(i),o=r();o[0]=t[0],o[1]=t[1],o[2]=e[0],o[3]=e[1],a=o,(d=(l=(n=o)[0])*(u=n[3])-(h=n[2])*(c=n[1]))&&(a[0]=u*(d=1/d),a[1]=-c*d,a[2]=-h*d,a[3]=l*d),s[0]=o[0],s[1]=o[1],s[4]=o[2],s[5]=o[3];}var a,n,l,c,h,u,d;return t.K(s,s,[1/o,1/o,1]),s}function xe(e,i,r,o){if(e){const e=t.H();if(!i){const{vecSouth:t,vecEast:i}=be(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1];}return t.K(e,e,[o,o,1]),e}return r.pixelsToClipSpaceMatrix}function be(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),o=Math.cos(e.pitchInRadians),s=Math.cos(e.bearingInRadians),a=Math.sin(e.bearingInRadians),n=t.ad();n[0]=-s*o*r-a*i,n[1]=-a*o*r+s*i;const l=t.ae(n);l<1e-9?t.af(n):t.ag(n,n,1/l);const c=t.ad();c[0]=s*o*i-a*r,c[1]=a*o*i+s*r;const h=t.ae(c);return h<1e-9?t.af(c):t.ag(c,c,1/h),{vecEast:c,vecSouth:n}}function ye(e,i,r,o){let s;o?(s=[e,i,o(e,i),1],t.al(s,s,r)):(s=[e,i,0,1],je(s,s,r));const a=s[3];return {point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}function we(e,t){return .5+e/t*.5}function Te(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Pe(e,i,r,o,s,a,n,l,c,h,u,d,_){const p=r?e.textSizeData:e.iconSizeData,m=t.ah(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const v=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let y=!1;for(let r=0;rMath.abs(r.x-i.x)*o?{useVertical:!0}:(e===t.ai.vertical?i.yr.x)?{needsFlipping:!0}:null}function Ee(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:o,fontSize:s,flip:a,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=s/24,_=o.lineOffsetX*d,p=o.lineOffsetY*d;let m;if(o.numGlyphs>1){const e=o.glyphStartIndex+o.numGlyphs,t=o.lineStartIndex,s=o.lineStartIndex+o.lineLength,c=Ce(d,l,_,p,a,o,u,i);if(!c)return {notEnoughRoom:!0};const f=De(c.first.point.x,c.first.point.y,i,r),g=De(c.last.point.x,c.last.point.y,i,r);if(n&&!a){const e=Ie(o.writingMode,f,g,h);if(e)return e}m=[c.first];for(let r=o.glyphStartIndex+1;r0?n.point:Me(i.tileAnchorPoint,a,e,1,i),c=De(e.x,e.y,i,r),u=De(l.x,l.y,i,r),d=Ie(o.writingMode,c,u,h);if(d)return d}const e=ke(d*l.getoffsetX(o.glyphStartIndex),_,p,a,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[e];}for(const e of m)t.ak(c,e.point,e.angle);return {}}function Me(e,t,i,r,o){const s=e.add(e.sub(t)._unit()),a=Re(s.x,s.y,o).point,n=i.sub(a);return i.add(n._mult(r/n.mag()))}function Se(e,i,r){const o=i.projectionCache;if(o.projections[e])return o.projections[e];const s=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),a=Re(s.x,s.y,i);if(a.signedDistanceFromCamera>0)return o.projections[e]=a.point,o.anyProjectionOccluded=o.anyProjectionOccluded||a.isOccluded,a.point;const n=e-r.direction;return Me(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),s,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Re(e,t,i){const r=e+i.translation[0],o=t+i.translation[1];let s;return i.pitchWithMap?(s=ye(r,o,i.pitchedLabelPlaneMatrix,i.getElevation),s.isOccluded=!1):(s=i.transform.projectTileCoordinates(r,o,i.unwrappedTileID,i.getElevation),s.point.x=(.5*s.point.x+.5)*i.width,s.point.y=(.5*-s.point.y+.5)*i.height),s}function De(e,i,r,o){if(r.pitchWithMap){const s=[e,i,0,1];return t.al(s,s,o),r.transform.projectTileCoordinates(s[0]/s[3],s[1]/s[3],r.unwrappedTileID,r.getElevation).point}return {x:e/r.width*2-1,y:i/r.height*2-1}}function ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ae(e,t,i){return e._unit()._perp()._mult(t*i)}function Le(e,i,r,o,s,a,n,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=r.add(i);if(e+c.direction=s)return l.projectionCache.offsets[e]=h,h;const u=Se(e+c.direction,l,c),d=Ae(u.sub(r),n,c.direction),_=r.add(d),p=u.add(d);return l.projectionCache.offsets[e]=t.am(a,h,_,p)||h,l.projectionCache.offsets[e]}function ke(e,t,i,r,o,s,a,n,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,_=h>0?s+o:s+o+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=Re(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const b=Math.abs(c),y=[];let w;for(;v+x<=b;){if(_+=h,_=a)return null;v+=x,g=f,m=p;const e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:g};if(f=Se(_,n,e),0===i)y.push(g),w=f.sub(g);else {let t;const r=f.sub(g);t=0===r.mag()?Ae(Se(_+h,n,e).sub(f),i,h):Ae(r,i,h),m||(m=g.add(t)),p=Le(_,t,f,s,a,m,i,n,e),y.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((b-v)/x)._add(m||g),P=u+Math.atan2(f.y-g.y,f.x-g.x);return y.push(T),{point:T,angle:l?P:0,path:y}}const Fe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Be(e,t){for(let i=0;i=1;e--)_.push(a.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let f=[];if(_.length>0){const e=_[0].clone(),i=_[0].clone();for(let t=1;t<_.length;t++)e.x=Math.min(e.x,_[t].x),e.y=Math.min(e.y,_[t].y),i.x=Math.max(i.x,_[t].x),i.y=Math.max(i.y,_[t].y);f=e.x>=r.x&&i.x<=o.x&&e.y>=r.y&&i.y<=o.y?[_]:i.xo.x||i.yo.y?[]:t.ao([_],r.x,r.y,o.x,o.y);}for(const t of f){s.reset(t,.25*i);let r=0;r=s.length<=.5*i?1:Math.ceil(s.paddedLength/p)+1;for(let t=0;t{const t=ye(e.x,e.y,r,i.getElevation),o=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height,o}))}(e,i);return function(e){let t=0,i=0,r=0,o=0;for(let s=0;si&&(i=o,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let r=1/0,o=1/0,s=-1/0,a=-1/0;for(const n of e){const e=new t.P(n.x+Oe,n.y+Oe);r=Math.min(r,e.x),o=Math.min(o,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y),i.push(e);}const n=this.grid.query(r,o,s,a).concat(this.ignoredGrid.query(r,o,s,a)),l={},c={};for(const e of n){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const o=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.ap(i,o)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex));}return c}insertCollisionBox(e,t,i,r,o,s){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:o,collisionGroupID:s,overlapMode:t},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,r,o,s){const a=i?this.ignoredGrid:this.grid,n={bucketInstanceId:r,featureIndex:o,collisionGroupID:s,overlapMode:t};for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,o,c,u)));S=e.some((e=>!e.isOccluded)),M=e.map((e=>new t.P(e.x,e.y)));}else S=!0;return {box:t.ar(M),allPointsOccluded:!S}}}class Ze{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Ge{constructor(e,t,i,r,o){this.text=new Ze(e?e.text:null,t,i,o),this.icon=new Ze(e?e.icon:null,t,r,o);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ue{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i;}}class Ve{constructor(e,t,i,r,o){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=o;}}class qe{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function He(e,i,r,o,s){const{horizontalAlign:a,verticalAlign:n}=t.ay(e);return new t.P(-(a-.5)*i+o[0]*s,-(n-.5)*r+o[1]*s)}class We{constructor(e,t,i,r,o){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Ne(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new qe(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,o){const s=r.getBucket(i),a=r.latestFeatureIndex;if(!s||!a||i.id!==s.layerIds[0])return;const n=r.collisionBoxArray,l=s.layers[0].layout,c=s.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.X,d=r.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=t.at(r,1,this.transform.zoom),m=t.au(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),f=t.au(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),g=ve(_,this.transform,p);this.retainedQueryData[s.bucketInstanceId]=new Ve(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,r.tileID);const v={bucket:s,layout:l,translationText:m,translationIcon:f,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.ah(s.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(o)for(const t of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:v});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:v});}attemptAnchorPlacement(e,i,r,o,s,a,n,l,c,h,u,d,_,p,m,f,g,v,x,b){const y=t.av[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=He(y,r,o,w,s),P=this.collisionIndex.placeCollisionBox(i,d,l,c,h,n,a,f,u.predicate,x,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,c,h,n,a,g,u.predicate,x,T,b).placeable)&&P.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID].text&&(e=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:w,width:r,height:o,anchor:y,textBoxScale:s,prevAnchor:e},this.markUsedJustification(p,y,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:T,placedGlyphBoxes:P}}}placeLayerBucketPart(e,i,r){const{bucket:o,layout:s,translationText:a,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=e.parameters,m=s.get("text-optional"),f=s.get("icon-optional"),g=t.aw(s,"text-overlap","text-allow-overlap"),v="always"===g,x=t.aw(s,"icon-overlap","icon-allow-overlap"),b="always"===x,y="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),P="viewport-y"===s.get("symbol-z-order"),C=v&&(b||!o.hasIconData()||f),I=b&&(v||!o.hasTextData()||m);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d);const E=this.retainedQueryData[o.bucketInstanceId].tileID,M=this._getTerrainElevationFunc(E),S=this.transform.getFastPathSimpleProjectionMatrix(E),R=(e,d,b)=>{var P,R;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new Ue(!1,!1,!1));let D=!1,z=!1,A=!0,L=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},F={box:null,placeable:!1,offscreen:null},B=null,j=null,O=null,N=0,Z=0,G=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(Z=d.verticalTextFeatureIndex);const U=d.textBox;if(U){const i=i=>{let r=t.ai.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(o,r,e));}return r},s=(i,r)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===t.ai.vertical?(k=r(),F=k):k=i(),k&&k.placeable)break}else k=i();},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,h,E,l,w,y,a,p.predicate,M,void 0,S);return r&&r.placeable&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),r};s((()=>r(U,t.ai.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.ai.vertical):{box:null,offscreen:null}})),i(k&&k.placeable);}else {let _=t.av[null===(R=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[e.crossTileID])||void 0===R?void 0:R.anchor];const m=(t,i,s)=>{const d=t.x2-t.x1,m=t.y2-t.y1,f=e.textBoxScale,v=T&&"never"===x?i:null;let b=null,P="never"===g?1:2,C="never";_&&P++;for(let i=0;im(U,d.iconBox,t.ai.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ai.vertical):{box:null,occluded:!0,offscreen:null}})),k&&(D=k.placeable,A=k.offscreen);const f=i(k&&k.placeable);if(!D&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,f));}}}if(B=k,D=B&&B.placeable,A=B&&B.offscreen,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),n=t.aj(o.textSizeData,_,i),h=s.get("text-padding");j=this.collisionIndex.placeCollisionCircles(g,i,o.lineVertexArray,o.glyphOffsetArray,n,l,c,r,w,p.predicate,e.collisionCircleDiameter,h,a,M),j.circles.length&&j.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),D=v||j.circles.length>0&&!j.collisionDetected,A=A&&j.offscreen;}if(d.iconFeatureIndex&&(G=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,E,l,w,y,n,p.predicate,M,T&&L?L:void 0,S);F&&F.placeable&&d.verticalIconBox?(O=e(d.verticalIconBox),z=O.placeable):(O=e(d.iconBox),z=O.placeable),A=A&&O.offscreen;}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,q=f||0===e.numIconVertices;V||q?q?V||(z=z&&D):D=z&&D:z=D=z&&D;const H=z&&O.placeable;if(D&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,s.get("text-ignore-placement"),o.bucketInstanceId,F&&F.placeable&&Z?Z:N,p.ID),H&&this.collisionIndex.insertCollisionBox(O.box,x,s.get("icon-ignore-placement"),o.bucketInstanceId,G,p.ID),j&&D&&this.collisionIndex.insertCollisionCircles(j.circles,g,s.get("text-ignore-placement"),o.bucketInstanceId,N,p.ID),r&&this.storeCollisionData(o.bucketInstanceId,b,d,B,O,j),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===o.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Ue((D||C)&&!(null==B?void 0:B.occluded),(z||I)&&!(null==O?void 0:O.occluded),A||o.justReloaded),i[e.crossTileID]=!0;};if(P){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=o.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];R(o.symbolInstances.get(i),o.collisionArrays[i],i);}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=s>=0&&t!==s?0:r.crossTileID);}markUsedOrientation(e,i,r){const o=i===t.ai.horizontal||i===t.ai.horizontalOnly?i:0,s=i===t.ai.vertical?i:0,a=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of a)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=s);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,o=t?t.opacities:{},s=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],s=o[e];s?(this.opacities[e]=new Ge(s,r,t.text,t.icon),i=i||t.text!==s.text.placed||t.icon!==s.icon.placed):(this.opacities[e]=new Ge(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon);}for(const e in o){const t=o[e];if(!this.opacities[e]){const o=new Ge(t,r,!1,!1);o.isHidden()||(this.opacities[e]=o,i=i||t.text.placed||t.icon.placed);}}for(const e in s)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=s[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray);}}updateBucketOpacities(e,i,r,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const s=e.layers[0],a=s.layout,n=new Ge(null,0,!1,!1,!0),l=a.get("text-allow-overlap"),c=a.get("icon-allow-overlap"),h=s._unevaluatedLayout.hasValue("text-variable-anchor")||s._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===a.get("text-rotation-alignment"),d="map"===a.get("text-pitch-alignment"),_="none"!==a.get("icon-text-fit"),p=new Ge(null,0,l&&(c||!e.hasIconData()||a.get("icon-optional")),c&&(l||!e.hasTextData()||a.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const m=(e,t,i)=>{for(let r=0;r0,v=this.placedOrientations[o.crossTileID],x=v===t.ai.vertical,b=v===t.ai.horizontal||v===t.ai.horizontalOnly;if(s>0||a>0){const t=it(c.text);m(e.text,s,x?rt:t),m(e.text,a,b?rt:t);const i=c.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||x?1:0);})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||b?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o));}if(g){const t=it(c.icon),i=!(_&&o.verticalPlacedIconSymbolIndex&&x);o.placedIconSymbolIndex>=0&&(m(e.icon,o.numIconVertices,i?t:rt),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=c.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,o.numVerticalIconVertices,i?rt:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden());}const y=f&&f.has(i)?f.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const r=e.collisionArrays[i];if(r){let i=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(i=He(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1;}if(r.textBox||r.verticalTextBox){let o;r.textBox&&(o=x),r.verticalTextBox&&(o=b),Xe(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||o,y.text,i.x,i.y);}}if(r.iconBox||r.verticalIconBox){const t=Boolean(!b&&r.verticalIconBox);let o;r.iconBox&&(o=t),r.verticalIconBox&&(o=!t),Xe(e.iconCollisionBox.collisionVertexArray,c.icon.placed,o,y.icon,_?i.x:0,_?i.y:0);}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId]);}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function Xe(e,t,i,r,o,s){r&&0!==r.length||(r=[0,0,0,0]);const a=r[0]-Oe,n=r[1]-Oe,l=r[2]-Oe,c=r[3]-Oe;e.emplaceBack(t?1:0,i?1:0,o||0,s||0,a,n),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,l,n),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,l,c),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,a,c);}const $e=Math.pow(2,25),Ke=Math.pow(2,24),Ye=Math.pow(2,17),Je=Math.pow(2,16),Qe=Math.pow(2,9),et=Math.pow(2,8),tt=Math.pow(2,1);function it(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*$e+t*Ke+i*Ye+t*Je+i*Qe+t*et+i*tt+t}const rt=0;class ot{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,r,o){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex!this._forceFullPlacement&&a.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=s)&&(!r.maxzoom||r.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new ot(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const at=512/t.X/2;class nt{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const o=new Map;for(let e=0;e({x:Math.floor(e.anchorX*at),y:Math.floor(e.anchorY*at)}))),crossTileIDs:i.map((e=>e.crossTileID))};if(r.positions.length>128){const e=new t.az(r.positions.length,16,Uint16Array);for(const{x:t,y:i}of r.positions)e.add(t,i);e.finish(),delete r.positions,r.index=e;}this._symbolsByKey[e]=r;}}getScaledCoordinates(e,i){const{x:r,y:o,z:s}=this.tileID.canonical,{x:a,y:n,z:l}=i.canonical,c=at/Math.pow(2,l-s),h=(n*t.X+e.anchorY)*c,u=o*t.X*at;return {x:Math.floor((a*t.X+e.anchorX)*c-r*t.X*at),y:Math.floor(h-u)}}findMatches(e,t,i){const r=this.tileID.canonical.ze))}}class lt{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class ct{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const o=i[e];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),r[o.tileID.key]=o;}this.indexes[e]=r;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in o){const s=o[i];s.tileID.isChildOf(e)&&s.findMatches(t.symbolInstances,e,r);}else {const s=o[e.scaledTo(Number(i)).key];s&&s.findMatches(t.symbolInstances,e,r);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var ut="void main() {fragColor=vec4(1.0);}";const dt={prelude:_t("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:_t("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:_t("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:_t("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:_t("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:_t("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:_t(ut,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:_t("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:_t("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:_t("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:_t("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:_t("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:_t(ut,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:_t("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:_t("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:_t("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:_t("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:_t("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));fragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:_t("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:_t("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:_t("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:_t("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:_t("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:_t("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:_t("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:_t("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:_t("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:_t("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:_t("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:_t("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:_t("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:_t("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function _t(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=s?s.concat(o):o,n={};return {fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const s="float"===r?"vec2":"vec4",a=o.match(/color/)?"color":s;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${s} a_${o};\nout ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${a}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${s} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${a}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,staticUniforms:a}}class pt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}var mt=t.aA([{name:"a_pos",type:"Int16",components:2}]);const ft="#define PROJECTION_MERCATOR",gt="mercator";class vt{constructor(){this._cachedMesh=null;}get name(){return "mercator"}get useSubdivision(){return !1}get shaderVariantName(){return gt}get shaderDefine(){return ft}get shaderPreludeCode(){return dt.projectionMercator}get vertexShaderPreludeCode(){return dt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aB.noSubdivision}get useGlobeControls(){return !1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,o,s){if(this._cachedMesh)return this._cachedMesh;const a=new t.aC;a.emplaceBack(0,0),a.emplaceBack(t.X,0),a.emplaceBack(0,t.X),a.emplaceBack(t.X,t.X);const n=e.createVertexBuffer(a,mt.members),l=t.aD.simpleSegment(0,0,4,2),c=new t.aE;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new pt(n,h,l),this._cachedMesh}recalculate(){}hasTransition(){return !1}setErrorQueryLatitudeDegrees(e){}}function xt(e,i){const r=t.ab(i.lat,-t.aF,t.aF);return new t.P(t.O(i.lng)*e,t.Q(r)*e)}function bt(e,i){return new t.Y(i.x/e,i.y/e).toLngLat()}function yt(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.aa(90-e.pitch)),Math.tan(t.aa(89.25-e.pitch)))}function wt(e,i){const r=e.canonical,o=i/t.aG(r.z),s=r.x+Math.pow(2,r.z)*e.wrap,a=t.aq(new Float64Array(16));return t.J(a,a,[s*o,r.y*o,0]),t.K(a,a,[o/t.X,o/t.X,1]),a}function Tt(e,i,r,o,s){const a=t.Y.fromLngLat(e,i),n=s*t.aH(1,e.lat),l=n*Math.cos(t.aa(r)),c=Math.sqrt(n*n-l*l),h=c*Math.sin(t.aa(-o)),u=c*Math.cos(t.aa(-o));return new t.Y(a.x+h,a.y+u,a.z+l)}class Pt{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r;}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.y.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.y.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.y.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.y.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.ab((this.left+e-this.right)/2,0,e),o=t.ab((this.top+i-this.bottom)/2,0,i);return new t.P(r,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Pt(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ct(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0;}function It(e){return Math.max(0,Math.floor(e))}class Et{constructor(e,i,r,o,s,a){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===a||!!a,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==o?0:o,this._maxPitch=null==s?60:s,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.N(0,0),this._elevation=0,this._zoom=0,this._tileZoom=It(this._zoom),this._scale=t.aG(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Pt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0;}apply(e,i,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=It(this._zoom),this._scale=t.aG(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Pt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices();}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e;}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)));}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)));}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aI(e,-180,180)*Math.PI/180;var o,s,a,n,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),o=this._rotationMatrix,a=-this._bearingInRadians,n=(s=this._rotationMatrix)[0],l=s[1],c=s[2],h=s[3],u=Math.sin(a),d=Math.cos(a),o[0]=n*d+c*u,o[1]=l*d+h*u,o[2]=n*-u+c*d,o[3]=l*-u+h*d);}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ab(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices());}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices());}get fovInRadians(){return this._fovInRadians}get fov(){return t.aJ(this._fovInRadians)}setFov(e){e=t.ab(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.aa(e),this._calcMatrices());}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.aG(i),this._constrain(),this._calcMatrices());}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices();}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices();}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices();}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new V([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-t.aF,t.aF]);}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return [i[0],e];{let r=e.x,o=e.y,s=e.x,a=e.y;for(const e of i)r=Math.min(r,e.x),o=Math.min(o,e.y),s=Math.max(s,e.x),a=Math.max(a,e.y);return [new t.P(r,o),new t.P(s,o),new t.P(s,a),new t.P(r,a),new t.P(r,o)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1;}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.aq(new Float64Array(16));t.K(e,e,[this._width/2,-this._height/2,1]),t.J(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.aq(new Float64Array(16)),t.K(e,e,[1,-1,1]),t.J(e,e,[-1,-1,0]),t.K(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height;}this._callbacks.calcMatrices();}calculateCenterFromCameraLngLatAlt(e,i,r,o){const s=void 0!==r?r:this.bearing,a=o=void 0!==o?o:this.pitch,n=t.Y.fromLngLat(e,i),l=-Math.cos(t.aa(a)),c=Math.sin(t.aa(a)),h=c*Math.sin(t.aa(s)),u=-c*Math.cos(t.aa(s));let d=this.elevation;const _=i-d;let p;l*_>=0||Math.abs(l)<.1?(p=1e4,d=i+p*l):p=-_/l;let m,f,g=t.aK(1,n.y),v=0;do{if(v+=1,v>10)break;f=p/g,m=new t.Y(n.x+h*f,n.y+u*f),g=1/m.meterInMercatorCoordinateUnits();}while(Math.abs(p-f*g)>1e-12);return {center:m.toLngLat(),elevation:d,zoom:t.a8(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.aH(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,o=t.Y.fromLngLat(this.center,this.elevation),s=Tt(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;const a=this.calculateCenterFromCameraLngLatAlt(s.toLngLat(),t.aK(s.z,o.y),this.bearing,this.pitch);this._elevation=a.elevation,this._center=a.center,this.setZoom(a.zoom);}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.aH(1,this.center.lat)*this.worldSize;return Tt(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return [0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class St{distanceToTile2d(e,t,i,r){const o=r.distanceX([e,t]),s=r.distanceY([e,t]);return Math.hypot(o,s)}getWrap(e,t,i){return i}getTileAABB(e,i,r,o){var s,a;let n=r,l=r;if(o.terrain){const c=new t.S(e.z,i,e.z,e.x,e.y),h=o.terrain.getMinMaxElevation(c);n=null!==(s=h.minElevation)&&void 0!==s?s:r,l=null!==(a=h.maxElevation)&&void 0!==a?a:r;}const c=1<o||e.padding.top>=.1}allowWorldCopies(){return !0}recalculateCache(){}}class Rt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i;}static fromInvProjectionMatrix(e,i=1,r=0){const o=Math.pow(2,r),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const s=1/(r=t.al([],r,e))[3]/i*o;return t.aO(r,r,[s,s,1/r[3],s])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.aP([],s[e[0]],s[e[1]]),r=t.aP([],s[e[2]],s[e[1]]),o=t.aQ([],t.aR([],i,r)),a=-t.aS(o,s[e[1]]);return o.concat(a)})),n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of s)for(let t=0;t<3;t++)n[t]=Math.min(n[t],e[t]),l[t]=Math.max(l[t],e[t]);return new Rt(s,a,new Mt(n,l))}}class Dt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,r,o){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Et({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,r,o),this._coveringTilesDetailsProvider=new St;}clone(){const e=new Dt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i);}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.aT(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),s=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),a=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),n=Math.floor(Math.min(r.x,o.x,s.x,a.x)),l=Math.floor(Math.max(r.x,o.x,s.x,a.x)),c=1;for(let r=n-c;r<=l+c;r++)0!==r&&i.push(new t.aT(r,e));}return i}getCameraFrustum(){return Rt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i);}setLocationAtPoint(e,i){const r=t.aH(this.elevation,this.center.lat),o=this.screenPointToMercatorCoordinateAtZ(i,r),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),a=t.Y.fromLngLat(e),n=new t.Y(a.x-(o.x-s.x),a.y-(o.y-s.y));this.setCenter(null==n?void 0:n.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap());}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.Y.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.Y.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,o=[e.x,e.y,0,1],s=[e.x,e.y,1,1];t.al(o,o,this._pixelMatrixInverse),t.al(s,s,this._pixelMatrixInverse);const a=o[3],n=s[3],l=o[1]/a,c=s[1]/n,h=o[2]/a,u=s[2]/n,d=h===u?0:(r-h)/(u-h);return new t.Y(t.y.number(o[0]/a,s[0]/n,d)/this.worldSize,t.y.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.al(o,o,r),new t.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this._helper._height/2-yt(this));return (new V).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-yt(this)}calculatePosMatrix(e,i=!1,r){var o;const s=null!==(o=e.key)&&void 0!==o?o:t.aU(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),a=i?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(s)){const e=a.get(s);return r?e.f32:e.f64}const n=wt(e,this.worldSize);t.L(n,i?this._alignedProjMatrix:this._viewProjMatrix,n);const l={f64:n,f32:new Float32Array(n)};return a.set(s,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const o=wt(e,this.worldSize);return t.L(o,this._fogMatrix,o),r.set(i,new Float32Array(o)),r.get(i)}getConstrained(e,i){i=t.ab(+i,this.minZoom,this.maxZoom);const r={center:new t.N(e.lng,e.lat),zoom:i};let o=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===o){const e=180-1e-10;o=[-e,e];}const s=this.tileSize*t.aG(r.zoom);let a=0,n=s,l=0,c=s,h=0,u=0;const{x:d,y:_}=this.size;if(this._helper._latRange){const e=this._helper._latRange;a=t.Q(e[1])*s,n=t.Q(e[0])*s,n-a<_&&(h=_/(n-a));}o&&(l=t.aI(t.O(o[0])*s,0,s),c=t.aI(t.O(o[1])*s,0,s),cn&&(g=n-e);}if(o){const e=(l+c)/2;let i=p;this._helper._renderWorldCopies&&(i=t.aI(p,e-s/2,e+s/2));const r=d/2;i-rc&&(f=c-r);}if(void 0!==f||void 0!==g){const e=new t.P(null!=f?f:p,null!=g?g:m);r.center=bt(s,e).wrap();}return r}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const o=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),s=e-o*this._helper._pixelPerMeter/Math.cos(i),a=o<0?s:e,n=Math.PI/2+this.pitchInRadians,l=t.aa(this.fov)*(Math.abs(Math.cos(t.aa(this.roll)))*this.height+Math.abs(Math.sin(t.aa(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*a/Math.sin(t.ab(Math.PI-n-l,.01,Math.PI-.01)),h=yt(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.aa(.75),_=u>d?2*u*(.5+r.y/(2*h)):d,p=Math.sin(_)*a/Math.sin(t.ab(Math.PI-n-_,.01,Math.PI-.01)),m=Math.min(c,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+a),this._helper._nearZ=this._helper._height/50;}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=xt(this.worldSize,this.center),r=i.x,o=i.y;this._helper._pixelPerMeter=t.aH(1,this.center.lat)*this.worldSize;const s=t.aa(Math.min(this.pitch,89.25)),a=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(s));let n;this._calculateNearFarZIfNeeded(a,s,e),n=new Float64Array(16),t.aV(n,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.an(this._invProjMatrix,n),n[8]=2*-e.x/this._helper._width,n[9]=2*e.y/this._helper._height,this._projectionMatrix=t.aW(n),t.K(n,n,[1,-1,1]),t.J(n,n,[0,0,-this._helper.cameraToCenterDistance]),t.aX(n,n,-this.rollInRadians),t.aY(n,n,this.pitchInRadians),t.aX(n,n,-this.bearingInRadians),t.J(n,n,[-r,-o,0]),this._mercatorMatrix=t.K([],n,[this.worldSize,this.worldSize,this.worldSize]),t.K(n,n,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.L(new Float64Array(16),this.clipSpaceToPixelsMatrix,n),t.J(n,n,[0,0,-this.elevation]),this._viewProjMatrix=n,this._invViewProjMatrix=t.an([],n);const l=[0,0,-1,1];t.al(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.aV(this._fogMatrix,this.fovInRadians,this.width/this.height,a,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.K(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.J(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.aX(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.aY(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.aX(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.J(this._fogMatrix,this._fogMatrix,[-r,-o,0]),t.K(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.J(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.L(new Float64Array(16),this.clipSpaceToPixelsMatrix,n);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),_=r-Math.round(r)+u*c+d*h,p=o-Math.round(o)+u*h+d*c,m=new Float64Array(n);if(t.J(m,m,[_>.5?_-1:_,p>.5?p-1:p,0]),this._alignedProjMatrix=m,n=t.an(new Float64Array(16),this._pixelMatrix),!n)throw new Error("failed to invert matrix");this._pixelMatrixInverse=n,this._clearMatrixCaches();}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear();}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.al(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.aH(1,this.center.lat)*this.worldSize;return Tt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.Y.fromLngLat(e),o=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.al(o,o,this._viewProjMatrix),o[2]/o[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:o}=e,s=this._helper.getMercatorTileCoordinates(i),a=i?this.calculatePosMatrix(i,r,!0):null;let n;return n=i&&i.terrainRttPosMatrix32f&&o?i.terrainRttPosMatrix32f:a||t.aZ(),{mainMatrix:n,tileMercatorCoords:s,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n}}isLocationOccluded(e){return !1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aN(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,o){const s=this.calculatePosMatrix(r);let a;o?(a=[e,i,o(e,i),1],t.al(a,a,s)):(a=[e,i,0,1],je(a,a,s));const n=a[3];return {point:new t.P(a[0]/n,a[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t);}getMatrixForModel(e,i){const r=t.Y.fromLngLat(e,i),o=r.meterInMercatorCoordinateUnits(),s=t.a_();return t.J(s,s,[r.x,r.y,r.z]),t.aX(s,s,Math.PI),t.aY(s,s,Math.PI/2),t.K(s,s,[-o,o,o]),s}getProjectionDataForCustomLayer(e=!0){const i=new t.S(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),o=wt(i,this.worldSize);t.L(o,this._viewProjMatrix,o),r.tileMercatorCoords=[0,0,1,1];const s=[t.X,t.X,this.worldSize/this._helper.pixelsPerMeter],a=t.a$();return t.K(a,o,s),r.fallbackMatrix=a,r.mainMatrix=a,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function zt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");}function At(e){if(e.useSlerp)if(e.k<1){const i=t.b0(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.b0(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),o=new Float64Array(4);t.b1(o,i,r,e.k);const s=t.b2(o);e.tr.setRoll(s.roll),e.tr.setPitch(s.pitch),e.tr.setBearing(s.bearing);}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.y.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.y.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.y.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k));}function Lt(e,i,r,o,s){const a=s.padding,n=xt(s.worldSize,r.getNorthWest()),l=xt(s.worldSize,r.getNorthEast()),c=xt(s.worldSize,r.getSouthEast()),h=xt(s.worldSize,r.getSouthWest()),u=t.aa(-o),d=n.rotate(u),_=l.rotate(u),p=c.rotate(u),m=h.rotate(u),f=new t.P(Math.max(d.x,_.x,m.x,p.x),Math.max(d.y,_.y,m.y,p.y)),g=new t.P(Math.min(d.x,_.x,m.x,p.x),Math.min(d.y,_.y,m.y,p.y)),v=f.sub(g),x=(s.width-(a.left+a.right+i.left+i.right))/v.x,b=(s.height-(a.top+a.bottom+i.top+i.bottom))/v.y;if(b<0||x<0)return void zt();const y=Math.min(t.a8(s.scale*Math.min(x,b)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.aa(o)),P=w.add(T).mult(s.scale/t.aG(y));return {center:bt(s.worldSize,n.add(c).div(2).sub(P)),zoom:y,bearing:o}}class kt{get useGlobeControls(){return !1}handlePanInertia(e,t){return {easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around);}cameraForBoxAndBearing(e,t,i,r,o){return Lt(e,t,i,r,o)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.N.convert(i.center));}handleEaseTo(e,i){const r=e.zoom,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},n=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=n?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:_,zoom:p}=e.getConstrained(t.N.convert(i.center||d),null!=h?h:r);Ct(e,_);const m=xt(e.worldSize,d),f=xt(e.worldSize,_).sub(m),g=t.aG(p-r);return c=p!==r,{easeFunc:n=>{if(c&&e.setZoom(t.y.number(r,p,n)),t.b3(s,a)||At({startEulerAngles:s,endEulerAngles:a,tr:e,k:n,useSlerp:s.roll!=a.roll}),l&&(e.interpolatePadding(o,i.padding,n),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else {const i=t.aG(e.zoom-r),o=p>r?Math.min(2,g):Math.max(.5,g),s=Math.pow(o,1-n),a=bt(e.worldSize,m.add(f.mult(n*s)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?a.wrap():a,u);}},isZooming:c,elevationCenter:_}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.zoom,s=e.getConstrained(t.N.convert(i.center||i.locationAtOffset),r?+i.zoom:o),a=s.center,n=s.zoom;Ct(e,a);const l=xt(e.worldSize,i.locationAtOffset),c=xt(e.worldSize,a).sub(l),h=c.mag(),u=t.aG(n-o);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,o,n),s=e.getConstrained(a,r).zoom;d=t.aG(s-o);}return {easeFunc:(i,r,s,h)=>{e.setZoom(1===i?n:o+t.a8(r));const u=1===i?a:bt(e.worldSize,l.add(c.mult(s)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h);},scaleOfZoom:u,targetCenter:a,scaleOfMinZoom:d,pixelPathLength:h}}}class Ft{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i;}}Ft.Replace=[1,0],Ft.disabled=new Ft(Ft.Replace,t.b4.transparent,[!1,!1,!1,!1]),Ft.unblended=new Ft(Ft.Replace,t.b4.transparent,[!0,!0,!0,!0]),Ft.alphaBlended=new Ft([1,771],t.b4.transparent,[!0,!0,!0,!0]);const Bt=2305;class jt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}jt.disabled=new jt(!1,1029,Bt),jt.backCCW=new jt(!0,1029,Bt),jt.frontCCW=new jt(!0,1028,Bt);class Ot{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Ot.ReadOnly=!1,Ot.ReadWrite=!0,Ot.disabled=new Ot(519,Ot.ReadOnly,[0,1]);const Nt=7680;class Zt{constructor(e,t,i,r,o,s){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=o,this.pass=s;}}Zt.disabled=new Zt({func:519,mask:0},0,0,Nt,Nt,Nt);const Gt=new WeakMap;function Ut(e){var t;if(Gt.has(e))return Gt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Gt.set(e,i),i}}class Vt{get awaitingQuery(){return !!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const o=new t.aC;o.emplaceBack(-1,-1),o.emplaceBack(2,-1),o.emplaceBack(-1,2);const s=new t.aE;s.emplaceBack(0,1,2),this._fullscreenTriangle=new pt(i.createVertexBuffer(o,mt.members),i.createIndexBuffer(s),t.aD.simpleSegment(0,0,o.length,s.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(a),Ut(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null));}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null;}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer);}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,o=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.b4.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,o.TRIANGLES,Ot.disabled,Zt.disabled,Ft.unblended,jt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Ut(o)){o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.readBuffer(o.COLOR_ATTACHMENT0),o.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const e=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);o.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e};}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null};}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Ut(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Vt._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount;}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const qt=t.X/128;function Ht(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,o=r+(e.generateBorders?2:0),s=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),a=o+1,n=s+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=r+(e.generateBorders?1:0),u=r+(e.generateBorders||e.extendToSouthPole?1:0),d=a*n,_=o*s*6,p=a*n>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,f=new Int16Array(2*d);let g=0;for(let i=c;i<=u;i++)for(let o=l;o<=h;o++){let s=o/r*t.X;-1===o&&(s=-qt),o===r+1&&(s=t.X+qt);let a=i/r*t.X;-1===i&&(a=e.extendToNorthPole?t.b6:-qt),i===r+1&&(a=e.extendToSouthPole?t.b7:t.X+qt),f[g++]=s,f[g++]=a;}const v=m?new Uint32Array(_):new Uint16Array(_);let x=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return "globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy();}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e);}getMeshFromTileID(e,t,i,r,o){return this.currentProjection.getMeshFromTileID(e,t,i,r,o)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator");}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e);}}function Yt(e){const t=ei(e.worldSize,e.center.lat);return 2*Math.PI*t}function Jt(e,i,r,o,s){const a=1/(1<1e-6){const o=e[0]/r,s=Math.acos(e[2]/r),a=(o>0?s:-s)/Math.PI*180;return new t.N(t.aI(a,-180,180),i)}return new t.N(0,i)}function ii(e){return Math.cos(e*Math.PI/180)}function ri(e,i){const r=ii(e),o=ii(i);return t.a8(o/r)}function oi(e,i){const r=e.rotate(i.bearingInRadians),o=i.zoom+ri(i.center.lat,0),s=t.b9(1/ii(i.center.lat),1/ii(Math.min(Math.abs(i.center.lat),60)),t.bc(o,7,3,0,1)),a=360/Yt({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.N(i.center.lng-r.x*a*s,t.ab(i.center.lat+r.y*a,-t.aF,t.aF))}function si(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function ai(e,i,r,o){const s=e.lat+r*o;if(Math.abs(r)>1){const a=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,n=Math.abs(e.lat+r)*Math.PI/180,l=si(a+o*(n-a)),c=si(a),h=si(n);return new t.N(e.lng+i*((l-c)/(h-c)),s)}return new t.N(e.lng+i*o,s)}class ni{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=e;}recalculateCache(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1;}getTileAABB(e,t,i,r){const o=`${e.z}_${e.x}_${e.y}`,s=this._cache.get(o);if(s)return s;const a=this._cachePrevious.get(o);if(a)return this._cache.set(o,a),a;const n=this._aabbFactory(e,t,i,r);return this._cache.set(o,n),this._hadAnyChanges=!0,n}}function li(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function ci(e,t,i,r,o){const s=e-i;let a;return a=s<0?Math.min(-s,1+s-o):s>1?Math.min(Math.max(s-o,0),1-s):0,Math.max(a,li(t,r,o))}class hi{constructor(){this._aabbCache=new ni(this._computeTileAABB);}recalculateCache(){this._aabbCache.recalculateCache();}distanceToTile2d(e,t,i,r){const o=1<4}allowWorldCopies(){return !1}getTileAABB(e,t,i,r){return this._aabbCache.getTileAABB(e,t,i,r)}_computeTileAABB(e,i,r,o){if(e.z<=0)return new Mt([-1,-1,-1],[1,1,1]);if(1===e.z)return new Mt([0===e.x?-1:0,0===e.y?0:-1,-1],[0===e.x?0:1,0===e.y?1:0,1]);{const i=[Jt(0,0,e.x,e.y,e.z),Jt(t.X,0,e.x,e.y,e.z),Jt(t.X,t.X,e.x,e.y,e.z),Jt(0,t.X,e.x,e.y,e.z)],r=[1,1,1],o=[-1,-1,-1];for(const e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);if(0===e.y||e.y===(1<{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new hi;}clone(){const e=new ui;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e);}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bf();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return {mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,o=Math.sin(i)*r,s=Math.cos(i)*r+1,a=1/Math.sqrt(o*o+s*s)*1;let n=-o,l=s;const c=Math.sqrt(n*n+l*l);n/=c,l/=c;const h=[0,n,l];return t.bg(h,h,[0,0,0],-this.bearingInRadians),t.bh(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bi(h,h,[0,0,0],this.center.lng*Math.PI/180),t.aL(h,h,.25),[...h,.25*-a]}isLocationOccluded(e){return !this.isSurfacePointVisible(Qt(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,o=Math.cos(r),s=[Math.sin(i)*o,Math.sin(r),Math.cos(i)*o],a=[s[2],0,-s[0]],n=[0,0,0];t.aR(n,a,s),t.aQ(a,a),t.aQ(n,n);const l=[0,0,0];return t.aQ(l,[a[0]*e[0]+n[0]*e[1]+s[0]*e[2],a[1]*e[0]+n[1]*e[1]+s[1]*e[2],a[2]*e[0]+n[2]*e[1]+s[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const o=function(e,i,r){const o=1/(1<s&&(s=i),rn&&(n=r);}const h=[c.lng+a,c.lat+l,c.lng+s,c.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new V(h)}getConstrained(e,i){const r=t.ab(e.lat,-t.aF,t.aF),o=t.ab(+i,this.minZoom+ri(0,r),this.maxZoom);return {center:new t.N(e.lng,r),zoom:o}}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=Qt(this.unprojectScreenPoint(i)),o=Qt(e),s=t.bf();t.bl(s);const a=t.bf();t.bi(a,r,s,-this.center.lng*Math.PI/180),t.bh(a,a,s,this.center.lat*Math.PI/180);const n=o[0]*o[0]+o[2]*o[2],l=a[0]*a[0];if(n=-g&&p<=g,x=f>=-g&&f<=g;let b,y;if(v&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bp(u,e)+t.bp(p,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return !1;const i=t.be();return t.al(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.aS(e,i),o=t.bf(),s=t.bf();t.aL(s,i,r),t.aP(o,e,s);const a=1-t.aS(o,o);if(a<0)return null;const n=t.aS(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(a),c=n/l,h=l;return {tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),o=this.rayPlanetIntersection(i,r);if(o){const e=t.bf();t.aM(e,i,[r[0]*o.tMin,r[1]*o.tMin,r[2]*o.tMin]);const s=t.bf();return t.aQ(s,e),ti(s)}const s=this._cachedClippingPlane[0]*r[0]+this._cachedClippingPlane[1]*r[1]+this._cachedClippingPlane[2]*r[2],a=-t.bn(this._cachedClippingPlane,i)/s,n=t.bf();if(a>0)t.aM(n,i,[r[0]*a,r[1]*a,r[2]*a]);else {const e=t.bf();t.aM(e,i,[2*r[0],2*r[1],2*r[2]]);const o=t.bn(this._cachedClippingPlane,e);t.aP(n,e,[this._cachedClippingPlane[0]*o,this._cachedClippingPlane[1]*o,this._cachedClippingPlane[2]*o]);}const l=t.bf();return t.aQ(l,n),ti(l)}getMatrixForModel(e,i){const r=t.N.convert(e),o=1/t.bo,s=t.a_();return t.bj(s,s,r.lng/180*Math.PI),t.aY(s,s,-r.lat/180*Math.PI),t.J(s,s,[0,0,1+i/t.bo]),t.aY(s,s,.5*Math.PI),t.K(s,s,[o,o,o]),s}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.S(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class di{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache();}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Et({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Dt,this._verticalPerspectiveTransform=new ui;}clone(){const e=new di;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians);}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return {mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.b9(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.b9(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const o=this._mercatorTransform.getPitchedTextCorrection(e,i,r),s=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.b9(o,s,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ);}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e);}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e);}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform);}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class _i{get useGlobeControls(){return !0}handlePanInertia(e,i){const r=oi(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,o=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const s=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const a=i.zoom-s;if(0===a)return;const n=t.bk(i.center.lng,o.lng),l=n/(Math.abs(n/180)+1),c=t.bk(i.center.lat,o.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*t.aS(u,h),_=t.bf();t.aM(_,u,[h[0]*d,h[1]*d,h[2]*d]);const p=t.bq(_)-1,m=Math.exp(.5*-Math.max(p-.3,0)),f=ei(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=t.bc(f,.9,.5,1,.25),v=(1-t.aG(-a))*Math.min(m,g),x=i.center.lat,b=i.zoom,y=new t.N(i.center.lng+l*v,t.ab(i.center.lat+c*v,-t.aF,t.aF));i.setLocationAtPoint(o,r);const w=i.center,T=t.bc(Math.abs(n),45,85,0,1),P=t.bc(f,.75,.35,0,1),C=Math.pow(Math.max(T,P),.25),I=t.bk(w.lng,y.lng),E=t.bk(w.lat,y.lat);i.setCenter(new t.N(w.lng+I*C,w.lat+E*C).wrap()),i.setZoom(b+ri(x,i.center.lat));}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,o=t.zoom;t.setCenter(oi(e.panDelta,t).wrap()),t.setZoom(o+ri(r,t.center.lat));}cameraForBoxAndBearing(e,i,r,o,s){const a=Lt(e,i,r,o,s),n=i.left/s.width*2-1,l=(s.width-i.right)/s.width*2-1,c=i.top/s.height*-2+1,h=(s.height-i.bottom)/s.height*-2+1,u=t.bk(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),_=u?r.getWest():r.getEast(),p=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),f=d+.5*t.bk(d,_),g=p+.5*t.bk(p,m),v=s.clone();v.setCenter(a.center),v.setBearing(a.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(a.zoom);const x=v.modelViewProjectionMatrix,b=[Qt(r.getNorthWest()),Qt(r.getNorthEast()),Qt(r.getSouthWest()),Qt(r.getSouthEast()),Qt(new t.N(_,g)),Qt(new t.N(d,g)),Qt(new t.N(f,p)),Qt(new t.N(f,m))],y=Qt(a.center);let w=Number.POSITIVE_INFINITY;for(const e of b)n<0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"x",n))),l>0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"x",l))),c>0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"y",c))),h<0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"y",h)));if(Number.isFinite(w)&&0!==w)return a.zoom=v.zoom+t.a8(w),a;zt();}handleJumpToCenterZoom(e,i){const r=e.center.lat,o=e.getConstrained(i.center?t.N.convert(i.center):e.center,e.zoom).center;e.setCenter(o.wrap());const s=void 0!==i.zoom?+i.zoom:e.zoom+ri(r,o.lat);e.zoom!==s&&e.setZoom(s);}handleEaseTo(e,i){const r=e.zoom,o=e.center,s=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.N.convert(i.center):o,d=e.getConstrained(u,r).center;Ct(e,d);const _=e.clone();_.setCenter(d),_.setZoom(l?+i.zoom:r+ri(o.lat,u.lat)),_.setBearing(i.bearing);const p=new t.P(t.ab(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ab(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));_.setLocationAtPoint(d,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,f=l?+i.zoom:r+ri(o.lat,m.lat),g=r+ri(o.lat,0),v=f+ri(m.lat,0),x=t.bk(o.lng,m.lng),b=t.bk(o.lat,m.lat),y=t.aG(v-g);return h=f!==r,{easeFunc:r=>{if(t.b3(a,n)||At({startEulerAngles:a,endEulerAngles:n,tr:e,k:r,useSlerp:a.roll!=n.roll}),c&&e.interpolatePadding(s,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else {const t=v>g?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-r),s=ai(o,x,b,r*i);e.setCenter(s.wrap());}if(h){const i=t.y.number(g,v,r)+ri(0,e.center.lat);e.setZoom(i);}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.center,s=e.zoom,a=!e.isPaddingEqual(i.padding),n=e.getConstrained(t.N.convert(i.center||i.locationAtOffset),s).center,l=r?+i.zoom:e.zoom+ri(e.center.lat,n.lat),c=e.clone();c.setCenter(n),a&&c.setPadding(i.padding),c.setZoom(l),c.setBearing(i.bearing);const h=new t.P(t.ab(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ab(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));c.setLocationAtPoint(n,h);const u=c.center;Ct(e,u);const d=function(e,i,r){const o=Qt(i),s=Qt(r),a=t.aS(o,s),n=Math.acos(a),l=Yt(e);return n/(2*Math.PI)*l}(e,o,u),_=s+ri(o.lat,0),p=l+ri(u.lat,0),m=t.aG(p-_);let f;if("number"==typeof i.minZoom){const r=+i.minZoom+ri(u.lat,0),o=Math.min(r,_,p)+ri(0,u.lat),s=e.getConstrained(u,o).zoom+ri(u.lat,0);f=t.aG(s-_);}const g=t.bk(o.lng,u.lng),v=t.bk(o.lat,u.lat);return {easeFunc:(i,r,s,a)=>{const n=ai(o,g,v,s),c=1===i?u:n;e.setCenter(c.wrap());const h=_+t.a8(r);e.setZoom(1===i?l:h+ri(0,c.lat));},scaleOfZoom:m,targetCenter:u,scaleOfMinZoom:f,pixelPathLength:d}}static solveVectorScale(e,t,i,r,o){const s="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],a=[i[3],i[7],i[11],i[15]],n=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],l=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],c=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],h=t[0]*a[0]+t[1]*a[1]+t[2]*a[2];return c+o*l===n+o*h||a[3]*(n-c)+s[3]*(h-l)+n*h==c*l?null:(c+s[3]-o*h-o*a[3])/(c-n-o*h+o*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.t(e,i&&i.filter((e=>"source.canvas"!==e.identifier))),fi=t.br();class gi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload();}},this.map=e,this.dispatcher=new B(F(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler("GI",((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new P(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new R(256,512),this.crossTileSymbolIndex=new ht,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bs,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",t.bt()),oe().on(te,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t);}}));}loadURL(e,i={},r){this.fire(new t.k("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const s=this._loadStyleRequest;t.h(o,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,i,r);})).catch((e=>{this._loadStyleRequest=null,e&&!s.signal.aborted&&this.fire(new t.j(e));}));}loadJSON(e,i={},r){this.fire(new t.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r);})).catch((()=>{}));}loadEmpty(){this.fire(new t.k("dataloading",{dataType:"style"})),this._load(fi,{validate:!1});}_load(e,i,r){var o,s;const a=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!mi(this,t.u(a))){this._loaded=!0,this.stylesheet=a;for(const e in a.sources)this.addSource(e,a.sources[e],{validate:!1});a.sprite?this._loadSprite(a.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(a.glyphs),this._createLayers(),this.light=new E(this.stylesheet.light),this._setProjectionInternal((null===(o=this.stylesheet.projection)||void 0===o?void 0:o.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(s=this.stylesheet.terrain)&&void 0!==s?s:null),this.fire(new t.k("data",{dataType:"style"})),this.fire(new t.k("style.load"));}}_createLayers(){const e=t.bu(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.bv(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e;}}_loadSprite(e,i=!1,r=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const s=f(e),n=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of s){const s=i.transformRequest(g(r,n,".json"),"SpriteJSON");l[e]=t.h(s,o);const a=i.transformRequest(g(r,n,".png"),"SpriteImage");c[e]=p.getImage(a,o);}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,(function*(){const t={};for(const r in e){t[r]={};const o=a.getImageCanvasContext((yield i[r]).data),s=(yield e[r]).data;for(const e in s){const{width:i,height:a,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=s[e];t[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:a,x:n,y:l,context:o}};}}return t}))}(l,c)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[t]){const o="default"===t?r:`${t}:${r}`;this._spritesImagesIds[t].push(o),o in this.imageManager.images?this.imageManager.updateImage(o,e[t][r],!1):this.imageManager.addImage(o,e[t][r]),i&&(this._changedImages[o]=!0);}}})).catch((e=>{this._spriteRequest=null,o=e,this.fire(new t.j(o));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.k("data",{dataType:"style"})),r&&r(o);}));}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const o=i.getSource();("geojson"===o.type||o.vectorLayerIds&&-1===o.vectorLayerIds.indexOf(r))&&this.fire(new t.j(new Error(`Source layer "${r}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bw(r):r);const o=[];for(const s of e)if(r[s]){const e=i?t.bw(r[s]):r[s];o.push(e);}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize());}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return !0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return !0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return !0;for(const e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else {if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates();}const r={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const e in r){const i=this.sourceCaches[e];!!r[e]!=!!i.used&&i.fire(new t.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.k("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){var r;this._checkLoaded();const o=this.serialize();if(e=i.transformStyle?i.transformStyle(o,e):e,(null===(r=i.validate)||void 0===r||r)&&mi(this,t.u(e)))return !1;(e=t.bw(e)).layers=t.bu(e.layers);const s=t.bx(o,e),a=this._getOperationsToPerform(s);if(a.unimplemented.length>0)throw new Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(0===a.operations.length)return !1;for(const e of a.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push((()=>this.addLayer.apply(this,r.args)));break;case"removeLayer":t.push((()=>this.removeLayer.apply(this,r.args)));break;case"setPaintProperty":t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case"setLayoutProperty":t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case"setFilter":t.push((()=>this.setFilter.apply(this,r.args)));break;case"addSource":t.push((()=>this.addSource.apply(this,r.args)));break;case"removeSource":t.push((()=>this.removeSource.apply(this,r.args)));break;case"setLayerZoomRange":t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case"setLight":t.push((()=>this.setLight.apply(this,r.args)));break;case"setGeoJSONSourceData":t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case"setGlyphs":t.push((()=>this.setGlyphs.apply(this,r.args)));break;case"setSprite":t.push((()=>this.setSprite.apply(this,r.args)));break;case"setTerrain":t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case"setSky":t.push((()=>this.setSky.apply(this,r.args)));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setTransition":t.push((()=>{}));break;default:i.push(r.command);}return {operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.j(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(e,t){this.imageManager.updateImage(e,t);}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.j(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.u.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=this.sourceCaches[e]=new de(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,(()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e}))),o.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.j(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0;}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.j(new Error(`Layer "${o}" already exists on this map.`)));let s;if("custom"===e.type){if(mi(this,t.by(e)))return;s=t.bv(e);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(o,e.source),e=t.bw(e),e=t.e(e,{source:o})),this._validate(t.u.layer,`layers.${o}`,e,{arrayIndex:-1},r))return;s=t.bv(e),this._validateLayer(s),s.setEventedParent(this,{layer:{id:o}});}const a=i?this._order.indexOf(i):this._order.length;if(i&&-1===a)this.fire(new t.j(new Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));else {if(this._order.splice(a,0,o),this._layerOrderChanged=!0,this._layers[o]=s,this._removedLayers[o]&&s.source&&"custom"!==s.type){const e=this._removedLayers[o];delete this._removedLayers[o],e.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",this.sourceCaches[s.source].pause());}this._updateLayer(s),s.onAdd&&s.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.j(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.j(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.j(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(e){return this._layers[e]}getLayersOrder(){return [...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.j(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!t.bz(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.u.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.bw(i),this._updateLayer(o)))}else this.fire(new t.j(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.bw(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const s=this.getLayer(e);s?t.bz(s.getLayoutProperty(i),r)||(s.setLayoutProperty(i,r,o),this._updateLayer(s)):this.fire(new t.j(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.j(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,r,o={}){this._checkLoaded();const s=this.getLayer(e);s?t.bz(s.getPaintProperty(i),r)||(s.setPaintProperty(i,r,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.j(new Error(`Cannot style non-existing layer "${e}".`)));}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,s=this.sourceCaches[r];if(void 0===s)return void this.fire(new t.j(new Error(`The source '${r}' does not exist in the map's style.`)));const a=s.getSource().type;"geojson"===a&&o?this.fire(new t.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==a||o?(void 0===e.id&&this.fire(new t.j(new Error("The feature id parameter must be provided."))),s.setFeatureState(o,e.id,i)):this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new t.j(new Error(`The source '${r}' does not exist in the map's style.`)));const s=o.getSource().type,a="vector"===s?e.sourceLayer:void 0;"vector"!==s||a?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.j(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(a,e.id,i):this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.sourceCaches[i];if(void 0!==o)return "vector"!==o.getSource().type||r?(void 0===e.id&&this.fire(new t.j(new Error("The feature id parameter must be provided."))),o.getFeatureState(r,e.id)):void this.fire(new t.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.j(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bA(this.sourceCaches,(e=>e.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,o=this.stylesheet;return t.bB({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,projection:o.projection,sources:e,layers:i,terrain:r},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s)){i[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=this._order.length-1;s>=0;s--){const a=this._order[s];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of o)t.push(e);}}return function(e,t,i){for(const r in e)for(const o of e[r])G(o,i[t[r].source]);return e}(n,e,i)}(this._layers,a,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.u.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],o={};for(let e=0;ee.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);s=s||r;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.now(),e.zoom))&&(this.pauseablePlacement=new st(e,this.map.terrain,this._order,o,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.now()),n=!0),s&&this.pauseablePlacement.placement.setStale()),n||s)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles();}getImages(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e}))}getGlyphs(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.u.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}addSprite(e,i,r={},o){this._checkLoaded();const s=[{id:e,url:i}],a=[...f(this.stylesheet.sprite),...s];this._validate(t.u.sprite,"sprite",a,null,r)||(this.stylesheet.sprite=a,this._loadSprite(s,!0,o));}removeSprite(e){this._checkLoaded();const i=f(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.k("data",{dataType:"style"}));}else this.fire(new t.j(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return f(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.u.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)));}}var vi=t.aA([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class xi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(e,t,i,r,o,s,a,n,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.b4.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:s?0:r?r.calculateFogBlendOpacity(o):0,u_horizon_color:r?r.properties.get("horizon-color"):t.b4.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:s?1:0}),yi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function wi(e){const t=[];for(let i=0;i({u_depth:new t.bC(e,i.u_depth),u_terrain:new t.bC(e,i.u_terrain),u_terrain_dim:new t.b5(e,i.u_terrain_dim),u_terrain_matrix:new t.bD(e,i.u_terrain_matrix),u_terrain_unpack:new t.bE(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.b5(e,i.u_terrain_exaggeration)}))(e,P),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bD(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bE(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bE(e,i.u_projection_clipping_plane),u_projection_transition:new t.b5(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bD(e,i.u_projection_fallback_matrix)}))(e,P),this.binderUniforms=r?r.getUniforms(e,P):[];}draw(e,t,i,r,o,s,a,n,l,c,h,u,d,_,p,m,f,g,v){const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(o),e.setCullFace(s),n){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,n.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,n.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(n[e]);}if(l)for(const e in l)this.projectionUniforms[yi[e]].set(l[e]);if(a)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(a[e]);m&&m.setUniforms(e,this.binderUniforms,_,{zoom:p});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1;}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new xi)).bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,f,g,v),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2);}}}function Pi(e,i,r){const o=1/t.at(r,1,i.transform.tileZoom),s=Math.pow(2,r.tileID.overscaledZ),a=r.tileSize*Math.pow(2,i.transform.tileZoom)/s,n=a*(r.tileID.canonical.x+r.tileID.wrap*s),l=a*r.tileID.canonical.y;return {u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[o,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}const Ci=(e,i,r,o)=>{const s=e.style.light,a=s.properties.get("position"),n=[a.x,a.y,a.z],l=t.bI();"viewport"===s.properties.get("anchor")&&t.bJ(l,e.transform.bearingInRadians),t.bK(n,n,l);const c=e.transform.transformLightDirection(n),h=s.properties.get("color");return {u_lightpos:n,u_lightpos_globe:c,u_lightintensity:s.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:o}},Ii=(e,i,r,o,s,a,n)=>t.e(Ci(e,i,r,o),Pi(a,e,n),{u_height_factor:-Math.pow(2,s.overscaledZ)/n.tileSize/8}),Ei=(e,i,r,o)=>t.e(Pi(i,e,r),{u_fill_translate:o}),Mi=(e,t)=>({u_world:e,u_fill_translate:t}),Si=(e,i,r,o,s)=>t.e(Ei(e,i,r,s),{u_world:o}),Ri=(e,i,r,o,s)=>{const a=e.transform;let n,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.at(i,1,a.zoom);n=!0,l=[e,e],c=e/(t.X*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*s;}else n=!1,l=a.pixelsToGLUnits;return {u_camera_to_center_distance:a.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:o}},Di=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),zi=e=>({u_viewport_size:[e.width,e.height]}),Ai=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Li=(e,i,r,o)=>{const s=t.at(e,1,i)/(t.X*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*o;return {u_extrude_scale:t.at(e,1,i),u_intensity:r,u_globe_extrude_scale:s}},ki=(e,i,r,o)=>{const s=t.H();t.bL(s,0,e.width,e.height,0,0,1);const a=e.context.gl;return {u_matrix:s,u_world:[a.drawingBufferWidth,a.drawingBufferHeight],u_image:r,u_color_ramp:o,u_opacity:i.paint.get("heatmap-opacity")}},Fi=(e,t,i)=>{const r=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);return "viewport"===i.paint.get("hillshade-illumination-anchor")&&(a+=e.transform.bearingInRadians),{u_image:0,u_latrange:ji(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:r,u_highlight:o,u_accent:s}},Bi=(e,i)=>{const r=i.stride,o=t.H();return t.bL(o,0,t.X,-t.X,0,0,1),t.J(o,o,[0,-t.X,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function ji(e,i){const r=Math.pow(2,i.canonical.z),o=i.canonical.y;return [new t.Y(0,o/r).toLngLat().lat,new t.Y(0,(o+1)/r).toLngLat().lat]}const Oi=(e,i,r,o)=>{const s=e.transform;return {u_translation:Vi(e,i,r),u_ratio:o/t.at(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Ni=(e,i,r,o,s)=>t.e(Oi(e,i,r,o),{u_image:0,u_image_height:s}),Zi=(e,i,r,o,s)=>{const a=e.transform,n=Ui(i,a);return {u_translation:Vi(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:o/t.at(i,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[n,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Gi=(e,i,r,o,s,a)=>{const n=e.lineAtlas,l=Ui(i,e.transform),c="round"===r.layout.get("line-cap"),h=n.getDash(s.from,c),u=n.getDash(s.to,c),d=h.width*a.fromScale,_=u.width*a.toScale;return t.e(Oi(e,i,r,o),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:a.t})};function Ui(e,i){return 1/t.at(e,1,i.tileZoom)}function Vi(e,i,r){return t.au(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const qi=(e,t,i,r,o)=>{return {u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(a=r.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=r.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:Hi(r.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]};var s,a;};function Hi(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Wi=(e,t,i,r,o,s,a,n,l,c,h,u,d)=>{const _=a.transform;return {u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_pitch:_.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:a.options.fadeDuration?a.symbolFadeChange:1,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:o,u_is_variable_anchor:s,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},Xi=(e,i,r,o,s,a,n,l,c,h,u,d,_,p)=>{const m=n.transform;return t.e(Wi(e,i,r,o,s,a,n,l,c,h,u,d,p),{u_gamma_scale:o?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:+_})},$i=(e,i,r,o,s,a,n,l,c,h,u,d,_)=>t.e(Xi(e,i,r,o,s,a,n,l,c,h,!0,u,!0,_),{u_texsize_icon:d,u_texture_icon:1}),Ki=(e,t)=>({u_opacity:e,u_color:t}),Yi=(e,i,r,o,s)=>t.e(function(e,i,r,o){const s=r.imageManager.getPattern(e.from.toString()),a=r.imageManager.getPattern(e.to.toString()),{width:n,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(o.tileID.canonical.x+o.tileID.wrap*c),d=h*o.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.at(o,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,s,i,o),{u_opacity:e}),Ji=(e,t)=>{},Qi={fillExtrusion:(e,i)=>({u_lightpos:new t.bG(e,i.u_lightpos),u_lightpos_globe:new t.bG(e,i.u_lightpos_globe),u_lightintensity:new t.b5(e,i.u_lightintensity),u_lightcolor:new t.bG(e,i.u_lightcolor),u_vertical_gradient:new t.b5(e,i.u_vertical_gradient),u_opacity:new t.b5(e,i.u_opacity),u_fill_translate:new t.bH(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bG(e,i.u_lightpos),u_lightpos_globe:new t.bG(e,i.u_lightpos_globe),u_lightintensity:new t.b5(e,i.u_lightintensity),u_lightcolor:new t.bG(e,i.u_lightcolor),u_vertical_gradient:new t.b5(e,i.u_vertical_gradient),u_height_factor:new t.b5(e,i.u_height_factor),u_opacity:new t.b5(e,i.u_opacity),u_fill_translate:new t.bH(e,i.u_fill_translate),u_image:new t.bC(e,i.u_image),u_texsize:new t.bH(e,i.u_texsize),u_pixel_coord_upper:new t.bH(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bH(e,i.u_pixel_coord_lower),u_scale:new t.bG(e,i.u_scale),u_fade:new t.b5(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bH(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bC(e,i.u_image),u_texsize:new t.bH(e,i.u_texsize),u_pixel_coord_upper:new t.bH(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bH(e,i.u_pixel_coord_lower),u_scale:new t.bG(e,i.u_scale),u_fade:new t.b5(e,i.u_fade),u_fill_translate:new t.bH(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bH(e,i.u_world),u_fill_translate:new t.bH(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bH(e,i.u_world),u_image:new t.bC(e,i.u_image),u_texsize:new t.bH(e,i.u_texsize),u_pixel_coord_upper:new t.bH(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bH(e,i.u_pixel_coord_lower),u_scale:new t.bG(e,i.u_scale),u_fade:new t.b5(e,i.u_fade),u_fill_translate:new t.bH(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.b5(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bC(e,i.u_scale_with_map),u_pitch_with_map:new t.bC(e,i.u_pitch_with_map),u_extrude_scale:new t.bH(e,i.u_extrude_scale),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.b5(e,i.u_globe_extrude_scale),u_translate:new t.bH(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bH(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bH(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bF(e,i.u_color),u_overlay:new t.bC(e,i.u_overlay),u_overlay_scale:new t.b5(e,i.u_overlay_scale)}),depth:Ji,clippingMask:Ji,heatmap:(e,i)=>({u_extrude_scale:new t.b5(e,i.u_extrude_scale),u_intensity:new t.b5(e,i.u_intensity),u_globe_extrude_scale:new t.b5(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bD(e,i.u_matrix),u_world:new t.bH(e,i.u_world),u_image:new t.bC(e,i.u_image),u_color_ramp:new t.bC(e,i.u_color_ramp),u_opacity:new t.b5(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bC(e,i.u_image),u_latrange:new t.bH(e,i.u_latrange),u_light:new t.bH(e,i.u_light),u_shadow:new t.bF(e,i.u_shadow),u_highlight:new t.bF(e,i.u_highlight),u_accent:new t.bF(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bD(e,i.u_matrix),u_image:new t.bC(e,i.u_image),u_dimension:new t.bH(e,i.u_dimension),u_zoom:new t.b5(e,i.u_zoom),u_unpack:new t.bE(e,i.u_unpack)}),line:(e,i)=>({u_translation:new t.bH(e,i.u_translation),u_ratio:new t.b5(e,i.u_ratio),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bH(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bH(e,i.u_translation),u_ratio:new t.b5(e,i.u_ratio),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bH(e,i.u_units_to_pixels),u_image:new t.bC(e,i.u_image),u_image_height:new t.b5(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bH(e,i.u_translation),u_texsize:new t.bH(e,i.u_texsize),u_ratio:new t.b5(e,i.u_ratio),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_image:new t.bC(e,i.u_image),u_units_to_pixels:new t.bH(e,i.u_units_to_pixels),u_scale:new t.bG(e,i.u_scale),u_fade:new t.b5(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bH(e,i.u_translation),u_ratio:new t.b5(e,i.u_ratio),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bH(e,i.u_units_to_pixels),u_patternscale_a:new t.bH(e,i.u_patternscale_a),u_patternscale_b:new t.bH(e,i.u_patternscale_b),u_sdfgamma:new t.b5(e,i.u_sdfgamma),u_image:new t.bC(e,i.u_image),u_tex_y_a:new t.b5(e,i.u_tex_y_a),u_tex_y_b:new t.b5(e,i.u_tex_y_b),u_mix:new t.b5(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bH(e,i.u_tl_parent),u_scale_parent:new t.b5(e,i.u_scale_parent),u_buffer_scale:new t.b5(e,i.u_buffer_scale),u_fade_t:new t.b5(e,i.u_fade_t),u_opacity:new t.b5(e,i.u_opacity),u_image0:new t.bC(e,i.u_image0),u_image1:new t.bC(e,i.u_image1),u_brightness_low:new t.b5(e,i.u_brightness_low),u_brightness_high:new t.b5(e,i.u_brightness_high),u_saturation_factor:new t.b5(e,i.u_saturation_factor),u_contrast_factor:new t.b5(e,i.u_contrast_factor),u_spin_weights:new t.bG(e,i.u_spin_weights),u_coords_top:new t.bE(e,i.u_coords_top),u_coords_bottom:new t.bE(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bC(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bC(e,i.u_is_size_feature_constant),u_size_t:new t.b5(e,i.u_size_t),u_size:new t.b5(e,i.u_size),u_camera_to_center_distance:new t.b5(e,i.u_camera_to_center_distance),u_pitch:new t.b5(e,i.u_pitch),u_rotate_symbol:new t.bC(e,i.u_rotate_symbol),u_aspect_ratio:new t.b5(e,i.u_aspect_ratio),u_fade_change:new t.b5(e,i.u_fade_change),u_label_plane_matrix:new t.bD(e,i.u_label_plane_matrix),u_coord_matrix:new t.bD(e,i.u_coord_matrix),u_is_text:new t.bC(e,i.u_is_text),u_pitch_with_map:new t.bC(e,i.u_pitch_with_map),u_is_along_line:new t.bC(e,i.u_is_along_line),u_is_variable_anchor:new t.bC(e,i.u_is_variable_anchor),u_texsize:new t.bH(e,i.u_texsize),u_texture:new t.bC(e,i.u_texture),u_translation:new t.bH(e,i.u_translation),u_pitched_scale:new t.b5(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bC(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bC(e,i.u_is_size_feature_constant),u_size_t:new t.b5(e,i.u_size_t),u_size:new t.b5(e,i.u_size),u_camera_to_center_distance:new t.b5(e,i.u_camera_to_center_distance),u_pitch:new t.b5(e,i.u_pitch),u_rotate_symbol:new t.bC(e,i.u_rotate_symbol),u_aspect_ratio:new t.b5(e,i.u_aspect_ratio),u_fade_change:new t.b5(e,i.u_fade_change),u_label_plane_matrix:new t.bD(e,i.u_label_plane_matrix),u_coord_matrix:new t.bD(e,i.u_coord_matrix),u_is_text:new t.bC(e,i.u_is_text),u_pitch_with_map:new t.bC(e,i.u_pitch_with_map),u_is_along_line:new t.bC(e,i.u_is_along_line),u_is_variable_anchor:new t.bC(e,i.u_is_variable_anchor),u_texsize:new t.bH(e,i.u_texsize),u_texture:new t.bC(e,i.u_texture),u_gamma_scale:new t.b5(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_is_halo:new t.bC(e,i.u_is_halo),u_translation:new t.bH(e,i.u_translation),u_pitched_scale:new t.b5(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bC(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bC(e,i.u_is_size_feature_constant),u_size_t:new t.b5(e,i.u_size_t),u_size:new t.b5(e,i.u_size),u_camera_to_center_distance:new t.b5(e,i.u_camera_to_center_distance),u_pitch:new t.b5(e,i.u_pitch),u_rotate_symbol:new t.bC(e,i.u_rotate_symbol),u_aspect_ratio:new t.b5(e,i.u_aspect_ratio),u_fade_change:new t.b5(e,i.u_fade_change),u_label_plane_matrix:new t.bD(e,i.u_label_plane_matrix),u_coord_matrix:new t.bD(e,i.u_coord_matrix),u_is_text:new t.bC(e,i.u_is_text),u_pitch_with_map:new t.bC(e,i.u_pitch_with_map),u_is_along_line:new t.bC(e,i.u_is_along_line),u_is_variable_anchor:new t.bC(e,i.u_is_variable_anchor),u_texsize:new t.bH(e,i.u_texsize),u_texsize_icon:new t.bH(e,i.u_texsize_icon),u_texture:new t.bC(e,i.u_texture),u_texture_icon:new t.bC(e,i.u_texture_icon),u_gamma_scale:new t.b5(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b5(e,i.u_device_pixel_ratio),u_is_halo:new t.bC(e,i.u_is_halo),u_translation:new t.bH(e,i.u_translation),u_pitched_scale:new t.b5(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.b5(e,i.u_opacity),u_color:new t.bF(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.b5(e,i.u_opacity),u_image:new t.bC(e,i.u_image),u_pattern_tl_a:new t.bH(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bH(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bH(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bH(e,i.u_pattern_br_b),u_texsize:new t.bH(e,i.u_texsize),u_mix:new t.b5(e,i.u_mix),u_pattern_size_a:new t.bH(e,i.u_pattern_size_a),u_pattern_size_b:new t.bH(e,i.u_pattern_size_b),u_scale_a:new t.b5(e,i.u_scale_a),u_scale_b:new t.b5(e,i.u_scale_b),u_pixel_coord_upper:new t.bH(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bH(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.b5(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bC(e,i.u_texture),u_ele_delta:new t.b5(e,i.u_ele_delta),u_fog_matrix:new t.bD(e,i.u_fog_matrix),u_fog_color:new t.bF(e,i.u_fog_color),u_fog_ground_blend:new t.b5(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.b5(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bF(e,i.u_horizon_color),u_horizon_fog_blend:new t.b5(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.b5(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.b5(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bC(e,i.u_texture),u_terrain_coords_id:new t.b5(e,i.u_terrain_coords_id),u_ele_delta:new t.b5(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.b5(e,i.u_input),u_output_expected:new t.b5(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bG(e,i.u_sun_pos),u_atmosphere_blend:new t.b5(e,i.u_atmosphere_blend),u_globe_position:new t.bG(e,i.u_globe_position),u_globe_radius:new t.b5(e,i.u_globe_radius),u_inv_proj_matrix:new t.bD(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bF(e,i.u_sky_color),u_horizon_color:new t.bF(e,i.u_horizon_color),u_horizon:new t.bH(e,i.u_horizon),u_horizon_normal:new t.bH(e,i.u_horizon_normal),u_sky_horizon_blend:new t.b5(e,i.u_sky_horizon_blend),u_sky_blend:new t.b5(e,i.u_sky_blend)})};class er{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const tr={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ir{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const o=e.gl;this.buffer=o.createBuffer(),e.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&(h.push({circleArray:f,circleOffset:d,coord:_}),u+=f.length/4,d=u),m&&c.draw(a,l.LINES,Ot.disabled,Zt.disabled,e.colorModeForRenderPass(),jt.disabled,Di(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(_),n.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer);}if(!s||!h.length)return;const _=e.useProgram("collisionCircle"),p=new t.bM;p.resize(4*u),p._trim();let m=0;for(const e of h)for(let t=0;t=0&&(f[g.associatedIconIndex]={shiftedAnchor:M,angle:S});}else Be(g.numGlyphs,p);}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");Pe(c,e,s,j,O,v,h,i,l.toUnwrapped(),f.width,f.height,Z,t);}const q=s&&P||V,H=x||q?Vr:v?j:e.transform.clipSpaceToPixelsMatrix,W=p&&0!==r.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);let X;X=p?c.iconsInText?$i(T.kind,S,b,v,x,q,e,H,N,Z,D,k,I):Xi(T.kind,S,b,v,x,q,e,H,N,Z,s,D,!0,I):Wi(T.kind,S,b,v,x,q,e,H,N,Z,s,D,I);const $={program:M,buffers:u,uniformValues:X,projectionData:G,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:A,atlasInterpolationIcon:L,isSDF:p,hasHalo:W};if(y&&c.canOverlap){w=!0;const e=u.segments.get();for(const i of e)C.push({segments:new t.aD([i]),sortKey:i.sortKey,state:$,terrainData:R});}else C.push({segments:u.segments,sortKey:0,state:$,terrainData:R});}w&&C.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of C){const i=t.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,Kr(i.buffers,t.segments,r,e,i.program,T,u,d,o,i.projectionData,t.terrainData)),o.u_is_halo=0;}Kr(i.buffers,t.segments,r,e,i.program,T,u,d,i.uniformValues,i.projectionData,t.terrainData);}}function Kr(e,t,i,r,o,s,a,n,l,c,h){const u=r.context;o.draw(u,u.gl.TRIANGLES,s,a,n,jt.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer);}function Yr(e,i,r,o,s){const a=e.context,n=a.gl,l=Zt.disabled,c=new Ft([n.ONE,n.ONE],t.b4.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=o.key;let d=r.heatmapFbos.get(u);d||(d=Qr(a,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),a.bindFramebuffer.set(d.framebuffer),a.viewport.set([0,0,i.tileSize,i.tileSize]),a.clear({color:t.b4.transparent});const _=h.programConfigurations.get(r.id),p=e.useProgram("heatmap",_,!s),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),f=e.style.map.terrain.getTerrainData(o);p.draw(a,n.TRIANGLES,Ot.disabled,l,c,jt.disabled,Li(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),f,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,_);}function Jr(e,t,i,r,o){const s=e.context,a=s.gl,n=e.transform;s.setColorMode(e.colorModeForRenderPass());const l=eo(s,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,h.colorAttachment.get()),s.activeTexture.set(a.TEXTURE1),l.bind(a.LINEAR,a.CLAMP_TO_EDGE);const u=n.getProjectionData({overscaledTileID:i,applyTerrainMatrix:o,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(s,a.TRIANGLES,Ot.disabled,Zt.disabled,e.colorModeForRenderPass(),jt.disabled,ki(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,n.zoom),h.destroy(),t.heatmapFbos.delete(c);}function Qr(e,t,i){var r,o;const s=e.gl,a=s.createTexture();s.bindTexture(s.TEXTURE_2D,a),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR);const n=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:s.UNSIGNED_BYTE,l=null!==(o=e.RGBA16F)&&void 0!==o?o:s.RGBA;s.texImage2D(s.TEXTURE_2D,0,l,t,i,0,s.RGBA,n,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(a),c}function eo(e,t){return t.colorRampTexture||(t.colorRampTexture=new v(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function to(e,t,i,r,o){if(!i||!r||!r.imageAtlas)return;const s=r.imageAtlas.patternPositions;let a=s[i.to.toString()],n=s[i.from.toString()];if(!a&&n&&(a=n),!n&&a&&(n=a),!a||!n){const e=o.getPaintProperty(t);a=s[e],n=s[e];}a&&n&&e.setConstantPatternPositions(a,n);}function io(e,i,r,o,s,a,n,l){const c=e.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),_=r.getCrossfadeParameters();let p,m,f,g,v;const x=e.transform,b=r.paint.get("fill-translate"),y=r.paint.get("fill-translate-anchor");n?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=c.LINES):(m=d?"fillPattern":"fill",p=c.TRIANGLES);const w=u.constantOr(null);for(const u of o){const T=i.getTile(u);if(d&&!T.patternsLoaded())continue;const P=T.getBucket(r);if(!P)continue;const C=P.programConfigurations.get(r.id),I=e.useProgram(m,C),E=e.style.map.terrain&&e.style.map.terrain.getTerrainData(u);d&&(e.context.activeTexture.set(c.TEXTURE0),T.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),C.updatePaintBuffers(_)),to(C,h,w,T,r);const M=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),S=t.au(x,T,b,y);if(n){g=P.indexBuffer2,v=P.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];f="fillOutlinePattern"===m&&d?Si(e,_,T,t,S):Mi(t,S);}else g=P.indexBuffer,v=P.segments,f=d?Ei(e,_,T,S):{u_fill_translate:S};let R;if("translucent"===e.renderPass&&l){const[t]=e.getStencilConfigForOverlapAndUpdateStencilID(o);R=t[u.overscaledZ];}else R=e.stencilModeForClipping(u);I.draw(e.context,p,s,R,a,jt.backCCW,f,E,M,r.id,P.layoutVertexBuffer,g,v,r.paint,e.transform.zoom,C);}}function ro(e,i,r,o,s,a,n,l){const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),_=d.constantOr(1),p=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),f=d.constantOr(null),g=e.transform;for(const d of o){const o=i.getTile(d),v=o.getBucket(r);if(!v)continue;const x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),b=v.programConfigurations.get(r.id),y=e.useProgram(_?"fillExtrusionPattern":"fillExtrusion",b);_&&(e.context.activeTexture.set(h.TEXTURE0),o.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const w=g.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});to(b,u,f,o,r);const T=t.au(g,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),C=_?Ii(e,P,m,T,d,p,o):Ci(e,P,m,T);y.draw(c,c.gl.TRIANGLES,s,a,n,jt.backCCW,C,x,w,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer);}}function oo(e,t,i,r,o,s,a,n,l){var c;const h=e.style.projection,u=e.context,d=e.transform,_=u.gl,p=e.useProgram("hillshade"),m=!e.options.moving;for(const f of r){const r=t.getTile(f),g=r.fbo;if(!g)continue;const v=h.getMeshFromTileID(u,f.canonical,n,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);u.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,g.colorAttachment.get());const b=d.getProjectionData({overscaledTileID:f,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(u,_.TRIANGLES,s,o[f.overscaledZ],a,jt.backCCW,Fi(e,r,i),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments);}}const so=[new t.P(0,0),new t.P(t.X,0),new t.P(t.X,t.X),new t.P(0,t.X)];function ao(e,t,i,r,o,s,a,n,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=e.context,d=u.gl,_=e.useProgram("raster"),p=e.transform,m=e.style.projection,f=e.colorModeForRenderPass(),g=!e.options.moving;for(const v of r){const r=e.getDepthModeForSublayer(v.overscaledZ-h,1===i.paint.get("raster-opacity")?Ot.ReadWrite:Ot.ReadOnly,d.LESS),x=t.getTile(v);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const b=t.findLoadedParent(v,0),y=t.findLoadedSibling(v),w=no(x,b||y||null,t,i,e.transform,e.style.map.terrain);let T,P;const C="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),b?(b.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,b.tileID.overscaledZ-x.tileID.overscaledZ),P=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),E=p.getProjectionData({overscaledTileID:v,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),M=qi(P||[0,0],T||1,w,i,n),S=m.getMeshFromTileID(u,v.canonical,s,a,"raster");_.draw(u,d.TRIANGLES,r,o?o[v.overscaledZ]:Zt.disabled,f,l?jt.frontCCW:jt.backCCW,M,I,E,i.id,S.vertexBuffer,S.indexBuffer,S.segments);}}function no(e,i,r,o,s,n){const l=o.paint.get("raster-fade-duration");if(!n&&l>0){const o=a.now(),n=(o-e.timeAdded)/l,c=i?(o-i.timeAdded)/l:-1,h=r.getSource(),u=he(s,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),_=d&&e.refreshedUponExpiration?1:t.ab(d?n:1-c,0,1);return e.refreshedUponExpiration&&n>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-_}:{opacity:_,mix:0}}return {opacity:1,mix:0}}const lo=new t.b4(1,0,0,1),co=new t.b4(0,1,0,1),ho=new t.b4(0,0,1,1),uo=new t.b4(1,0,1,1),_o=new t.b4(0,1,1,1);function po(e,t,i,r){fo(e,0,t+i/2,e.transform.width,i,r);}function mo(e,t,i,r){fo(e,t-i/2,0,i,e.transform.height,r);}function fo(e,t,i,r,o,s){const a=e.context,n=a.gl;n.enable(n.SCISSOR_TEST),n.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,o*e.pixelRatio),a.clear({color:s}),n.disable(n.SCISSOR_TEST);}function go(e,i,r){const o=e.context,s=o.gl,a=e.useProgram("debug"),n=Ot.disabled,l=Zt.disabled,c=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);o.activeTexture.set(s.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,_=Math.floor((d&&d.byteLength||0)/1024),p=i.getTile(r).tileSize,m=512/Math.min(p,512)*(r.overscaledZ/e.transform.zoom)*.5;let f=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(f+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,o=e.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(t,5,5),o.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,`${f} ${_}kB`);const g=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(o,s.TRIANGLES,n,l,Ft.alphaBlended,jt.disabled,Ai(t.b4.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),a.draw(o,s.LINE_STRIP,n,l,c,jt.disabled,Ai(t.b4.red),u,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function vo(e,t,i,r){const{isRenderingGlobe:o}=r,s=e.context,a=s.gl,n=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");s.bindFramebuffer.set(null),s.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),u=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,u.texture);const _=t.getMeshFrameDelta(n.zoom),p=n.calculateFogMatrix(r.tileID.toUnwrapped()),m=bi(_,p,e.style.sky,n.pitch,o),f=n.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(s,a.TRIANGLES,c,Zt.disabled,l,jt.backCCW,m,d,f,"terrain",i.vertexBuffer,i.indexBuffer,i.segments);}}function xo(e,i){if(!i.mesh){const r=new t.aC;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const o=new t.aE;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),i.mesh=new pt(e.createVertexBuffer(r,mt.members),e.createIndexBuffer(o),t.aD.simpleSegment(0,0,r.length,o.length));}return i.mesh}class bo{constructor(e,i){this.context=new Zr(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.aq(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=de.maxUnderzooming+de.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ht;}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize();}setup(){const e=this.context,i=new t.aC;i.emplaceBack(0,0),i.emplaceBack(t.X,0),i.emplaceBack(0,t.X),i.emplaceBack(t.X,t.X),this.tileExtentBuffer=e.createVertexBuffer(i,mt.members),this.tileExtentSegments=t.aD.simpleSegment(0,0,4,2);const r=new t.aC;r.emplaceBack(0,0),r.emplaceBack(t.X,0),r.emplaceBack(0,t.X),r.emplaceBack(t.X,t.X),this.debugBuffer=e.createVertexBuffer(r,mt.members),this.debugSegments=t.aD.simpleSegment(0,0,4,5);const o=new t.bT;o.emplaceBack(0,0,0,0),o.emplaceBack(t.X,0,t.X,0),o.emplaceBack(0,t.X,0,t.X),o.emplaceBack(t.X,t.X,t.X,t.X),this.rasterBoundsBuffer=e.createVertexBuffer(o,vi.members),this.rasterBoundsSegments=t.aD.simpleSegment(0,0,4,2);const s=new t.aC;s.emplaceBack(0,0),s.emplaceBack(t.X,0),s.emplaceBack(0,t.X),s.emplaceBack(t.X,t.X),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(s,mt.members),this.rasterBoundsSegmentsPosOnly=t.aD.simpleSegment(0,0,4,5);const a=new t.aC;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(a,mt.members),this.viewportSegments=t.aD.simpleSegment(0,0,4,2);const n=new t.bU;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);const l=new t.aE;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Zt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new pt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.H();t.bL(r,0,this.width,this.height,0,0,1),t.K(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const o={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,Ot.disabled,this.stencilClearMode,Ft.disabled,jt.disabled,null,null,o,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Ft.disabled),r.setDepthMode(Ot.disabled);const o={};for(const e of t)o[e.key]=this.nextStencilID++;this._renderTileMasks(o,t,i,!0),this._renderTileMasks(o,t,i,!1),this._tileClippingMaskIDs=o;}_renderTileMasks(e,t,i,r){const o=this.context,s=o.gl,a=this.style.projection,n=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=a.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=n.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});l.draw(o,s.TRIANGLES,Ot.disabled,new Zt({func:s.ALWAYS,mask:0},t,255,s.KEEP,s.KEEP,s.REPLACE),Ft.disabled,i?jt.disabled:jt.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments);}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,o=this.useProgram("depth"),s=this.getDepthModeFor3D(),a=ue(r,{tileSize:r.tileSize});for(const n of a){const a=this.style.map.terrain&&this.style.map.terrain.getTerrainData(n),l=i.getMeshFromTileID(this.context,n.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(e,t.TRIANGLES,s,Zt.disabled,Ft.disabled,jt.backCCW,null,a,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Zt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Zt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(this.clearStencil(),o>1){const e={},s={};for(let i=0;i0};for(const e in n){const t=n[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse();}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.b4.black:t.b4.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,o=((e,t,i)=>{const r=Math.cos(t.rollInRadians),o=Math.sin(t.rollInRadians),s=yt(t),a=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return {u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-s*o)*i,(t.height/2+s*r)*i],u_horizon_normal:[-o,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:a}})(t,e.style.map.transform,e.pixelRatio),s=new Ot(r.LEQUAL,Ot.ReadWrite,[0,1]),a=Zt.disabled,n=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=xo(i,t);l.draw(i,r.TRIANGLES,s,a,n,jt.disabled,o,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments);}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[s[this.currentLayer]],t=n[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,u);}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:o}))(c,u,[p[0],p[1],p[2]],d,_),f=xo(o,i);a.draw(o,s.TRIANGLES,n,Zt.disabled,Ft.alphaBlended,jt.disabled,m,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments);}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[])),o=r.filter((e=>"vector"===e.getSource().type)),s=r.filter((e=>"vector"!==e.getSource().type)),a=e=>{(!i||i.getSource().maxzooma(e))),i||s.forEach((e=>a(e))),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;ru.getElevation(s,e,t):null;Wr(a,d,_,c,h,f,i,p,g,t.au(h,e,n,l),s.toUnwrapped(),r);}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),s),0!==r.paint.get("icon-opacity").constantOr(1)&&$r(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,n),0!==r.paint.get("text-opacity").constantOr(1)&&$r(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,n),i.map.showCollisionBoxes&&(Ur(e,i,r,o,!0),Ur(e,i,r,o,!1));}(e,i,r,o,this.style.placement.variableOffsets,s):t.bZ(r)?function(e,i,r,o,s){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:a}=s,n=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===n.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,_=e.transform,p=e.getDepthModeForSublayer(0,Ot.ReadOnly),m=Zt.disabled,f=e.colorModeForRenderPass(),g=[],v=_.getCircleRadiusCorrection();for(let s=0;se.sortKey-t.sortKey));for(const t of g){const{programConfiguration:i,program:o,layoutVertexBuffer:s,indexBuffer:a,uniformValues:n,terrainData:l,projectionData:c}=t.state;o.draw(u,d.TRIANGLES,p,m,f,jt.backCCW,n,l,c,r.id,s,a,t.segments,r.paint,e.transform.zoom,i);}}(e,i,r,o,s):t.b_(r)?function(e,i,r,o,s){if(0===r.paint.get("heatmap-opacity"))return;const a=e.context,{isRenderingToTexture:n,isRenderingGlobe:l}=s;if(e.style.map.terrain){for(const t of o){const o=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?Yr(e,o,r,t,l):"translucent"===e.renderPass&&Jr(e,r,t,n,l));}a.viewport.set([0,0,e.width,e.height]);}else "offscreen"===e.renderPass?function(e,i,r,o){const s=e.context,a=s.gl,n=e.transform,l=Zt.disabled,c=new Ft([a.ONE,a.ONE],t.b4.transparent,[!0,!0,!0,!0]);((function(e,i,r){const o=e.gl;e.activeTexture.set(o.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let s=r.heatmapFbos.get(t.bP);s?(o.bindTexture(o.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)):(s=Qr(e,i.width/4,i.height/4),r.heatmapFbos.set(t.bP,s));}))(s,e,r),s.clear({color:t.b4.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return !1;if(!e.from||!e.to)return !0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return !t||!i}useProgram(e,t,i=!1){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,s=e+(t?t.cacheKey:"")+`/${i?gt:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"");return this.cache[s]||(this.cache[s]=new Ti(this.context,dt[e],t,Qi[e],this._showOverdrawInspector,r,i?dt.projectionMercator:o.shaderPreludeCode,i?ft:o.shaderDefine)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new v(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function yo(e,t){let i,r=!1,o=null,s=null;const a=()=>{o=null,r&&(e.apply(s,i),o=setTimeout(a,t),r=!1);};return (...e)=>(r=!0,s=this,i=e,o||a(),o)}class wo{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return !1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e);},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let o=window.location.href.replace(/(#.+)?$/,r);o=o.replace("&&","&"),window.history.replaceState(window.history.state,null,o);},this._updateHash=yo(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e);}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),s=Math.round(t.lng*o)/o,a=Math.round(t.lat*o)/o,n=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${s}/${a}/${i}`:`${i}/${a}/${s}`,(n||l)&&(c+="/"+Math.round(10*n)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return `#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return !1;try{new t.N(+e[2],+e[1]);}catch(e){return !1}const i=+e[0],r=+(e[3]||0),o=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=0&&r<=180&&o>=this._map.getMinPitch()&&o<=this._map.getMaxPitch()}}const To={linearity:.3,easing:t.c6(0,0,.3,1)},Po=t.e({deceleration:2500,maxSpeed:1400},To),Co=t.e({deceleration:20,maxSpeed:1400},To),Io=t.e({deceleration:1e3,maxSpeed:360},To),Eo=t.e({deceleration:1e3,maxSpeed:90},To),Mo=t.e({deceleration:1e3,maxSpeed:360},To);class So{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=a.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const s=Do(i.pan.mag(),r,t.e({},Po,e||{})),a=i.pan.mult(s.amount/i.pan.mag()),n=this._map.cameraHelper.handlePanInertia(a,this._map.transform);o.center=n.easingCenter,o.offset=n.easingOffset,Ro(o,s);}if(i.zoom){const e=Do(i.zoom,r,Co);o.zoom=this._map.transform.zoom+e.amount,Ro(o,e);}if(i.bearing){const e=Do(i.bearing,r,Io);o.bearing=this._map.transform.bearing+t.ab(e.amount,-179,179),Ro(o,e);}if(i.pitch){const e=Do(i.pitch,r,Eo);o.pitch=this._map.transform.pitch+e.amount,Ro(o,e);}if(i.roll){const e=Do(i.roll,r,Mo);o.roll=this._map.transform.roll+t.ab(e.amount,-179,179),Ro(o,e);}if(o.zoom||o.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;o.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),t.e(o,{noMoveStart:!0})}}function Ro(e,t){(!e.duration||e.durationi.unproject(e))),l=s.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:s,point:l,lngLats:a,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1;}}class Lo extends t.k{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class ko{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){delete this._mousedownPos;}wheel(e){return this._firePreventable(new Lo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new zo(e.type,this._map,e))}mouseup(e){this._map.fire(new zo(e.type,this._map,e));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new zo(e.type,this._map,e));}dblclick(e){return this._firePreventable(new zo(e.type,this._map,e))}mouseover(e){this._map.fire(new zo(e.type,this._map,e));}mouseout(e){this._map.fire(new zo(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Ao(e.type,this._map,e))}touchmove(e){this._map.fire(new Ao(e.type,this._map,e));}touchend(e){this._map.fire(new Ao(e.type,this._map,e));}touchcancel(e){this._map.fire(new Ao(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Fo{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(e){this._map.fire(new zo(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new zo("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new zo(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Bo{constructor(e){this._map=e;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class jo{constructor(e,t){this._map=e,this._tr=new Bo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(r,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.k(e,{originalEvent:i}))}}function Oo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=Oo(r,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=Oo(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Zo{constructor(e){this.singleTap=new No(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Go{constructor(e){this._tr=new Bo(e),this._zoomIn=new Zo({numTouches:1,numTaps:2}),this._zoomOut=new Zo({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),o=this._zoomOut.touchend(e,t,i),s=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:s.zoom+1,around:s.unproject(r)},{originalEvent:e})}):o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:s.zoom-1,around:s.unproject(o)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Uo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset();}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e);}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return !this._moved&&r.dist(i)!0}),t=new Ho){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t;}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)));}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)));}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Xo=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault();};};class $o{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0);}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const o=Oo(r,i),s=new t.P(0,0),a=new t.P(0,0);let n=0;for(const e in o){const t=o[e],i=this._touches[e];i&&(s._add(t),a._add(t.sub(i)),n++,o[e]=t);}if(this._touches=o,this._shouldBePrevented(n)||!a.mag())return;const l=a.div(n);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class rs extends Ko{constructor(e){super(),this._currentTouchCount=0,this._map=e;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length;}_start(e){this._lastPoints=e,is(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),o=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,o=t.mag()>=2;if(!r&&!o)return;if(!r||!o)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=e.y>0==t.y>0;return is(e)&&is(t)&&s}}const os={panStep:100,bearingStep:15,pitchStep:10};class ss{constructor(e){this._tr=new Bo(e);const t=os;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,o=0,s=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),o=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),o=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),s=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const n=this._tr;a.easeTo({duration:300,easeId:"keyboardHandler",easing:as,zoom:t?Math.round(n.zoom)+t*(e.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+r*this._pitchStep,offset:[-o*this._panStep,-s*this._panStep],center:n.center},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function as(e){return e*(2-e)}const ns=4.000244140625;class ls{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);},this._map=e,this._tr=new Bo(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(e){return !!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=a.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%ns==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=n.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.N.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t);}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>ns?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const o="number"!=typeof this._targetZoom?e.scale:t.aG(this._targetZoom);this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,t.a8(o*r))),"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,o=this._easing;let s,n=!1;if("wheel"===this._type&&r&&o){const e=a.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=o(l);s=t.y.number(r,i,c),l<1?this._frameId||(this._frameId=!0):n=!0;}else s=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout;}),200)),this._lastExpectedZoom=s,{noInertia:!0,needsRenderFrame:!n,zoomDelta:s-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.c8;if(this._prevEase){const e=this._prevEase,r=(a.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),s=.27/Math.sqrt(o*o+1e-4)*.01,n=Math.sqrt(.0729-s*s);i=t.c6(s,n,.25,1);}return this._prevEase={start:a.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class cs{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class hs{constructor(e){this._tr=new Bo(e),this.reset();}reset(){this._active=!1;}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class us{constructor(){this._tap=new Zo({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],o=e.timeStamp-this._tapTime<500,s=this._tapPoint.dist(r)<30;o&&s?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(e,t,i);}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ds{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class _s{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class ps{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class ms{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=n.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const o=document.createElement("div");o.className="maplibregl-mobile-message",o.textContent=i,this._container.appendChild(o),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(n.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.k("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const fs=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class gs extends t.k{}function vs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class xs{constructor(e,t){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`);},this.handleEvent=(e,t)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},o={},s={},a=e.touches,l=a?this._getMapTouches(a):void 0,c=l?n.touchPos(this._map.getCanvas(),l):n.mousePos(this._map.getCanvas(),e);for(const{handlerName:a,handler:n,allowed:h}of this._handlers){if(!n.isEnabled())continue;let u;this._blockedByActive(s,h,a)?n.reset():n[t||e.type]&&(u=n[t||e.type](e,c,l),this.mergeHandlerResult(r,o,u,a,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||n.isActive())&&(s[a]=n);}const h={};for(const e in this._previousActiveHandlers)s[e]||(h[e]=i);this._previousActiveHandlers=s,(Object.keys(h).length||vs(r))&&(this._changes.push([r,o,h]),this._triggerRenderFrame()),(Object.keys(s).length||vs(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map));},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new So(e),this._bearingSnap=t.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(t);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)n.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[e,t,i]of this._listeners)n.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new ko(i,e));const o=i.boxZoom=new jo(i,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const s=i.cooperativeGestures=new ms(i,e.cooperativeGestures);this._add("cooperativeGestures",s),e.cooperativeGestures&&s.enable();const a=new Go(i),l=new hs(i);i.doubleClickZoom=new cs(l,a),this._add("tapZoom",a),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new us;this._add("tapDragZoom",c);const h=i.touchPitch=new rs(i);this._add("touchPitch",h),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:o=100,rotateDegreesPerPixelMoved:s=.8},a){const l=new qo({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Uo({clickTolerance:i,move:(e,i)=>{const n=a();if(r&&Math.abs(n.y-e.y)>o)return {bearingDelta:t.c7(new t.P(e.x,i.y),i,n)};let l=(i.x-e.x)*s;return r&&i.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Uo({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:Xo})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const o=new qo({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Uo({clickTolerance:t,move:(e,t)=>{const o=r();let s=(t.x-e.x)*i;return t.y0===n.mouseButton(e)&&!e.ctrlKey});return new Uo({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Xo})}(e),f=new $o(e,i);i.dragPan=new ds(r,m,f),this._add("mousePan",m),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new ts,v=new Qo;i.touchZoomRotate=new ps(r,v,g,c),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",v,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const x=i.scrollZoom=new ls(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const b=i.keyboard=new ss(i);this._add("keyboard",b),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Fo(i));}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[];}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(fs(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,o,s){if(!r)return;t.e(e,r);const a={handlerName:o,originalEvent:r.originalEvent||s};void 0!==r.zoomDelta&&(i.zoom=a),void 0!==r.panDelta&&(i.drag=a),void 0!==r.rollDelta&&(i.roll=a),void 0!==r.pitchDelta&&(i.pitch=a),void 0!==r.bearingDelta&&(i.rotate=a);}_applyChanges(){const e={},i={},r={};for(const[o,s,a]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(e.rollDelta=(e.rollDelta||0)+o.rollDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.e(i,s),t.e(r,a);this._updateMapTransform(e,i,r),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,o=r._getTransformForUpdate(),s=r.terrain;if(!(vs(e)||s&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:a,zoomDelta:n,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u=u||r.transform.centerPoint,s&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const _={panDelta:a,zoomDelta:n,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const p=u.distSqr(o.centerPoint)<.01?o.center:o.screenPointToLocation(a?u.sub(a):u);s?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?o.setCenter(o.screenPointToLocation(o.centerPoint.sub(a))):this._map.cameraHelper.handleMapControlsPan(_,o,p):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(_,o,p))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._map.cameraHelper.handleMapControlsPan(_,o,p)),r._applyUpdatedTransform(o),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,i,r){const o=fs(this._eventsInProgress),s=fs(e),n={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(n[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!o&&s&&this._fireEvent("movestart",s.originalEvent);for(const e in n)this._fireEvent(e,n[e]);s&&this._fireEvent("move",s.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||r,l[`${e}end`]=c);}for(const e in l)this._fireEvent(e,l[e]);const h=fs(this._eventsInProgress),u=(o||s)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e);}if(r&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new gs("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class bs extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((a.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState;}));}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t;}getCenter(){return new t.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e;}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.k("movestart",i)).fire(new t.k("move",i)).fire(new t.k("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){f.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.k("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.k("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.k("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.k("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.k("rollstart",e));}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.setElevation(t.y.number(this._elevationStart,this._elevationTarget,e));}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return {};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:o,roll:s,pitch:a,bearing:n,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==o&&t.setZoom(o),void 0!==s&&t.setRoll(s),void 0!==a&&t.setPitch(a),void 0!==n&&t.setBearing(n),i.apply(t);}this.transform.apply(i);}_fireMoveEvents(e){this.fire(new t.k("move",e)),this._zooming&&this.fire(new t.k("zoom",e)),this._rotating&&this.fire(new t.k("rotate",e)),this._pitching&&this.fire(new t.k("pitch",e)),this._rolling&&this.fire(new t.k("roll",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,o=this._rotating,s=this._pitching,a=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.k("zoomend",e)),o&&this.fire(new t.k("rotateend",e)),s&&this.fire(new t.k("pitchend",e)),a&&this.fire(new t.k("rollend",e)),this.fire(new t.k("moveend",e));}flyTo(e,i){if(!e.essential&&a.prefersReducedMotion){const r=t.M(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.c8},e);const r=this._getTransformForUpdate(),o=r.bearing,s=r.pitch,n=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:s,u="roll"in e?this._normalizeBearing(e.roll,n):n,d="padding"in e?e.padding:r.padding,_=t.P.convert(e.offset);let p=r.centerPoint.add(_);const m=r.screenPointToLocation(p),f=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:_,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let g=e.curve;const v=Math.max(r.width,r.height),x=v/f.scaleOfZoom,b=f.pixelPathLength;"number"==typeof f.scaleOfMinZoom&&(g=Math.sqrt(v/f.scaleOfMinZoom/b*2));const y=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*y*y*b*b)/(2*(e?x:v)*y*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const C=w(!1);let I=function(e){return P(C)/P(C+g*e)},E=function(e){return v*((P(C)*(T(t=C+g*e)/P(t))-T(C))/y)/b;var t;},M=(w(!0)-C)/g;if(Math.abs(b)<2e-6||!isFinite(M)){if(Math.abs(v-x)<1e-6)return this.easeTo(e,i);const t=x0,I=e=>Math.exp(t*g*e);}return e.duration="duration"in e?+e.duration:1e3*M/("screenSpeed"in e?+e.screenSpeed/g:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==s,this._rolling=u!==n,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease((a=>{const m=a*M,g=1/I(m),v=E(m);this._rotating&&r.setBearing(t.y.number(o,c,a)),this._pitching&&r.setPitch(t.y.number(s,h,a)),this._rolling&&r.setRoll(t.y.number(n,u,a)),this._padding&&(r.interpolatePadding(l,d,a),p=r.centerPoint.add(_)),f.easeFunc(a,g,v,p),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t);}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=a.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.aI(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class ws{constructor(e=ys){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=e;}getDefaultPosition(){return "bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._sanitizedAttributionHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style.sourceCaches;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return !1;return !0}));const i=e.join(" | ");i!==this._sanitizedAttributionHTML&&(this._sanitizedAttributionHTML=n.sanitize(i),e.length?(this._innerContainer.innerHTML=this._sanitizedAttributionHTML,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class Ts{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact");}},this.options=e;}getDefaultPosition(){return "bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=n.create("div","maplibregl-ctrl");const t=n.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class Ps{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var Cs=t.aA([{name:"a_pos3d",type:"Int16",components:3}]);class Is extends t.E{constructor(e){super(),this._lastTilesetChange=a.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const r={};for(const o of ue(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float64Array(16),t.bL(o.terrainRttPosMatrix32f,0,t.X,t.X,0,0,1),this._tiles[o.key]=new se(o,this.tileSize),this._lastTilesetChange=a.now());for(const e in this._tiles)r[e]||delete this._tiles[e];}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e){const i={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID,s=e.clone(),a=t.a$();if(o.canonical.equals(e.canonical))t.bL(a,0,t.X,t.X,0,0,1);else if(o.canonical.isChildOf(e.canonical)){const i=o.canonical.z-e.canonical.z,r=o.canonical.x-(o.canonical.x>>i<>i<>i;t.bL(a,0,n,n,0,0,1),t.J(a,a,[-r*n,-s*n,0]);}else {if(!e.canonical.isChildOf(o.canonical))continue;{const i=e.canonical.z-o.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bL(a,0,t.X,t.X,0,0,1),t.J(a,a,[r*n,s*n,0]),t.K(a,a,[1/2**i,1/2**i,0]);}}s.terrainRttPosMatrix32f=new Float32Array(a),i[r]=s;}return i}getSourceTile(e,t){const i=this.sourceCache._source;let r=e.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!o||!o.dem);)o=this.sourceCache.getTileByID(e.scaledTo(r--).key);return o}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}}class Es{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Is(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(e,i,r,o=t.X){var s;if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?o=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const s=e.canonical.x-(e.canonical.x>>o<>o<>8<<4|e>>8,i[t+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),o=new v(e,r,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,o=r.gl,s=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),a=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(s,n-a-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,_=(1<0,o=r&&0===e.canonical.y,s=r&&e.canonical.y===(1<e.id!==t)),this._recentlyUsed.push(e.id);}stampObject(e){e.stamp=++this._stamp;}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1;}freeAllObjects(){for(const e of this._objects)this.freeObject(e);}isFull(){return !(this._objects.length!e.inUse))}}const Ss={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Rs{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Ms(e.context,30,t.sourceCache.tileSize*t.qualityFactor);}destruct(){this.pool.destruct();}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates();for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e]);}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],r=i.source;if(Ss[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join();}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[]);}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return !1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),o=e.type,s=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Ss[o]&&(this._prevType&&Ss[this._prevType]||this._stacks.push([]),this._prevType=o,this._stacks[this._stacks.length-1].push(e.id),!a))return !0;if(Ss[this._prevType]||Ss[o]&&a){this._prevType=o;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const o of this._renderableTiles){if(this.pool.isFull()&&(vo(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(o),o.rtt[e]){const t=this.pool.getObjectForId(o.rtt[e].id);if(t.stamp===o.rtt[e].stamp){this.pool.useObject(t);continue}}const a=this.pool.getOrCreateFreeObject();this.pool.useObject(a),this.pool.stampObject(a),o.rtt[e]={id:a.id,stamp:a.stamp},s.context.bindFramebuffer.set(a.fbo.framebuffer),s.context.clear({color:t.b4.transparent,stencil:0}),s.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=e=>{this.move(e,n.mousePos(this.element,e));},this.mouseup=e=>{this._rotatePitchHanlder.dragEnd(e),this.offTemp();},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend));},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos));},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10,this.element=i;const o=new Wo;this._rotatePitchHanlder=new Uo({clickTolerance:3,move:(e,o)=>{const s=i.getBoundingClientRect(),a=new t.P((s.bottom-s.top)/2,(s.right-s.left)/2);return {bearingDelta:t.c7(new t.P(e.x,o.y),o,a),pitchDelta:r?-.5*(o.y-e.y):void 0}},moveStateManager:o,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(i,"mousedown",this.mousedown),n.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(i,"touchcancel",this.reset);}startMove(e,t){this._rotatePitchHanlder.dragStart(e,t),n.disableDrag();}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:o}=this._rotatePitchHanlder.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),o&&i.setPitch(i.getPitch()+o);}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp();}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend);}}let Fs;function Bs(e,i,r){const o=new t.N(e.lng,e.lat);if(e=new t.N(e.lng,e.lat),i){const o=new t.N(e.lng-360,e.lat),s=new t.N(e.lng+360,e.lat),a=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(o).distSqr(i)180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360;}return e.lng!==o.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:o}const js={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Os(e,t,i){const r=e.classList;for(const e in js)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`);}class Ns extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();},this._update=e=>{var t;if(!this._map)return;const i=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!i)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Bs(this._lngLat,this._flatPos,this._map.transform):null===(t=this._lngLat)||void 0===t?void 0:t.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?r=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let o="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?o="rotateX(0deg)":"map"===this._pitchAlignment&&(o=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${js[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${o} ${r}`),a.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type);})).catch((()=>{}));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.k("dragstart"))),this.fire(new t.k("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.k("dragend")),this._state="inactive";},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=n.create("div");const i=n.createNS("http://www.w3.org/2000/svg","svg"),r=41,o=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${o}px`),i.setAttributeNS(null,"viewBox",`0 0 ${o} ${r}`);const s=n.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"stroke","none"),s.setAttributeNS(null,"stroke-width","1"),s.setAttributeNS(null,"fill","none"),s.setAttributeNS(null,"fill-rule","evenodd");const a=n.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"fill-rule","nonzero");const l=n.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=n.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t);}const h=n.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=n.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=n.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=n.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=n.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=n.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=n.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),a.appendChild(l),a.appendChild(h),a.appendChild(d),a.appendChild(p),a.appendChild(m),i.appendChild(a),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();})),Os(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.N.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;if(!(null===(i=this._map)||void 0===i?void 0:i.terrain)){const e=this._map.transform.isLocationOccluded(this._lngLat)?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const o=this._map,s=o.terrain.depthAtPoint(this._pos),a=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,a)-s<.006)return void(this._element.style.opacity=this._opacity);const n=-this._offset.y/o.transform.pixelsPerMeter,l=Math.sin(o.getPitch()*Math.PI/180)*n,c=o.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),h=o.transform.lngLatToCameraDepth(this._lngLat,a+l)-c>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity;}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e);}removeClassName(e){this._element.classList.remove(e);}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return void 0===e&&void 0===t&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Zs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Gs=0,Us=!1;const Vs={maxWidth:100,unit:"metric"};function qs(e,t,i){const r=i&&i.maxWidth||100,o=e._container.clientHeight/2,s=e._container.clientWidth/2,a=e.unproject([s-r/2,o]),n=e.unproject([s+r/2,o]),l=Math.round(e.project(n).x-e.project(a).x),c=Math.min(r,l,e._container.clientWidth),h=a.distanceTo(n);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Hs(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Hs(t,c,i,e._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?Hs(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Hs(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):Hs(t,c,h,e._getUIString("ScaleControl.Meters"));}function Hs(e,t,i,r){const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(o/i)+"px",e.innerHTML=`${o} ${r}`;}const Ws={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Xs=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function $s(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return $s(new t.P(0,0))}const Ks=i;e.AJAXError=t.cg,e.Event=t.k,e.Evented=t.E,e.LngLat=t.N,e.MercatorCoordinate=t.Y,e.Point=t.P,e.addProtocol=t.ch,e.config=t.a,e.removeProtocol=t.ci,e.AttributionControl=ws,e.BoxZoomHandler=jo,e.CanvasSource=J,e.CooperativeGesturesHandler=ms,e.DoubleClickZoomHandler=cs,e.DragPanHandler=ds,e.DragRotateHandler=_s,e.EdgeInsets=Pt,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},e.GeoJSONSource=$,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.k("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.N(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),s=t.e({bearing:o},this.options.fitBoundsOptions),a=V.fromLngLat(i,r);this._map.fitBounds(a,s,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&Us)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.k("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ns({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ns({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.k("trackuserlocationend")),this.fire(new t.k("userlocationlostfocus")));}));}},this.options=t.e({},Zs,e);}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(void 0!==Fs&&!e)return Fs;if(void 0===window.navigator.permissions)return Fs=!!window.navigator.geolocation,Fs;try{const e=yield window.navigator.permissions.query({name:"geolocation"});Fs="denied"!==e.state;}catch(e){Fs=!!window.navigator.geolocation;}return Fs}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Gs=0,Us=!1;}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),r=t.distanceTo(i),o=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Gs--,Us=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.k("trackuserlocationstart")),this.fire(new t.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Gs++,Gs>1?(e={maximumAge:6e5,timeout:0},Us=!0):(e=this.options.positionOptions,Us=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon();},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"));};}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0;}},e.Hash=wo,e.ImageSource=K,e.KeyboardHandler=ss,e.LngLatBounds=V,e.LogoControl=Ts,e.Map=class extends bs{constructor(e){var i,r;t.cd.mark(t.ce.create);const o=Object.assign(Object.assign(Object.assign({},As),e),{canvasContextAttributes:Object.assign(Object.assign({},As.canvasContextAttributes),e.canvasContextAttributes)});if(null!=o.minZoom&&null!=o.maxZoom&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=o.minPitch&&null!=o.maxPitch&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=o.minPitch&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=o.maxPitch&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const s=new Dt,a=new kt;if(void 0!==o.minZoom&&s.setMinZoom(o.minZoom),void 0!==o.maxZoom&&s.setMaxZoom(o.maxZoom),void 0!==o.minPitch&&s.setMinPitch(o.minPitch),void 0!==o.maxPitch&&s.setMaxPitch(o.maxPitch),void 0!==o.renderWorldCopies&&s.setRenderWorldCopies(o.renderWorldCopies),super(s,a,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ps,this._controls=[],this._mapId=t.a1(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.k("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.k("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=!0===o.trackResize,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=!0===o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=!0===o.crossSourceCollisions,this._collectResourceTiming=!0===o.collectResourceTiming,this._locale=Object.assign(Object.assign({},Ds),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this.transformCameraUpdate=o.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===o.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=p.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(o.transformRequest),"string"==typeof o.container){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else {if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container;}if(o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})),this.once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=yo((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw());}),50);this._resizeObserver=new ResizeObserver((i=>{e?t(i):e=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new xs(this,o),this._hash=o.hash&&new wo("string"==typeof o.hash&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,t.e({},o.fitBoundsOptions,{duration:0}))));const n="string"==typeof o.style||!("globe"===(null===(r=null===(i=o.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,n),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new ws("boolean"==typeof o.attributionControl?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Ts,o.logoPosition),this.on("style.load",(()=>{if(n||this._resizeTransform(),this.transform.unmodified){const e=t.M(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e);}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.k(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.k(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.k("sourcedataabort",e));}));}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return -1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){const[r,o]=this._containerDimensions(),s=this._getClampedPixelRatio(r,o);if(this._resizeCanvas(r,o,s),this.painter.resize(r,o,s),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(r,o);this._resizeCanvas(r,o,t),this.painter.resize(r,o,t);}this._resizeTransform(i);const a=!this._moving;return a&&(this.stop(),this.fire(new t.k("movestart",e)).fire(new t.k("move",e))),this.fire(new t.k("resize",e)),a&&this.fire(new t.k("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e);}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,o=this.getPixelRatio(),s=e*o,a=t*o;return Math.min(s>i?i/s:1,a>r?r/a:1)*o}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(V.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.N.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const o=o=>{const s=t.filter((e=>this.getLayer(e))),a=0!==s.length?this.queryRenderedFeatures(o.point,{layers:s}):[];a.length?r||(r=!0,i.call(this,new zo(e,this,o.originalEvent,{features:a}))):r=!1;};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=o=>{const s=t.filter((e=>this.getLayer(e)));(0!==s.length?this.queryRenderedFeatures(o.point,{layers:s}):[]).length?r=!0:r&&(r=!1,i.call(this,new zo(e,this,o.originalEvent)));},s=t=>{r&&(r=!1,i.call(this,new zo(e,this,t.originalEvent)));};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:s}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),o=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];o.length&&(e.features=o,i.call(this,e),delete e.features);};return {layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t);}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let e=0;et.includes(e)))){for(const e in o.delegates)this.off(e,o.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,o);for(const e in o.delegates)this.on(e,o.delegates[e]);return {unsubscribe:()=>{this._removeDelegatedListener(e,r,i);}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);for(const t in o.delegates){const s=o.delegates[t];o.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),s(...t);};}this._saveDelegatedListener(e,o);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return [];let r;const o=e instanceof t.P||Array.isArray(e),s=o?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(o?{}:e)||{},s instanceof t.P||"number"==typeof s[0])r=[t.P.convert(s)];else {const e=t.P.convert(s[0]),i=t.P.convert(s[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e];}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return !1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new gi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new gi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,"Style");t.h(r,new AbortController).then((e=>{this._updateDiff(e.data,i);})).catch((e=>{e&&this.fire(new t.j(e));}));}else "object"==typeof e&&this._updateDiff(e,i);}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.j(new Error(`There is no source with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new Es(this.painter,i,e),this.painter.renderToTexture=new Rs(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),this.terrain.sourceCache.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.k("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(e,i,r={}){const{pixelRatio:o=1,sdf:s=!1,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:a,data:d}=i,_=i;return this.style.addImage(e,{data:new t.R({width:r,height:a},new Uint8Array(d)),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:s,version:0,userImage:_}),_.onAdd&&_.onAdd(this,e),this}}{const{width:r,height:d,data:_}=a.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},_),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:s,version:0});}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||t.b(i)?a.getImageData(i):i,{width:s,height:n,data:l}=o;if(void 0===s||void 0===n)return this.fire(new t.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(s!==r.data.width||n!==r.data.height)return this.fire(new t.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.j(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e){return p.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,(e=>{e||this._update(!0);})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0);})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const o=this._controlContainer=n.create("div","maplibregl-control-container",e),s=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{s[e]=n.create("div",`maplibregl-ctrl-${e} `,o);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type);}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new bo(i,this.transform),l.testSupport(i);}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.k("projectiontransition",{newProjection:this.style.projection.name}));}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_render(e){var i,r,o,s,n;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=a.now();this.style.zoomHistory.update(e,i);const r=new t.z(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=r.crossFadingFactor();1===o&&o===this._crossFadingFactor||(h=!0,this._crossFadingFactor=o),this.style.update(r);}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(o=this.style.projection)||void 0===o||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState,null===(n=this.style.projection)||void 0===n?void 0:n.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cd.mark(t.ce.load),this.fire(new t.k("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.k("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cd.mark(t.ce.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),p.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cd.clearMetrics(),this._removed=!0,this.fire(new t.k("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then((e=>{t.cd.frame(e),this._frameRequest=null,this._render(e);})).catch((e=>{if(!t.cf(e)&&!function(e){return e.message===Or}(e))throw e})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get version(){return zs}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=zo,e.MapTouchEvent=Ao,e.MapWheelEvent=Lo,e.Marker=Ns,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`;},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i);},this.options=t.e({},Ls,e),this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e});})),this._compassIcon=n.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ks(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(e,t){const i=n.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this.remove=()=>(this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.k("close"))),this),this._onMouseUp=e=>{this._update(e.point);},this._onMouseMove=e=>{this._update(e.point);},this._onDrag=e=>{this._update(e.point);},this._update=e=>{var t;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?Bs(this._lngLat,this._flatPos,this._map.transform):null===(t=this._lngLat)||void 0===t?void 0:t.wrap(),this._trackPointer&&!e)return;const i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor;const o=$s(this.options.offset);if(!r){const e=this._container.offsetWidth,t=this._container.offsetHeight;let s;s=i.y+o.bottom.ythis._map.transform.height-t?["bottom"]:[],i.xthis._map.transform.width-e/2&&s.push("right"),r=0===s.length?"bottom":s.join("-");}let s=i.add(o[r]);this.options.subpixelPositioning||(s=s.round()),n.setTransform(this._container,`${js[r]} translate(${s.x}px,${s.y}px)`),Os(this._container,r,"popup");},this._onClose=()=>{this.remove();},this.options=t.e(Object.create(Ws),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.k("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.N.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Xs);e&&e.focus();}},e.RasterDEMTileSource=X,e.RasterTileSource=W,e.ScaleControl=class{constructor(e){this._onMove=()=>{qs(this._map,this._container,this.options);},this.setUnit=e=>{this.options.unit=e,qs(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},Vs),e);}getDefaultPosition(){return "bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},e.ScrollZoomHandler=ls,e.Style=gi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=e;}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},e.TwoFingersTouchPitchHandler=rs,e.TwoFingersTouchRotateHandler=ts,e.TwoFingersTouchZoomHandler=Qo,e.TwoFingersTouchZoomRotateHandler=ps,e.VectorTileSource=H,e.VideoSource=Y,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,(function*(){if(ee(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{Q[e]=t;})(e,i);})),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(D),L=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},e.createTileMesh=Ht,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return oe().getRTLTextPluginStatus()},e.getVersion=function(){return Ks},e.getWorkerCount=function(){return z.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return j().broadcast("IS",e)},e.prewarm=function(){F().acquire(D);},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e;},e.setRTLTextPlugin=function(e,t){return oe().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){z.workerCount=e;},e.setWorkerUrl=function(e){t.a.WORKER_URL=e;};})); + +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + + +var maplibregl$1 = maplibregl; + +return maplibregl$1; + +})); +//# sourceMappingURL=maplibre-gl.js.map diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.3.0/LICENSE.txt b/docs/articles/layers-overview_files/maplibre-gl-5.3.0/LICENSE.txt new file mode 100644 index 00000000..1e8acbb5 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.3.0/LICENSE.txt @@ -0,0 +1,116 @@ +Copyright (c) 2023, MapLibre contributors + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of MapLibre GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from mapbox-gl-js v1.13 and earlier + +Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license + +Copyright (c) 2020, Mapbox +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Mapbox GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from glfx.js + +Copyright (C) 2011 by Evan Wallace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +Contains a portion of d3-color https://github.com/d3/d3-color + +Copyright 2010-2016 Mike Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.3.0/maplibre-gl.css b/docs/articles/layers-overview_files/maplibre-gl-5.3.0/maplibre-gl.css new file mode 100644 index 00000000..aa4f4650 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.3.0/maplibre-gl.css @@ -0,0 +1 @@ +.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.3.0/maplibre-gl.js b/docs/articles/layers-overview_files/maplibre-gl-5.3.0/maplibre-gl.js new file mode 100644 index 00000000..61db6d9b --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.3.0/maplibre-gl.js @@ -0,0 +1,59 @@ +/** + * MapLibre GL JS + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.3.0/LICENSE.txt + */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); +})(this, (function () { 'use strict'; + +/* eslint-disable */ + +var maplibregl = {}; +var modules = {}; +function define(moduleName, _dependencies, moduleFactory) { + modules[moduleName] = moduleFactory; + + // to get the list of modules see generated dist/maplibre-gl-dev.js file (look for `define(` calls) + if (moduleName !== 'index') { + return; + } + + // we assume that when an index module is initializing then other modules are loaded already + var workerBundleString = 'var sharedModule = {}; (' + modules.shared + ')(sharedModule); (' + modules.worker + ')(sharedModule);' + + var sharedModule = {}; + // the order of arguments of a module factory depends on rollup (it decides who is whose dependency) + // to check the correct order, see dist/maplibre-gl-dev.js file (look for `define(` calls) + // we assume that for our 3 chunks it will generate 3 modules and their order is predefined like the following + modules.shared(sharedModule); + modules.index(maplibregl, sharedModule); + + if (typeof window !== 'undefined') { + maplibregl.setWorkerUrl(window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }))); + } + + return maplibregl; +}; + + + +define("shared",["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t));}catch(t){s(t);}}function o(t){try{l(n.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(a,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n,i;function s(){if(i)return n;function t(t,e){this.x=t,this.y=e;}return i=1,n=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},n}"function"==typeof SuppressedError&&SuppressedError;var a,o,l=r(s()),u=function(){if(o)return a;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return o=1,a=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},a}(),c=r(u);let h,p;function f(){return null==h&&(h="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),h}function d(){if(null==p&&(p=!1,f())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function B(t,e,r,n){const i=new c(t,e,r,n);return t=>i.solve(t)}const V=B(.25,.1,.25,1);function E(t,e,r){return Math.min(r,Math.max(e,t))}function T(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function F(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let $=1;function L(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function O(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function D(t){return Array.isArray(t)?t.map(D):"object"==typeof t&&t?L(t,D):t}const R={};function j(t){R[t]||("undefined"!=typeof console&&console.warn(t),R[t]=!0);}function N(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function U(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let q=null;function G(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const Z="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,r,n,i){const s=4*Math.max(1,0),a=(Math.max(0,r)-r)*n*4+s,o=4*n,l=Math.max(0,e),u=Math.max(0,r);return {rect:{x:l,y:u,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-u},layout:[{offset:a,stride:o}]}}(t,r,n,i,s)),o)for(let t=0;t{t.removeEventListener(e,r,n);}}}function J(t){return t/Math.PI*180}const W={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Q={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},tt="AbortError";function et(){return new Error(tt)}const rt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function nt(t){return rt.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const it="global-dispatcher";class st extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n;}}const at=()=>U(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ot=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=nt(t.url);if(e)return e(t,r);if(U(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:it},r)}if(!(/^file:/.test(n=t.url)||/^file:/.test(at())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:at(),signal:r.signal});let n,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e);}catch(e){throw new st(0,e.message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new st(n.status,n.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw et();return {data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(U(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:it},r)}var n;return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new st(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),n(et());})),s.send(t.body);}))}(t,r)};function lt(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function ut(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function ct(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class ht{constructor(t,e={}){F(this,e),this.type=t;}}class pt extends ht{constructor(t,e={}){super("error",F({error:t},e));}}class ft{on(t,e){return this._listeners=this._listeners||{},ut(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e);}}}off(t,e){return ct(t,e,this._listeners),ct(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},ut(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new ht(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)ct(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(F(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof pt&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var dt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const yt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function mt(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return yt.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function gt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Gt=[Ct,Bt,Vt,Et,Tt,Ft,Dt,$t,Ut(Lt),Rt,jt,Nt];function Zt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Zt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Gt)if(!Zt(t,e))return null}return `Expected ${qt(t)} but found ${qt(e)} instead.`}function Kt(t,e){return e.some((e=>e.kind===t.kind))}function Xt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function Ht(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Yt=.96422,Jt=.82521,Wt=4/29,Qt=6/29,te=3*Qt*Qt,ee=Qt*Qt*Qt,re=Math.PI/180,ne=180/Math.PI;function ie(t){return (t%=360)<0&&(t+=360),t}function se([t,e,r,n]){let i,s;const a=oe((.2225045*(t=ae(t))+.7168786*(e=ae(e))+.0606169*(r=ae(r)))/1);t===e&&e===r?i=s=a:(i=oe((.4360747*t+.3850649*e+.1430804*r)/Yt),s=oe((.0139322*t+.0971045*e+.7141733*r)/Jt));const o=116*a-16;return [o<0?0:o,500*(i-a),200*(a-s),n]}function ae(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function oe(t){return t>ee?Math.pow(t,1/3):t/te+Wt}function le([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*ce(i),s=Yt*ce(s),a=Jt*ce(a),[ue(3.1338561*s-1.6168667*i-.4906146*a),ue(-.9787684*s+1.9161415*i+.033454*a),ue(.0719453*s-.2289914*i+1.4052427*a),n]}function ue(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ce(t){return t>Qt?t*t*t:te*(t-Wt)}function he(t){return parseInt(t.padEnd(2,t),16)/255}function pe(t,e){return fe(e?t/100:t,0,1)}function fe(t,e,r){return Math.min(Math.max(e,t),r)}function de(t){return !t.some(Number.isNaN)}const ye={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function me(t,e,r){return t+r*(e-t)}function ge(t,e,r){return t.map(((t,n)=>me(t,e[n],r)))}class xe{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof xe)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=ye[t];if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [he(t.slice(r,r+=e)),he(t.slice(r,r+=e)),he(t.slice(r,r+=e)),he(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[fe(+r/e,0,1),fe(+s/e,0,1),fe(+l/e,0,1),h?pe(+h,p):1];if(de(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,fe(+i,0,100),fe(+a,0,100),l?pe(+l,u):1];if(de(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=ie(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new xe(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=se(t),s=Math.sqrt(r*r+n*n);return [Math.round(1e4*s)?ie(Math.atan2(n,r)*ne):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",se(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}static interpolate(t,e,r,n="rgb"){switch(n){case "rgb":{const[n,i,s,a]=ge(t.rgb,e.rgb,r);return new xe(n,i,s,a,!1)}case "hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*re,le([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:me(i,l,r),me(s,u,r),me(a,c,r)]);return new xe(f,d,y,m,!1)}case "lab":{const[n,i,s,a]=le(ge(t.lab,e.lab,r));return new xe(n,i,s,a,!1)}}}}xe.black=new xe(0,0,0,1),xe.white=new xe(1,1,1,1),xe.transparent=new xe(0,0,0,0),xe.red=new xe(1,0,0,1);class ve{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const be=["bottom","center","top"];class we{constructor(t,e,r,n,i,s){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i,this.verticalAlign=s;}}class _e{constructor(t){this.sections=t;}static fromString(t){return new _e([new we(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof _e?t:_e.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Se{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Se)return t;if("number"==typeof t)return new Se([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new Se(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new Se(ge(t.values,e.values,r))}}class Ae{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}}const ke=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Me{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Me)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ce(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof ze||t instanceof xe||t instanceof ve||t instanceof _e||t instanceof Se||t instanceof Me||t instanceof Ie)return !0;if(Array.isArray(t)){for(const e of t)if(!Ce(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!Ce(t[e]))return !1;return !0}return !1}function Be(t){if(null===t)return Ct;if("string"==typeof t)return Vt;if("boolean"==typeof t)return Et;if("number"==typeof t)return Bt;if(t instanceof xe)return Tt;if(t instanceof ze)return Ft;if(t instanceof ve)return Ot;if(t instanceof _e)return Dt;if(t instanceof Se)return Rt;if(t instanceof Me)return Nt;if(t instanceof Ie)return jt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=Be(e);if(r){if(r===t)continue;r=Lt;break}r=t;}return Ut(r||Lt,e)}return $t}function Ve(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof xe||t instanceof ze||t instanceof _e||t instanceof Se||t instanceof Me||t instanceof Ie?t.toString():JSON.stringify(t)}class Ee{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ce(t[1]))return e.error("invalid value");const r=t[1];let n=Be(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Ee(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}const Te={string:Vt,number:Bt,boolean:Et,object:$t};class Fe{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in Te)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Te[r],n++;}else i=Lt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=Ut(i,s);}else {if(!Te[i])throw new Error(`Types doesn't contain name = ${i}`);r=Te[i];}const s=[];for(;nt.outputDefined()))}}const $e={"to-boolean":Et,"to-color":Tt,"to-number":Bt,"to-string":Vt};class Le{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!$e[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=$e[r],i=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Pe(e[0],e[1],e[2],e[3]),!r))return new xe(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ae(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=Se.parse(e);if(n)return n}throw new Ae(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=Me.parse(e);if(n)return n}throw new Ae(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new Ae(`Could not convert ${JSON.stringify(e)} to number.`)}case "formatted":return _e.fromString(Ve(this.args[0].evaluate(t)));case "resolvedImage":return Ie.fromString(Ve(this.args[0].evaluate(t)));case "projectionDefinition":return this.args[0].evaluate(t);default:return Ve(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Oe=["Unknown","Point","LineString","Polygon"];class De{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null;}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Oe[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=xe.parse(t)),e}}class Re{constructor(t,e,r=[],n,i=new Pt,s=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new Fe(e,[t]):"coerce"===r?new Le(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("projectionDefinition"!==t.kind||"string"!==i.kind&&"array"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind)if("padding"!==t.kind||"value"!==i.kind&&"number"!==i.kind&&"array"!==i.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==i.kind&&"array"!==i.kind){if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof Ee)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new De;try{n=new Ee(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new Re(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new zt(r,t));}checkSubtype(t,e){const r=Zt(t,e);return r&&this.error(r),r}}class je{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new Ae(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new Ae(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class qe{constructor(t,e){this.type=Et,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Lt),n=e.parse(t[2],2,Lt);return r&&n?Kt(r.type,[Et,Vt,Bt,Ct,Lt])?new qe(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${qt(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!Xt(e,["boolean","string","number","null"]))throw new Ae(`Expected first argument to be of type boolean, string, number or null, but found ${qt(Be(e))} instead.`);if(!Xt(r,["string","array"]))throw new Ae(`Expected second argument to be of type array or string, but found ${qt(Be(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class Ge{constructor(t,e,r){this.type=Bt,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Lt),n=e.parse(t[2],2,Lt);if(!r||!n)return null;if(!Kt(r.type,[Et,Vt,Bt,Ct,Lt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${qt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Bt);return i?new Ge(r,n,i):null}return new Ge(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Xt(e,["boolean","string","number","null"]))throw new Ae(`Expected first argument to be of type boolean, string, number or null, but found ${qt(Be(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),Xt(r,["string"])){const t=r.indexOf(e,n);return -1===t?-1:[...r.slice(0,t)].length}if(Xt(r,["array"]))return r.indexOf(e,n);throw new Ae(`Expected second argument to be of type array or string, but found ${qt(Be(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class Ze{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,Be(t)))return null}else r=Be(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,Lt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new Ze(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (Be(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class Ke{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class Xe{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Lt),n=e.parse(t[2],2,Bt);if(!r||!n)return null;if(!Kt(r.type,[Ut(Lt),Vt,Lt]))return e.error(`Expected first argument to be of type array or string, but found ${qt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Bt);return i?new Xe(r.type,r,n,i):null}return new Xe(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),Xt(e,["string"]))return [...e].slice(r,n).join("");if(Xt(e,["array"]))return e.slice(r,n);throw new Ae(`Expected first argument to be of type array or string, but found ${qt(Be(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function He(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new Ae("Input is not a number.");a=o-1;}return 0}class Ye{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,Bt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Ye(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[He(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Je(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var We,Qe,tr=function(){if(Qe)return We;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return Qe=1,We=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},We}(),er=Je(tr);class rr{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=nr(e,t.base,r,n);else if("linear"===t.name)i=nr(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new er(s[0],s[1],s[2],s[3]).solve(nr(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Bt),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Tt:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return Ht(o,Bt)||Ht(o,Ft)||Ht(o,Tt)||Ht(o,Rt)||Ht(o,Nt)||Ht(o,Ut(Bt))?new rr(o,r,n,i,a):e.error(`Type ${qt(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=He(e,n),a=rr.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case "interpolate":switch(this.type.kind){case "number":return me(o,l,a);case "color":return xe.interpolate(o,l,a);case "padding":return Se.interpolate(o,l,a);case "variableAnchorOffsetCollection":return Me.interpolate(o,l,a);case "array":return ge(o,l,a);case "projectionDefinition":return ze.interpolate(o,l,a)}case "interpolate-hcl":return xe.interpolate(o,l,a,"hcl");case "interpolate-lab":return xe.interpolate(o,l,a,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function nr(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}const ir={color:xe.interpolate,number:me,padding:Se.interpolate,variableAnchorOffsetCollection:Me.interpolate,array:ge};class sr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const s=n&&i.some((t=>Zt(n,t.type)));return new sr(s?Lt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof Ie&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function ar(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function or(t,e,r,n){return 0===n.compare(e,r)}function lr(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=Et,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,Lt);if(!s)return null;if(!ar(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${qt(s.type)}'.`);let a=e.parse(t[2],2,Lt);if(!a)return null;if(!ar(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${qt(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${qt(s.type)}' and '${qt(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new Fe(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new Fe(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ot),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=Be(s),r=Be(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ae(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=Be(s),r=Be(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const ur=lr("==",(function(t,e,r){return e===r}),or),cr=lr("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !or(0,e,r,n)})),hr=lr("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),fr=lr("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),dr=lr(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class yr{constructor(t,e,r){this.type=Ot,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,Et);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Et);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,Vt),!s)?null:new yr(n,i,s)}evaluate(t){return new ve(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class mr{constructor(t,e,r,n,i){this.type=Vt,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Bt);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,Vt),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Vt),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Bt),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,Bt),!o)?null:new mr(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class gr{constructor(t){this.type=Dt,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Bt),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,Ut(Vt)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,Tt),!a))return null;let o=null;if(s["vertical-align"]){if("string"==typeof s["vertical-align"]&&!be.includes(s["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(o=e.parse(s["vertical-align"],1,Vt),!o)return null}const l=n[n.length-1];l.scale=t,l.font=r,l.textColor=a,l.verticalAlign=o;}else {const s=e.parse(t[r],1,Lt);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null});}}return new gr(n)}evaluate(t){return new _e(this.sections.map((e=>{const r=e.content.evaluate(t);return Be(r)===jt?new we("",r,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new we(Ve(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign);}outputDefined(){return !1}}class xr{constructor(t){this.type=jt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Vt);return r?new xr(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=Ie.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class vr{constructor(t){this.type=Bt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${qt(r.type)} instead.`):new vr(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new Ae(`Expected value to be of type string or array, but found ${qt(Be(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const br=8192;function wr(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*br),Math.round(n*i*br)]}function _r(t,e){const r=Math.pow(2,e.z);return [(i=(t[0]/br+e.x)/r,360*i-180),(n=(t[1]/br+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i;}function Sr(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function Ar(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function kr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Mr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Vr(t,e,r,n)||!Vr(r,n,t,e));var i,s;}function Ir(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(a=o[e+1])[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}var i,s,a;return n}function Pr(t,e){for(const r of e)if(zr(t,r))return !0;return !1}function Cr(t,e){for(const r of t)if(!zr(r,e))return !1;for(let r=0;r0&&o<0||a<0&&o>0}function Er(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Sr(e,t);}function $r(t,e,r,n){const i=Math.pow(2,n.z)*br,s=[n.x*br,n.y*br],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Fr(n,e,r,i),a.push(n);}return a}function Lr(t,e,r,n){const i=Math.pow(2,n.z)*br,s=[n.x*br,n.y*br],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Sr(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)Fr(n,e,r,i);}var o;return a}class Or{constructor(t,e){this.type=Et,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ce(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n);}if(t.length)return new Or(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Or(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Or(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Er(e.coordinates,n,i),a=$r(t.geometry(),r,n,i);if(!Ar(r,n))return !1;for(const t of a)if(!zr(t,s))return !1}if("MultiPolygon"===e.type){const s=Tr(e.coordinates,n,i),a=$r(t.geometry(),r,n,i);if(!Ar(r,n))return !1;for(const t of a)if(!Pr(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Er(e.coordinates,n,i),a=Lr(t.geometry(),r,n,i);if(!Ar(r,n))return !1;for(const t of a)if(!Cr(t,s))return !1}if("MultiPolygon"===e.type){const s=Tr(e.coordinates,n,i),a=Lr(t.geometry(),r,n,i);if(!Ar(r,n))return !1;for(const t of a)if(!Br(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let Dr=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}};function Rr(t,e,r=0,n=t.length-1,i=Nr){for(;n>r;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Rr(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(jr(t,r,e),i(t[n],s)>0&&jr(t,r,n);a0;)o--;}0===i(t[r],s)?jr(t,r,o):(o++,jr(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function jr(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Nr(t,e){return te?1:0}function Ur(t,e){if(t.length<=1)return [t];const r=[];let n,i;for(const e of t){const t=Gr(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e));}if(n&&r.push(n),e>1)for(let t=0;t1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function Yr(t,e){return e[0]-t[0]}function Jr(t){return t[1]-t[0]+1}function Wr(t,e){return t[1]>=t[0]&&t[1]t[1])return [null,null];const r=Jr(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return [t,null];const n=Math.floor(r/2)-1;return [[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function tn(t,e){if(!Wr(e,t.length))return [1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)Sr(r,t[n]);return r}function en(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)Sr(e,t);return e}function rn(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function nn(t,e,r){if(!rn(t)||!rn(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Ar(i,s)){if(hn(t,e))return 0}else if(hn(e,t))return 0;let a=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=a.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(Jr(l)<=u){if(!Wr(l,t.length))return NaN;if(e){const e=cn(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=un(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else {const r=Qr(l,e);fn(a,s,n,t,o,r[0]),fn(a,s,n,t,o,r[1]);}}return s}function mn(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new Dr([[0,[0,t.length-1],[0,r.length-1]]],Yr);for(;o.length>0;){const s=o.pop();if(s[0]>=a)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(Jr(l)<=c&&Jr(u)<=h){if(!Wr(l,t.length)&&Wr(u,r.length))return NaN;let s;if(e&&n)s=on(t,l,r,u,i),a=Math.min(a,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=sn(r[t],e,i),a=Math.min(a,s),0===a)return a}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=sn(t[r],e,i),a=Math.min(a,s),0===a)return a}else s=ln(t,l,r,u,i),a=Math.min(a,s);}else {const s=Qr(l,e),c=Qr(u,n);dn(o,a,i,t,r,s[0],c[0]),dn(o,a,i,t,r,s[0],c[1]),dn(o,a,i,t,r,s[1],c[0]),dn(o,a,i,t,r,s[1],c[1]);}}return a}function gn(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class xn{constructor(t,e){this.type=Bt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ce(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new xn(e,e.features.map((t=>gn(t.geometry))).flat());if("Feature"===e.type)return new xn(e,gn(e.geometry));if("type"in e&&"coordinates"in e)return new xn(e,gn(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>_r([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Hr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,mn(n,!1,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,mn(n,!1,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,yn(n,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>_r([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Hr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,mn(n,!0,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,mn(n,!0,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,yn(n,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Ur(r,0).map((e=>e.map((e=>e.map((e=>_r([e.x,e.y],t.canonical))))))),i=new Hr(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case "Point":s=Math.min(s,yn([t.coordinates],!1,e,i,s));break;case "LineString":s=Math.min(s,yn(t.coordinates,!0,e,i,s));break;case "Polygon":s=Math.min(s,pn(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}const vn={"==":ur,"!=":cr,">":pr,"<":hr,">=":dr,"<=":fr,array:Fe,at:Ue,boolean:Fe,case:Ke,coalesce:sr,collator:yr,format:gr,image:xr,in:qe,"index-of":Ge,interpolate:rr,"interpolate-hcl":rr,"interpolate-lab":rr,length:vr,let:je,literal:Ee,match:Ze,number:Fe,"number-format":mr,object:Fe,slice:Xe,step:Ye,string:Fe,"to-boolean":Le,"to-color":Le,"to-number":Le,"to-string":Le,var:Ne,within:Or,distance:xn};class bn{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const r=t[0],n=bn.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new Re(e.registry,kn,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(qt).join(", ")})`:`(${qt(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&kn(t):r&&t instanceof Ee;})),!!r&&Mn(t)&&zn(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Mn(t){if(t instanceof bn){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Or)return !1;if(t instanceof xn)return !1;let e=!0;return t.eachChild((t=>{e&&!Mn(t)&&(e=!1);})),e}function In(t){if(t instanceof bn&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!In(t)&&(e=!1);})),e}function zn(t,e){if(t instanceof bn&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!zn(t,e)&&(r=!1);})),r}function Pn(t){return {result:"success",value:t}}function Cn(t){return {result:"error",value:t}}function Bn(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Vn(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function En(t){return !!t.expression&&t.expression.interpolated}function Tn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Fn(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function $n(t){return t}function Ln(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(En(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?xe.parse:Se.parse;(t=It({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default);}if(t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;let o,l,u;if("exponential"===s)o=jn;else if("interval"===s)o=Rn;else if("categorical"===s){o=Dn,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=Nn;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>jn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:rr.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?On(t.default,e.default):o(t,e,i,l,u)}}}function On(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Dn(t,e,r,n,i){return On(typeof r===i?n[r]:void 0,t.default,e.default)}function Rn(t,e,r){if("number"!==Tn(r))return On(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=He(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function jn(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Tn(r))return On(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=He(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=ir[e.type]||$n;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function Nn(t,e,r){switch(e.type){case "color":r=xe.parse(r);break;case "formatted":r=_e.fromString(r.toString());break;case "resolvedImage":r=Ie.fromString(r.toString());break;case "padding":r=Se.parse(r);break;default:Tn(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return On(r,t.default,e.default)}bn.register(vn,{error:[{kind:"error"},[Vt],(t,[e])=>{throw new Ae(e.evaluate(t))}],typeof:[Vt,[Lt],(t,[e])=>qt(Be(e.evaluate(t)))],"to-rgba":[Ut(Bt,4),[Tt],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return [255*r,255*n,255*i,s]}],rgb:[Tt,[Bt,Bt,Bt],wn],rgba:[Tt,[Bt,Bt,Bt,Bt],wn],has:{type:Et,overloads:[[[Vt],(t,[e])=>_n(e.evaluate(t),t.properties())],[[Vt,$t],(t,[e,r])=>_n(e.evaluate(t),r.evaluate(t))]]},get:{type:Lt,overloads:[[[Vt],(t,[e])=>Sn(e.evaluate(t),t.properties())],[[Vt,$t],(t,[e,r])=>Sn(e.evaluate(t),r.evaluate(t))]]},"feature-state":[Lt,[Vt],(t,[e])=>Sn(e.evaluate(t),t.featureState||{})],properties:[$t,[],t=>t.properties()],"geometry-type":[Vt,[],t=>t.geometryType()],id:[Lt,[],t=>t.id()],zoom:[Bt,[],t=>t.globals.zoom],"heatmap-density":[Bt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Bt,[],t=>t.globals.lineProgress||0],accumulated:[Lt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Bt,An(Bt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[Bt,An(Bt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:Bt,overloads:[[[Bt,Bt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Bt],(t,[e])=>-e.evaluate(t)]]},"/":[Bt,[Bt,Bt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Bt,[Bt,Bt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Bt,[],()=>Math.LN2],pi:[Bt,[],()=>Math.PI],e:[Bt,[],()=>Math.E],"^":[Bt,[Bt,Bt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Bt,[Bt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Bt,[Bt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Bt,[Bt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Bt,[Bt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Bt,[Bt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Bt,[Bt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Bt,[Bt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Bt,[Bt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Bt,[Bt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Bt,[Bt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Bt,An(Bt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Bt,An(Bt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Bt,[Bt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Bt,[Bt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Bt,[Bt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Bt,[Bt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Et,[Vt,Lt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[Et,[Lt],(t,[e])=>t.id()===e.value],"filter-type-==":[Et,[Vt],(t,[e])=>t.geometryType()===e.value],"filter-<":[Et,[Vt,Lt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[Et,[Vt,Lt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Et,[Lt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Et,[Vt,Lt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Et,[Lt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Et,[Vt,Lt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Et,[Lt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Et,[Lt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Et,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Et,[Ut(Vt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Et,[Ut(Lt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Et,[Vt,Ut(Lt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Et,[Vt,Ut(Lt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Et,overloads:[[[Et,Et],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[An(Et),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:Et,overloads:[[[Et,Et],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[An(Et),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[Et,[Et],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Et,[Vt],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Vt,[Vt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Vt,[Vt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Vt,An(Lt),(t,e)=>e.map((e=>Ve(e.evaluate(t)))).join("")],"resolved-locale":[Vt,[Ot],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Un{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new De,this._defaultValue=e?"color"===(r=e).type&&Fn(r.default)?new xe(0,0,0,0):"color"===r.type?xe.parse(r.default)||null:"padding"===r.type?Se.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?Me.parse(r.default)||null:"projectionDefinition"===r.type?ze.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ae(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function qn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in vn}function Gn(t,e){const r=new Re(vn,kn,[],e?function(t){const e={color:Tt,string:Vt,number:Bt,enum:Vt,boolean:Et,formatted:Dt,padding:Rt,projectionDefinition:Ft,resolvedImage:jt,variableAnchorOffsetCollection:Nt};return "array"===t.type?Ut(e[t.value]||Lt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Pn(new Un(n,e)):Cn(r.errors)}class Zn{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!In(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class Kn{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!In(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?rr.interpolationFactor(this.interpolationType,t,e,r):0}}function Xn(t,e){const r=Gn(t,e);if("error"===r.result)return r;const n=r.value.expression,i=Mn(n);if(!i&&!Bn(e))return Cn([new zt("","data expressions not supported")]);const s=zn(n,["zoom"]);if(!s&&!Vn(e))return Cn([new zt("","zoom expressions not supported")]);const a=Yn(n);return a||s?a instanceof zt?Cn([a]):a instanceof rr&&!En(e)?Cn([new zt("",'"interpolate" expressions cannot be used with this property')]):Pn(a?new Kn(i?"camera":"composite",r.value,a.labels,a instanceof rr?a.interpolation:void 0):new Zn(i?"constant":"source",r.value)):Cn([new zt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Hn{constructor(t,e){this._parameters=t,this._specification=e,It(this,Ln(this._parameters,this._specification));}static deserialize(t){return new Hn(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function Yn(t){let e=null;if(t instanceof je)e=Yn(t.result);else if(t instanceof sr){for(const r of t.args)if(e=Yn(r),e)break}else (t instanceof Ye||t instanceof rr)&&t.input instanceof bn&&"zoom"===t.input.name&&(e=t);return e instanceof zt||t.eachChild((t=>{const r=Yn(t);r instanceof zt?e=r:!e&&r?e=new zt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new zt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function Jn(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case "has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case "in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case "any":case "all":for(const e of t.slice(1))if(!Jn(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const Wn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Qn(t){if(null==t)return {filter:()=>!0,needGeometry:!1};Jn(t)||(t=ri(t));const e=Gn(t,Wn);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:ei(t)}}function ti(t,e){return te?1:0}function ei(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?ni(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(ri))):"all"===e?["all"].concat(t.slice(1).map(ri)):"none"===e?["all"].concat(t.slice(1).map(ri).map(ai)):"in"===e?ii(t[1],t.slice(2)):"!in"===e?ai(ii(t[1],t.slice(2))):"has"===e?si(t[1]):"!has"!==e||ai(si(t[1]));var r;}function ni(t,e,r){switch(t){case "$type":return [`filter-type-${r}`,e];case "$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function ii(t,e){if(0===e.length)return !1;switch(t){case "$type":return ["filter-type-in",["literal",e]];case "$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ti)]]:["filter-in-small",t,["literal",e]]}}function si(t){switch(t){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",t]}}function ai(t){return ["!",t]}function oi(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${oi(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new Mt(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function yi(t){const e=t.valueSpec,r=ci(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===Tn(t.value.stops)&&"array"===Tn(t.value.stops[0])&&"object"===Tn(t.value.stops[0][0]),c=pi({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new Mt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(fi({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Tn(n)&&0===n.length&&e.push(new Mt(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new Mt(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new Mt(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!En(t.valueSpec)&&c.push(new Mt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Bn(t.valueSpec)?c.push(new Mt(t.key,t.value,"property functions not supported")):o&&!Vn(t.valueSpec)&&c.push(new Mt(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new Mt(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==Tn(n))return [new Mt(o,n,`array expected, ${Tn(n)} found`)];if(2!==n.length)return [new Mt(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==Tn(n[0]))return [new Mt(o,n,`object expected, ${Tn(n[0])} found`)];if(void 0===n[0].zoom)return [new Mt(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new Mt(o,n,"object stop key must have value")];if(s&&s>ci(n[0].zoom))return [new Mt(o,n[0].zoom,"stop zoom values must appear in ascending order")];ci(n[0].zoom)!==s&&(s=ci(n[0].zoom),i=void 0,a={}),r=r.concat(pi({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:di,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return qn(hi(n[1]))?r.concat([new Mt(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=Tn(t.value),l=ci(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return [new Mt(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new Mt(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return Bn(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Mt(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew Mt(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new Mt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!In(r))return [new Mt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!In(r))return [new Mt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!zn(r,["zoom","feature-state"]))return [new Mt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Mn(r))return [new Mt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function gi(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(ci(r))&&i.push(new Mt(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(ci(r))&&i.push(new Mt(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function xi(t){return Jn(hi(t.value))?mi(It({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):vi(t)}function vi(t){const e=t.value,r=t.key;if("array"!==Tn(e))return [new Mt(r,e,`array expected, ${Tn(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return [new Mt(r,e,"filter array must have at least 1 element")];switch(s=s.concat(gi({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),ci(e[0])){case "<":case "<=":case ">":case ">=":e.length>=2&&"$type"===ci(e[1])&&s.push(new Mt(r,e,`"$type" cannot be use with operator "${e[0]}"`));case "==":case "!=":3!==e.length&&s.push(new Mt(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case "in":case "!in":e.length>=2&&(i=Tn(e[1]),"string"!==i&&s.push(new Mt(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new Mt(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{ci(e.id)===o&&(t=e);})),t?t.ref?e.push(new Mt(n,r.ref,"ref cannot reference another ref layer")):a=ci(t.type):e.push(new Mt(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&ci(t.type);t?"vector"===s&&"raster"===a?e.push(new Mt(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new Mt(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new Mt(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new Mt(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new Mt(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Mt(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Mt(n,r.source,`source "${r.source}" not found`));}else e.push(new Mt(n,r,'missing required property "source"'));return e=e.concat(pi({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:xi,layout:t=>pi({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>_i(It({layerType:a},t))}}),paint:t=>pi({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>wi(It({layerType:a},t))}})}})),e}function Ai(t){const e=t.value,r=t.key,n=Tn(e);return "string"!==n?[new Mt(r,e,`string expected, ${n} found`)]:[]}const ki={promoteId:function({key:t,value:e}){if("string"===Tn(e))return Ai({key:t,value:e});{const r=[];for(const n in e)r.push(...Ai({key:`${t}.${n}`,value:e[n]}));return r}}};function Mi(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new Mt(r,e,'"type" is required')];const a=ci(e.type);let o;switch(a){case "vector":case "raster":return o=pi({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:ki,validateSpec:s}),o;case "raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=Tn(n);if(void 0===n)return o;if("object"!==l)return o.push(new Mt("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===ci(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new Mt(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new Mt(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case "geojson":if(o=pi({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:ki}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],s="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...mi({key:`${r}.${t}.map`,value:i,expressionContext:"cluster-map"})),o.push(...mi({key:`${r}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}));}return o;case "video":return pi({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case "image":return pi({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case "canvas":return [new Mt(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return gi({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Ii(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=Tn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Mt("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Mt(a,e[a],`unknown property "${a}"`)]);}return s}function zi(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=Tn(e);if(void 0===e)return [];if("object"!==s)return [new Mt("sky",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Mt(s,e[s],`unknown property "${s}"`)]);return a}function Pi(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=Tn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Mt("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Mt(a,e[a],`unknown property "${a}"`)]);return s}function Ci(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new Mt(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new Mt(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(pi({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Ai({key:n,value:r})}const Bi={"*":()=>[],array:fi,boolean:function(t){const e=t.value,r=t.key,n=Tn(e);return "boolean"!==n?[new Mt(r,e,`boolean expected, ${n} found`)]:[]},number:di,color:function(t){const e=t.key,r=t.value,n=Tn(r);return "string"!==n?[new Mt(e,r,`color expected, ${n} found`)]:xe.parse(String(r))?[]:[new Mt(e,r,`color expected, "${r}" found`)]},constants:ui,enum:gi,filter:xi,function:yi,layer:Si,object:pi,source:Mi,light:Ii,sky:zi,terrain:Pi,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=Tn(e);if(void 0===e)return [];if("object"!==s)return [new Mt("projection",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Mt(s,e[s],`unknown property "${s}"`)]);return a},projectionDefinition:function(t){const e=t.key;let r=t.value;r=r instanceof String?r.valueOf():r;const n=Tn(r);return "array"!==n||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(r)||function(t){return !!["interpolate","step","literal"].includes(t[0])}(r)?["array","string"].includes(n)?[]:[new Mt(e,r,`projection expected, invalid type "${n}" found`)]:[new Mt(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:Ai,formatted:function(t){return 0===Ai(t).length?[]:mi(t)},resolvedImage:function(t){return 0===Ai(t).length?[]:mi(t)},padding:function(t){const e=t.key,r=t.value;if("array"===Tn(r)){if(r.length<1||r.length>4)return [new Mt(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(ui({key:"constants",value:t.constants}))),$i(r)}function Fi(t){return function(e){return t({...e,validateSpec:Vi})}}function $i(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function Li(t){return function(...e){return $i(t.apply(this,e))}}Ti.source=Li(Fi(Mi)),Ti.sprite=Li(Fi(Ci)),Ti.glyphs=Li(Fi(Ei)),Ti.light=Li(Fi(Ii)),Ti.sky=Li(Fi(zi)),Ti.terrain=Li(Fi(Pi)),Ti.layer=Li(Fi(Si)),Ti.filter=Li(Fi(xi)),Ti.paintProperty=Li(Fi(wi)),Ti.layoutProperty=Li(Fi(_i));const Oi=Ti,Di=Oi.light,Ri=Oi.sky,ji=Oi.paintProperty,Ni=Oi.layoutProperty;function Ui(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new pt(new Error(n.message))),r=!0;return r}class qi{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1;}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const s=t[n];i[n]=Gi[r].shallow.indexOf(n)>=0?s:Yi(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(i.$name=r),i}function Ji(t){if(Hi(t))return t;if(Array.isArray(t))return t.map(Ji);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=Xi(t)||"Object";if(!Gi[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Gi[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=Gi[e].shallow.indexOf(r)>=0?i:Ji(i);}return n}class Wi{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Hangul Syllables":t=>t>=44032&&t<=55215,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function ts(t){for(const e of t)if(as(e.charCodeAt(0)))return !0;return !1}function es(t){for(const e of t)if(!is(e.charCodeAt(0)))return !1;return !0}function rs(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const ns=rs(["Arab","Dupl","Mong","Ougr","Syrc"]);function is(t){return !ns.test(String.fromCodePoint(t))}const ss=rs(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function as(t){return !(746!==t&&747!==t&&(t<4352||!(Qi["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Qi["CJK Compatibility"](t)||Qi["CJK Strokes"](t)||!(!Qi["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Qi["Enclosed CJK Letters and Months"](t)||Qi["Ideographic Description Characters"](t)||Qi.Kanbun(t)||Qi.Katakana(t)&&12540!==t||!(!Qi["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Qi["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Qi["Vertical Forms"](t)||Qi["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||ss.test(String.fromCodePoint(t)))))}function os(t){return !(as(t)||function(t){return !!(Qi["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Qi["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||Qi["Letterlike Symbols"](t)||Qi["Number Forms"](t)||Qi["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||Qi["Control Pictures"](t)&&9251!==t||Qi["Optical Character Recognition"](t)||Qi["Enclosed Alphanumerics"](t)||Qi["Geometric Shapes"](t)||Qi["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Qi["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Qi["CJK Symbols and Punctuation"](t)||Qi.Katakana(t)||Qi["Private Use Area"](t)||Qi["CJK Compatibility Forms"](t)||Qi["Small Form Variants"](t)||Qi["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const ls=rs(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function us(t){return ls.test(String.fromCodePoint(t))}function cs(t,e){return !(!e&&us(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Qi.Khmer(t))}function hs(t){for(const e of t)if(us(e.charCodeAt(0)))return !0;return !1}const ps=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{};}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(ps.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve();}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,r){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((t=>{this.loadScriptResolve=t;}));r(e);const i=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([n,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class fs{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Wi,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!cs(r.charCodeAt(0),e))return !1;return !0}(t,"loaded"===ps.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class ds{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Fn(t))return new Hn(t,e);if(qn(t)){const r=Xn(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=xe.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?r=Me.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(r=ze.parse(t)):r=Se.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class ys{constructor(t){this.property=t,this.value=new ds(t,void 0);}transitioned(t,e){return new gs(this.property,this.value,e,F({},t.transition,this.transition),t.now)}untransitioned(){return new gs(this.property,this.value,null,{},0)}}class ms{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return D(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ys(this._values[t].property)),this._values[t].value=new ds(this._values[t].property,null===e?void 0:D(e));}getTransition(t){return D(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new ys(this._values[t].property)),this._values[t].transition=D(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new xs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new xs(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class gs{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(nn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class ks{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new fs(Math.floor(e.zoom-1),e)),t.expression.evaluate(new fs(Math.floor(e.zoom),e)),t.expression.evaluate(new fs(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Ms{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class Is{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new ds(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new ys(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}Zi("DataDrivenProperty",Ss),Zi("DataConstantProperty",_s),Zi("CrossFadedDataDrivenProperty",As),Zi("CrossFadedProperty",ks),Zi("ColorRampProperty",Ms);const zs="-transition";class Ps extends ft{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new vs(e.layout)),e.paint)){this._transitionablePaint=new ms(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ws(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(Ni,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(zs)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(ji,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(zs))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),O(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&Ui(this,t.call(Oi,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:dt,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof bs&&Bn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const Cs={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Bs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class Vs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Es(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=Cs[t.type].BYTES_PER_ELEMENT,s=r=Ts(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Ts(r,Math.max(n,e)),alignment:e}}function Ts(t,e){return Math.ceil(t/e)*e}class Fs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Fs.prototype.bytesPerElement=4,Zi("StructArrayLayout2i4",Fs);class $s extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}$s.prototype.bytesPerElement=6,Zi("StructArrayLayout3i6",$s);class Ls extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Ls.prototype.bytesPerElement=8,Zi("StructArrayLayout4i8",Ls);class Os extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Os.prototype.bytesPerElement=12,Zi("StructArrayLayout2i4i12",Os);class Ds extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}Ds.prototype.bytesPerElement=8,Zi("StructArrayLayout2i4ub8",Ds);class Rs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Rs.prototype.bytesPerElement=8,Zi("StructArrayLayout2f8",Rs);class js extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}js.prototype.bytesPerElement=20,Zi("StructArrayLayout10ui20",js);class Ns extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}Ns.prototype.bytesPerElement=24,Zi("StructArrayLayout4i4ui4i24",Ns);class Us extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Us.prototype.bytesPerElement=12,Zi("StructArrayLayout3f12",Us);class qs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}qs.prototype.bytesPerElement=4,Zi("StructArrayLayout1ul4",qs);class Gs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}Gs.prototype.bytesPerElement=20,Zi("StructArrayLayout6i1ul2ui20",Gs);class Zs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Zs.prototype.bytesPerElement=12,Zi("StructArrayLayout2i2i2i12",Zs);class Ks extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}Ks.prototype.bytesPerElement=16,Zi("StructArrayLayout2f1f2i16",Ks);class Xs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=16*t,l=4*t,u=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=a,t}}Xs.prototype.bytesPerElement=16,Zi("StructArrayLayout2ub2f2i16",Xs);class Hs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Hs.prototype.bytesPerElement=6,Zi("StructArrayLayout3ui6",Hs);class Ys extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}Ys.prototype.bytesPerElement=48,Zi("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Ys);class Js extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k,M,I,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=S,this.uint32[C+12]=A,this.float32[C+13]=k,this.float32[C+14]=M,this.uint16[P+30]=I,this.uint16[P+31]=z,t}}Js.prototype.bytesPerElement=64,Zi("StructArrayLayout8i15ui1ul2f2ui64",Js);class Ws extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Ws.prototype.bytesPerElement=4,Zi("StructArrayLayout1f4",Ws);class Qs extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Qs.prototype.bytesPerElement=12,Zi("StructArrayLayout1ui2f12",Qs);class ta extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}ta.prototype.bytesPerElement=8,Zi("StructArrayLayout1ul2ui8",ta);class ea extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}ea.prototype.bytesPerElement=4,Zi("StructArrayLayout2ui4",ea);class ra extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}ra.prototype.bytesPerElement=2,Zi("StructArrayLayout1ui2",ra);class na extends Vs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}na.prototype.bytesPerElement=16,Zi("StructArrayLayout4f16",na);class ia extends Bs{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}ia.prototype.size=20;class sa extends Gs{get(t){return new ia(this,t)}}Zi("CollisionBoxArray",sa);class aa extends Bs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}aa.prototype.size=48;class oa extends Ys{get(t){return new aa(this,t)}}Zi("PlacedSymbolArray",oa);class la extends Bs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}la.prototype.size=64;class ua extends Js{get(t){return new la(this,t)}}Zi("SymbolInstanceArray",ua);class ca extends Ws{getoffsetX(t){return this.float32[1*t+0]}}Zi("GlyphOffsetArray",ca);class ha extends $s{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Zi("SymbolLineVertexArray",ha);class pa extends Bs{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}pa.prototype.size=12;class fa extends Qs{get(t){return new pa(this,t)}}Zi("TextAnchorOffsetArray",fa);class da extends Bs{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}da.prototype.size=8;class ya extends ta{get(t){return new da(this,t)}}Zi("FeatureIndexArray",ya);class ma extends Fs{}class ga extends Fs{}class xa extends Fs{}class va extends Os{}class ba extends Ds{}class wa extends Rs{}class _a extends js{}class Sa extends Ns{}class Aa extends Us{}class ka extends qs{}class Ma extends Zs{}class Ia extends Xs{}class za extends Hs{}class Pa extends ea{}const Ca=Es([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ba}=Ca;class Va{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t;}prepareSegment(t,e,r,n){const i=this.segments[this.segments.length-1];return t>Va.MAX_VERTEX_ARRAY_LENGTH&&j(`Max vertices per segment is ${Va.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Va.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+t>Va.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n?this.createNewSegment(e,r,n):i}createNewSegment(t,e,r){const n={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==r&&(n.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(t,e,r){return this.prepareSegment(0,t,e,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0;}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new Va([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ea(t,e){return 256*(t=E(Math.floor(t),0,255))+E(Math.floor(e),0,255)}Va.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Zi("SegmentVector",Va);const Ta=Es([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Fa,$a,La,Oa={exports:{}},Da={exports:{}},Ra={exports:{}},ja=function(){if(La)return Oa.exports;La=1;var t=(Fa||(Fa=1,Da.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Da.exports),e=($a||($a=1,Ra.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),Ra.exports);return Oa.exports=t,Oa.exports.murmur3=t,Oa.exports.murmur2=e,Oa.exports}(),Na=r(ja);class Ua{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(qa(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=qa(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Ga(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new Ua;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function qa(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Na(String(t))}function Ga(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;Za(t,s,a),Za(e,3*s,3*a),Za(e,3*s+1,3*a+1),Za(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new Ya(t,e):new Xa(t,e)}}class to{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new Ha(t,e):new Xa(t,e)}}class eo{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new fs(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=Wa(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new fs(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new fs(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Wa(r),s=Wa(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof eo||r instanceof ro)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new io(n,e,r);this.needsUpload=!1,this._featureMap=new Ua,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function ao(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function oo(t,e,r){const n={color:{source:Rs,composite:na},number:{source:Ws,composite:Rs}},i=function(t){return {"line-pattern":{source:_a,composite:_a},"fill-pattern":{source:_a,composite:_a},"fill-extrusion-pattern":{source:_a,composite:_a}}[t]}(t);return i&&i[r]||n[e][r]}Zi("ConstantBinder",Qa),Zi("CrossFadedConstantBinder",to),Zi("SourceExpressionBinder",eo),Zi("CrossFadedCompositeBinder",no),Zi("CompositeExpressionBinder",ro),Zi("ProgramConfiguration",io,{omit:["_buffers"]}),Zi("ProgramConfigurationSet",so);const lo=Math.pow(2,14)-1,uo=-lo-1;function co(t){const e=M/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&j("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function ho(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?co(t):[]}}const po=-32768;function fo(t,e,r,n,i){t.emplaceBack(po+8*e+n,po+8*r+i);}class yo{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ga,this.indexArray=new za,this.segments=new Va,this.programConfigurations=new so(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1,o="heatmap"===n.type;if("circle"===n.type){const t=n;s=t.layout.get("circle-sort-key"),a=!s.isConstant(),o=o||"map"===t.paint.get("circle-pitch-alignment");}const l=o?e.subdivisionGranularity.circle:1;for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ho(e,t);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:co(e),patterns:{},sortKey:c};i.push(h);}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r,l),e.featureIndex.insert(o,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ba),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const a=s.length;for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=M||n<0||n>=M)continue;const i=this.segments.prepareSegment(a*a,this.layoutVertexArray,this.indexArray,t.sortKey),o=i.vertexLength;for(let t=0;t1){if(bo(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function Ao(t,e){for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function Mo(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=N(t,e,r[0]);return s!==N(t,e,r[1])||s!==N(t,e,r[2])||s!==N(t,e,r[3])}function Io(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function zo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Po(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=l.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let e=0;eTo(t,e,r,n)))}(l,i,a,o),p=c?u*s:u;for(const t of n)for(const e of t){const t=c?e:To(e,i,a,o);let r=p;const n=i.projectTileCoordinates(e.x,e.y,a,o).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n/i.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=i.cameraToCenterDistance/n),go(h,t,r))return !0}return !1}}function To(t,e,r,n){const i=e.projectTileCoordinates(t.x,t.y,r,n).point;return new l((.5*i.x+.5)*e.width,(.5*-i.y+.5)*e.height)}class Fo extends yo{}let $o;Zi("HeatmapBucket",Fo,{omit:["layers"]});var Lo={get paint(){return $o=$o||new Is({"heatmap-radius":new Ss(dt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ss(dt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new _s(dt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ms(dt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new _s(dt.paint_heatmap["heatmap-opacity"])})}};function Oo(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function Do(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Oo({},{width:e,height:r},n);Ro(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function Ro(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a);};if(t.clips)for(let e=0,i=0;e0)for(let i=e;i=e;i-=n)s=wl(i/n|0,t[i],t[i+1],s);return s&&yl(s,s.next)&&(_l(s),s=s.next),s}function tl(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!yl(n,n.next)&&0!==dl(n.prev,n,n.next))n=n.next;else {if(_l(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function el(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=ul(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?nl(t,n,i,s):rl(t))e.push(l.i,t.i,u.i),_l(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?el(t=il(tl(t),e),e,r,n,i,s,2):2===a&&sl(t,e,r,n,i,s):el(tl(t),e,r,n,i,s,1);break}}}function rl(t){const e=t.prev,r=t,n=t.next;if(dl(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),p=Math.max(i,s,a),f=Math.max(o,l,u);let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&pl(i,o,s,l,a,u,d.x,d.y)&&dl(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function nl(t,e,r,n){const i=t.prev,s=t,a=t.next;if(dl(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=Math.min(o,l,u),d=Math.min(c,h,p),y=Math.max(o,l,u),m=Math.max(c,h,p),g=ul(f,d,e,r,n),x=ul(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&pl(o,c,l,h,u,p,v.x,v.y)&&dl(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&pl(o,c,l,h,u,p,b.x,b.y)&&dl(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&pl(o,c,l,h,u,p,v.x,v.y)&&dl(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&pl(o,c,l,h,u,p,b.x,b.y)&&dl(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function il(t,e){let r=t;do{const n=r.prev,i=r.next.next;!yl(n,i)&&ml(n,r,r.next,i)&&vl(n,i)&&vl(i,n)&&(e.push(n.i,r.i,i.i),_l(r),_l(r.next),r=t=i),r=r.next;}while(r!==t);return tl(r)}function sl(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&fl(a,t)){let o=bl(a,t);return a=tl(a,a.next),o=tl(o,o.next),el(a,e,r,n,i,s,0),void el(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function al(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function ol(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;if(yl(t,r))return r;do{if(yl(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&hl(is.x||r.x===s.x&&ll(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=bl(r,t);return tl(n,n.next),tl(r,r.next)}function ll(t,e){return dl(t.prev,t,e.prev)<0&&dl(e.next,t,t.next)<0}function ul(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function cl(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function pl(t,e,r,n,i,s,a,o){return !(t===a&&e===o)&&hl(t,e,r,n,i,s,a,o)}function fl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&ml(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(vl(t,e)&&vl(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(dl(t.prev,t,e.prev)||dl(t,e.prev,e))||yl(t,e)&&dl(t.prev,t,t.next)>0&&dl(e.prev,e,e.next)>0)}function dl(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function yl(t,e){return t.x===e.x&&t.y===e.y}function ml(t,e,r,n){const i=xl(dl(t,e,r)),s=xl(dl(t,e,n)),a=xl(dl(r,n,t)),o=xl(dl(r,n,e));return i!==s&&a!==o||!(0!==i||!gl(t,r,e))||!(0!==s||!gl(t,n,e))||!(0!==a||!gl(r,t,n))||!(0!==o||!gl(r,e,n))}function gl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function xl(t){return t>0?1:t<0?-1:0}function vl(t,e){return dl(t.prev,t,t.next)<0?dl(t,e,t.next)>=0&&dl(t,t.prev,e)>=0:dl(t,e,t.prev)<0||dl(t,t.next,e)<0}function bl(t,e){const r=Sl(t.i,t.x,t.y),n=Sl(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function wl(t,e,r,n){const i=Sl(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function _l(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Sl(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Al{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e;}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const r=0|Math.round(t),n=0|Math.round(e),i=this._getKey(r,n);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(r,n),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const r=[];for(let n=0;n0?(r.push(i),r.push(a),r.push(s)):(r.push(i),r.push(s),r.push(a));}return r}(this._vertexBuffer,t);const e=[],r=t.length;for(let n=0;n=1||v<=0)||y&&(oi)){u>=n&&u<=i&&s.push(r[(t+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(a+p*x,o+f*x));const b=a+p*Math.max(x,0),w=a+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,a,o,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(a+p*v,o+f*v)),(y||u>=n&&u<=i)&&s.push(r[(t+1)%3]),!y&&(u<=n||u>=i)&&this._generateInterEdgeVertices(s,a,o,l,u,c,h,w,n,i);}return s}_generateIntraEdgeVertices(t,e,r,n,i,s,a){const o=n-e,l=i-r,u=0===l,c=u?Math.min(e,n):Math.min(s,a),h=u?Math.max(e,n):Math.max(s,a),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?e=p;n--){const i=n*this._granularityCellSize;t.push(this._vertexToIndex(i,r+l*(i-e)/o));}}_generateInterEdgeVertices(t,e,r,n,i,s,a,o,l,u){const c=i-r,h=s-n,p=a-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=n+h*y;let x=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,b=o=1||m<=0){const t=r-a,n=s+(e-s)*Math.min((l-a)/t,(u-a)/t);x=Math.floor(Math.min(n,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,o)/this._granularityCellSize)-1,b=o0?u:l;if(b)for(let e=x;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,_));else for(let e=v;e>=x;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,_));}_generateOutline(t){const e=[];for(const r of t){const t=Cl(r,this._granularity,!0),n=this._pointArrayToIndices(t),i=[];for(let t=1;ti!=(s===Ml)?(t.push(e),t.push(r),t.push(this._vertexToIndex(n,s)),t.push(r),t.push(this._vertexToIndex(i,s)),t.push(this._vertexToIndex(n,s))):(t.push(r),t.push(e),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(i,s)),t.push(r),t.push(this._vertexToIndex(n,s)));}_fillPoles(t,e,r){const n=this._vertexBuffer,i=M,s=t.length;for(let a=2;a80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return el(s,a,r,o,l,u,0),a}(r,n),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e);}catch(t){console.error(t);}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(t,e){const r=[];for(let n=0;n0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,e=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(x-t),n=Math.abs(v-e),i=Math.abs(x-c),s=Math.abs(v-h),u=p?r/m:Number.POSITIVE_INFINITY,b=f?n/g:Number.POSITIVE_INFINITY;if((i<=r||!p)&&(s<=n||!f))break;if(u=0?a-1:s-1,i=(o+1)%s,l=t[2*e[n]],u=t[2*e[i]],c=t[2*e[a]],h=t[2*e[a]+1],p=t[2*e[o]+1];let f=!1;if(lu)f=!1;else {const r=p-h,s=-(t[2*e[o]]-c),a=h((u-c)*r+(t[2*e[i]+1]-h)*s)*a&&(f=!0);}if(f){const t=e[n],i=e[a],l=e[o];t!==i&&t!==l&&i!==l&&r.push(l,i,t),a--,a<0&&(a=s-1);}else {const t=e[i],n=e[a],l=e[o];t!==n&&t!==l&&n!==l&&r.push(l,n,t),o++,o>=s&&(o=0);}if(n===i)break}}function Vl(t,e,r,n,i,s,a,o,l){const u=i.length/2,c=a&&o&&l;if(uVa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,g=!0,c=0);const x=El(a,n,s,o,p,y,u),v=El(a,n,s,o,f,m,u),b=El(a,n,s,o,d,g,u);r.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++;}}(e,r,n,i,s,t),c&&function(t,e,r,n,i,s){const a=[];for(let t=0;tVa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,d=!0,y=!0,c=0);const m=El(a,n,s,o,i,d,u),g=El(a,n,s,o,h,y,u);r.emplaceBack(c+m-l,c+g-l),u.primitiveLength++;}}}(a,r,o,i,l,t),e.forceNewSegmentOnNextPrepare(),null==a||a.forceNewSegmentOnNextPrepare();}function El(t,e,r,n,i,s,a){if(s){const s=n.count;return r(e[2*i],e[2*i+1]),t[i]=n.count,n.count++,a.vertexLength++,s}return t[i]}class Tl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new xa,this.indexArray=new za,this.indexArray2=new Pa,this.programConfigurations=new so(t.layers,t.zoom),this.segments=new Va,this.segments2=new Va,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Jo("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ho(a,t);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:co(a),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Wo("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Yo),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s){for(const t of Ur(e,500)){const e=Pl(t,n,s.fill.getGranularityForZoomLevel(n.z)),r=this.layoutVertexArray;Vl(((t,e)=>{r.emplaceBack(t,e);}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}}let Fl,$l;Zi("FillBucket",Tl,{omit:["layers","patternFeatures"]});var Ll={get paint(){return $l=$l||new Is({"fill-antialias":new _s(dt.paint_fill["fill-antialias"]),"fill-opacity":new Ss(dt.paint_fill["fill-opacity"]),"fill-color":new Ss(dt.paint_fill["fill-color"]),"fill-outline-color":new Ss(dt.paint_fill["fill-outline-color"]),"fill-translate":new _s(dt.paint_fill["fill-translate"]),"fill-translate-anchor":new _s(dt.paint_fill["fill-translate-anchor"]),"fill-pattern":new As(dt.paint_fill["fill-pattern"])})},get layout(){return Fl=Fl||new Is({"fill-sort-key":new Ss(dt.layout_fill["fill-sort-key"])})}};class Ol extends Ps{constructor(t){super(t,Ll);}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Tl(t)}queryRadius(){return zo(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:r,pixelsToTileUnits:n}){return xo(Po(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,n),e)}isTileClipped(){return !0}}const Dl=Es([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Rl=Es([{name:"a_centroid",components:2,type:"Int16"}],4),{members:jl}=Dl;var Nl,Ul,ql,Gl,Zl,Kl,Xl,Hl={};function Yl(){if(Ul)return Nl;Ul=1;var t=s();function e(t,e,n,i,s){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=s,t.readFields(r,this,e);}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){for(var r=t.readVarint()+t.pos;t.pos>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(a,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var s,a,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return ql=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},ql}function Wl(){return Xl||(Xl=1,Hl.VectorTile=function(){if(Kl)return Zl;Kl=1;var t=Jl();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return Zl=function(t,r){this.layers=t.readFields(e,{},r);},Zl}(),Hl.VectorTileFeature=Yl(),Hl.VectorTileLayer=Jl()),Hl}var Ql=r(Wl());const tu=Ql.VectorTileFeature.types,eu=Math.pow(2,13);function ru(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*eu)+a,i*eu*2,s*eu*2,Math.round(o));}class nu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new va,this.centroidVertexArray=new ma,this.indexArray=new za,this.programConfigurations=new so(t.layers,t.zoom),this.segments=new Va,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=Jo("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=ho(n,t);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:co(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Wo("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{},e.subdivisionGranularity),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0);}}addFeatures(t,e,r){for(const n of this.features){const{geometry:i}=n;this.addFeature(n,i,n.index,e,r,t.subdivisionGranularity);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,jl),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Rl.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i,s){for(const r of Ur(e,500)){const e={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(e,n,t,r,s);const a=this.layoutVertexArray.length-i,o=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t{ru(u,t,e,0,0,1,1,0);}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles);}_generateSideFaces(t,e){let r=0;for(let n=1;nVa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const a=i.sub(s)._perp()._unit(),o=s.dist(i);r+o>32768&&(r=0),ru(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,0,r),ru(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,1,r),r+=o,ru(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,0,r),ru(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,1,r);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2;}}}function iu(t,e){for(let r=0;rM)||t.y===e.y&&(t.y<0||t.y>M)}function au(t){return t.every((t=>t.x<0))||t.every((t=>t.x>M))||t.every((t=>t.y<0))||t.every((t=>t.y>M))}let ou;Zi("FillExtrusionBucket",nu,{omit:["layers","features"]});var lu={get paint(){return ou=ou||new Is({"fill-extrusion-opacity":new _s(dt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ss(dt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new _s(dt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new _s(dt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new As(dt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ss(dt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ss(dt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new _s(dt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class uu extends Ps{constructor(t){super(t,lu);}createBucket(t){return new nu(t)}queryRadius(){return zo(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s,pixelPosMatrix:a}){const o=Po(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-i.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(e,r),c=this.paint.get("fill-extrusion-base").evaluate(e,r),h=function(t,e,r){const n=[];for(const r of t){const t=[r.x,r.y,0,1];_(t,t,e),n.push(new l(t[0]/t[3],t[1]/t[3]));}return n}(o,a),p=function(t,e,r,n){const i=[],s=[],a=n[8]*e,o=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,s=i.y,y=n[0]*e+n[4]*s+n[12],m=n[1]*e+n[5]*s+n[13],g=n[2]*e+n[6]*s+n[14],x=n[3]*e+n[7]*s+n[15],v=g+u,b=x+c,w=y+h,_=m+p,S=g+f,A=x+d,k=new l((y+a)/b,(m+o)/b);k.z=v/b,t.push(k);const M=new l(w/A,_/A);M.z=S/A,r.push(M);}i.push(t),s.push(r);}return [i,s]}(n,c,u,a);return function(t,e,r){let n=1/0;xo(r,e)&&(n=hu(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new ba,this.layoutVertexArray2=new wa,this.indexArray=new za,this.programConfigurations=new so(t.layers,t.zoom),this.segments=new Va,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=Jo("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ho(e,t);if(!this.layers[0]._featureFilter.filter(new fs(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:co(e),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Wo("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,yu)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,fu),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),l=a.get("line-cap"),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,s,a,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Cl(t,a?o.line.getGranularityForZoomLevel(a.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c0;if(w&&e>c){const t=f.dist(d);if(t>2*h){const e=f.sub(f.sub(d)._mult(h/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,m,0,0,p),d=e;}}const S=d&&y;let A=S?r:l?"butt":n;if(S&&"round"===A&&(vi&&(A="bevel"),"bevel"===A&&(v>2&&(A="flipbevel"),v100)a=g.mult(-1);else {const t=v*m.add(g).mag()/m.sub(g).mag();a._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(f,a,0,0,p),this.addCurrentVertex(f,a.mult(-1),0,0,p);}else if("bevel"===A||"fakeround"===A){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(d&&this.addCurrentVertex(f,m,e,r,p),"fakeround"===A){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*h){const e=f.add(y.sub(f)._mult(h/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,p),f=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>xu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s));}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(xu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let bu,wu;Zi("LineBucket",vu,{omit:["layers","patternFeatures"]});var _u={get paint(){return wu=wu||new Is({"line-opacity":new Ss(dt.paint_line["line-opacity"]),"line-color":new Ss(dt.paint_line["line-color"]),"line-translate":new _s(dt.paint_line["line-translate"]),"line-translate-anchor":new _s(dt.paint_line["line-translate-anchor"]),"line-width":new Ss(dt.paint_line["line-width"]),"line-gap-width":new Ss(dt.paint_line["line-gap-width"]),"line-offset":new Ss(dt.paint_line["line-offset"]),"line-blur":new Ss(dt.paint_line["line-blur"]),"line-dasharray":new ks(dt.paint_line["line-dasharray"]),"line-pattern":new As(dt.paint_line["line-pattern"]),"line-gradient":new Ms(dt.paint_line["line-gradient"])})},get layout(){return bu=bu||new Is({"line-cap":new _s(dt.layout_line["line-cap"]),"line-join":new Ss(dt.layout_line["line-join"]),"line-miter-limit":new _s(dt.layout_line["line-miter-limit"]),"line-round-limit":new _s(dt.layout_line["line-round-limit"]),"line-sort-key":new Ss(dt.layout_line["line-sort-key"])})}};class Su extends Ss{possiblyEvaluate(t,e){return e=new fs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=F({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let Au;class ku extends Ps{constructor(t){super(t,_u),this.gradientVersion=0,Au||(Au=new Su(_u.paint.properties["line-width"].specification),Au.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Ye,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Au.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new vu(t)}queryRadius(t){const e=t,r=Mu(Io("line-width",this,e),Io("line-gap-width",this,e)),n=Io("line-offset",this,e);return r/2+Math.abs(n)+zo(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s}){const a=Po(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-i.bearingInRadians,s),o=s/2*Mu(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Iu=Es([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),zu=Es([{name:"a_projected_pos",components:3,type:"Float32"}],4);Es([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Pu=Es([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Es([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cu=Es([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Bu=Es([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Vu(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),ps.applyArabicShaping&&(t=ps.applyArabicShaping(t)),t}(t.text,e,r);})),t}Es([{name:"triangle",components:3,type:"Uint16"}]),Es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Es([{type:"Float32",name:"offsetX"}]),Es([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Es([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Eu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Tu,Fu,$u,Lu=24,Ou={};function Du(){return Tu||(Tu=1,Ou.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},Ou.write=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;}),Ou}function Ru(){if($u)return Fu;$u=1,Fu=e;var t=Du();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function v(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return a(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=s(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},Fu}var ju=r(Ru());const Nu=3;function Uu(t,e,r){1===t&&r.readMessage(qu,e);}function qu(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(Gu,{});e.push({id:t,bitmap:new jo({width:i+2*Nu,height:s+2*Nu},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}}function Gu(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const Zu=Nu;function Ku(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&rc[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new tc;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}getMaxImageSize(t){let e=0,r=0;for(let n=0;n=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ec(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=tc.fromFeature(e,s);let g;p===t.ah.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=ps;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),cc(m,c,a,r,i,d));for(const e of t){const t=new tc;t.text=e,t.sections=m.sections;for(let r=0;r=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/a,a=t;}return {x1:n,y1:i,x2:n+s,y2:i+a}}function bc(t,e,r,n,i,s){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-a.displaySize[1])/2,p=c+a.displaySize[1]),{image:a,top:c,right:h,bottom:p,left:f,collisionPadding:o}}const wc=255,_c=128,Sc=wc*_c;function Ac(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new fs(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ac(this.zoom,r["text-size"]),this.iconSizeData=Ac(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap="never"!==kc(n,"text-overlap","text-allow-overlap")||"never"!==kc(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ah[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Bc(new so(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Bc(new so(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new ca,this.lineVertexArray=new ha,this.symbolInstances=new ua,this.textAnchorOffsets=new fa;}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new fs(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=ho(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=co(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=_e.factory(t),r=this.hasRTLText=this.hasRTLText||Cc(e);(!r||"unavailable"===ps.getRTLTextPluginStatus()||r&&ps.isParsed())&&(x=Vu(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof Ie?t:Ie.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:Mc[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=a.evaluate(g,{},n).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ah.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=ts(x.toString()),i=t.fontStack||e,s=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,s,r,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Tc,Fc;Zi("SymbolBucket",Ec,{omit:["layers","collisionBoxArray","features","compareText"]}),Ec.MAX_GLYPHS=65535,Ec.addDynamicAttributes=Pc;var $c={get paint(){return Fc=Fc||new Is({"icon-opacity":new Ss(dt.paint_symbol["icon-opacity"]),"icon-color":new Ss(dt.paint_symbol["icon-color"]),"icon-halo-color":new Ss(dt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ss(dt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ss(dt.paint_symbol["icon-halo-blur"]),"icon-translate":new _s(dt.paint_symbol["icon-translate"]),"icon-translate-anchor":new _s(dt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ss(dt.paint_symbol["text-opacity"]),"text-color":new Ss(dt.paint_symbol["text-color"],{runtimeType:Tt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Ss(dt.paint_symbol["text-halo-color"]),"text-halo-width":new Ss(dt.paint_symbol["text-halo-width"]),"text-halo-blur":new Ss(dt.paint_symbol["text-halo-blur"]),"text-translate":new _s(dt.paint_symbol["text-translate"]),"text-translate-anchor":new _s(dt.paint_symbol["text-translate-anchor"])})},get layout(){return Tc=Tc||new Is({"symbol-placement":new _s(dt.layout_symbol["symbol-placement"]),"symbol-spacing":new _s(dt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new _s(dt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ss(dt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new _s(dt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new _s(dt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new _s(dt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new _s(dt.layout_symbol["icon-ignore-placement"]),"icon-optional":new _s(dt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new _s(dt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ss(dt.layout_symbol["icon-size"]),"icon-text-fit":new _s(dt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new _s(dt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ss(dt.layout_symbol["icon-image"]),"icon-rotate":new Ss(dt.layout_symbol["icon-rotate"]),"icon-padding":new Ss(dt.layout_symbol["icon-padding"]),"icon-keep-upright":new _s(dt.layout_symbol["icon-keep-upright"]),"icon-offset":new Ss(dt.layout_symbol["icon-offset"]),"icon-anchor":new Ss(dt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new _s(dt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new _s(dt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new _s(dt.layout_symbol["text-rotation-alignment"]),"text-field":new Ss(dt.layout_symbol["text-field"]),"text-font":new Ss(dt.layout_symbol["text-font"]),"text-size":new Ss(dt.layout_symbol["text-size"]),"text-max-width":new Ss(dt.layout_symbol["text-max-width"]),"text-line-height":new _s(dt.layout_symbol["text-line-height"]),"text-letter-spacing":new Ss(dt.layout_symbol["text-letter-spacing"]),"text-justify":new Ss(dt.layout_symbol["text-justify"]),"text-radial-offset":new Ss(dt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new _s(dt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ss(dt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ss(dt.layout_symbol["text-anchor"]),"text-max-angle":new _s(dt.layout_symbol["text-max-angle"]),"text-writing-mode":new _s(dt.layout_symbol["text-writing-mode"]),"text-rotate":new Ss(dt.layout_symbol["text-rotate"]),"text-padding":new _s(dt.layout_symbol["text-padding"]),"text-keep-upright":new _s(dt.layout_symbol["text-keep-upright"]),"text-transform":new Ss(dt.layout_symbol["text-transform"]),"text-offset":new Ss(dt.layout_symbol["text-offset"]),"text-allow-overlap":new _s(dt.layout_symbol["text-allow-overlap"]),"text-overlap":new _s(dt.layout_symbol["text-overlap"]),"text-ignore-placement":new _s(dt.layout_symbol["text-ignore-placement"]),"text-optional":new _s(dt.layout_symbol["text-optional"])})}};class Lc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Ct,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Zi("FormatSectionOverride",Lc,{omit:["defaultValue"]});class Oc extends Ps{constructor(t){super(t,$c);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||qn(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Ec(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of $c.paint.overridableProperties){if(!Oc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Lc(e),n=new Un(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Zn("source",n):new Kn("composite",n,e.value.zoomStops),this.paint._values[t]=new bs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&Oc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=$c.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof _e)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof Ee&&Be(e.value)===Dt?s(e.value.sections):e instanceof gr?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Dc;var Rc={get paint(){return Dc=Dc||new Is({"background-color":new _s(dt.paint_background["background-color"]),"background-pattern":new ks(dt.paint_background["background-pattern"]),"background-opacity":new _s(dt.paint_background["background-opacity"])})}};class jc extends Ps{constructor(t){super(t,Rc);}}let Nc;var Uc={get paint(){return Nc=Nc||new Is({"raster-opacity":new _s(dt.paint_raster["raster-opacity"]),"raster-hue-rotate":new _s(dt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new _s(dt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new _s(dt.paint_raster["raster-brightness-max"]),"raster-saturation":new _s(dt.paint_raster["raster-saturation"]),"raster-contrast":new _s(dt.paint_raster["raster-contrast"]),"raster-resampling":new _s(dt.paint_raster["raster-resampling"]),"raster-fade-duration":new _s(dt.paint_raster["raster-fade-duration"])})}};class qc extends Ps{constructor(t){super(t,Uc);}}class Gc extends Ps{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Zc{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle();}),0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const Kc={once:!0},Xc=6371008.8;class Hc{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Hc(T(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Xc*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof Hc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Hc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Hc(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Yc=2*Math.PI*Xc;function Jc(t){return Yc*Math.cos(t*Math.PI/180)}function Wc(t){return (180+t)/360}function Qc(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function th(t,e){return t/Jc(e)}function eh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function rh(t,e){return t*Jc(eh(e))}class nh{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=Hc.convert(t);return new nh(Wc(r.lng),Qc(r.lat),th(e,r.lat))}toLngLat(){return new Hc(360*this.x-180,eh(this.y))}toAltitude(){return rh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Yc*(t=eh(this.y),1/Math.cos(t*Math.PI/180));var t;}}function ih(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class sh{constructor(t,e,r){if(!function(t,e,r){return !(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=lh(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=ih(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=ih(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*M,(t.y*e-this.y)*M)}toString(){return `${this.z}/${this.x}/${this.y}`}}class ah{constructor(t,e){this.wrap=t,this.canonical=e,this.key=lh(t,e.z,e.z,e.x,e.y);}}class oh{constructor(t,e,r,n,i){if(this.terrainRttPosMatrix32f=null,t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new sh(r,+n,+i),this.key=lh(e,t,r,n,i);}clone(){return new oh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new oh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new oh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?lh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):lh(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new oh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new oh(e,this.wrap,e,r,n),new oh(e,this.wrap,e,r+1,n),new oh(e,this.wrap,e,r,n+1),new oh(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new No({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class hh{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class ph{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new qi(M,16,0),this.grid3D=new qi(M,16,0),this.featureIndexArray=new ya,this.promoteId=e;}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ql.VectorTile(new ju(this.rawTileData)).layers,this.sourceLayerCoder=new ch(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params,s=M/t.tileSize/t.scale,a=Qn(i.filter),o=t.queryGeometry,u=t.queryPadding*s,c=dh(o),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=dh(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new l(e,r),new l(e,i),new l(n,i),new l(n,r)];if(t.length>2)for(const e of s)if(ko(t,e))return !0;for(let e=0;e(p||(p=co(e)),r.queryIntersectsFeature({queryGeometry:o,feature:e,featureState:n,geometry:p,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))));}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!h.some((t=>s.has(t))))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=ho(f,!0);if(!i.filter(new fs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new fs(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const a=e instanceof ws?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function dh(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {minX:e,minY:r,maxX:n,maxY:i}}function yh(t,e){return e-t}function mh(t,e,r,n,i){const s=[];for(let a=0;a=n&&c.x>=n||(a.x>=n?a=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=n&&(c=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=i&&c.y>=i||(a.y>=i?a=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y>=i&&(c=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),u&&a.equals(u[u.length-1])||(u=[a],s.push(u)),u.push(c)))));}}return s}Zi("FeatureIndex",ph,{omit:["rawTileData","sourceLayerCoder"]});class gh extends l{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new gh(this.x,this.y,this.angle,this.segment)}}function xh(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function vh(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=ir.number(n.x,i.x,c),p=ir.number(n.y,i.y,c),f=new gh(h,p,i.angleTo(n),r);return f._round(),!a||xh(t,f,o,a,e)?f:void 0}l+=s;}}function Sh(t,e,r,n,i,s,a,o,l){const u=bh(n,s,a),c=wh(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new gh(g,x,y,e);r._round(),n&&!xh(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=Ah(t,h/2,r,n,i,s,a,!0,l)),f}Zi("Anchor",gh);const kh=Xu;function Mh(t,e,r,n){const i=[],s=t.image,a=s.pixelRatio,o=s.paddedRect.w-2*kh,u=s.paddedRect.h-2*kh;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=s.stretchX||[[0,o]],p=s.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=o-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,S=m,A=0,k=g;if(s.content&&n){const e=s.content,r=e[2]-e[0],n=e[3]-e[1];(s.textFitWidth||s.textFitHeight)&&(c=vc(t)),x=Ih(h,0,e[0]),b=Ih(p,0,e[1]),v=Ih(h,e[0],e[2]),w=Ih(p,e[1],e[3]),_=e[0]-x,A=e[1]-b,S=r-v,k=n-w;}const M=c.x1,I=c.y1,z=c.x2-M,P=c.y2-I,C=(t,n,i,o)=>{const u=Ph(t.stretch-x,v,z,M),c=Ch(t.fixed-_,S,t.stretch,d),h=Ph(n.stretch-b,w,P,I),p=Ch(n.fixed-A,k,n.stretch,y),f=Ph(i.stretch-x,v,z,M),m=Ch(i.fixed-_,S,i.stretch,d),g=Ph(o.stretch-b,w,P,I),C=Ch(o.fixed-A,k,o.stretch,y),B=new l(u,h),V=new l(f,h),E=new l(f,g),T=new l(u,g),F=new l(c/a,p/a),$=new l(m/a,C/a),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),r=[e,-t,t,e];B._matMult(r),V._matMult(r),T._matMult(r),E._matMult(r);}const O=t.stretch+t.fixed,D=n.stretch+n.fixed;return {tl:B,tr:V,bl:T,br:E,tex:{x:s.paddedRect.x+kh+O,y:s.paddedRect.y+kh+D,w:i.stretch+i.fixed-O,h:o.stretch+o.fixed-D},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:$,minFontScaleX:S/a/z,minFontScaleY:k/a/P,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=zh(h,m,d),e=zh(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {const u=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?vc(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};u.y1=u.y1*a-o[0],u.y2=u.y2*a+o[2],u.x1=u.x1*a-o[3],u.x2=u.x2*a+o[1];const p=s.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const t=new l(u.x1,u.y1),e=new l(u.x2,u.y1),r=new l(u.x1,u.y2),n=new l(u.x2,u.y2),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,i);}this.boxEndIndex=t.length;}}class Vh{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}function Eh(t,e=1,r=!1){let n=1/0,i=1/0,s=-1/0,a=-1/0;const o=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const u=Math.min(s-n,a-i);let c=u/2;const h=new Vh([],Th);if(0===u)return new l(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Fh(n.p.x-c,n.p.y-c,c,t)),h.push(new Fh(n.p.x+c,n.p.y-c,c,t)),h.push(new Fh(n.p.x-c,n.p.y+c,c,t)),h.push(new Fh(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Th(t,e){return e.max-t.max}function Fh(t,e,r,n){this.p=new l(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,So(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var $h;t.ay=void 0,($h=t.ay||(t.ay={}))[$h.center=1]="center",$h[$h.left=2]="left",$h[$h.right=3]="right",$h[$h.top=4]="top",$h[$h.bottom=5]="bottom",$h[$h["top-left"]=6]="top-left",$h[$h["top-right"]=7]="top-right",$h[$h["bottom-left"]=8]="bottom-left",$h[$h["bottom-right"]=9]="bottom-right";const Lh=7,Oh=Number.POSITIVE_INFINITY;function Dh(t,e){return e[1]!==Oh?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case "top-right":case "top-left":case "top":i=r-Lh;break;case "bottom-right":case "bottom-left":case "bottom":i=-r+Lh;}switch(t){case "top-right":case "bottom-right":case "right":n=-e;break;case "top-left":case "bottom-left":case "left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case "top-right":case "top-left":n=i-Lh;break;case "bottom-right":case "bottom-left":n=-i+Lh;break;case "bottom":n=-e+Lh;break;case "top":n=e-Lh;}switch(t){case "top-right":case "bottom-right":r=-i;break;case "top-left":case "bottom-left":r=i;break;case "left":r=e;break;case "right":r=-e;}return [r,n]}(t,e[0])}function Rh(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*Lu));n.startsWith("top")?i[1]-=Lh:n.startsWith("bottom")&&(i[1]+=Lh),e[r+1]=i;}return new Me(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Lu,Oh]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Lu));const s=[];for(const t of a)s.push(t,Dh(t,n));return new Me(s)}return null}function jh(t){switch(t){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function Nh(e,r,n,i,s,a,o,l,u,c,h,p){let f=a.textMaxSize.evaluate(r,{});void 0===f&&(f=o);const d=e.layers[0].layout,y=d.get("icon-offset").evaluate(r,{},h),m=qh(n.horizontal),g=o/24,x=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*d.get("symbol-spacing"),_=d.get("text-padding")*e.tilePixelRatio,S=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),s=i&&i.values;return [s[0]*n,s[1]*n,s[2]*n,s[3]*n]}(d,r,h,e.tilePixelRatio),A=d.get("text-max-angle")/180*Math.PI,k="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),I="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),z=d.get("symbol-placement"),P=w/2,C=d.get("icon-text-fit");let B;i&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(B=bc(i,n.vertical,C,d.get("icon-text-fit-padding"),y,g)),m&&(i=bc(i,m,C,d.get("icon-text-fit-padding"),y,g)));const V=h?p.line.getGranularityForZoomLevel(h.z):1,E=(l,p)=>{p.x<0||p.x>=M||p.y<0||p.y>=M||function(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,k){const M=e.addToLineVertexArray(r,n);let I,z,P,C,B=0,V=0,E=0,T=0,F=-1,$=-1;const L={};let O=Na("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},A)+90;P=new Bh(u,r,c,h,p,i.vertical,f,d,y,t),o&&(C=new Bh(u,r,c,h,p,o,g,x,y,t));}if(s){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),a=Mh(s,n,S,i),f=o?Mh(o,n,S,i):void 0;z=new Bh(u,r,c,h,p,s,g,x,!1,n),B=4*a.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[_c*l.layout.get("icon-size").evaluate(w,{})],y[0]>Sc&&j(`${e.layerIds[0]}: Value for "icon-size" is >= ${wc}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[_c*_.compositeIconSizes[0].evaluate(w,{},A),_c*_.compositeIconSizes[1].evaluate(w,{},A)],(y[0]>Sc||y[1]>Sc)&&j(`${e.layerIds[0]}: Value for "icon-size" is >= ${wc}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,y,b,v,w,t.ah.none,r,M.lineStartIndex,M.lineLength,-1,A),F=e.icon.placedSymbolArray.length-1,f&&(V=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.ah.vertical,r,M.lineStartIndex,M.lineLength,-1,A),$=e.icon.placedSymbolArray.length-1);}const D=Object.keys(i.horizontal);for(const n of D){const s=i.horizontal[n];if(!I){O=Na(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},A);I=new Bh(u,r,c,h,p,s,f,d,y,t);}const o=1===s.positionedLines.length;if(E+=Uh(e,r,s,a,l,y,w,m,M,i.vertical?t.ah.horizontal:t.ah.horizontalOnly,o?D:[n],L,F,_,A),o)break}i.vertical&&(T+=Uh(e,r,i.vertical,a,l,y,w,m,M,t.ah.vertical,["vertical"],L,$,_,A));const R=I?I.boxStartIndex:e.collisionBoxArray.length,N=I?I.boxEndIndex:e.collisionBoxArray.length,U=P?P.boxStartIndex:e.collisionBoxArray.length,q=P?P.boxEndIndex:e.collisionBoxArray.length,G=z?z.boxStartIndex:e.collisionBoxArray.length,Z=z?z.boxEndIndex:e.collisionBoxArray.length,K=C?C.boxStartIndex:e.collisionBoxArray.length,X=C?C.boxEndIndex:e.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(I,H),H=Y(P,H),H=Y(z,H),H=Y(C,H);const J=H>-1?1:0;J&&(H*=k/Lu),e.glyphOffsetArray.length>=Ec.MAX_GLYPHS&&j("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=Rh(l,w,A),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,F,$,O,R,N,U,q,G,Z,K,X,c,E,T,B,V,J,0,f,H,Q,tt);}(e,p,l,n,i,s,B,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,x,[_,_,_,_],k,u,b,S,I,y,r,a,c,h,o);};if("line"===z)for(const t of mh(r.geometry,0,0,M,M)){const r=Cl(t,V),s=Sh(r,w,A,n.vertical||m,i,24,v,e.overscaling,M);for(const t of s)m&&Gh(e,m.text,P,t)||E(r,t);}else if("line-center"===z){for(const t of r.geometry)if(t.length>1){const e=Cl(t,V),r=_h(e,A,n.vertical||m,i,24,v);r&&E(e,r);}}else if("Polygon"===r.type)for(const t of Ur(r.geometry,0)){const e=Eh(t,16);E(Cl(t[0],V,!0),new gh(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry){const e=Cl(t,V);E(e,new gh(e[0].x,e[0].y,0));}else if("Point"===r.type)for(const t of r.geometry)for(const e of t)E([e],new gh(e.x,e.y,0));}function Uh(t,e,r,n,i,s,a,o,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,s,a,o){const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=Zu+1,p=!0,f=1,d=0;const y=(i||o)&&n.vertical,m=n.metrics.advance*n.scale/2;if(o&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Lu-n.metrics.width*n.scale)/2:(n.scale-1)*Lu)),n.imageName){const t=a[n.imageName];p=t.sdf,f=t.pixelRatio,h=Xu/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],S=w+s.w/b*n.scale/f,A=_+s.h/b*n.scale/f,k=new l(w,_),M=new l(S,_),I=new l(w,A),z=new l(S,A);if(y){const t=new l(-m,m-Wu),e=-Math.PI/2,r=Lu/2-m,i=new l(5-Wu-r,-(n.imageName?r:0)),s=new l(...v);k._rotateAround(e,t)._add(i)._add(s),M._rotateAround(e,t)._add(i)._add(s),I._rotateAround(e,t)._add(i)._add(s),z._rotateAround(e,t)._add(i)._add(s);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),M._matMult(r),I._matMult(r),z._matMult(r);}const P=new l(0,0),C=new l(0,0);c.push({tl:k,tr:M,bl:I,br:z,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,o,i,s,a,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[_c*i.layout.get("text-size").evaluate(a,{})],x[0]>Sc&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${wc}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[_c*d.compositeTextSizes[0].evaluate(a,{},y),_c*d.compositeTextSizes[1].evaluate(a,{},y)],(x[0]>Sc||x[1]>Sc)&&j(`${t.layerIds[0]}: Value for "text-size" is >= ${wc}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,o,s,a,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function qh(t){for(const e in t)return t[e];return null}function Gh(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=Zh[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Kh(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=Zh.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)Wh(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Wh(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function Xh(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;Hh(t,e,a,n,i,s),Xh(t,e,r,n,a-1,1-s),Xh(t,e,r,a+1,i,1-s);}function Hh(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);Hh(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(Yh(t,e,n,r),e[2*i+s]>a&&Yh(t,e,n,i);oa;)l--;}e[2*n+s]===a?Yh(t,e,n,l):(l++,Yh(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function Yh(t,e,r,n){Jh(t,r,n),Jh(e,2*r,2*n),Jh(e,2*r+1,2*n+1);}function Jh(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Wh(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}var Qh;t.ck=void 0,(Qh=t.ck||(t.ck={})).create="create",Qh.load="load",Qh.fullLoad="fullLoad";let tp=null,ep=[];const rp=1e3/60,np="loadTime",ip="fullLoadTime",sp={mark(t){performance.mark(t);},frame(t){const e=t;null!=tp&&ep.push(e-tp),tp=e;},clearMetrics(){tp=null,ep=[],performance.clearMeasures(np),performance.clearMeasures(ip);for(const e in t.ck)performance.clearMarks(t.ck[e]);},getPerformanceMetrics(){performance.measure(np,t.ck.create,t.ck.load),performance.measure(ip,t.ck.create,t.ck.fullLoad);const e=performance.getEntriesByName(np)[0].duration,r=performance.getEntriesByName(ip)[0].duration,n=ep.length,i=1/(ep.reduce(((t,e)=>t+e),0)/n/1e3),s=ep.filter((t=>t>rp)).reduce(((t,e)=>t+(e-rp)/rp),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:s/(n+s)*100,totalFrames:n}}};t.$=nh,t.A=g,t.B=ir,t.C=fs,t.D=_s,t.E=ft,t.F=Ri,t.G=function(t){if(null==q){const e=t.navigator?t.navigator.userAgent:null;q=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return q},t.H=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Zc((()=>this.process())),this.subscription=Y(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=U(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=e?Y(e.signal,"abort",(()=>{null==s||s.unsubscribe(),delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),Kc):null;this.resolveRejects[i]={resolve:t=>{null==s||s.unsubscribe(),r(t);},reject:t=>{null==s||s.unsubscribe(),n(t);}};const a=[],o=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:Yi(t.data,a)});this.target.postMessage(o,{transfer:a});}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(U(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(Ji(r.error)):e.resolve(Ji(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=Ji(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i);}catch(e){this.completeTask(t,e);}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?Yi(e):null,data:Yi(r,n)};this.target.postMessage(i,{transfer:n});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.I=Hu,t.J=it,t.K=function(){var t=new g(16);return g!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.L=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=a*y+c*m+d*g+e[15]),t},t.M=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.N=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*o+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*s+b*u+w*f+_*g,t[3]=v*a+b*c+w*d+_*x,t[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*s+b*u+w*f+_*g,t[7]=v*a+b*c+w*d+_*x,t[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*s+b*u+w*f+_*g,t[11]=v*a+b*c+w*d+_*x,t[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*s+b*u+w*f+_*g,t[15]=v*a+b*c+w*d+_*x,t},t.O=function(t,e){const r={};for(let n=0;n{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e);};for(const r of t){const t=window.document.createElement("source");lt(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t);}}))},t.a3=Mt,t.a4=function(){return $++},t.a5=sa,t.a6=Ec,t.a7=Qn,t.a8=ho,t.a9=hh,t.aA=jh,t.aB=hc,t.aC=Kh,t.aD=Es,t.aE=kl,t.aF=ma,t.aG=Va,t.aH=za,t.aI=function(t){return Math.pow(2,t)},t.aJ=85.051129,t.aK=th,t.aL=T,t.aM=J,t.aN=rh,t.aO=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},t.aP=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},t.aQ=function(t){var e=new g(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aR=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},t.aS=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},t.aT=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.aU=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},t.aV=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aW=ah,t.aX=lh,t.aY=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.aZ=function(t){var e=new g(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.a_=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.aa=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.ab=function(t){return Math.log(t)/Math.LN2},t.ac=function(t){var e=t[0],r=t[1];return e*e+r*r},t.ad=function(t){return t*Math.PI/180},t.ae=E,t.af=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ag=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:a}=t,o=i?E(rr.interpolationFactor(i,e,s,a),0,1):0;"camera"===t.kind?n=ir.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.ai=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/_c:"composite"===t.kind?ir.number(n/_c,i/_c,r):e},t.aj=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,S=i*u-s*l,A=c*y-h*d,k=c*m-p*d,M=c*g-f*d,I=h*m-p*y,z=h*g-f*y,P=p*g-f*m,C=x*P-v*z+b*I+w*M-_*k+S*A;return C?(t[0]=(o*P-l*z+u*I)*(C=1/C),t[1]=(i*z-n*P-s*I)*C,t[2]=(y*S-m*_+g*w)*C,t[3]=(p*_-h*S-f*w)*C,t[4]=(l*M-a*P-u*k)*C,t[5]=(r*P-i*M+s*k)*C,t[6]=(m*b-d*S-g*v)*C,t[7]=(c*S-p*b+f*v)*C,t[8]=(a*z-o*M+u*A)*C,t[9]=(n*M-r*z-s*A)*C,t[10]=(d*_-y*b+g*x)*C,t[11]=(h*b-c*_-f*x)*C,t[12]=(o*k-a*I-l*A)*C,t[13]=(r*I-n*k+i*A)*C,t[14]=(y*v-d*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null},t.ak=A,t.al=function(t){return Math.hypot(t[0],t[1])},t.am=function(t){return t[0]=0,t[1]=0,t},t.an=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},t.ao=Pc,t.ap=_,t.aq=function(t,e,r,n){const i=e.y-t.y,s=e.x-t.x,a=n.y-r.y,o=n.x-r.x,u=a*s-o*i;if(0===u)return null;const c=(o*(t.y-r.y)-a*(t.x-r.x))/u;return new l(t.x+c*s,t.y+c*i)},t.ar=mh,t.as=mo,t.at=v,t.au=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return [e,r,n,i]},t.av=Lu,t.aw=I,t.ax=function(t,e,r,n,i=!1){if(!r[0]&&!r[1])return [0,0];const s=i?"map"===n?-t.bearingInRadians:0:"viewport"===n?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e];}return [i?r[0]:I(e,r[0],t.zoom),i?r[1]:I(e,r[1],t.zoom)]},t.az=kc,t.b=G,t.b$=t=>"symbol"===t.type,t.b0=function(){const t=new Float32Array(16);return v(t),t},t.b1=function(){const t=new Float64Array(16);return v(t),t},t.b2=function(){return new Float64Array(16)},t.b3=function(t,e,r){const n=new Float64Array(4);return function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u;}(n,t,e-90,r),n},t.b4=function(t,e,r,n){var i,s,a,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],y=r[2],g=r[3];return (s=u*f+c*d+h*y+p*g)<0&&(s=-s,f=-f,d=-d,y=-y,g=-g),1-s>m?(i=Math.acos(s),a=Math.sin(i),o=Math.sin((1-n)*i)/a,l=Math.sin(n*i)/a):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*y,t[3]=o*p+l*g,t},t.b5=function(t){const e=new Float64Array(9);var r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v;h=(i=(n=t)[0])*(l=i+i),p=(s=n[1])*l,d=(a=n[2])*l,y=a*(u=s+s),g=(o=n[3])*l,x=o*u,v=o*(c=a+a),(r=e)[0]=1-(f=s*u)-(m=a*c),r[3]=p-v,r[6]=d+x,r[1]=p+v,r[4]=1-h-m,r[7]=y-g,r[2]=d-x,r[5]=y+g,r[8]=1-h-f;const b=J(-Math.asin(E(e[2],-1,1)));let w,_;return Math.hypot(e[5],e[8])<.001?(w=0,_=-J(Math.atan2(e[3],e[4]))):(w=J(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),_=J(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:w,pitch:b+90,bearing:_}},t.b6=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b7=xe,t.b8=Xa,t.b9=Ml,t.bA=function(t,e){if(!t)return [{command:"setStyle",args:[e]}];let r=[];try{if(!gt(t.version,e.version))return [{command:"setStyle",args:[e]}];gt(t.center,e.center)||r.push({command:"setCenter",args:[e.center]}),gt(t.centerAltitude,e.centerAltitude)||r.push({command:"setCenterAltitude",args:[e.centerAltitude]}),gt(t.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),gt(t.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),gt(t.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),gt(t.roll,e.roll)||r.push({command:"setRoll",args:[e.roll]}),gt(t.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),gt(t.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),gt(t.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),gt(t.light,e.light)||r.push({command:"setLight",args:[e.light]}),gt(t.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),gt(t.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),gt(t.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const n={},i=[];!function(t,e,r,n){let i;for(i in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)||bt(i,r,n));for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)?gt(t[i],e[i])||("geojson"===t[i].type&&"geojson"===e[i].type&&_t(t,e,i)?xt(r,{command:"setGeoJSONSourceData",args:[i,e[i].data]}):wt(i,e,r,n)):vt(i,e,r));}(t.sources,e.sources,i,n);const s=[];t.layers&&t.layers.forEach((t=>{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):s.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(At),i=e.map(At),s=t.reduce(kt,{}),a=e.reduce(kt,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;tr?i-360:i+360;return Math.abs(i)0?a:-a},t.bq=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.br=Xc,t.bs=function(t,e){const r=z(t,2*Math.PI),n=z(e,2*Math.PI);return Math.min(Math.abs(r-n),Math.abs(r-n+2*Math.PI),Math.abs(r-n-2*Math.PI))},t.bt=function(t){return Math.hypot(t[0],t[1],t[2])},t.bu=function(){const t={},e=dt.$version;for(const r in dt.$root){const n=dt.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.bv=Wi,t.bw=at,t.bx=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r"circle"===t.type,t.c1=t=>"heatmap"===t.type,t.c2=t=>"line"===t.type,t.c3=t=>"fill"===t.type,t.c4=t=>"fill-extrusion"===t.type,t.c5=t=>"hillshade"===t.type,t.c6=t=>"raster"===t.type,t.c7=t=>"background"===t.type,t.c8=t=>"custom"===t.type,t.c9=B,t.cA=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start);}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.cB=function(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if(d())try{return yield K(t,r,n,i,s)}catch(t){}return function(t,e,r,n,i){const s=t.width,a=t.height;X&&H||(X=new OffscreenCanvas(s,a),H=X.getContext("2d",{willReadFrequently:!0})),X.width=s,X.height=a,H.drawImage(t,0,0,s,a);const o=H.getImageData(e,r,n,i);return H.clearRect(0,0,s,a),o.data}(t,r,n,i,s)}))},t.cC=uh,t.cD=r,t.cE=s,t.cF=Wl,t.cG=Ru,t.cH=Gn,t.cI=ps,t.ca=function(t,e,r){const n=k(e.x-r.x,e.y-r.y),i=k(t.x-r.x,t.y-r.y);var s,a;return J(Math.atan2(n[0]*i[1]-n[1]*i[0],(s=n)[0]*(a=i)[0]+s[1]*a[1]))},t.cb=V,t.cc=function(t,e){return Q[e]&&(t instanceof MouseEvent||t instanceof WheelEvent)},t.cd=function(t,e){return W[e]&&"touches"in t},t.ce=function(t){return W[t]||Q[t]},t.cf=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},t.cg=function(t,e){const{x:r,y:n}=nh.fromLngLat(e);return !(t<0||t>25||n<0||n>=1||r<0||r>=1)},t.ch=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.ci=class extends $s{},t.cj=sp,t.cl=function(t){return t.message===tt},t.cm=st,t.cn=function(t,e){rt.REGISTERED_PROTOCOLS[t]=e;},t.co=function(t){delete rt.REGISTERED_PROTOCOLS[t];},t.cp=function(t,e){const r={};for(let n=0;nt*Lu));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(i,{},e.canonical)*Lu:1/0,w=()=>{e.bucket.allowVerticalPlacement&&ts(s)&&(d.vertical=ec(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,b,a,m,"left",f,g,t.ah.vertical,!0,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.g=nt,t.h=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=Z;}));},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):Z;})),t.i=U,t.j=(t,e)=>ot(F(t,{type:"json"}),e),t.k=pt,t.l=ht,t.m=ot,t.n=(t,e)=>ot(F(t,{type:"arrayBuffer"}),e),t.o=function(t){return new ju(t).readFields(Uu,[])},t.p=Ku,t.q=jo,t.r=Is,t.s=Y,t.t=Di,t.u=Qi,t.v=dt,t.w=j,t.x=Ui,t.y=Oi,t.z=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}};})); + +define("worker",["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const o of t){this._layerConfigs[o.id]=o;const t=this._layers[o.id]=e.by(o);t._featureFilter=e.a7(t.filter),this.keyCache[o.id]&&delete this.keyCache[o.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=e.cp(Object.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let r=this.familiesBySource[i];r||(r=this.familiesBySource[i]={});const s=o.sourceLayer||"_geojsonTileLayer";let n=r[s];n||(n=r[s]=[]),n.push(t);}}}class o{constructor(t){const o={},i=[];for(const e in t){const r=t[e],s=o[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};i.push(o),s[e]={rect:o,metrics:t.metrics};}}const{w:r,h:s}=e.p(i),n=new e.q({width:r||1,height:s||1});for(const i in t){const r=t[i];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=o[i][t].rect;e.q.copy(s.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap);}}this.image=n,this.positions=o;}}e.cq("GlyphAtlas",o);class i{constructor(t){this.tileID=new e.Y(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,i,s,n,a){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a5;const l=new e.cr(Object.keys(t.layers).sort()),c=new e.cs(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:s,subdivisionGranularity:a},d=i.familiesBySource[this.source];for(const o in d){const i=t.layers[o];if(!i)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(o),a=[];for(let e=0;e=o.maxzoom||"none"!==o.visibility&&(r(t,this.zoom,s),(u[o.id]=o.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}const f=e.bD(h.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let g=Promise.resolve({});if(Object.keys(f).length){const e=new AbortController;this.inFlightDependencies.push(e),g=n.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const p=Object.keys(h.iconDependencies);let m=Promise.resolve({});if(p.length){const e=new AbortController;this.inFlightDependencies.push(e),m=n.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},e);}const y=Object.keys(h.patternDependencies);let v=Promise.resolve({});if(y.length){const e=new AbortController;this.inFlightDependencies.push(e),v=n.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const[w,x,_]=yield Promise.all([g,m,v]),b=new o(w),M=new e.ct(x,_);for(const t in u){const o=u[t];o instanceof e.a6?(r(o.layers,this.zoom,s),e.cu({bucket:o,glyphMap:w,glyphPositions:b.positions,imageMap:x,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):o.hasPattern&&(o instanceof e.cv||o instanceof e.cw||o instanceof e.cx)&&(r(o.layers,this.zoom,s),o.addFeatures(h,this.tileID.canonical,M.patternPositions));}return this.status="done",{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:M,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function r(t,o,i){const r=new e.C(o);for(const e of t)e.recalculate(r,i);}class s{constructor(e,t,o){this.actor=e,this.layerIndex=t,this.availableImages=o,this.fetching={},this.loading={},this.loaded={};}loadVectorTile(t,o){return e._(this,void 0,void 0,(function*(){const i=yield e.n(t.request,o);try{return {vectorTile:new e.cy.VectorTile(new e.cz(i.data)),rawData:i.data,cacheControl:i.cacheControl,expires:i.expires}}catch(e){const o=new Uint8Array(i.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cA(t.request),s=new i(t);this.loading[o]=s;const n=new AbortController;s.abort=n;try{const i=yield this.loadVectorTile(t,n);if(delete this.loading[o],!i)return null;const a=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}s.vectorTile=i.vectorTile;const u=s.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[o]=s,this.fetching[o]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[o];}}catch(e){throw delete this.loading[o],s.status="done",this.loaded[o]=s,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid;if(!this.loaded||!this.loaded[o])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const i=this.loaded[o];if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=yield i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let s;if(this.fetching[o]){const{rawTileData:t,cacheControl:i,resourceTiming:n}=this.fetching[o];delete this.fetching[o],s=e.e({rawTileData:t.slice(0)},r,i,n);}else s=r;return s}if("done"===i.status&&i.vectorTile)return i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){const e=this.loading,o=t.uid;e&&e[o]&&e[o].abort&&(e[o].abort.abort(),delete e[o]);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid];}))}}class n{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:i,rawImageData:r,redFactor:s,greenFactor:n,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cB(r,-1,-1,c,u)):r,d=new e.cC(o,h,i,s,n,a,l);return this.loaded=this.loaded||{},this.loaded[o]=d,d}))}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}var a,l,c=function(){if(l)return a;function e(e,o){if(0!==e.length){t(e[0],o);for(var i=1;i=Math.abs(a)?o-l+a:a-l+o,o=l;}o+i>=0!=!!t&&e.reverse();}return l=1,a=function t(o,i){var r,s=o&&o.type;if("FeatureCollection"===s)for(r=0;r>31}function c(e,t){for(var o=e.loadGeometry(),i=e.type,r=0,s=0,n=o.length,c=0;ce},_=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;const M=3,S=5,I=6;class P{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const s=[];for(let t=0;t=o;e--){const o=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,r=180;else if(o>r){const e=this.getClusters([o,i,180,s],t),n=this.getClusters([-180,i,r,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(D(o),C(s),D(r),C(i)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+S]>1?k(l,t,this.clusterProps):this.points[l[t+M]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(i);const s=r.data;if(t*this.stride>=s.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const o=t*this.stride;s[o+4]===e&&l.push(s[o+S]>1?k(s,o,this.clusterProps):this.points[s[o+M]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(o-a)/r,c=(o+1+a)/r,u={features:[]};return this._addTileFeatures(i.range((t-a)/r,l,(t+1+a)/r,c),i.data,t,o,r,u),0===t&&this._addTileFeatures(i.range(1-a/r,l,1,c),i.data,r,o,r,u),t===r-1&&this._addTileFeatures(i.range(0,l,a/r,c),i.data,-1,o,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=i?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,o,i,r):r1;let l,c,u;if(a)l=T(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+M]];l=o.properties;const[i,r]=o.geometry.coordinates;c=D(i),u=C(r);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-o)),Math.round(this.options.extent*(u*r-i))]],tags:l};let d;d=a||this.options.generateId?t[e+M]:this.points[t[e+M]].id,void 0!==d&&(h.id=d),s.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:r,minPoints:s}=this.options,n=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+S]);}if(f>d&&f>=s){let e,s=i*d,n=u*d,g=-1;const p=((o/c|0)<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+S];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=p,r&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)));}a[o+4]=p,l.push(s/f,n/f,1/0,p,-1,f),r&&l.push(g);}else {for(let e=0;e1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+S]>1){const i=this.clusterProps[e[t+I]];return o?Object.assign({},i):i}const i=this.points[e[t+M]].properties,r=this.options.map(i);return o&&r===i?Object.assign({},r):r}}function k(e,t,o){return {type:"Feature",id:e[t+M],properties:T(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),O(e[t+1])]}};var i;}function T(e,t,o){const i=e[t+S],r=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,s=e[t+I],n=-1===s?{}:Object.assign({},o[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+M],point_count:i,point_count_abbreviated:r})}function D(e){return e/360+.5}function C(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function O(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function L(e,t,o,i){let r=i;const s=t+(o-t>>1);let n,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;ir)n=i,r=t;else if(t===r){const e=Math.abs(i-s);ei&&(n-t>3&&L(e,t,n,i),e[n+2]=r,o-n>3&&L(e,n,o,i));}function F(e,t,o,i,r,s){let n=r-o,a=s-i;if(0!==n||0!==a){const l=((e-o)*n+(t-i)*a)/(n*n+a*a);l>1?(o=r,i=s):l>0&&(o+=n*l,i+=a*l);}return n=e-o,a=t-i,n*n+a*a}function G(e,t,o,i){const r={id:null==e?null:e,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)z(r,o);else if("Polygon"===t)z(r,o[0]);else if("MultiLineString"===t)for(const e of o)z(r,e);else if("MultiPolygon"===t)for(const e of o)z(r,e[0]);return r}function z(e,t){for(let o=0;o0&&(n+=i?(r*l-a*s)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-s,2))),r=a,s=l;}const a=t.length-3;t[2]=1,L(t,0,a,o),t[a+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function Z(e,t,o,i){for(let r=0;r1?1:o}function W(e,t,o,i,r,s,n,a){if(i/=t,s>=(o/=t)&&n=i)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const n=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(n>=o&&c=i)continue;let u=[];if("Point"===s||"MultiPoint"===s)R(e,u,o,i,r);else if("LineString"===s)Y(e,u,o,i,r,!1,a.lineMetrics);else if("MultiLineString"===s)H(e,u,o,i,r,!1);else if("Polygon"===s)H(e,u,o,i,r,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];H(t,e,o,i,r,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(G(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(G(t.id,s,u,t.tags));}}return l.length?l:null}function R(e,t,o,i,r){for(let s=0;s=o&&n<=i&&V(t,e[s],e[s+1],e[s+2]);}}function Y(e,t,o,i,r,s,n){let a=q(e);const l=0===r?X:B;let c,u,h=e.start;for(let d=0;do&&(u=l(a,f,g,m,y,o),n&&(a.start=h+c*u)):v>i?w=o&&(u=l(a,f,g,m,y,o),x=!0),w>i&&v<=i&&(u=l(a,f,g,m,y,i),x=!0),!s&&x&&(n&&(a.end=h+c*u),t.push(a),a=q(e)),n&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===r?f:g;p>=o&&p<=i&&V(a,f,g,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&V(a,a[0],a[1],a[2]),a.length&&t.push(a);}function q(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function H(e,t,o,i,r,s){for(const n of e)Y(n,t,o,i,r,s,!1);}function V(e,t,o,i){e.push(t,o,i);}function X(e,t,o,i,r,s){const n=(s-t)/(i-t);return V(e,s,o+(r-o)*n,1),n}function B(e,t,o,i,r,s){const n=(s-o)/(r-o);return V(e,t+(i-t)*n,s,1),n}function $(e,t){const o=[];for(let i=0;i0&&t.size<(r?n:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;en)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;r&&function(e,t){let o=0;for(let t=0,i=e.length,r=i-2;t0===t)for(let t=0,o=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=ee(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(o!==s>>e||i!==n>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,v=null,w=null,x=null,_=W(e,u,o-f,o+p,0,d.minX,d.maxX,l),b=W(e,u,o+g,o+m,0,d.minX,d.maxX,l);e=null,_&&(y=W(_,u,i-f,i+p,1,d.minY,d.maxY,l),v=W(_,u,i+g,i+m,1,d.minY,d.maxY,l),_=null),b&&(w=W(b,u,i-f,i+p,1,d.minY,d.maxY,l),x=W(b,u,i+g,i+m,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(v||[],t+1,2*o,2*i+1),a.push(w||[],t+1,2*o+1,2*i),a.push(x||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:r,debug:s}=i;if(e<0||e>24)return null;const n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[se(c,u,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),s>1&&console.timeEnd("drilling down"),this.tiles[a]?K(this.tiles[a],r):null):null}}function se(e,t,o){return 32*((1<{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,n);},t}(t)).load((yield this._pendingData).features):(r=yield this._pendingData,new re(r,t.geojsonVtOptions)),this.loaded={};const o={};if(i){const e=i.finish();e&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}return o}catch(t){if(delete this._pendingRequest,e.cl(t))return {abandoned:!0};throw t}var r;}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){let i=yield this.loadGeoJSON(t,o);if(delete this._pendingRequest,"object"!=typeof i)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(i,!0),t.filter){const o=e.cH(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const r=i.features.filter((e=>o.value.evaluate({zoom:0},e)));i={type:"FeatureCollection",features:r};}return i}))}loadGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){const{promoteId:i}=t;if(t.request){const r=yield e.j(t.request,o);return this._dataUpdateable=ae(r.data,i)?le(r.data,i):void 0,r.data}if("string"==typeof t.data)try{const e=JSON.parse(t.data);return this._dataUpdateable=ae(e,i)?le(e,i):void 0,e}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return function(e,t,o){var i,r,s,n;if(t.removeAll&&e.clear(),t.remove)for(const o of t.remove)e.delete(o);if(t.add)for(const i of t.add){const t=ne(i,o);null!=t&&e.set(t,i);}if(t.update)for(const o of t.update){let t=e.get(o.id);if(null==t)continue;const a=!o.removeAllProperties&&((null===(i=o.removeProperties)||void 0===i?void 0:i.length)>0||(null===(r=o.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((o.newGeometry||o.removeAllProperties||a)&&(t=Object.assign({},t),e.set(o.id,t),a&&(t.properties=Object.assign({},t.properties))),o.newGeometry&&(t.geometry=o.newGeometry),o.removeAllProperties)t.properties={};else if((null===(s=o.removeProperties)||void 0===s?void 0:s.length)>0)for(const e of o.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:i}of o.addOrUpdateProperties)t.properties[e]=i;}}(this._dataUpdateable,t.dataDiff,i),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class ue{constructor(t){this.self=t,this.actor=new e.H(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.cn,this.self.removeProtocol=e.co,this.self.registerRTLTextPlugin=t=>{e.cI.setMethods(t);},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,o)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,o.source).removeTile(o);})))),this.actor.registerMessageHandler("GCEZ",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterExpansionZoom(o)})))),this.actor.registerMessageHandler("GCC",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterChildren(o)})))),this.actor.registerMessageHandler("GCL",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterLeaves(o)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,o)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][o.type]||!this.workerSources[t][o.type][o.source])return;const e=this.workerSources[t][o.type][o.source];delete this.workerSources[t][o.type][o.source],void 0!==e.removeSource&&e.removeSource(o);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t];})))),this.actor.registerMessageHandler("SR",((t,o)=>e._(this,void 0,void 0,(function*(){this.referrer=o;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,o)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(o);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(o.layers,o.removedIds);})))),this.actor.registerMessageHandler("SL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(o);}))));}_setImages(t,o){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=o;for(const e in this.workerSources[t]){const i=this.workerSources[t][e];for(const e in i)i[e].availableImages=o;}}))}_syncRTLPluginState(t,o){return e._(this,void 0,void 0,(function*(){return yield e.cI.syncState(o,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let o=this.layerIndexes[e];return o||(o=this.layerIndexes[e]=new t),o}_getWorkerSource(e,t,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][o]){const i={sendAsync:(t,o)=>(t.targetMapId=e,this.actor.sendAsync(t,o))};switch(t){case "vector":this.workerSources[e][t][o]=new s(i,this._getLayerIndex(e),this._getAvailableImages(e));break;case "geojson":this.workerSources[e][t][o]=new ce(i,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][o]=new this.externalWorkerSourceTypes[t](i,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][o]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue})); + +define("index",["exports","./shared"],(function(e,t){"use strict";var i="5.3.0";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let o,a;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,i,r){const o=requestAnimationFrame((e=>{a(),i(e);})),{unsubscribe:a}=t.s(e.signal,"abort",(()=>{a(),cancelAnimationFrame(o),r(t.c());}),!1);},frameAsync(e){return new Promise(((t,i)=>{this.frame(e,t,i);}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(o||(o=document.createElement("a")),o.href=e,o.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==a&&(a=matchMedia("(prefers-reduced-motion: reduce)")),a.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",n.suppressClickInternal,!0);}),0);}static getScale(e){const t=e.getBoundingClientRect();return {x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const o=i.boundingClientRect;return new t.P((r.clientX-o.left)/i.x-e.clientLeft,(r.clientY-o.top)/i.y-e.clientTop)}static mousePos(e,t){const i=n.getScale(e);return n.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=n.getScale(e);for(let o=0;o{c&&_(c),c=null,d=!0;},h.onerror=()=>{u=!0,c=null;},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,r,o,a;e.resetRequestQueue=()=>{i=[],r=0,o=0,a={};},e.addThrottleControl=e=>{const t=o++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],n();},e.getImage=(e,r,o=!0)=>new Promise(((a,s)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:o,state:"queued",onError:e=>{s(e);},onSuccess:e=>{a(e);}}),n();}));const s=e=>t._(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:i,supportImageRefresh:o,onError:a,onSuccess:s,abortController:l}=e,h=!1===o&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((e,t)=>e&&"accept"===t),!0));r++;const u=h?c(i,l):t.m(i,l);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(t){delete e.abortController,a(t);}finally{r--,n();}var d;})),n=()=>{const e=(()=>{for(const e of Object.keys(a))if(a[e]())return !0;return !1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e);}},c=(e,i)=>new Promise(((r,o)=>{const a=new Image,s=e.url,n=e.credentials;n&&"include"===n?a.crossOrigin="use-credentials":(n&&"same-origin"===n||!t.d(s))&&(a.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{a.src="",o(t.c());})),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,r({data:a});},a.onerror=()=>{a.onerror=a.onload=null,i.signal.aborted||o(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},a.src=s;}));}(p||(p={})),p.resetRequestQueue();class m{constructor(e){this._transformRequestFn=e;}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e;}}function f(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:o}of e){const e=`${r}${o}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:o}));}}return t}function g(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}class v{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:o,height:a}=e,s=!(this.size&&this.size[0]===o&&this.size[1]===a||r),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),s)this.size=[o,a],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,o,a,0,this.format,l.UNSIGNED_BYTE,e.data);else {const{x:i,y:s}=r||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,s,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,s,o,a,l.RGBA,l.UNSIGNED_BYTE,e.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D);}bind(e,t,i){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),i!==o.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=o.LINEAR),e!==this.filter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,t),this.wrap=t);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t);}_validate(e,i){let r=!0;const o=i.data||i.spriteData;return this._validateStretch(i.stretchX,o&&o.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,o&&o.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return !0;let i=0;for(const r of e){if(r[0]{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t});}))}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.l("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return {width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else {const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},o=new t.I(i,r);this.patterns[e]={bin:i,position:o};}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new v(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE);}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),o=this.atlasImage;o.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,a=i.y+1,s=this.getImage(e).data,n=s.width,l=s.height;t.R.copy(s,o,{x:0,y:0},{x:r,y:a},{width:n,height:l}),t.R.copy(s,o,{x:0,y:l-1},{x:r,y:a-1},{width:n,height:1}),t.R.copy(s,o,{x:0,y:0},{x:r,y:a+l},{width:n,height:1}),t.R.copy(s,o,{x:n-1,y:0},{x:r-1,y:a},{width:1,height:l}),t.R.copy(s,o,{x:0,y:0},{x:r+n,y:a},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e);}}}const y=1e20;function w(e,t,i,r,o,a,s,n,l){for(let c=t;c-1);l++,a[l]=n,s[l]=c,s[l+1]=y;}for(let n=0,l=0;n65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[o])return {stack:e,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[o]){const i=P.loadGlyphRange(e,o,this.url,this.requestManager);t.requests[o]=i;}const a=yield t.requests[o];for(const e in a)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=a[+e]);return t.ranges[o]=!0,{stack:e,id:i,glyph:a[i]||null}}))}_doesCharSupportLocalGlyph(e){return !!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||t.u["CJK Unified Ideographs"](e)||t.u["Hangul Syllables"](e)||t.u.Hiragana(e)||t.u.Katakana(e)||t.u["CJK Symbols and Punctuation"](e)||t.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,i,r){const o=this.localIdeographFontFamily;if(!o)return;if(!this._doesCharSupportLocalGlyph(r))return;let a=e.tinySDF;if(!a){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),a=e.tinySDF=new P.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:t});}const s=a.draw(String.fromCharCode(r));return {id:r,bitmap:new t.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}P.loadGlyphRange=function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=256*i,s=a+255,n=o.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${a}-${s}`),"Glyphs"),l=yield t.n(n,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${a}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c}))},P.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:a="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const n=this.size=e+4*t,l=this._createCanvas(n),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${a} ${e}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:a}=this.ctx.measureText(e),s=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-o))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=n+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),_={data:d,width:c,height:h,glyphWidth:n,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(e,m,m+s);const v=p.getImageData(m,m,n,l);g.fill(y,0,u),f.fill(0,0,u);for(let e=0;e0?e*e:0,f[r]=e<0?e*e:0;}}w(g,0,0,c,h,c,this.f,this.v,this.z),w(f,m,m,n,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++a]);const l=Math.abs(n-s.left),c=Math.abs(n-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.data[o+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let o=0,a=e[o];for(let t=0;t1&&(a=e[++o]);const i=Math.abs(t-a.left),s=Math.abs(t-a.right),n=Math.min(i,s);this.data[r+t]=Math.max(0,Math.min(255,(a.isDash?n:-n)+128));}}addDash(e,i){const r=i?7:0,o=2*r+1;if(this.nextRow+o>this.height)return t.w("LineAtlas out of space"),null;let a=0;for(let t=0;t{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[D]}numActive(){return Object.keys(this.active).length}}const A=Math.floor(s.hardwareConcurrency/2);let L,k;function F(){return L||(L=new z),L}z.workerCount=t.G(globalThis)?Math.max(Math.min(A,3),1):1;class B{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let e=0;e{e.remove();})),this.actors=[],e&&this.workerPool.release(this.id);}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t);}}function O(){return k||(k=new B(F(),t.J),k.registerMessageHandler("GR",((e,i,r)=>t.m(i,r)))),k}function j(e,i){const r=t.K();return t.L(r,r,[1,1,0]),t.M(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.N(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function Z(e,t,i,r,o,a,s){var n;const l=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return !0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return !0}return !1}(null!==(n=null==o?void 0:o.layers)&&void 0!==n?n:null,t,e.id),c=a.maxPitchScaleFactor(),h=e.tilesIn(r,c,l);h.sort(N);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,o,a,c,j(e.transform,r.tileID),s?(e,t)=>s(r.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const r of e[i])G(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,o=r.wrappedTileID,a=i[o]=i[o]||{};for(const i in e){const r=e[i],o=a[i]=a[i]||{},s=t[i]=t[i]||[];for(const e of r)o[e.featureIndex]||(o[e.featureIndex]=!0,s.push(e));}}return t}(u),e)}function N(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function G(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r;}function U(e,i,r){return t._(this,void 0,void 0,(function*(){let o=e;if(e.url?o=(yield t.j(i.transformRequest(e.url,"Source"),r)).data:yield s.frameAsync(r),!o)return null;const a=t.O(t.e(o,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in o&&o.vector_layers&&(a.vectorLayerIds=o.vector_layers.map((e=>e.id))),a}))}class V{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])));}setNorthEast(e){return this._ne=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}extend(e){const i=this._sw,r=this._ne;let o,a;if(e instanceof t.Q)o=e,a=e;else {if(!(e instanceof V))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(V.convert(e)):this.extend(t.Q.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.Q.convert(e)):this;if(o=e._sw,a=e._ne,!o||!a)return this}return i||r?(i.lng=Math.min(o.lng,i.lng),i.lat=Math.min(o.lat,i.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)):(this._sw=new t.Q(o.lng,o.lat),this._ne=new t.Q(a.lng,a.lat)),this}getCenter(){return new t.Q((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.Q(this.getWest(),this.getNorth())}getSouthEast(){return new t.Q(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:r}=t.Q.convert(e);let o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&o}static convert(e){return e instanceof V?e:e?new V(e):e}static fromLngLat(e,i=0){const r=360*i/40075017,o=r/Math.cos(Math.PI/180*e.lat);return new V(new t.Q(e.lng-o,e.lat-r),new t.Q(e.lng+o,e.lat+r))}adjustAntiMeridian(){const e=new t.Q(this._sw.lng,this._sw.lat),i=new t.Q(this._ne.lng,this._ne.lat);return new V(e,e.lng>i.lng?new t.Q(i.lng+360,i.lat):i)}}class q{constructor(e,t,i){this.bounds=V.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.U(this.bounds.getWest())*i),o=Math.floor(t.S(this.bounds.getNorth())*i),a=Math.ceil(t.U(this.bounds.getEast())*i),s=Math.ceil(t.S(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((t,i)=>{e.reloadPromise={resolve:t,reject:i};}))}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null);}}))}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject);}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class $ extends t.E{constructor(e,i,r,o){super(),this.id=e,this.dispatcher=r,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.O(i,["url","scheme","tileSize"]));}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield U(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e));}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}serialize(){return t.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const i=yield p.getImage(this.map._requestManager.transformRequest(t,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const t=this.map.painter.context,r=t.gl,o=i.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new v(t,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController);}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture);}))}hasTransition(){return !1}}class H extends ${constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield p.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const o=t.b(r)&&t.V()?r:yield this.readImageNow(r),a={type:this.type,uid:e.uid,source:this.id,rawImageData:o,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:a});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded";}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.W()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.X(e,-1,-1,i,r))}catch(e){}}return s.getImageData(e,1)}))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,a=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,n=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.Y(e.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.Y(e.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return t._(this,void 0,void 0,(function*(){const e=new V,t=yield this.getData();let i;switch(t.type){case "FeatureCollection":i=t.features.map((e=>this.getCoordinatesFromGeometry(e.geometry))).flat(1/0);break;case "Feature":i=this.getCoordinatesFromGeometry(t.geometry);break;default:i=this.getCoordinatesFromGeometry(t);}if(0==i.length)return e;for(let t=0;t0&&t.e(o,{resourceTiming:r}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content"})));}catch(e){if(this._pendingLoads--,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e));}}))}loaded(){return 0===this._pendingLoads}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t);}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0;}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}}class X extends t.E{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t;}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield p.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading());}catch(e){this._request=null,this._loaded=!0,this.fire(new t.k(e));}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.$.fromLngLat);var r;return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s=Math.max(o-i,a-r),n=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,n);return new t.a1(n,Math.floor((i+o)/2*l),Math.floor((r+a)/2*l))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new v(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}_getOverlappingTileRanges(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s={};for(let e=0;e<=t.a0;e++){const t=Math.pow(2,e),n=Math.floor(i*t),l=Math.floor(r*t),c=Math.floor(o*t),h=Math.floor(a*t);s[e]={minTileX:n,minTileY:l,maxTileX:c,maxTileY:h};}return s}}class Q extends X{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a2(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading();}catch(e){this.fire(new t.k(e));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.a3(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new v(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Y extends X{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.a3(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new v(i,this.canvas,r.RGBA,{premultiply:!0});let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}}const J={},ee=e=>{switch(e){case "geojson":return K;case "image":return X;case "raster":return $;case "raster-dem":return H;case "vector":return W;case "video":return Q;case "canvas":return Y}return J[e]},te="RTLPluginLoaded";class ie extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=O();}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(te));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let re=null;function oe(){return re||(re=new ie),re}class ae{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a4(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r;}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6&&i.hasRTLText){this.hasRTLText=!0,oe().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage);}else this.collisionBoxArray=new t.a5;}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new v(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new v(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null);}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture);}queryRenderedFeatures(e,t,i,r,o,a,s,n,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:o,scale:a,tileSize:this.tileSize,pixelPosMatrix:c,transform:n,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const o=r.loadVTLayers(),a=i&&i.sourceLayer?i.sourceLayer:"",s=o._geojsonTileLayer||o[a];if(!s)return;const n=t.a7(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,o);}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class ne{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,i,r){const o=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},t.e(this.stateChanges[e][o],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null);}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,i){const r=String(i),o=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete o[e];}return o}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,i){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}r[e]=r[e]||{},t.e(r[e],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i);}}function le(e,t,i){const r=t.intersectsFrustum(e);if(!i)return r;const o=t.intersectsPlane(i);return 0===r||0===o?0:2===r&&2===o?2:1}function ce(e,i,r,o,a){let s=e;const n=Math.atan(i/r),l=Math.hypot(i,r);return s=e+t.ab(o/l/Math.max(.5,Math.cos(t.ad(a/2)))),s+=1*t.ab(Math.cos(n))/2,s+=t.ae(e-s,-0,0),s}function he(e,i){const r=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ab(e.tileSize/i.tileSize));return Math.max(0,r)}function ue(e,i){const r=e.getCameraFrustum(),o=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.$.fromLngLat(e.center,e.elevation);a.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const n=e.getCoveringTilesDetailsProvider(),l=n.allowVariableZoom(e,i),c=he(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),_=Math.pow(2,d),p=[_*a.x,_*a.y,0],m=[_*s.x,_*s.y,0],f=Math.hypot(s.x-a.x,s.y-a.y),g=Math.abs(s.z-a.z),v=Math.hypot(f,g),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],y=[];if(e.renderWorldCopies&&n.allowWorldCopies())for(let e=1;e<=3;e++)b.push(x(-e)),b.push(x(e));for(b.push(x(0));b.length>0;){const _=b.pop(),f=_.x,x=_.y;let w=_.fullyVisible;const T={x:f,y:x,z:_.zoom},P=n.getTileAABB(T,_.wrap,e.elevation,i);if(!w){const e=le(r,P,o);if(0===e)continue;w=2===e;}const C=n.distanceToTile2d(a.x,a.y,T,P);let I=c;l&&(I=(i.calculateTileZoom||ce)(e.zoom+t.ab(e.tileSize/i.tileSize),C,g,v,e.fov)),I=(i.roundZoom?Math.round:Math.floor)(I),I=Math.max(0,I);const M=Math.min(I,u);if(_.wrap=n.getWrap(s,T,_.wrap),_.zoom>=M){if(_.zoom>1),wrap:_.wrap,fullyVisible:w});}return y.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}class de extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((e,t,i,r)=>{const o=new(ee(t.type))(e,t,i,r);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return o})(e,t,i,this),this._tiles={},this._cache=new se(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ne,this._didEmitContent=!1,this._updated=!1;}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e);}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(e,i,r){return t._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,r);}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain);}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e);}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(_e).map((e=>e.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,o=i.tileID,a=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(o.canonical.x,o.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-o.overscaledZ||s.y-a.y||s.x-a.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(_e).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)(e||"errored"!==this._tiles[t].state)&&this._reloadTile(t,"reloading");}}_reloadTile(e,i){return t._(this,void 0,void 0,(function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i));}))}_tileLoaded(e,i,r){e.timeAdded=s.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[a]&&(e.neighboringTiles[a].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const o in this._tiles){let a=this._tiles[o];if(r[o]||!a.hasData()||a.tileID.overscaledZ<=t||a.tileID.overscaledZ>i)continue;let s=a.tileID;for(;a&&a.tileID.overscaledZ>t+1;){const e=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[e.key],a&&a.hasData()&&(s=e);}let n=s;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]||e[n.canonical.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e]);}}_updateCoveredAndRetainedTiles(e,t,i,r,o,a){const n={},l={},c=Object.keys(e),h=s.now();for(const i of c){const r=e[i],o=this._tiles[i];if(!o||0!==o.fadeEndTime&&o.fadeEndTime<=h)continue;const a=this.findLoadedParent(r,t),s=this.findLoadedSibling(r),c=a||s||null;c&&(this._addTile(c.tileID),n[c.tileID.key]=c.tileID),l[i]=r;}this._retainLoadedChildren(l,r,i,e);for(const t in n)e[t]||(this._coveredTiles[t]=!0,e[t]=n[t]);if(a){const t={},i={};for(const e of o)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const r in i){const o=i[r].children(this._source.maxzoom);this._tiles[o[0].key]&&this._tiles[o[1].key]&&this._tiles[o[2].key]&&this._tiles[o[3].key]&&(t[o[0].key]=e[o[0].key]=o[0],t[o[1].key]=e[o[1].key]=o[1],t[o[2].key]=e[o[2].key]=o[2],t[o[3].key]=e[o[3].key]=o[3],delete i[r]);}for(const r in i){const o=i[r],a=this.findLoadedParent(o,this._source.minzoom),s=this.findLoadedSibling(o),n=a||s||null;if(n){t[n.tileID.key]=e[n.tileID.key]=n.tileID;for(const e in t)t[e].isChildOf(n.tileID)&&delete t[e];}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0);}}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.Y(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=ue(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const o=he(e,this._source),a=Math.max(o-de.maxOverzooming,this._source.minzoom),s=Math.max(o+de.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of r)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const r=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[r.key]=r;}r=r.concat(Object.values(e));}const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,o);pe(this._source.type)&&this._updateCoveredAndRetainedTiles(l,a,s,o,r,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.af(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e);}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e);}_updateRetainedTiles(e,t){var i;const r={},o={},a=Math.max(t-de.maxOverzooming,this._source.minzoom),s=Math.max(t+de.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);r[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=s.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){r[e.key]=e;continue}}else {const e=s.children(this._source.maxzoom);if(r[e[0].key]&&r[e[1].key]&&r[e[2].key]&&r[e[3].key])continue}let n=e.wasRequested();for(let t=s.overscaledZ-1;t>=a;--t){const a=s.scaledTo(t);if(o[a.key])break;if(o[a.key]=!0,e=this.getTile(a),!e&&n&&(e=this._addTile(a)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=e.wasRequested(),t)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i;}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new ae(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset();}tilesIn(e,i,r){const o=[],a=this.transform;if(!a)return o;const s=r?a.getCameraQueryGeometry(e):e,n=e.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),l=s.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),c=this.getIds();let h=1/0,u=1/0,d=-1/0,_=-1/0;for(const e of l)h=Math.min(h,e.x),u=Math.min(u,e.y),d=Math.max(d,e.x),_=Math.max(_,e.y);for(let e=0;e=0&&f[1].y+m>=0){const e=n.map((e=>s.getTilePoint(e))),t=l.map((e=>s.getTilePoint(e)));o.push({tile:r,tileID:s,queryGeometry:e,cameraQueryGeometry:t,scale:p});}}return o}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return !0;if(pe(this._source.type)){const e=s.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}}function _e(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function pe(e){return "raster"===e||"image"===e||"video"===e}de.maxOverzooming=10,de.maxUnderzooming=3;class me{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(o-s)/n:0;return this.points[a].mult(1-l).add(this.points[i].mult(l))}}function fe(e,t){let i=!0;return "always"===e||"never"!==e&&"never"!==t||(i=!1),i}class ge{constructor(e,t,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return [];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(o)return [{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e0}hitTestCircle(e,t,i,r,o){const a=e-i,s=e+i,n=t-i,l=t+i;if(s<0||a>this.width||l<0||n>this.height)return !1;const c=[];return this._forEachCell(a,n,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},o),c.length>0}_queryCell(e,t,i,r,o,a,s,n){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const o=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,d=this.boxKeys[s];if(e<=o[u+2]&&t<=o[u+3]&&i>=o[u+0]&&r>=o[u+1]&&(!n||n(d))&&(!c||!fe(h,d.overlapMode))&&(a.push({key:d,x1:o[u],y1:o[u+1],x2:o[u+2],y2:o[u+3]}),c))return !0}}const d=this.circleCells[o];if(null!==d){const o=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],e,t,i,r)&&(!n||n(d))&&(!c||!fe(h,d.overlapMode))){const e=o[u],t=o[u+1],i=o[u+2];if(a.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return !0}}}return !1}_queryCellCircle(e,t,i,r,o,a,s,n){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(r))&&!fe(h,r.overlapMode))return a.push(!0),!0}}const d=this.circleCells[o];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!n||n(r))&&!fe(h,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,i,r,o,a,s,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(o.call(this,e,t,i,r,this.xCellCount*l+d,a,s,n))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,o,a){const s=r-e,n=o-t,l=i+a;return l*l>s*s+n*n}_circleAndRectCollide(e,t,i,r,o,a,s){const n=(a-r)/2,l=Math.abs(e-(r+n));if(l>n+i)return !1;const c=(s-o)/2,h=Math.abs(t-(o+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}function ve(e,i,o){const a=t.K();if(!e){const{vecSouth:e,vecEast:t}=be(i),o=r();o[0]=t[0],o[1]=t[1],o[2]=e[0],o[3]=e[1],s=o,(d=(l=(n=o)[0])*(u=n[3])-(h=n[2])*(c=n[1]))&&(s[0]=u*(d=1/d),s[1]=-c*d,s[2]=-h*d,s[3]=l*d),a[0]=o[0],a[1]=o[1],a[4]=o[2],a[5]=o[3];}var s,n,l,c,h,u,d;return t.M(a,a,[1/o,1/o,1]),a}function xe(e,i,r,o){if(e){const e=t.K();if(!i){const{vecSouth:t,vecEast:i}=be(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1];}return t.M(e,e,[o,o,1]),e}return r.pixelsToClipSpaceMatrix}function be(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),o=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),n=t.ak();n[0]=-a*o*r-s*i,n[1]=-s*o*r+a*i;const l=t.al(n);l<1e-9?t.am(n):t.an(n,n,1/l);const c=t.ak();c[0]=a*o*i-s*r,c[1]=s*o*i+a*r;const h=t.al(c);return h<1e-9?t.am(c):t.an(c,c,1/h),{vecEast:c,vecSouth:n}}function ye(e,i,r,o){let a;o?(a=[e,i,o(e,i),1],t.ap(a,a,r)):(a=[e,i,0,1],Oe(a,a,r));const s=a[3];return {point:new t.P(a[0]/s,a[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function we(e,t){return .5+e/t*.5}function Te(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Pe(e,i,r,o,a,s,n,l,c,h,u,d,_){const p=r?e.textSizeData:e.iconSizeData,m=t.ag(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const v=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let y=!1;for(let r=0;rMath.abs(r.x-i.x)*o?{useVertical:!0}:(e===t.ah.vertical?i.yr.x)?{needsFlipping:!0}:null}function Me(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:o,fontSize:a,flip:s,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=a/24,_=o.lineOffsetX*d,p=o.lineOffsetY*d;let m;if(o.numGlyphs>1){const e=o.glyphStartIndex+o.numGlyphs,t=o.lineStartIndex,a=o.lineStartIndex+o.lineLength,c=Ce(d,l,_,p,s,o,u,i);if(!c)return {notEnoughRoom:!0};const f=De(c.first.point.x,c.first.point.y,i,r),g=De(c.last.point.x,c.last.point.y,i,r);if(n&&!s){const e=Ie(o.writingMode,f,g,h);if(e)return e}m=[c.first];for(let r=o.glyphStartIndex+1;r0?n.point:Ee(i.tileAnchorPoint,s,e,1,i),c=De(e.x,e.y,i,r),u=De(l.x,l.y,i,r),d=Ie(o.writingMode,c,u,h);if(d)return d}const e=ke(d*l.getoffsetX(o.glyphStartIndex),_,p,s,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[e];}for(const e of m)t.ao(c,e.point,e.angle);return {}}function Ee(e,t,i,r,o){const a=e.add(e.sub(t)._unit()),s=Re(a.x,a.y,o).point,n=i.sub(s);return i.add(n._mult(r/n.mag()))}function Se(e,i,r){const o=i.projectionCache;if(o.projections[e])return o.projections[e];const a=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Re(a.x,a.y,i);if(s.signedDistanceFromCamera>0)return o.projections[e]=s.point,o.anyProjectionOccluded=o.anyProjectionOccluded||s.isOccluded,s.point;const n=e-r.direction;return Ee(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),a,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Re(e,t,i){const r=e+i.translation[0],o=t+i.translation[1];let a;return i.pitchWithMap?(a=ye(r,o,i.pitchedLabelPlaneMatrix,i.getElevation),a.isOccluded=!1):(a=i.transform.projectTileCoordinates(r,o,i.unwrappedTileID,i.getElevation),a.point.x=(.5*a.point.x+.5)*i.width,a.point.y=(.5*-a.point.y+.5)*i.height),a}function De(e,i,r,o){if(r.pitchWithMap){const a=[e,i,0,1];return t.ap(a,a,o),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}return {x:e/r.width*2-1,y:i/r.height*2-1}}function ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ae(e,t,i){return e._unit()._perp()._mult(t*i)}function Le(e,i,r,o,a,s,n,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=r.add(i);if(e+c.direction=a)return l.projectionCache.offsets[e]=h,h;const u=Se(e+c.direction,l,c),d=Ae(u.sub(r),n,c.direction),_=r.add(d),p=u.add(d);return l.projectionCache.offsets[e]=t.aq(s,h,_,p)||h,l.projectionCache.offsets[e]}function ke(e,t,i,r,o,a,s,n,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,_=h>0?a+o:a+o+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=Re(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const b=Math.abs(c),y=[];let w;for(;v+x<=b;){if(_+=h,_=s)return null;v+=x,g=f,m=p;const e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:g};if(f=Se(_,n,e),0===i)y.push(g),w=f.sub(g);else {let t;const r=f.sub(g);t=0===r.mag()?Ae(Se(_+h,n,e).sub(f),i,h):Ae(r,i,h),m||(m=g.add(t)),p=Le(_,t,f,a,s,m,i,n,e),y.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((b-v)/x)._add(m||g),P=u+Math.atan2(f.y-g.y,f.x-g.x);return y.push(T),{point:T,angle:l?P:0,path:y}}const Fe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Be(e,t){for(let i=0;i=1;e--)_.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let f=[];if(_.length>0){const e=_[0].clone(),i=_[0].clone();for(let t=1;t<_.length;t++)e.x=Math.min(e.x,_[t].x),e.y=Math.min(e.y,_[t].y),i.x=Math.max(i.x,_[t].x),i.y=Math.max(i.y,_[t].y);f=e.x>=r.x&&i.x<=o.x&&e.y>=r.y&&i.y<=o.y?[_]:i.xo.x||i.yo.y?[]:t.ar([_],r.x,r.y,o.x,o.y);}for(const t of f){a.reset(t,.25*i);let r=0;r=a.length<=.5*i?1:Math.ceil(a.paddedLength/p)+1;for(let t=0;t{const t=ye(e.x,e.y,r,i.getElevation),o=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height,o}))}(e,i);return function(e){let t=0,i=0,r=0,o=0;for(let a=0;ai&&(i=o,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let r=1/0,o=1/0,a=-1/0,s=-1/0;for(const n of e){const e=new t.P(n.x+je,n.y+je);r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y),i.push(e);}const n=this.grid.query(r,o,a,s).concat(this.ignoredGrid.query(r,o,a,s)),l={},c={};for(const e of n){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const o=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.as(i,o)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex));}return c}insertCollisionBox(e,t,i,r,o,a){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,r,o,a){const s=i?this.ignoredGrid:this.grid,n={bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t};for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,o,c,u)));S=e.some((e=>!e.isOccluded)),E=e.map((e=>new t.P(e.x,e.y)));}else S=!0;return {box:t.au(E),allPointsOccluded:!S}}}class Ne{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Ge{constructor(e,t,i,r,o){this.text=new Ne(e?e.text:null,t,i,o),this.icon=new Ne(e?e.icon:null,t,r,o);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ue{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i;}}class Ve{constructor(e,t,i,r,o){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=o;}}class qe{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function We(e,i,r,o,a){const{horizontalAlign:s,verticalAlign:n}=t.aB(e);return new t.P(-(s-.5)*i+o[0]*a,-(n-.5)*r+o[1]*a)}class $e{constructor(e,t,i,r,o){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new Ze(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new qe(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,o){const a=r.getBucket(i),s=r.latestFeatureIndex;if(!a||!s||i.id!==a.layerIds[0])return;const n=r.collisionBoxArray,l=a.layers[0].layout,c=a.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.Z,d=r.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=t.aw(r,1,this.transform.zoom),m=t.ax(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),f=t.ax(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),g=ve(_,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new Ve(a.bucketInstanceId,s,a.sourceLayerIndex,a.index,r.tileID);const v={bucket:a,layout:l,translationText:m,translationIcon:f,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.ag(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(o)for(const t of a.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:v});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v});}attemptAnchorPlacement(e,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v,x,b){const y=t.ay[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=We(y,r,o,w,a),P=this.collisionIndex.placeCollisionBox(i,d,l,c,h,n,s,f,u.predicate,x,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,c,h,n,s,g,u.predicate,x,T,b).placeable)&&P.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID].text&&(e=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:w,width:r,height:o,anchor:y,textBoxScale:a,prevAnchor:e},this.markUsedJustification(p,y,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:T,placedGlyphBoxes:P}}}placeLayerBucketPart(e,i,r){const{bucket:o,layout:a,translationText:s,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=e.parameters,m=a.get("text-optional"),f=a.get("icon-optional"),g=t.az(a,"text-overlap","text-allow-overlap"),v="always"===g,x=t.az(a,"icon-overlap","icon-allow-overlap"),b="always"===x,y="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),T="none"!==a.get("icon-text-fit"),P="viewport-y"===a.get("symbol-z-order"),C=v&&(b||!o.hasIconData()||f),I=b&&(v||!o.hasTextData()||m);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d);const M=this.retainedQueryData[o.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(M),S=this.transform.getFastPathSimpleProjectionMatrix(M),R=(e,d,b)=>{var P,R;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new Ue(!1,!1,!1));let D=!1,z=!1,A=!0,L=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,j=null,Z=0,N=0,G=0;d.textFeatureIndex?Z=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(Z=e.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const U=d.textBox;if(U){const i=i=>{let r=t.ah.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(o,r,e));}return r},a=(i,r)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===t.ah.vertical?(k=r(),F=k):k=i(),k&&k.placeable)break}else k=i();},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,h,M,l,w,y,s,p.predicate,E,void 0,S);return r&&r.placeable&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),r};a((()=>r(U,t.ah.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.ah.vertical):{box:null,offscreen:null}})),i(k&&k.placeable);}else {let _=t.ay[null===(R=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[e.crossTileID])||void 0===R?void 0:R.anchor];const m=(t,i,a)=>{const d=t.x2-t.x1,m=t.y2-t.y1,f=e.textBoxScale,v=T&&"never"===x?i:null;let b=null,P="never"===g?1:2,C="never";_&&P++;for(let i=0;im(U,d.iconBox,t.ah.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ah.vertical):{box:null,occluded:!0,offscreen:null}})),k&&(D=k.placeable,A=k.offscreen);const f=i(k&&k.placeable);if(!D&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,f));}}}if(B=k,D=B&&B.placeable,A=B&&B.offscreen,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),n=t.ai(o.textSizeData,_,i),h=a.get("text-padding");O=this.collisionIndex.placeCollisionCircles(g,i,o.lineVertexArray,o.glyphOffsetArray,n,l,c,r,w,p.predicate,e.collisionCircleDiameter,h,s,E),O.circles.length&&O.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),D=v||O.circles.length>0&&!O.collisionDetected,A=A&&O.offscreen;}if(d.iconFeatureIndex&&(G=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,M,l,w,y,n,p.predicate,E,T&&L?L:void 0,S);F&&F.placeable&&d.verticalIconBox?(j=e(d.verticalIconBox),z=j.placeable):(j=e(d.iconBox),z=j.placeable),A=A&&j.offscreen;}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,q=f||0===e.numIconVertices;V||q?q?V||(z=z&&D):D=z&&D:z=D=z&&D;const W=z&&j.placeable;if(D&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,a.get("text-ignore-placement"),o.bucketInstanceId,F&&F.placeable&&N?N:Z,p.ID),W&&this.collisionIndex.insertCollisionBox(j.box,x,a.get("icon-ignore-placement"),o.bucketInstanceId,G,p.ID),O&&D&&this.collisionIndex.insertCollisionCircles(O.circles,g,a.get("text-ignore-placement"),o.bucketInstanceId,Z,p.ID),r&&this.storeCollisionData(o.bucketInstanceId,b,d,B,j,O),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===o.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Ue((D||C)&&!(null==B?void 0:B.occluded),(z||I)&&!(null==j?void 0:j.occluded),A||o.justReloaded),i[e.crossTileID]=!0;};if(P){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=o.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];R(o.symbolInstances.get(i),o.collisionArrays[i],i);}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID);}markUsedOrientation(e,i,r){const o=i===t.ah.horizontal||i===t.ah.horizontalOnly?i:0,a=i===t.ah.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,o=t?t.opacities:{},a=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],a=o[e];a?(this.opacities[e]=new Ge(a,r,t.text,t.icon),i=i||t.text!==a.text.placed||t.icon!==a.icon.placed):(this.opacities[e]=new Ge(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon);}for(const e in o){const t=o[e];if(!this.opacities[e]){const o=new Ge(t,r,!1,!1);o.isHidden()||(this.opacities[e]=o,i=i||t.text.placed||t.icon.placed);}}for(const e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray);}}updateBucketOpacities(e,i,r,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const a=e.layers[0],s=a.layout,n=new Ge(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),_="none"!==s.get("icon-text-fit"),p=new Ge(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const m=(e,t,i)=>{for(let r=0;r0,v=this.placedOrientations[o.crossTileID],x=v===t.ah.vertical,b=v===t.ah.horizontal||v===t.ah.horizontalOnly;if(a>0||s>0){const t=it(c.text);m(e.text,a,x?rt:t),m(e.text,s,b?rt:t);const i=c.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||x?1:0);})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||b?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o));}if(g){const t=it(c.icon),i=!(_&&o.verticalPlacedIconSymbolIndex&&x);o.placedIconSymbolIndex>=0&&(m(e.icon,o.numIconVertices,i?t:rt),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=c.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,o.numVerticalIconVertices,i?rt:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden());}const y=f&&f.has(i)?f.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const r=e.collisionArrays[i];if(r){let i=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(i=We(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1;}if(r.textBox||r.verticalTextBox){let o;r.textBox&&(o=x),r.verticalTextBox&&(o=b),He(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||o,y.text,i.x,i.y);}}if(r.iconBox||r.verticalIconBox){const t=Boolean(!b&&r.verticalIconBox);let o;r.iconBox&&(o=t),r.verticalIconBox&&(o=!t),He(e.iconCollisionBox.collisionVertexArray,c.icon.placed,o,y.icon,_?i.x:0,_?i.y:0);}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId]);}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function He(e,t,i,r,o,a){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-je,n=r[1]-je,l=r[2]-je,c=r[3]-je;e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,c),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,c);}const Ke=Math.pow(2,25),Xe=Math.pow(2,24),Qe=Math.pow(2,17),Ye=Math.pow(2,16),Je=Math.pow(2,9),et=Math.pow(2,8),tt=Math.pow(2,1);function it(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Ke+t*Xe+i*Qe+t*Ye+i*Je+t*et+i*tt+t}const rt=0;class ot{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,r,o){const a=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex!this._forceFullPlacement&&s.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=a)&&(!r.maxzoom||r.maxzoom>a)){if(this._inProgressLayer||(this._inProgressLayer=new ot(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const st=512/t.Z/2;class nt{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const o=new Map;for(let e=0;e({x:Math.floor(e.anchorX*st),y:Math.floor(e.anchorY*st)}))),crossTileIDs:i.map((e=>e.crossTileID))};if(r.positions.length>128){const e=new t.aC(r.positions.length,16,Uint16Array);for(const{x:t,y:i}of r.positions)e.add(t,i);e.finish(),delete r.positions,r.index=e;}this._symbolsByKey[e]=r;}}getScaledCoordinates(e,i){const{x:r,y:o,z:a}=this.tileID.canonical,{x:s,y:n,z:l}=i.canonical,c=st/Math.pow(2,l-a),h=(n*t.Z+e.anchorY)*c,u=o*t.Z*st;return {x:Math.floor((s*t.Z+e.anchorX)*c-r*t.Z*st),y:Math.floor(h-u)}}findMatches(e,t,i){const r=this.tileID.canonical.ze))}}class lt{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class ct{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const o=i[e];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),r[o.tileID.key]=o;}this.indexes[e]=r;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in o){const a=o[i];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,r);}else {const a=o[e.scaledTo(Number(i)).key];a&&a.findMatches(t.symbolInstances,e,r);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var ut="void main() {fragColor=vec4(1.0);}";const dt={prelude:_t("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:_t("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:_t("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:_t("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:_t("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:_t("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:_t(ut,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:_t("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:_t("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:_t("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:_t("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:_t("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:_t(ut,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:_t("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:_t("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:_t("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:_t("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:_t("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));fragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:_t("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:_t("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:_t("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:_t("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:_t("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:_t("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:_t("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:_t("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:_t("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:_t("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:_t("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:_t("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:_t("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:_t("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:_t("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function _t(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=a?a.concat(o):o,n={};return {fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\nout ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,staticUniforms:s}}class pt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}var mt=t.aD([{name:"a_pos",type:"Int16",components:2}]);const ft="#define PROJECTION_MERCATOR",gt="mercator";class vt{constructor(){this._cachedMesh=null;}get name(){return "mercator"}get useSubdivision(){return !1}get shaderVariantName(){return gt}get shaderDefine(){return ft}get shaderPreludeCode(){return dt.projectionMercator}get vertexShaderPreludeCode(){return dt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aE.noSubdivision}get useGlobeControls(){return !1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,o,a){if(this._cachedMesh)return this._cachedMesh;const s=new t.aF;s.emplaceBack(0,0),s.emplaceBack(t.Z,0),s.emplaceBack(0,t.Z),s.emplaceBack(t.Z,t.Z);const n=e.createVertexBuffer(s,mt.members),l=t.aG.simpleSegment(0,0,4,2),c=new t.aH;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new pt(n,h,l),this._cachedMesh}recalculate(){}hasTransition(){return !1}setErrorQueryLatitudeDegrees(e){}}function xt(e,i){const r=t.ae(i.lat,-85.051129,t.aJ);return new t.P(t.U(i.lng)*e,t.S(r)*e)}function bt(e,i){return new t.$(i.x/e,i.y/e).toLngLat()}function yt(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.ad(90-e.pitch)),Math.tan(t.ad(89.25-e.pitch)))}function wt(e,i){const r=e.canonical,o=i/t.aI(r.z),a=r.x+Math.pow(2,r.z)*e.wrap,s=t.at(new Float64Array(16));return t.L(s,s,[a*o,r.y*o,0]),t.M(s,s,[o/t.Z,o/t.Z,1]),s}function Tt(e,i,r,o,a){const s=t.$.fromLngLat(e,i),n=a*t.aK(1,e.lat),l=n*Math.cos(t.ad(r)),c=Math.sqrt(n*n-l*l),h=c*Math.sin(t.ad(-o)),u=c*Math.cos(t.ad(-o));return new t.$(s.x+h,s.y+u,s.z+l)}class Pt{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r;}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.B.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.B.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.B.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.B.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.ae((this.left+e-this.right)/2,0,e),o=t.ae((this.top+i-this.bottom)/2,0,i);return new t.P(r,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Pt(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ct(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0;}function It(e){return Math.max(0,Math.floor(e))}class Mt{constructor(e,i,r,o,a,s){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==o?0:o,this._maxPitch=null==a?60:a,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.Q(0,0),this._elevation=0,this._zoom=0,this._tileZoom=It(this._zoom),this._scale=t.aI(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Pt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0;}apply(e,i,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=It(this._zoom),this._scale=t.aI(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Pt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices();}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e;}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)));}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)));}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aL(e,-180,180)*Math.PI/180;var o,a,s,n,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),o=this._rotationMatrix,s=-this._bearingInRadians,n=(a=this._rotationMatrix)[0],l=a[1],c=a[2],h=a[3],u=Math.sin(s),d=Math.cos(s),o[0]=n*d+c*u,o[1]=l*d+h*u,o[2]=n*-u+c*d,o[3]=l*-u+h*d);}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ae(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices());}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices());}get fovInRadians(){return this._fovInRadians}get fov(){return t.aM(this._fovInRadians)}setFov(e){e=t.ae(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ad(e),this._calcMatrices());}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.aI(i),this._constrain(),this._calcMatrices());}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices();}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices();}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices();}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new V([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-85.051129,t.aJ]);}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return [i[0],e];{let r=e.x,o=e.y,a=e.x,s=e.y;for(const e of i)r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y);return [new t.P(r,o),new t.P(a,o),new t.P(a,s),new t.P(r,s),new t.P(r,o)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1;}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.at(new Float64Array(16));t.M(e,e,[this._width/2,-this._height/2,1]),t.L(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.at(new Float64Array(16)),t.M(e,e,[1,-1,1]),t.L(e,e,[-1,-1,0]),t.M(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height;}this._callbacks.calcMatrices();}calculateCenterFromCameraLngLatAlt(e,i,r,o){const a=void 0!==r?r:this.bearing,s=o=void 0!==o?o:this.pitch,n=t.$.fromLngLat(e,i),l=-Math.cos(t.ad(s)),c=Math.sin(t.ad(s)),h=c*Math.sin(t.ad(a)),u=-c*Math.cos(t.ad(a));let d=this.elevation;const _=i-d;let p;l*_>=0||Math.abs(l)<.1?(p=1e4,d=i+p*l):p=-_/l;let m,f,g=t.aN(1,n.y),v=0;do{if(v+=1,v>10)break;f=p/g,m=new t.$(n.x+h*f,n.y+u*f),g=1/m.meterInMercatorCoordinateUnits();}while(Math.abs(p-f*g)>1e-12);return {center:m.toLngLat(),elevation:d,zoom:t.ab(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.aK(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,o=t.$.fromLngLat(this.center,this.elevation),a=Tt(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(a.toLngLat(),t.aN(a.z,o.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom);}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.aK(1,this.center.lat)*this.worldSize;return Tt(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return [0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class St{distanceToTile2d(e,t,i,r){const o=r.distanceX([e,t]),a=r.distanceY([e,t]);return Math.hypot(o,a)}getWrap(e,t,i){return i}getTileAABB(e,i,r,o){var a,s;let n=r,l=r;if(o.terrain){const c=new t.Y(e.z,i,e.z,e.x,e.y),h=o.terrain.getMinMaxElevation(c);n=null!==(a=h.minElevation)&&void 0!==a?a:r,l=null!==(s=h.maxElevation)&&void 0!==s?s:r;}const c=1<o}allowWorldCopies(){return !0}recalculateCache(){}}class Rt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i;}static fromInvProjectionMatrix(e,i=1,r=0){const o=Math.pow(2,r),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const a=1/(r=t.ap([],r,e))[3]/i*o;return t.aR(r,r,[a,a,1/r[3],a])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.aS([],a[e[0]],a[e[1]]),r=t.aS([],a[e[2]],a[e[1]]),o=t.aT([],t.aU([],i,r)),s=-t.aV(o,a[e[1]]);return o.concat(s)})),n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of a)for(let t=0;t<3;t++)n[t]=Math.min(n[t],e[t]),l[t]=Math.max(l[t],e[t]);return new Rt(a,s,new Et(n,l))}}class Dt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,r,o){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Mt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,r,o),this._coveringTilesDetailsProvider=new St;}clone(){const e=new Dt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i);}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.aW(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),n=Math.floor(Math.min(r.x,o.x,a.x,s.x)),l=Math.floor(Math.max(r.x,o.x,a.x,s.x)),c=1;for(let r=n-c;r<=l+c;r++)0!==r&&i.push(new t.aW(r,e));}return i}getCameraFrustum(){return Rt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i);}setLocationAtPoint(e,i){const r=t.aK(this.elevation,this.center.lat),o=this.screenPointToMercatorCoordinateAtZ(i,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),s=t.$.fromLngLat(e),n=new t.$(s.x-(o.x-a.x),s.y-(o.y-a.y));this.setCenter(null==n?void 0:n.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap());}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.$.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.$.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,o=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.ap(o,o,this._pixelMatrixInverse),t.ap(a,a,this._pixelMatrixInverse);const s=o[3],n=a[3],l=o[1]/s,c=a[1]/n,h=o[2]/s,u=a[2]/n,d=h===u?0:(r-h)/(u-h);return new t.$(t.B.number(o[0]/s,a[0]/n,d)/this.worldSize,t.B.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.ap(o,o,r),new t.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this._helper._height/2-yt(this));return (new V).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-yt(this)}calculatePosMatrix(e,i=!1,r){var o;const a=null!==(o=e.key)&&void 0!==o?o:t.aX(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(a)){const e=s.get(a);return r?e.f32:e.f64}const n=wt(e,this.worldSize);t.N(n,i?this._alignedProjMatrix:this._viewProjMatrix,n);const l={f64:n,f32:new Float32Array(n)};return s.set(a,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const o=wt(e,this.worldSize);return t.N(o,this._fogMatrix,o),r.set(i,new Float32Array(o)),r.get(i)}getConstrained(e,i){i=t.ae(+i,this.minZoom,this.maxZoom);const r={center:new t.Q(e.lng,e.lat),zoom:i};let o=this._helper._lngRange;this._helper._renderWorldCopies||null!==o||(o=[-179.9999999999,180-1e-10]);const a=this.tileSize*t.aI(r.zoom);let s=0,n=a,l=0,c=a,h=0,u=0;const{x:d,y:_}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.S(e[1])*a,n=t.S(e[0])*a,n-s<_&&(h=_/(n-s));}o&&(l=t.aL(t.U(o[0])*a,0,a),c=t.aL(t.U(o[1])*a,0,a),cn&&(g=n-e);}if(o){const e=(l+c)/2;let i=p;this._helper._renderWorldCopies&&(i=t.aL(p,e-a/2,e+a/2));const r=d/2;i-rc&&(f=c-r);}if(void 0!==f||void 0!==g){const e=new t.P(null!=f?f:p,null!=g?g:m);r.center=bt(a,e).wrap();}return r}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const o=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-o*this._helper._pixelPerMeter/Math.cos(i),s=o<0?a:e,n=Math.PI/2+this.pitchInRadians,l=t.ad(this.fov)*(Math.abs(Math.cos(t.ad(this.roll)))*this.height+Math.abs(Math.sin(t.ad(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*s/Math.sin(t.ae(Math.PI-n-l,.01,Math.PI-.01)),h=yt(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.ad(.75),_=u>d?2*u*(.5+r.y/(2*h)):d,p=Math.sin(_)*s/Math.sin(t.ae(Math.PI-n-_,.01,Math.PI-.01)),m=Math.min(c,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50;}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=xt(this.worldSize,this.center),r=i.x,o=i.y;this._helper._pixelPerMeter=t.aK(1,this.center.lat)*this.worldSize;const a=t.ad(Math.min(this.pitch,89.25)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a));let n;this._calculateNearFarZIfNeeded(s,a,e),n=new Float64Array(16),t.aY(n,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.aj(this._invProjMatrix,n),n[8]=2*-e.x/this._helper._width,n[9]=2*e.y/this._helper._height,this._projectionMatrix=t.aZ(n),t.M(n,n,[1,-1,1]),t.L(n,n,[0,0,-this._helper.cameraToCenterDistance]),t.a_(n,n,-this.rollInRadians),t.a$(n,n,this.pitchInRadians),t.a_(n,n,-this.bearingInRadians),t.L(n,n,[-r,-o,0]),this._mercatorMatrix=t.M([],n,[this.worldSize,this.worldSize,this.worldSize]),t.M(n,n,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n),t.L(n,n,[0,0,-this.elevation]),this._viewProjMatrix=n,this._invViewProjMatrix=t.aj([],n);const l=[0,0,-1,1];t.ap(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.aY(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.M(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.a_(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.a$(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.a_(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.L(this._fogMatrix,this._fogMatrix,[-r,-o,0]),t.M(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),_=r-Math.round(r)+u*c+d*h,p=o-Math.round(o)+u*h+d*c,m=new Float64Array(n);if(t.L(m,m,[_>.5?_-1:_,p>.5?p-1:p,0]),this._alignedProjMatrix=m,n=t.aj(new Float64Array(16),this._pixelMatrix),!n)throw new Error("failed to invert matrix");this._pixelMatrixInverse=n,this._clearMatrixCaches();}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear();}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.ap(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.aK(1,this.center.lat)*this.worldSize;return Tt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.$.fromLngLat(e),o=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.ap(o,o,this._viewProjMatrix),o[2]/o[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:o}=e,a=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;let n;return n=i&&i.terrainRttPosMatrix32f&&o?i.terrainRttPosMatrix32f:s||t.b0(),{mainMatrix:n,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n}}isLocationOccluded(e){return !1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aQ(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,o){const a=this.calculatePosMatrix(r);let s;o?(s=[e,i,o(e,i),1],t.ap(s,s,a)):(s=[e,i,0,1],Oe(s,s,a));const n=s[3];return {point:new t.P(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t);}getMatrixForModel(e,i){const r=t.$.fromLngLat(e,i),o=r.meterInMercatorCoordinateUnits(),a=t.b1();return t.L(a,a,[r.x,r.y,r.z]),t.a_(a,a,Math.PI),t.a$(a,a,Math.PI/2),t.M(a,a,[-o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=new t.Y(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),o=wt(i,this.worldSize);t.N(o,this._viewProjMatrix,o),r.tileMercatorCoords=[0,0,1,1];const a=[t.Z,t.Z,this.worldSize/this._helper.pixelsPerMeter],s=t.b2();return t.M(s,o,a),r.fallbackMatrix=s,r.mainMatrix=s,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function zt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");}function At(e){if(e.useSlerp)if(e.k<1){const i=t.b3(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.b3(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),o=new Float64Array(4);t.b4(o,i,r,e.k);const a=t.b5(o);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing);}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.B.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.B.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.B.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k));}function Lt(e,i,r,o,a){const s=a.padding,n=xt(a.worldSize,r.getNorthWest()),l=xt(a.worldSize,r.getNorthEast()),c=xt(a.worldSize,r.getSouthEast()),h=xt(a.worldSize,r.getSouthWest()),u=t.ad(-o),d=n.rotate(u),_=l.rotate(u),p=c.rotate(u),m=h.rotate(u),f=new t.P(Math.max(d.x,_.x,m.x,p.x),Math.max(d.y,_.y,m.y,p.y)),g=new t.P(Math.min(d.x,_.x,m.x,p.x),Math.min(d.y,_.y,m.y,p.y)),v=f.sub(g),x=(a.width-(s.left+s.right+i.left+i.right))/v.x,b=(a.height-(s.top+s.bottom+i.top+i.bottom))/v.y;if(b<0||x<0)return void zt();const y=Math.min(t.ab(a.scale*Math.min(x,b)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ad(o)),P=w.add(T).mult(a.scale/t.aI(y));return {center:bt(a.worldSize,n.add(c).div(2).sub(P)),zoom:y,bearing:o}}class kt{get useGlobeControls(){return !1}handlePanInertia(e,t){return {easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around);}cameraForBoxAndBearing(e,t,i,r,o){return Lt(e,t,i,r,o)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.Q.convert(i.center));}handleEaseTo(e,i){const r=e.zoom,o=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},n=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=n?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:_,zoom:p}=e.getConstrained(t.Q.convert(i.center||d),null!=h?h:r);Ct(e,_);const m=xt(e.worldSize,d),f=xt(e.worldSize,_).sub(m),g=t.aI(p-r);return c=p!==r,{easeFunc:n=>{if(c&&e.setZoom(t.B.number(r,p,n)),t.b6(a,s)||At({startEulerAngles:a,endEulerAngles:s,tr:e,k:n,useSlerp:a.roll!=s.roll}),l&&(e.interpolatePadding(o,i.padding,n),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else {const i=t.aI(e.zoom-r),o=p>r?Math.min(2,g):Math.max(.5,g),a=Math.pow(o,1-n),s=bt(e.worldSize,m.add(f.mult(n*a)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,u);}},isZooming:c,elevationCenter:_}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.zoom,a=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),r?+i.zoom:o),s=a.center,n=a.zoom;Ct(e,s);const l=xt(e.worldSize,i.locationAtOffset),c=xt(e.worldSize,s).sub(l),h=c.mag(),u=t.aI(n-o);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,o,n),a=e.getConstrained(s,r).zoom;d=t.aI(a-o);}return {easeFunc:(i,r,a,h)=>{e.setZoom(1===i?n:o+t.ab(r));const u=1===i?s:bt(e.worldSize,l.add(c.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h);},scaleOfZoom:u,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:h}}}class Ft{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i;}}Ft.Replace=[1,0],Ft.disabled=new Ft(Ft.Replace,t.b7.transparent,[!1,!1,!1,!1]),Ft.unblended=new Ft(Ft.Replace,t.b7.transparent,[!0,!0,!0,!0]),Ft.alphaBlended=new Ft([1,771],t.b7.transparent,[!0,!0,!0,!0]);const Bt=2305;class Ot{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Ot.disabled=new Ot(!1,1029,Bt),Ot.backCCW=new Ot(!0,1029,Bt),Ot.frontCCW=new Ot(!0,1028,Bt);class jt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}jt.ReadOnly=!1,jt.ReadWrite=!0,jt.disabled=new jt(519,jt.ReadOnly,[0,1]);const Zt=7680;class Nt{constructor(e,t,i,r,o,a){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=o,this.pass=a;}}Nt.disabled=new Nt({func:519,mask:0},0,0,Zt,Zt,Zt);const Gt=new WeakMap;function Ut(e){var t;if(Gt.has(e))return Gt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Gt.set(e,i),i}}class Vt{get awaitingQuery(){return !!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const o=new t.aF;o.emplaceBack(-1,-1),o.emplaceBack(2,-1),o.emplaceBack(-1,2);const a=new t.aH;a.emplaceBack(0,1,2),this._fullscreenTriangle=new pt(i.createVertexBuffer(o,mt.members),i.createIndexBuffer(a),t.aG.simpleSegment(0,0,o.length,a.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Ut(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null));}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null;}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer);}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,o=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.b7.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,o.TRIANGLES,jt.disabled,Nt.disabled,Ft.unblended,Ot.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Ut(o)){o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.readBuffer(o.COLOR_ATTACHMENT0),o.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const e=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);o.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e};}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null};}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Ut(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Vt._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount;}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const qt=t.Z/128;function Wt(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,o=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=o+1,n=a+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=r+(e.generateBorders?1:0),u=r+(e.generateBorders||e.extendToSouthPole?1:0),d=s*n,_=o*a*6,p=s*n>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,f=new Int16Array(2*d);let g=0;for(let i=c;i<=u;i++)for(let o=l;o<=h;o++){let a=o/r*t.Z;-1===o&&(a=-64),o===r+1&&(a=t.Z+qt);let s=i/r*t.Z;-1===i&&(s=e.extendToNorthPole?t.b9:-64),i===r+1&&(s=e.extendToSouthPole?t.ba:t.Z+qt),f[g++]=a,f[g++]=s;}const v=m?new Uint32Array(_):new Uint16Array(_);let x=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return "globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy();}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e);}getMeshFromTileID(e,t,i,r,o){return this.currentProjection.getMeshFromTileID(e,t,i,r,o)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator");}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e);}}function Qt(e){const t=ei(e.worldSize,e.center.lat);return 2*Math.PI*t}function Yt(e,i,r,o,a){const s=1/(1<1e-6){const o=e[0]/r,a=Math.acos(e[2]/r),s=(o>0?a:-a)/Math.PI*180;return new t.Q(t.aL(s,-180,180),i)}return new t.Q(0,i)}function ii(e){return Math.cos(e*Math.PI/180)}function ri(e,i){const r=ii(e),o=ii(i);return t.ab(o/r)}function oi(e,i){const r=e.rotate(i.bearingInRadians),o=i.zoom+ri(i.center.lat,0),a=t.bc(1/ii(i.center.lat),1/ii(Math.min(Math.abs(i.center.lat),60)),t.bf(o,7,3,0,1)),s=360/Qt({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.Q(i.center.lng-r.x*s*a,t.ae(i.center.lat+r.y*s,-85.051129,t.aJ))}function ai(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function si(e,i,r,o){const a=e.lat+r*o;if(Math.abs(r)>1){const s=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,n=Math.abs(e.lat+r)*Math.PI/180,l=ai(s+o*(n-s)),c=ai(s),h=ai(n);return new t.Q(e.lng+i*((l-c)/(h-c)),a)}return new t.Q(e.lng+i*o,a)}class ni{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=e;}recalculateCache(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1;}getTileAABB(e,t,i,r){const o=`${e.z}_${e.x}_${e.y}`,a=this._cache.get(o);if(a)return a;const s=this._cachePrevious.get(o);if(s)return this._cache.set(o,s),s;const n=this._aabbFactory(e,t,i,r);return this._cache.set(o,n),this._hadAnyChanges=!0,n}}function li(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function ci(e,t,i,r,o){const a=e-i;let s;return s=a<0?Math.min(-a,1+a-o):a>1?Math.min(Math.max(a-o,0),1-a):0,Math.max(s,li(t,r,o))}class hi{constructor(){this._aabbCache=new ni(this._computeTileAABB);}recalculateCache(){this._aabbCache.recalculateCache();}distanceToTile2d(e,t,i,r){const o=1<4}allowWorldCopies(){return !1}getTileAABB(e,t,i,r){return this._aabbCache.getTileAABB(e,t,i,r)}_computeTileAABB(e,i,r,o){if(e.z<=0)return new Et([-1,-1,-1],[1,1,1]);if(1===e.z)return new Et([0===e.x?-1:0,0===e.y?0:-1,-1],[0===e.x?0:1,0===e.y?1:0,1]);{const i=[Yt(0,0,e.x,e.y,e.z),Yt(t.Z,0,e.x,e.y,e.z),Yt(t.Z,t.Z,e.x,e.y,e.z),Yt(0,t.Z,e.x,e.y,e.z)],r=[1,1,1],o=[-1,-1,-1];for(const e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);if(0===e.y||e.y===(1<{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new hi;}clone(){const e=new ui;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e);}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bi();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return {mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,o=Math.sin(i)*r,a=Math.cos(i)*r+1,s=1/Math.sqrt(o*o+a*a)*1;let n=-o,l=a;const c=Math.sqrt(n*n+l*l);n/=c,l/=c;const h=[0,n,l];return t.bj(h,h,[0,0,0],-this.bearingInRadians),t.bk(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bl(h,h,[0,0,0],this.center.lng*Math.PI/180),t.aO(h,h,.25),[...h,.25*-s]}isLocationOccluded(e){return !this.isSurfacePointVisible(Jt(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,o=Math.cos(r),a=[Math.sin(i)*o,Math.sin(r),Math.cos(i)*o],s=[a[2],0,-a[0]],n=[0,0,0];t.aU(n,s,a),t.aT(s,s),t.aT(n,n);const l=[0,0,0];return t.aT(l,[s[0]*e[0]+n[0]*e[1]+a[0]*e[2],s[1]*e[0]+n[1]*e[1]+a[1]*e[2],s[2]*e[0]+n[2]*e[1]+a[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const o=function(e,i,r){const o=1/(1<a&&(a=i),rn&&(n=r);}const h=[c.lng+s,c.lat+l,c.lng+a,c.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new V(h)}getConstrained(e,i){const r=t.ae(e.lat,-85.051129,t.aJ),o=t.ae(+i,this.minZoom+ri(0,r),this.maxZoom);return {center:new t.Q(e.lng,r),zoom:o}}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=Jt(this.unprojectScreenPoint(i)),o=Jt(e),a=t.bi();t.bo(a);const s=t.bi();t.bl(s,r,a,-this.center.lng*Math.PI/180),t.bk(s,s,a,this.center.lat*Math.PI/180);const n=o[0]*o[0]+o[2]*o[2],l=s[0]*s[0];if(n=-g&&p<=g,x=f>=-g&&f<=g;let b,y;if(v&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bs(u,e)+t.bs(p,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return !1;const i=t.bh();return t.ap(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.aV(e,i),o=t.bi(),a=t.bi();t.aO(a,i,r),t.aS(o,e,a);const s=1-t.aV(o,o);if(s<0)return null;const n=t.aV(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(s),c=n/l,h=l;return {tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),o=this.rayPlanetIntersection(i,r);if(o){const e=t.bi();t.aP(e,i,[r[0]*o.tMin,r[1]*o.tMin,r[2]*o.tMin]);const a=t.bi();return t.aT(a,e),ti(a)}const a=this._cachedClippingPlane[0]*r[0]+this._cachedClippingPlane[1]*r[1]+this._cachedClippingPlane[2]*r[2],s=-t.bq(this._cachedClippingPlane,i)/a,n=t.bi();if(s>0)t.aP(n,i,[r[0]*s,r[1]*s,r[2]*s]);else {const e=t.bi();t.aP(e,i,[2*r[0],2*r[1],2*r[2]]);const o=t.bq(this._cachedClippingPlane,e);t.aS(n,e,[this._cachedClippingPlane[0]*o,this._cachedClippingPlane[1]*o,this._cachedClippingPlane[2]*o]);}const l=t.bi();return t.aT(l,n),ti(l)}getMatrixForModel(e,i){const r=t.Q.convert(e),o=1/t.br,a=t.b1();return t.bm(a,a,r.lng/180*Math.PI),t.a$(a,a,-r.lat/180*Math.PI),t.L(a,a,[0,0,1+i/t.br]),t.a$(a,a,.5*Math.PI),t.M(a,a,[o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.Y(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class di{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache();}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Mt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Dt,this._verticalPerspectiveTransform=new ui;}clone(){const e=new di;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians);}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return {mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bc(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bc(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const o=this._mercatorTransform.getPitchedTextCorrection(e,i,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.bc(o,a,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ);}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e);}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e);}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform);}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class _i{get useGlobeControls(){return !0}handlePanInertia(e,i){const r=oi(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,o=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const a=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-a;if(0===s)return;const n=t.bn(i.center.lng,o.lng),l=n/(Math.abs(n/180)+1),c=t.bn(i.center.lat,o.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*t.aV(u,h),_=t.bi();t.aP(_,u,[h[0]*d,h[1]*d,h[2]*d]);const p=t.bt(_)-1,m=Math.exp(.5*-Math.max(p-.3,0)),f=ei(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=t.bf(f,.9,.5,1,.25),v=(1-t.aI(-s))*Math.min(m,g),x=i.center.lat,b=i.zoom,y=new t.Q(i.center.lng+l*v,t.ae(i.center.lat+c*v,-85.051129,t.aJ));i.setLocationAtPoint(o,r);const w=i.center,T=t.bf(Math.abs(n),45,85,0,1),P=t.bf(f,.75,.35,0,1),C=Math.pow(Math.max(T,P),.25),I=t.bn(w.lng,y.lng),M=t.bn(w.lat,y.lat);i.setCenter(new t.Q(w.lng+I*C,w.lat+M*C).wrap()),i.setZoom(b+ri(x,i.center.lat));}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,o=t.zoom;t.setCenter(oi(e.panDelta,t).wrap()),t.setZoom(o+ri(r,t.center.lat));}cameraForBoxAndBearing(e,i,r,o,a){const s=Lt(e,i,r,o,a),n=i.left/a.width*2-1,l=(a.width-i.right)/a.width*2-1,c=i.top/a.height*-2+1,h=(a.height-i.bottom)/a.height*-2+1,u=t.bn(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),_=u?r.getWest():r.getEast(),p=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),f=d+.5*t.bn(d,_),g=p+.5*t.bn(p,m),v=a.clone();v.setCenter(s.center),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);const x=v.modelViewProjectionMatrix,b=[Jt(r.getNorthWest()),Jt(r.getNorthEast()),Jt(r.getSouthWest()),Jt(r.getSouthEast()),Jt(new t.Q(_,g)),Jt(new t.Q(d,g)),Jt(new t.Q(f,p)),Jt(new t.Q(f,m))],y=Jt(s.center);let w=Number.POSITIVE_INFINITY;for(const e of b)n<0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"x",n))),l>0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"x",l))),c>0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"y",c))),h<0&&(w=_i.getLesserNonNegativeNonNull(w,_i.solveVectorScale(e,y,x,"y",h)));if(Number.isFinite(w)&&0!==w)return s.zoom=v.zoom+t.ab(w),s;zt();}handleJumpToCenterZoom(e,i){const r=e.center.lat,o=e.getConstrained(i.center?t.Q.convert(i.center):e.center,e.zoom).center;e.setCenter(o.wrap());const a=void 0!==i.zoom?+i.zoom:e.zoom+ri(r,o.lat);e.zoom!==a&&e.setZoom(a);}handleEaseTo(e,i){const r=e.zoom,o=e.center,a=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.Q.convert(i.center):o,d=e.getConstrained(u,r).center;Ct(e,d);const _=e.clone();_.setCenter(d),_.setZoom(l?+i.zoom:r+ri(o.lat,u.lat)),_.setBearing(i.bearing);const p=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));_.setLocationAtPoint(d,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,f=l?+i.zoom:r+ri(o.lat,m.lat),g=r+ri(o.lat,0),v=f+ri(m.lat,0),x=t.bn(o.lng,m.lng),b=t.bn(o.lat,m.lat),y=t.aI(v-g);return h=f!==r,{easeFunc:r=>{if(t.b6(s,n)||At({startEulerAngles:s,endEulerAngles:n,tr:e,k:r,useSlerp:s.roll!=n.roll}),c&&e.interpolatePadding(a,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else {const t=v>g?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-r),a=si(o,x,b,r*i);e.setCenter(a.wrap());}if(h){const i=t.B.number(g,v,r)+ri(0,e.center.lat);e.setZoom(i);}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.center,a=e.zoom,s=e.padding,n=!e.isPaddingEqual(i.padding),l=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),a).center,c=r?+i.zoom:e.zoom+ri(e.center.lat,l.lat),h=e.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(l,u);const d=h.center;Ct(e,d);const _=function(e,i,r){const o=Jt(i),a=Jt(r),s=t.aV(o,a),n=Math.acos(s),l=Qt(e);return n/(2*Math.PI)*l}(e,o,d),p=a+ri(o.lat,0),m=c+ri(d.lat,0),f=t.aI(m-p);let g;if("number"==typeof i.minZoom){const r=+i.minZoom+ri(d.lat,0),o=Math.min(r,p,m)+ri(0,d.lat),a=e.getConstrained(d,o).zoom+ri(d.lat,0);g=t.aI(a-p);}const v=t.bn(o.lng,d.lng),x=t.bn(o.lat,d.lat);return {easeFunc:(r,a,l,h)=>{const u=si(o,v,x,l);n&&e.interpolatePadding(s,i.padding,r);const _=1===r?d:u;e.setCenter(_.wrap());const m=p+t.ab(a);e.setZoom(1===r?c:m+ri(0,_.lat));},scaleOfZoom:f,targetCenter:d,scaleOfMinZoom:g,pixelPathLength:_}}static solveVectorScale(e,t,i,r,o){const a="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],n=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],h=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+o*l===n+o*h||s[3]*(n-c)+a[3]*(h-l)+n*h==c*l?null:(c+a[3]-o*h-o*s[3])/(c-n-o*h+o*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.x(e,i&&i.filter((e=>"source.canvas"!==e.identifier))),fi=t.bu();class gi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload();}},this.map=e,this.dispatcher=new B(F(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler("GI",((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new P(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new R(256,512),this.crossTileSymbolIndex=new ht,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bv,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",t.bw()),oe().on(te,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t);}}));}loadURL(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const a=this._loadStyleRequest;t.j(o,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,i,r);})).catch((e=>{this._loadStyleRequest=null,e&&!a.signal.aborted&&this.fire(new t.k(e));}));}loadJSON(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r);})).catch((()=>{}));}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(fi,{validate:!1});}_load(e,i,r){var o,a;const s=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!mi(this,t.y(s))){this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new M(this.stylesheet.light),this._setProjectionInternal((null===(o=this.stylesheet.projection)||void 0===o?void 0:o.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(a=this.stylesheet.terrain)&&void 0!==a?a:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"));}}_createLayers(){const e=t.bx(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.by(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e;}}_loadSprite(e,i=!1,r=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=f(e),n=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of a){const a=i.transformRequest(g(r,n,".json"),"SpriteJSON");l[e]=t.j(a,o);const s=i.transformRequest(g(r,n,".png"),"SpriteImage");c[e]=p.getImage(s,o);}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,(function*(){const t={};for(const r in e){t[r]={};const o=s.getImageCanvasContext((yield i[r]).data),a=(yield e[r]).data;for(const e in a){const{width:i,height:s,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=a[e];t[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:s,x:n,y:l,context:o}};}}return t}))}(l,c)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[t]){const o="default"===t?r:`${t}:${r}`;this._spritesImagesIds[t].push(o),o in this.imageManager.images?this.imageManager.updateImage(o,e[t][r],!1):this.imageManager.addImage(o,e[t][r]),i&&(this._changedImages[o]=!0);}}})).catch((e=>{this._spriteRequest=null,o=e,this.fire(new t.k(o));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),r&&r(o);}));}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const o=i.getSource();("geojson"===o.type||o.vectorLayerIds&&-1===o.vectorLayerIds.indexOf(r))&&this.fire(new t.k(new Error(`Source layer "${r}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bz(r):r);const o=[];for(const a of e)if(r[a]){const e=i?t.bz(r[a]):r[a];o.push(e);}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize());}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return !0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return !0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return !0;for(const e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else {if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates();}const r={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const e in r){const i=this.sourceCaches[e];!!r[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){var r;this._checkLoaded();const o=this.serialize();if(e=i.transformStyle?i.transformStyle(o,e):e,(null===(r=i.validate)||void 0===r||r)&&mi(this,t.y(e)))return !1;(e=t.bz(e)).layers=t.bx(e.layers);const a=t.bA(o,e),s=this._getOperationsToPerform(a);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return !1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case "setCenter":case "setZoom":case "setBearing":case "setPitch":case "setRoll":continue;case "addLayer":t.push((()=>this.addLayer.apply(this,r.args)));break;case "removeLayer":t.push((()=>this.removeLayer.apply(this,r.args)));break;case "setPaintProperty":t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case "setLayoutProperty":t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case "setFilter":t.push((()=>this.setFilter.apply(this,r.args)));break;case "addSource":t.push((()=>this.addSource.apply(this,r.args)));break;case "removeSource":t.push((()=>this.removeSource.apply(this,r.args)));break;case "setLayerZoomRange":t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case "setLight":t.push((()=>this.setLight.apply(this,r.args)));break;case "setGeoJSONSourceData":t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case "setGlyphs":t.push((()=>this.setGlyphs.apply(this,r.args)));break;case "setSprite":t.push((()=>this.setSprite.apply(this,r.args)));break;case "setTerrain":t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case "setSky":t.push((()=>this.setSky.apply(this,r.args)));break;case "setProjection":this.setProjection.apply(this,r.args);break;case "setTransition":t.push((()=>{}));break;default:i.push(r.command);}return {operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(e,t){this.imageManager.updateImage(e,t);}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.y.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=this.sourceCaches[e]=new de(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,(()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e}))),o.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0;}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.k(new Error(`Layer "${o}" already exists on this map.`)));let a;if("custom"===e.type){if(mi(this,t.bB(e)))return;a=t.by(e);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(o,e.source),e=t.bz(e),e=t.e(e,{source:o})),this._validate(t.y.layer,`layers.${o}`,e,{arrayIndex:-1},r))return;a=t.by(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:o}});}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));else {if(this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=a,this._removedLayers[o]&&a.source&&"custom"!==a.type){const e=this._removedLayers[o];delete this._removedLayers[o],e.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause());}this._updateLayer(a),a.onAdd&&a.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(e){return this._layers[e]}getLayersOrder(){return [...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!t.bC(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.y.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.bz(i),this._updateLayer(o)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.bz(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bC(a.getLayoutProperty(i),r)||(a.setLayoutProperty(i,r,o),this._updateLayer(a)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bC(a.getPaintProperty(i),r)||(a.setPaintProperty(i,r,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,a=this.sourceCaches[r];if(void 0===a)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=a.getSource().type;"geojson"===s&&o?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||o?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),a.setFeatureState(o,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.getSource().type,s="vector"===a?e.sourceLayer:void 0;"vector"!==a||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.sourceCaches[i];if(void 0!==o)return "vector"!==o.getSource().type||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.getFeatureState(r,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bD(this.sourceCaches,(e=>e.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,o=this.stylesheet;return t.bE({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,projection:o.projection,sources:e,layers:i,terrain:r},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a)){i[a]=o;for(const t of e){const e=t[a];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let a=this._order.length-1;a>=0;a--){const s=this._order[a];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&a.push(function(e,t,i,r,o,a,s){const n={},l=a.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(N);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,o.filter,o.layers,o.availableImages,e);for(const e in r){const t=n[e]=n[e]||[],o=r[e];o.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of o)t.push(e);}}return function(e,t,i){for(const r in e)for(const o of e[r])G(o,i[t[r].source]);return e}(n,e,i)}(this._layers,s,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.y.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],o={};for(let e=0;ee.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);a=a||r;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),e.zoom))&&(this.pauseablePlacement=new at(e,this.map.terrain,this._order,o,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.now()),n=!0),a&&this.pauseablePlacement.placement.setStale()),n||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles();}getImages(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e}))}getGlyphs(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.y.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}addSprite(e,i,r={},o){this._checkLoaded();const a=[{id:e,url:i}],s=[...f(this.stylesheet.sprite),...a];this._validate(t.y.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(a,!0,o));}removeSprite(e){this._checkLoaded();const i=f(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return f(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.y.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)));}}var vi=t.aD([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class xi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(e,t,i,r,o,a,s,n,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.b7.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(o):0,u_horizon_color:r?r.properties.get("horizon-color"):t.b7.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:a?1:0}),yi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function wi(e){const t=[];for(let i=0;i({u_depth:new t.bF(e,i.u_depth),u_terrain:new t.bF(e,i.u_terrain),u_terrain_dim:new t.b8(e,i.u_terrain_dim),u_terrain_matrix:new t.bH(e,i.u_terrain_matrix),u_terrain_unpack:new t.bI(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.b8(e,i.u_terrain_exaggeration)}))(e,P),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bH(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bI(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bI(e,i.u_projection_clipping_plane),u_projection_transition:new t.b8(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bH(e,i.u_projection_fallback_matrix)}))(e,P),this.binderUniforms=r?r.getUniforms(e,P):[];}draw(e,t,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v){const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(o),e.setCullFace(a),n){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,n.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,n.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(n[e]);}if(l)for(const e in l)this.projectionUniforms[yi[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,_,{zoom:p});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1;}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new xi)).bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,f,g,v),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2);}}}function Pi(e,i,r){const o=1/t.aw(r,1,i.transform.tileZoom),a=Math.pow(2,r.tileID.overscaledZ),s=r.tileSize*Math.pow(2,i.transform.tileZoom)/a,n=s*(r.tileID.canonical.x+r.tileID.wrap*a),l=s*r.tileID.canonical.y;return {u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[o,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}const Ci=(e,i,r,o)=>{const a=e.style.light,s=a.properties.get("position"),n=[s.x,s.y,s.z],l=t.bL();"viewport"===a.properties.get("anchor")&&t.bM(l,e.transform.bearingInRadians),t.bN(n,n,l);const c=e.transform.transformLightDirection(n),h=a.properties.get("color");return {u_lightpos:n,u_lightpos_globe:c,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:o}},Ii=(e,i,r,o,a,s,n)=>t.e(Ci(e,i,r,o),Pi(s,e,n),{u_height_factor:-Math.pow(2,a.overscaledZ)/n.tileSize/8}),Mi=(e,i,r,o)=>t.e(Pi(i,e,r),{u_fill_translate:o}),Ei=(e,t)=>({u_world:e,u_fill_translate:t}),Si=(e,i,r,o,a)=>t.e(Mi(e,i,r,a),{u_world:o}),Ri=(e,i,r,o,a)=>{const s=e.transform;let n,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.aw(i,1,s.zoom);n=!0,l=[e,e],c=e/(t.Z*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*a;}else n=!1,l=s.pixelsToGLUnits;return {u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:o}},Di=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),zi=e=>({u_viewport_size:[e.width,e.height]}),Ai=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Li=(e,i,r,o)=>{const a=t.aw(e,1,i)/(t.Z*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*o;return {u_extrude_scale:t.aw(e,1,i),u_intensity:r,u_globe_extrude_scale:a}},ki=(e,i,r,o)=>{const a=t.K();t.bO(a,0,e.width,e.height,0,0,1);const s=e.context.gl;return {u_matrix:a,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:r,u_color_ramp:o,u_opacity:i.paint.get("heatmap-opacity")}},Fi=(e,t,i)=>{const r=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let s=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);return "viewport"===i.paint.get("hillshade-illumination-anchor")&&(s+=e.transform.bearingInRadians),{u_image:0,u_latrange:Oi(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),s],u_shadow:r,u_highlight:o,u_accent:a}},Bi=(e,i)=>{const r=i.stride,o=t.K();return t.bO(o,0,t.Z,-8192,0,0,1),t.L(o,o,[0,-8192,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Oi(e,i){const r=Math.pow(2,i.canonical.z),o=i.canonical.y;return [new t.$(0,o/r).toLngLat().lat,new t.$(0,(o+1)/r).toLngLat().lat]}const ji=(e,i,r,o)=>{const a=e.transform;return {u_translation:Vi(e,i,r),u_ratio:o/t.aw(i,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Zi=(e,i,r,o,a)=>t.e(ji(e,i,r,o),{u_image:0,u_image_height:a}),Ni=(e,i,r,o,a)=>{const s=e.transform,n=Ui(i,s);return {u_translation:Vi(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:o/t.aw(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[n,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Gi=(e,i,r,o,a,s)=>{const n=e.lineAtlas,l=Ui(i,e.transform),c="round"===r.layout.get("line-cap"),h=n.getDash(a.from,c),u=n.getDash(a.to,c),d=h.width*s.fromScale,_=u.width*s.toScale;return t.e(ji(e,i,r,o),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:s.t})};function Ui(e,i){return 1/t.aw(e,1,i.tileZoom)}function Vi(e,i,r){return t.ax(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const qi=(e,t,i,r,o)=>{return {u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=r.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Wi(r.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]};var a,s;};function Wi(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const $i=(e,t,i,r,o,a,s,n,l,c,h,u,d)=>{const _=s.transform;return {u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_pitch:_.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:o,u_is_variable_anchor:a,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},Hi=(e,i,r,o,a,s,n,l,c,h,u,d,_,p)=>{const m=n.transform;return t.e($i(e,i,r,o,a,s,n,l,c,h,u,d,p),{u_gamma_scale:o?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:1})},Ki=(e,i,r,o,a,s,n,l,c,h,u,d,_)=>t.e(Hi(e,i,r,o,a,s,n,l,c,h,!0,u,0,_),{u_texsize_icon:d,u_texture_icon:1}),Xi=(e,t)=>({u_opacity:e,u_color:t}),Qi=(e,i,r,o,a)=>t.e(function(e,i,r,o){const a=r.imageManager.getPattern(e.from.toString()),s=r.imageManager.getPattern(e.to.toString()),{width:n,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(o.tileID.canonical.x+o.tileID.wrap*c),d=h*o.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aw(o,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,a,i,o),{u_opacity:e}),Yi=(e,t)=>{},Ji={fillExtrusion:(e,i)=>({u_lightpos:new t.bJ(e,i.u_lightpos),u_lightpos_globe:new t.bJ(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bJ(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bK(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bJ(e,i.u_lightpos),u_lightpos_globe:new t.bJ(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bJ(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_height_factor:new t.b8(e,i.u_height_factor),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bK(e,i.u_fill_translate),u_image:new t.bF(e,i.u_image),u_texsize:new t.bK(e,i.u_texsize),u_pixel_coord_upper:new t.bK(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bK(e,i.u_pixel_coord_lower),u_scale:new t.bJ(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bK(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bF(e,i.u_image),u_texsize:new t.bK(e,i.u_texsize),u_pixel_coord_upper:new t.bK(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bK(e,i.u_pixel_coord_lower),u_scale:new t.bJ(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bK(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bK(e,i.u_world),u_fill_translate:new t.bK(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bK(e,i.u_world),u_image:new t.bF(e,i.u_image),u_texsize:new t.bK(e,i.u_texsize),u_pixel_coord_upper:new t.bK(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bK(e,i.u_pixel_coord_lower),u_scale:new t.bJ(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bK(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bF(e,i.u_scale_with_map),u_pitch_with_map:new t.bF(e,i.u_pitch_with_map),u_extrude_scale:new t.bK(e,i.u_extrude_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale),u_translate:new t.bK(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bK(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bK(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bG(e,i.u_color),u_overlay:new t.bF(e,i.u_overlay),u_overlay_scale:new t.b8(e,i.u_overlay_scale)}),depth:Yi,clippingMask:Yi,heatmap:(e,i)=>({u_extrude_scale:new t.b8(e,i.u_extrude_scale),u_intensity:new t.b8(e,i.u_intensity),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bH(e,i.u_matrix),u_world:new t.bK(e,i.u_world),u_image:new t.bF(e,i.u_image),u_color_ramp:new t.bF(e,i.u_color_ramp),u_opacity:new t.b8(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bF(e,i.u_image),u_latrange:new t.bK(e,i.u_latrange),u_light:new t.bK(e,i.u_light),u_shadow:new t.bG(e,i.u_shadow),u_highlight:new t.bG(e,i.u_highlight),u_accent:new t.bG(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bH(e,i.u_matrix),u_image:new t.bF(e,i.u_image),u_dimension:new t.bK(e,i.u_dimension),u_zoom:new t.b8(e,i.u_zoom),u_unpack:new t.bI(e,i.u_unpack)}),line:(e,i)=>({u_translation:new t.bK(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bK(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bK(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bK(e,i.u_units_to_pixels),u_image:new t.bF(e,i.u_image),u_image_height:new t.b8(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bK(e,i.u_translation),u_texsize:new t.bK(e,i.u_texsize),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_image:new t.bF(e,i.u_image),u_units_to_pixels:new t.bK(e,i.u_units_to_pixels),u_scale:new t.bJ(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bK(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bK(e,i.u_units_to_pixels),u_patternscale_a:new t.bK(e,i.u_patternscale_a),u_patternscale_b:new t.bK(e,i.u_patternscale_b),u_sdfgamma:new t.b8(e,i.u_sdfgamma),u_image:new t.bF(e,i.u_image),u_tex_y_a:new t.b8(e,i.u_tex_y_a),u_tex_y_b:new t.b8(e,i.u_tex_y_b),u_mix:new t.b8(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bK(e,i.u_tl_parent),u_scale_parent:new t.b8(e,i.u_scale_parent),u_buffer_scale:new t.b8(e,i.u_buffer_scale),u_fade_t:new t.b8(e,i.u_fade_t),u_opacity:new t.b8(e,i.u_opacity),u_image0:new t.bF(e,i.u_image0),u_image1:new t.bF(e,i.u_image1),u_brightness_low:new t.b8(e,i.u_brightness_low),u_brightness_high:new t.b8(e,i.u_brightness_high),u_saturation_factor:new t.b8(e,i.u_saturation_factor),u_contrast_factor:new t.b8(e,i.u_contrast_factor),u_spin_weights:new t.bJ(e,i.u_spin_weights),u_coords_top:new t.bI(e,i.u_coords_top),u_coords_bottom:new t.bI(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bF(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bF(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bF(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bH(e,i.u_label_plane_matrix),u_coord_matrix:new t.bH(e,i.u_coord_matrix),u_is_text:new t.bF(e,i.u_is_text),u_pitch_with_map:new t.bF(e,i.u_pitch_with_map),u_is_along_line:new t.bF(e,i.u_is_along_line),u_is_variable_anchor:new t.bF(e,i.u_is_variable_anchor),u_texsize:new t.bK(e,i.u_texsize),u_texture:new t.bF(e,i.u_texture),u_translation:new t.bK(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bF(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bF(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bF(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bH(e,i.u_label_plane_matrix),u_coord_matrix:new t.bH(e,i.u_coord_matrix),u_is_text:new t.bF(e,i.u_is_text),u_pitch_with_map:new t.bF(e,i.u_pitch_with_map),u_is_along_line:new t.bF(e,i.u_is_along_line),u_is_variable_anchor:new t.bF(e,i.u_is_variable_anchor),u_texsize:new t.bK(e,i.u_texsize),u_texture:new t.bF(e,i.u_texture),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bF(e,i.u_is_halo),u_translation:new t.bK(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bF(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bF(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bF(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bH(e,i.u_label_plane_matrix),u_coord_matrix:new t.bH(e,i.u_coord_matrix),u_is_text:new t.bF(e,i.u_is_text),u_pitch_with_map:new t.bF(e,i.u_pitch_with_map),u_is_along_line:new t.bF(e,i.u_is_along_line),u_is_variable_anchor:new t.bF(e,i.u_is_variable_anchor),u_texsize:new t.bK(e,i.u_texsize),u_texsize_icon:new t.bK(e,i.u_texsize_icon),u_texture:new t.bF(e,i.u_texture),u_texture_icon:new t.bF(e,i.u_texture_icon),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bF(e,i.u_is_halo),u_translation:new t.bK(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_color:new t.bG(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_image:new t.bF(e,i.u_image),u_pattern_tl_a:new t.bK(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bK(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bK(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bK(e,i.u_pattern_br_b),u_texsize:new t.bK(e,i.u_texsize),u_mix:new t.b8(e,i.u_mix),u_pattern_size_a:new t.bK(e,i.u_pattern_size_a),u_pattern_size_b:new t.bK(e,i.u_pattern_size_b),u_scale_a:new t.b8(e,i.u_scale_a),u_scale_b:new t.b8(e,i.u_scale_b),u_pixel_coord_upper:new t.bK(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bK(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.b8(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bF(e,i.u_texture),u_ele_delta:new t.b8(e,i.u_ele_delta),u_fog_matrix:new t.bH(e,i.u_fog_matrix),u_fog_color:new t.bG(e,i.u_fog_color),u_fog_ground_blend:new t.b8(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.b8(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bG(e,i.u_horizon_color),u_horizon_fog_blend:new t.b8(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.b8(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.b8(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bF(e,i.u_texture),u_terrain_coords_id:new t.b8(e,i.u_terrain_coords_id),u_ele_delta:new t.b8(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.b8(e,i.u_input),u_output_expected:new t.b8(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bJ(e,i.u_sun_pos),u_atmosphere_blend:new t.b8(e,i.u_atmosphere_blend),u_globe_position:new t.bJ(e,i.u_globe_position),u_globe_radius:new t.b8(e,i.u_globe_radius),u_inv_proj_matrix:new t.bH(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bG(e,i.u_sky_color),u_horizon_color:new t.bG(e,i.u_horizon_color),u_horizon:new t.bK(e,i.u_horizon),u_horizon_normal:new t.bK(e,i.u_horizon_normal),u_sky_horizon_blend:new t.b8(e,i.u_sky_horizon_blend),u_sky_blend:new t.b8(e,i.u_sky_blend)})};class er{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const tr={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ir{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const o=e.gl;this.buffer=o.createBuffer(),e.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&(h.push({circleArray:f,circleOffset:d,coord:_}),u+=f.length/4,d=u),m&&c.draw(s,l.LINES,jt.disabled,Nt.disabled,e.colorModeForRenderPass(),Ot.disabled,Di(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(_),n.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer);}if(!a||!h.length)return;const _=e.useProgram("collisionCircle"),p=new t.bP;p.resize(4*u),p._trim();let m=0;for(const e of h)for(let t=0;t=0&&(f[g.associatedIconIndex]={shiftedAnchor:E,angle:S});}else Be(g.numGlyphs,p);}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");Pe(c,e,a,O,j,v,h,i,l.toUnwrapped(),f.width,f.height,N,t);}const q=a&&P||V,W=x||q?Vr:v?O:e.transform.clipSpaceToPixelsMatrix,$=p&&0!==r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let H;H=p?c.iconsInText?Ki(T.kind,S,b,v,x,q,e,W,Z,N,D,k,I):Hi(T.kind,S,b,v,x,q,e,W,Z,N,a,D,0,I):$i(T.kind,S,b,v,x,q,e,W,Z,N,a,D,I);const K={program:E,buffers:u,uniformValues:H,projectionData:G,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:A,atlasInterpolationIcon:L,isSDF:p,hasHalo:$};if(y&&c.canOverlap){w=!0;const e=u.segments.get();for(const i of e)C.push({segments:new t.aG([i]),sortKey:i.sortKey,state:K,terrainData:R});}else C.push({segments:u.segments,sortKey:0,state:K,terrainData:R});}w&&C.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of C){const i=t.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,Xr(i.buffers,t.segments,r,e,i.program,T,u,d,o,i.projectionData,t.terrainData)),o.u_is_halo=0;}Xr(i.buffers,t.segments,r,e,i.program,T,u,d,i.uniformValues,i.projectionData,t.terrainData);}}function Xr(e,t,i,r,o,a,s,n,l,c,h){const u=r.context;o.draw(u,u.gl.TRIANGLES,a,s,n,Ot.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer);}function Qr(e,i,r,o,a){const s=e.context,n=s.gl,l=Nt.disabled,c=new Ft([n.ONE,n.ONE],t.b7.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=o.key;let d=r.heatmapFbos.get(u);d||(d=Jr(s,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.b7.transparent});const _=h.programConfigurations.get(r.id),p=e.useProgram("heatmap",_,!a),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),f=e.style.map.terrain.getTerrainData(o);p.draw(s,n.TRIANGLES,jt.disabled,l,c,Ot.disabled,Li(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),f,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,_);}function Yr(e,t,i,r,o){const a=e.context,s=a.gl,n=e.transform;a.setColorMode(e.colorModeForRenderPass());const l=eo(a,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),a.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=n.getProjectionData({overscaledTileID:i,applyTerrainMatrix:o,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(a,s.TRIANGLES,jt.disabled,Nt.disabled,e.colorModeForRenderPass(),Ot.disabled,ki(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,n.zoom),h.destroy(),t.heatmapFbos.delete(c);}function Jr(e,t,i){var r,o;const a=e.gl,s=a.createTexture();a.bindTexture(a.TEXTURE_2D,s),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);const n=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:a.UNSIGNED_BYTE,l=null!==(o=e.RGBA16F)&&void 0!==o?o:a.RGBA;a.texImage2D(a.TEXTURE_2D,0,l,t,i,0,a.RGBA,n,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function eo(e,t){return t.colorRampTexture||(t.colorRampTexture=new v(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function to(e,t,i,r,o){if(!i||!r||!r.imageAtlas)return;const a=r.imageAtlas.patternPositions;let s=a[i.to.toString()],n=a[i.from.toString()];if(!s&&n&&(s=n),!n&&s&&(n=s),!s||!n){const e=o.getPaintProperty(t);s=a[e],n=a[e];}s&&n&&e.setConstantPatternPositions(s,n);}function io(e,i,r,o,a,s,n,l){const c=e.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),_=r.getCrossfadeParameters();let p,m,f,g,v;const x=e.transform,b=r.paint.get("fill-translate"),y=r.paint.get("fill-translate-anchor");n?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=c.LINES):(m=d?"fillPattern":"fill",p=c.TRIANGLES);const w=u.constantOr(null);for(const u of o){const T=i.getTile(u);if(d&&!T.patternsLoaded())continue;const P=T.getBucket(r);if(!P)continue;const C=P.programConfigurations.get(r.id),I=e.useProgram(m,C),M=e.style.map.terrain&&e.style.map.terrain.getTerrainData(u);d&&(e.context.activeTexture.set(c.TEXTURE0),T.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),C.updatePaintBuffers(_)),to(C,h,w,T,r);const E=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),S=t.ax(x,T,b,y);if(n){g=P.indexBuffer2,v=P.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];f="fillOutlinePattern"===m&&d?Si(e,_,T,t,S):Ei(t,S);}else g=P.indexBuffer,v=P.segments,f=d?Mi(e,_,T,S):{u_fill_translate:S};let R;if("translucent"===e.renderPass&&l){const[t]=e.getStencilConfigForOverlapAndUpdateStencilID(o);R=t[u.overscaledZ];}else R=e.stencilModeForClipping(u);I.draw(e.context,p,a,R,s,Ot.backCCW,f,M,E,r.id,P.layoutVertexBuffer,g,v,r.paint,e.transform.zoom,C);}}function ro(e,i,r,o,a,s,n,l){const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),_=d.constantOr(1),p=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),f=d.constantOr(null),g=e.transform;for(const d of o){const o=i.getTile(d),v=o.getBucket(r);if(!v)continue;const x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),b=v.programConfigurations.get(r.id),y=e.useProgram(_?"fillExtrusionPattern":"fillExtrusion",b);_&&(e.context.activeTexture.set(h.TEXTURE0),o.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const w=g.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});to(b,u,f,o,r);const T=t.ax(g,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),C=_?Ii(e,P,m,T,d,p,o):Ci(e,P,m,T);y.draw(c,c.gl.TRIANGLES,a,s,n,Ot.backCCW,C,x,w,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer);}}function oo(e,t,i,r,o,a,s,n,l){var c;const h=e.style.projection,u=e.context,d=e.transform,_=u.gl,p=e.useProgram("hillshade"),m=!e.options.moving;for(const f of r){const r=t.getTile(f),g=r.fbo;if(!g)continue;const v=h.getMeshFromTileID(u,f.canonical,n,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);u.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,g.colorAttachment.get());const b=d.getProjectionData({overscaledTileID:f,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(u,_.TRIANGLES,a,o[f.overscaledZ],s,Ot.backCCW,Fi(e,r,i),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments);}}const ao=[new t.P(0,0),new t.P(t.Z,0),new t.P(t.Z,t.Z),new t.P(0,t.Z)];function so(e,t,i,r,o,a,s,n,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=e.context,d=u.gl,_=e.useProgram("raster"),p=e.transform,m=e.style.projection,f=e.colorModeForRenderPass(),g=!e.options.moving;for(const v of r){const r=e.getDepthModeForSublayer(v.overscaledZ-h,1===i.paint.get("raster-opacity")?jt.ReadWrite:jt.ReadOnly,d.LESS),x=t.getTile(v);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const b=t.findLoadedParent(v,0),y=t.findLoadedSibling(v),w=no(x,b||y||null,t,i,e.transform,e.style.map.terrain);let T,P;const C="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),b?(b.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,b.tileID.overscaledZ-x.tileID.overscaledZ),P=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),M=p.getProjectionData({overscaledTileID:v,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),E=qi(P||[0,0],T||1,w,i,n),S=m.getMeshFromTileID(u,v.canonical,a,s,"raster");_.draw(u,d.TRIANGLES,r,o?o[v.overscaledZ]:Nt.disabled,f,l?Ot.frontCCW:Ot.backCCW,E,I,M,i.id,S.vertexBuffer,S.indexBuffer,S.segments);}}function no(e,i,r,o,a,n){const l=o.paint.get("raster-fade-duration");if(!n&&l>0){const o=s.now(),n=(o-e.timeAdded)/l,c=i?(o-i.timeAdded)/l:-1,h=r.getSource(),u=he(a,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),_=d&&e.refreshedUponExpiration?1:t.ae(d?n:1-c,0,1);return e.refreshedUponExpiration&&n>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-_}:{opacity:_,mix:0}}return {opacity:1,mix:0}}const lo=new t.b7(1,0,0,1),co=new t.b7(0,1,0,1),ho=new t.b7(0,0,1,1),uo=new t.b7(1,0,1,1),_o=new t.b7(0,1,1,1);function po(e,t,i,r){fo(e,0,t+i/2,e.transform.width,i,r);}function mo(e,t,i,r){fo(e,t-i/2,0,i,e.transform.height,r);}function fo(e,t,i,r,o,a){const s=e.context,n=s.gl;n.enable(n.SCISSOR_TEST),n.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,o*e.pixelRatio),s.clear({color:a}),n.disable(n.SCISSOR_TEST);}function go(e,i,r){const o=e.context,a=o.gl,s=e.useProgram("debug"),n=jt.disabled,l=Nt.disabled,c=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);o.activeTexture.set(a.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,_=Math.floor((d&&d.byteLength||0)/1024),p=i.getTile(r).tileSize,m=512/Math.min(p,512)*(r.overscaledZ/e.transform.zoom)*.5;let f=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(f+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,o=e.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(t,5,5),o.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,`${f} ${_}kB`);const g=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(o,a.TRIANGLES,n,l,Ft.alphaBlended,Ot.disabled,Ai(t.b7.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(o,a.LINE_STRIP,n,l,c,Ot.disabled,Ai(t.b7.red),u,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function vo(e,t,i,r){const{isRenderingGlobe:o}=r,a=e.context,s=a.gl,n=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),u=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const _=t.getMeshFrameDelta(n.zoom),p=n.calculateFogMatrix(r.tileID.toUnwrapped()),m=bi(_,p,e.style.sky,n.pitch,o),f=n.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(a,s.TRIANGLES,c,Nt.disabled,l,Ot.backCCW,m,d,f,"terrain",i.vertexBuffer,i.indexBuffer,i.segments);}}function xo(e,i){if(!i.mesh){const r=new t.aF;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const o=new t.aH;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),i.mesh=new pt(e.createVertexBuffer(r,mt.members),e.createIndexBuffer(o),t.aG.simpleSegment(0,0,r.length,o.length));}return i.mesh}class bo{constructor(e,i){this.context=new Nr(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.at(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=de.maxUnderzooming+de.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ht;}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize();}setup(){const e=this.context,i=new t.aF;i.emplaceBack(0,0),i.emplaceBack(t.Z,0),i.emplaceBack(0,t.Z),i.emplaceBack(t.Z,t.Z),this.tileExtentBuffer=e.createVertexBuffer(i,mt.members),this.tileExtentSegments=t.aG.simpleSegment(0,0,4,2);const r=new t.aF;r.emplaceBack(0,0),r.emplaceBack(t.Z,0),r.emplaceBack(0,t.Z),r.emplaceBack(t.Z,t.Z),this.debugBuffer=e.createVertexBuffer(r,mt.members),this.debugSegments=t.aG.simpleSegment(0,0,4,5);const o=new t.bW;o.emplaceBack(0,0,0,0),o.emplaceBack(t.Z,0,t.Z,0),o.emplaceBack(0,t.Z,0,t.Z),o.emplaceBack(t.Z,t.Z,t.Z,t.Z),this.rasterBoundsBuffer=e.createVertexBuffer(o,vi.members),this.rasterBoundsSegments=t.aG.simpleSegment(0,0,4,2);const a=new t.aF;a.emplaceBack(0,0),a.emplaceBack(t.Z,0),a.emplaceBack(0,t.Z),a.emplaceBack(t.Z,t.Z),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,mt.members),this.rasterBoundsSegmentsPosOnly=t.aG.simpleSegment(0,0,4,5);const s=new t.aF;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,mt.members),this.viewportSegments=t.aG.simpleSegment(0,0,4,2);const n=new t.bX;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);const l=new t.aH;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Nt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new pt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.K();t.bO(r,0,this.width,this.height,0,0,1),t.M(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const o={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,jt.disabled,this.stencilClearMode,Ft.disabled,Ot.disabled,null,null,o,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Ft.disabled),r.setDepthMode(jt.disabled);const o={};for(const e of t)o[e.key]=this.nextStencilID++;this._renderTileMasks(o,t,i,!0),this._renderTileMasks(o,t,i,!1),this._tileClippingMaskIDs=o;}_renderTileMasks(e,t,i,r){const o=this.context,a=o.gl,s=this.style.projection,n=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=s.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=n.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!0,applyTerrainMatrix:!0});l.draw(o,a.TRIANGLES,jt.disabled,new Nt({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),Ft.disabled,i?Ot.disabled:Ot.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments);}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,o=this.useProgram("depth"),a=this.getDepthModeFor3D(),s=ue(r,{tileSize:r.tileSize});for(const n of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(n),l=i.getMeshFromTileID(this.context,n.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(e,t.TRIANGLES,a,Nt.disabled,Ft.disabled,Ot.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Nt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Nt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(this.clearStencil(),o>1){const e={},a={};for(let i=0;i0};for(const e in n){const t=n[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse();}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.b7.black:t.b7.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,o=((e,t,i)=>{const r=Math.cos(t.rollInRadians),o=Math.sin(t.rollInRadians),a=yt(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return {u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-a*o)*i,(t.height/2+a*r)*i],u_horizon_normal:[-o,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),a=new jt(r.LEQUAL,jt.ReadWrite,[0,1]),s=Nt.disabled,n=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=xo(i,t);l.draw(i,r.TRIANGLES,a,s,n,Ot.disabled,o,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments);}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[a[this.currentLayer]],t=n[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,u);}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:o}))(c,u,[p[0],p[1],p[2]],d,_),f=xo(o,i);s.draw(o,a.TRIANGLES,n,Nt.disabled,Ft.alphaBlended,Ot.disabled,m,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments);}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[])),o=r.filter((e=>"vector"===e.getSource().type)),a=r.filter((e=>"vector"!==e.getSource().type)),s=e=>{(!i||i.getSource().maxzooms(e))),i||a.forEach((e=>s(e))),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;ru.getElevation(a,e,t):null;$r(s,d,_,c,h,f,i,p,g,t.ax(h,e,n,l),a.toUnwrapped(),r);}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),a),0!==r.paint.get("icon-opacity").constantOr(1)&&Kr(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,n),0!==r.paint.get("text-opacity").constantOr(1)&&Kr(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,n),i.map.showCollisionBoxes&&(Ur(e,i,r,o,!0),Ur(e,i,r,o,!1));}(e,i,r,o,this.style.placement.variableOffsets,a):t.c0(r)?function(e,i,r,o,a){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=a,n=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===n.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,_=e.transform,p=e.getDepthModeForSublayer(0,jt.ReadOnly),m=Nt.disabled,f=e.colorModeForRenderPass(),g=[],v=_.getCircleRadiusCorrection();for(let a=0;ae.sortKey-t.sortKey));for(const t of g){const{programConfiguration:i,program:o,layoutVertexBuffer:a,indexBuffer:s,uniformValues:n,terrainData:l,projectionData:c}=t.state;o.draw(u,d.TRIANGLES,p,m,f,Ot.backCCW,n,l,c,r.id,a,s,t.segments,r.paint,e.transform.zoom,i);}}(e,i,r,o,a):t.c1(r)?function(e,i,r,o,a){if(0===r.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:n,isRenderingGlobe:l}=a;if(e.style.map.terrain){for(const t of o){const o=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?Qr(e,o,r,t,l):"translucent"===e.renderPass&&Yr(e,r,t,n,l));}s.viewport.set([0,0,e.width,e.height]);}else "offscreen"===e.renderPass?function(e,i,r,o){const a=e.context,s=a.gl,n=e.transform,l=Nt.disabled,c=new Ft([s.ONE,s.ONE],t.b7.transparent,[!0,!0,!0,!0]);((function(e,i,r){const o=e.gl;e.activeTexture.set(o.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let a=r.heatmapFbos.get(t.bS);a?(o.bindTexture(o.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=Jr(e,i.width/4,i.height/4),r.heatmapFbos.set(t.bS,a));}))(a,e,r),a.clear({color:t.b7.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return !1;if(!e.from||!e.to)return !0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return !t||!i}useProgram(e,t,i=!1){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,a=e+(t?t.cacheKey:"")+`/${i?gt:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"");return this.cache[a]||(this.cache[a]=new Ti(this.context,dt[e],t,Ji[e],this._showOverdrawInspector,r,i?dt.projectionMercator:o.shaderPreludeCode,i?ft:o.shaderDefine)),this.cache[a]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new v(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function yo(e,t){let i,r=!1,o=null,a=null;const s=()=>{o=null,r&&(e.apply(a,i),o=setTimeout(s,t),r=!1);};return (...e)=>(r=!0,a=this,i=e,o||s(),o)}class wo{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return !1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e);},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let o=window.location.href.replace(/(#.+)?$/,r);o=o.replace("&&","&"),window.history.replaceState(window.history.state,null,o);},this._updateHash=yo(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e);}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),a=Math.round(t.lng*o)/o,s=Math.round(t.lat*o)/o,n=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${a}/${s}/${i}`:`${i}/${s}/${a}`,(n||l)&&(c+="/"+Math.round(10*n)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return `#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return !1;try{new t.Q(+e[2],+e[1]);}catch(e){return !1}const i=+e[0],r=+(e[3]||0),o=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&o>=this._map.getMinPitch()&&o<=this._map.getMaxPitch()}}const To={linearity:.3,easing:t.c9(0,0,.3,1)},Po=t.e({deceleration:2500,maxSpeed:1400},To),Co=t.e({deceleration:20,maxSpeed:1400},To),Io=t.e({deceleration:1e3,maxSpeed:360},To),Mo=t.e({deceleration:1e3,maxSpeed:90},To),Eo=t.e({deceleration:1e3,maxSpeed:360},To);class So{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=s.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const a=Do(i.pan.mag(),r,t.e({},Po,e||{})),s=i.pan.mult(a.amount/i.pan.mag()),n=this._map.cameraHelper.handlePanInertia(s,this._map.transform);o.center=n.easingCenter,o.offset=n.easingOffset,Ro(o,a);}if(i.zoom){const e=Do(i.zoom,r,Co);o.zoom=this._map.transform.zoom+e.amount,Ro(o,e);}if(i.bearing){const e=Do(i.bearing,r,Io);o.bearing=this._map.transform.bearing+t.ae(e.amount,-179,179),Ro(o,e);}if(i.pitch){const e=Do(i.pitch,r,Mo);o.pitch=this._map.transform.pitch+e.amount,Ro(o,e);}if(i.roll){const e=Do(i.roll,r,Eo);o.roll=this._map.transform.roll+t.ae(e.amount,-179,179),Ro(o,e);}if(o.zoom||o.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;o.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),t.e(o,{noMoveStart:!0})}}function Ro(e,t){(!e.duration||e.durationi.unproject(e))),l=a.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1;}}class Lo extends t.l{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class ko{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){delete this._mousedownPos;}wheel(e){return this._firePreventable(new Lo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new zo(e.type,this._map,e))}mouseup(e){this._map.fire(new zo(e.type,this._map,e));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new zo(e.type,this._map,e));}dblclick(e){return this._firePreventable(new zo(e.type,this._map,e))}mouseover(e){this._map.fire(new zo(e.type,this._map,e));}mouseout(e){this._map.fire(new zo(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Ao(e.type,this._map,e))}touchmove(e){this._map.fire(new Ao(e.type,this._map,e));}touchend(e){this._map.fire(new Ao(e.type,this._map,e));}touchcancel(e){this._map.fire(new Ao(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Fo{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(e){this._map.fire(new zo(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new zo("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new zo(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Bo{constructor(e){this._map=e;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class Oo{constructor(e,t){this._map=e,this._tr=new Bo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(r,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function jo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=jo(r,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=jo(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class No{constructor(e){this.singleTap=new Zo(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Go{constructor(e){this._tr=new Bo(e),this._zoomIn=new No({numTouches:1,numTaps:2}),this._zoomOut=new No({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),o=this._zoomOut.touchend(e,t,i),a=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(r)},{originalEvent:e})}):o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(o)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Uo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset();}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e);}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return !this._moved&&r.dist(i)!0}),t=new Wo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t;}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)));}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)));}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Ho=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault();};};class Ko{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0);}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const o=jo(r,i),a=new t.P(0,0),s=new t.P(0,0);let n=0;for(const e in o){const t=o[e],i=this._touches[e];i&&(a._add(t),s._add(t.sub(i)),n++,o[e]=t);}if(this._touches=o,this._shouldBePrevented(n)||!s.mag())return;const l=s.div(n);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class ra extends Xo{constructor(e){super(),this._currentTouchCount=0,this._map=e;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length;}_start(e){this._lastPoints=e,ia(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),o=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,o=t.mag()>=2;if(!r&&!o)return;if(!r||!o)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const a=e.y>0==t.y>0;return ia(e)&&ia(t)&&a}}const oa={panStep:100,bearingStep:15,pitchStep:10};class aa{constructor(e){this._tr=new Bo(e);const t=oa;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,o=0,a=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),o=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),o=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const n=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:sa,zoom:t?Math.round(n.zoom)+t*(e.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+r*this._pitchStep,offset:[-o*this._panStep,-a*this._panStep],center:n.center},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function sa(e){return e*(2-e)}const na=4.000244140625;class la{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);},this._map=e,this._tr=new Bo(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(e){return !!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=s.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%na==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=n.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.Q.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t);}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>na?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const o="number"!=typeof this._targetZoom?e.scale:t.aI(this._targetZoom);this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,t.ab(o*r))),"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,o=this._easing;let a,n=!1;if("wheel"===this._type&&r&&o){const e=s.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=o(l);a=t.B.number(r,i,c),l<1?this._frameId||(this._frameId=!0):n=!0;}else a=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout;}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!n,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cb;if(this._prevEase){const e=this._prevEase,r=(s.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(o*o+1e-4)*.01,n=Math.sqrt(.0729-a*a);i=t.c9(a,n,.25,1);}return this._prevEase={start:s.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class ca{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class ha{constructor(e){this._tr=new Bo(e),this.reset();}reset(){this._active=!1;}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ua{constructor(){this._tap=new No({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],o=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;o&&a?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(e,t,i);}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class da{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class _a{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class pa{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class ma{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=n.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const o=document.createElement("div");o.className="maplibregl-mobile-message",o.textContent=i,this._container.appendChild(o),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(n.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const fa=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class ga extends t.l{}function va(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class xa{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`);},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===e.type?void 0:e,o={needsRenderFrame:!1},a={},s={};for(const{handlerName:l,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(s,h,l))c.reset();else if(c[i||e.type]){if(t.cc(e,i||e.type)){const t=n.mousePos(this._map.getCanvas(),e);u=c[i||e.type](e,t);}else if(t.cd(e,i||e.type)){const t=this._getMapTouches(e.touches),r=n.touchPos(this._map.getCanvas(),t);u=c[i||e.type](e,r,t);}else t.ce(i||e.type)||(u=c[i||e.type](e));this.mergeHandlerResult(o,a,u,l,r),u&&u.needsRenderFrame&&this._triggerRenderFrame();}(u||c.isActive())&&(s[l]=c);}const l={};for(const e in this._previousActiveHandlers)s[e]||(l[e]=r);this._previousActiveHandlers=s,(Object.keys(l).length||va(o))&&(this._changes.push([o,a,l]),this._triggerRenderFrame()),(Object.keys(s).length||va(o))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=o;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map));},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new So(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)n.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[e,t,i]of this._listeners)n.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new ko(i,e));const o=i.boxZoom=new Oo(i,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const a=i.cooperativeGestures=new ma(i,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();const s=new Go(i),l=new ha(i);i.doubleClickZoom=new ca(l,s),this._add("tapZoom",s),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new ua;this._add("tapDragZoom",c);const h=i.touchPitch=new ra(i);this._add("touchPitch",h),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:o=100,rotateDegreesPerPixelMoved:a=.8},s){const l=new qo({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Uo({clickTolerance:i,move:(e,i)=>{const n=s();if(r&&Math.abs(n.y-e.y)>o)return {bearingDelta:t.ca(new t.P(e.x,i.y),i,n)};let l=(i.x-e.x)*a;return r&&i.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Uo({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:Ho})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const o=new qo({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Uo({clickTolerance:t,move:(e,t)=>{const o=r();let a=(t.x-e.x)*i;return t.y0===n.mouseButton(e)&&!e.ctrlKey});return new Uo({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Ho})}(e),f=new Ko(e,i);i.dragPan=new da(r,m,f),this._add("mousePan",m),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new ta,v=new Jo;i.touchZoomRotate=new pa(r,v,g,c),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",v,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const x=i.scrollZoom=new la(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const b=i.keyboard=new aa(i);this._add("keyboard",b),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Fo(i));}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[];}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(fa(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,o,a){if(!r)return;t.e(e,r);const s={handlerName:o,originalEvent:r.originalEvent||a};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s);}_applyChanges(){const e={},i={},r={};for(const[o,a,s]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(e.rollDelta=(e.rollDelta||0)+o.rollDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.e(i,a),t.e(r,s);this._updateMapTransform(e,i,r),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,o=r._getTransformForUpdate(),a=r.terrain;if(!(va(e)||a&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:n,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u=u||r.transform.centerPoint,a&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const _={panDelta:s,zoomDelta:n,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const p=u.distSqr(o.centerPoint)<.01?o.center:o.screenPointToLocation(s?u.sub(s):u);a?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?o.setCenter(o.screenPointToLocation(o.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(_,o,p):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(_,o,p))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._map.cameraHelper.handleMapControlsPan(_,o,p)),r._applyUpdatedTransform(o),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,i,r){const o=fa(this._eventsInProgress),a=fa(e),n={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(n[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!o&&a&&this._fireEvent("movestart",a.originalEvent);for(const e in n)this._fireEvent(e,n[e]);a&&this._fireEvent("move",a.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||r,l[`${e}end`]=c);}for(const e in l)this._fireEvent(e,l[e]);const h=fa(this._eventsInProgress),u=(o||a)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e);}if(r&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ga("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class ba extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState;}));}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t;}getCenter(){return new t.Q(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e;}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){f.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.l("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.l("rollstart",e));}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.setElevation(t.B.number(this._elevationStart,this._elevationTarget,e));}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return {};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:o,roll:a,pitch:s,bearing:n,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==o&&t.setZoom(o),void 0!==a&&t.setRoll(a),void 0!==s&&t.setPitch(s),void 0!==n&&t.setBearing(n),i.apply(t);}this.transform.apply(i);}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,o=this._rotating,a=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l("zoomend",e)),o&&this.fire(new t.l("rotateend",e)),a&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e));}flyTo(e,i){if(!e.essential&&s.prefersReducedMotion){const r=t.O(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cb},e);const r=this._getTransformForUpdate(),o=r.bearing,a=r.pitch,n=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:a,u="roll"in e?this._normalizeBearing(e.roll,n):n,d="padding"in e?e.padding:r.padding,_=t.P.convert(e.offset);let p=r.centerPoint.add(_);const m=r.screenPointToLocation(p),f=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:_,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let g=e.curve;const v=Math.max(r.width,r.height),x=v/f.scaleOfZoom,b=f.pixelPathLength;"number"==typeof f.scaleOfMinZoom&&(g=Math.sqrt(v/f.scaleOfMinZoom/b*2));const y=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*y*y*b*b)/(2*(e?x:v)*y*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const C=w(!1);let I=function(e){return P(C)/P(C+g*e)},M=function(e){return v*((P(C)*(T(t=C+g*e)/P(t))-T(C))/y)/b;var t;},E=(w(!0)-C)/g;if(Math.abs(b)<2e-6||!isFinite(E)){if(Math.abs(v-x)<1e-6)return this.easeTo(e,i);const t=x0,I=e=>Math.exp(t*g*e);}return e.duration="duration"in e?+e.duration:1e3*E/("screenSpeed"in e?+e.screenSpeed/g:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==a,this._rolling=u!==n,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease((s=>{const m=s*E,g=1/I(m),v=M(m);this._rotating&&r.setBearing(t.B.number(o,c,s)),this._pitching&&r.setPitch(t.B.number(a,h,s)),this._rolling&&r.setRoll(t.B.number(n,u,s)),this._padding&&(r.interpolatePadding(l,d,s),p=r.centerPoint.add(_)),f.easeFunc(s,g,v,p),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t);}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.aL(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class wa{constructor(e=ya){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=e;}getDefaultPosition(){return "bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style.sourceCaches;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return !1;return !0}));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=n.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class Ta{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact");}},this.options=e;}getDefaultPosition(){return "bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=n.create("div","maplibregl-ctrl");const t=n.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class Pa{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var Ca=t.aD([{name:"a_pos3d",type:"Int16",components:3}]);class Ia extends t.E{constructor(e){super(),this._lastTilesetChange=s.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const r={};for(const o of ue(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float64Array(16),t.bO(o.terrainRttPosMatrix32f,0,t.Z,t.Z,0,0,1),this._tiles[o.key]=new ae(o,this.tileSize),this._lastTilesetChange=s.now());for(const e in this._tiles)r[e]||delete this._tiles[e];}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID,a=e.clone(),s=t.b2();if(o.canonical.equals(e.canonical))t.bO(s,0,t.Z,t.Z,0,0,1);else if(o.canonical.isChildOf(e.canonical)){const i=o.canonical.z-e.canonical.z,r=o.canonical.x-(o.canonical.x>>i<>i<>i;t.bO(s,0,n,n,0,0,1),t.L(s,s,[-r*n,-a*n,0]);}else {if(!e.canonical.isChildOf(o.canonical))continue;{const i=e.canonical.z-o.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bO(s,0,t.Z,t.Z,0,0,1),t.L(s,s,[r*n,a*n,0]),t.M(s,s,[1/2**i,1/2**i,0]);}}a.terrainRttPosMatrix32f=new Float32Array(s),i[r]=a;}return i}_getTerrainCoordsForTileRanges(e,i){const r={};for(const o of this._renderableTilesKeys){const a=this._tiles[o].tileID;if(!this._isWithinTileRanges(a,i))continue;const s=e.clone(),n=t.b2();if(a.canonical.z===e.canonical.z){const i=e.canonical.x-a.canonical.x,r=e.canonical.y-a.canonical.y;t.bO(n,0,t.Z,t.Z,0,0,1),t.L(n,n,[i*t.Z,r*t.Z,0]);}else if(a.canonical.z>e.canonical.z){const i=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>i<>i<>i),l=e.canonical.y-(a.canonical.y>>i),c=t.Z>>i;t.bO(n,0,c,c,0,0,1),t.L(n,n,[-r*c+s*t.Z,-o*c+l*t.Z,0]);}else {const i=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i)-a.canonical.x,l=(e.canonical.y>>i)-a.canonical.y,c=t.Z<i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!o||!o.dem);)o=this.sourceCache.getTileByID(e.scaledTo(r--).key);return o}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Ma{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Ia(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(e,i,r,o=t.Z){var a;if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?o=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=e.canonical.x-(e.canonical.x>>o<>o<>8<<4|e>>8,i[t+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),o=new v(e,r,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,o=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(a,n-s-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,_=(1<0,o=r&&0===e.canonical.y,a=r&&e.canonical.y===(1<e.id!==t)),this._recentlyUsed.push(e.id);}stampObject(e){e.stamp=++this._stamp;}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1;}freeAllObjects(){for(const e of this._objects)this.freeObject(e);}isFull(){return !(this._objects.length!e.inUse))}}const Sa={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ra{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Ea(e.context,30,t.sourceCache.tileSize*t.qualityFactor);}destruct(){this.pool.destruct();}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates(),r=e.sourceCaches[t].getSource(),o=r instanceof X?r.terrainTileRanges:null;for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e,o);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e]);}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],r=i.source;if(Sa[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join();}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[]);}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return !1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),o=e.type,a=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Sa[o]&&(this._prevType&&Sa[this._prevType]||this._stacks.push([]),this._prevType=o,this._stacks[this._stacks.length-1].push(e.id),!s))return !0;if(Sa[this._prevType]||Sa[o]&&s){this._prevType=o;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const o of this._renderableTiles){if(this.pool.isFull()&&(vo(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(o),o.rtt[e]){const t=this.pool.getObjectForId(o.rtt[e].id);if(t.stamp===o.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),o.rtt[e]={id:s.id,stamp:s.stamp},a.context.bindFramebuffer.set(s.fbo.framebuffer),a.context.clear({color:t.b7.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=e=>{this.move(e,n.mousePos(this.element,e));},this.mouseup=e=>{this._rotatePitchHanlder.dragEnd(e),this.offTemp();},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend));},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos));},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10,this.element=i;const o=new $o;this._rotatePitchHanlder=new Uo({clickTolerance:3,move:(e,o)=>{const a=i.getBoundingClientRect(),s=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return {bearingDelta:t.ca(new t.P(e.x,o.y),o,s),pitchDelta:r?-.5*(o.y-e.y):void 0}},moveStateManager:o,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(i,"mousedown",this.mousedown),n.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(i,"touchcancel",this.reset);}startMove(e,t){this._rotatePitchHanlder.dragStart(e,t),n.disableDrag();}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:o}=this._rotatePitchHanlder.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),o&&i.setPitch(i.getPitch()+o);}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp();}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend);}}let Fa;function Ba(e,i,r){const o=new t.Q(e.lng,e.lat);if(e=new t.Q(e.lng,e.lat),i){const o=new t.Q(e.lng-360,e.lat),a=new t.Q(e.lng+360,e.lat),s=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(o).distSqr(i)180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360;}return e.lng!==o.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:o}const Oa={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function ja(e,t,i){const r=e.classList;for(const e in Oa)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`);}class Za extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();},this._update=e=>{var t;if(!this._map)return;const i=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!i)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Ba(this._lngLat,this._flatPos,this._map.transform):null===(t=this._lngLat)||void 0===t?void 0:t.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?r=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let o="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?o="rotateX(0deg)":"map"===this._pitchAlignment&&(o=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${Oa[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${o} ${r}`),s.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type);})).catch((()=>{}));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive";},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=n.create("div");const i=n.createNS("http://www.w3.org/2000/svg","svg"),r=41,o=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${o}px`),i.setAttributeNS(null,"viewBox",`0 0 ${o} ${r}`);const a=n.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");const s=n.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=n.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=n.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t);}const h=n.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=n.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=n.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=n.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=n.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=n.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=n.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),s.appendChild(l),s.appendChild(h),s.appendChild(d),s.appendChild(p),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();})),ja(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-13.5,-1*(t-i)]}:this._offset;}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;if(!(null===(i=this._map)||void 0===i?void 0:i.terrain)){const e=this._map.transform.isLocationOccluded(this._lngLat)?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const o=this._map,a=o.terrain.depthAtPoint(this._pos),s=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,s)-a<.006)return void(this._element.style.opacity=this._opacity);const n=-this._offset.y/o.transform.pixelsPerMeter,l=Math.sin(o.getPitch()*Math.PI/180)*n,c=o.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),h=o.transform.lngLatToCameraDepth(this._lngLat,s+l)-c>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity;}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e);}removeClassName(e){this._element.classList.remove(e);}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return (void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Na={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Ga=0,Ua=!1;const Va={maxWidth:100,unit:"metric"};function qa(e,t,i){const r=i&&i.maxWidth||100,o=e._container.clientHeight/2,a=e._container.clientWidth/2,s=e.unproject([a-r/2,o]),n=e.unproject([a+r/2,o]),l=Math.round(e.project(n).x-e.project(s).x),c=Math.min(r,l,e._container.clientWidth),h=s.distanceTo(n);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Wa(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Wa(t,c,i,e._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?Wa(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Wa(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):Wa(t,c,h,e._getUIString("ScaleControl.Meters"));}function Wa(e,t,i,r){const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(o/i)+"px",e.innerHTML=`${o} ${r}`;}const $a={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Ha=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ka(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Ka(new t.P(0,0))}const Xa=i;e.AJAXError=t.cm,e.Event=t.l,e.Evented=t.E,e.LngLat=t.Q,e.MercatorCoordinate=t.$,e.Point=t.P,e.addProtocol=t.cn,e.config=t.a,e.removeProtocol=t.co,e.AttributionControl=wa,e.BoxZoomHandler=Oo,e.CanvasSource=Y,e.CooperativeGesturesHandler=ma,e.DoubleClickZoomHandler=ca,e.DragPanHandler=da,e.DragRotateHandler=_a,e.EdgeInsets=Pt,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},e.GeoJSONSource=K,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "BACKGROUND":case "BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.Q(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),a=t.e({bearing:o},this.options.fitBoundsOptions),s=V.fromLngLat(i,r);this._map.fitBounds(s,a,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.Q(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&Ua)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Za({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Za({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")));}));}},this.options=t.e({},Na,e);}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(void 0!==Fa&&!e)return Fa;if(void 0===window.navigator.permissions)return Fa=!!window.navigator.geolocation,Fa;try{const e=yield window.navigator.permissions.query({name:"geolocation"});Fa="denied"!==e.state;}catch(e){Fa=!!window.navigator.geolocation;}return Fa}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ga=0,Ua=!1;}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case "ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),r=t.distanceTo(i),o=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.l("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":Ga--,Ua=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case "BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case "WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ga++,Ga>1?(e={maximumAge:6e5,timeout:0},Ua=!0):(e=this.options.positionOptions,Ua=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon();},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"));};}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0;}},e.Hash=wo,e.ImageSource=X,e.KeyboardHandler=aa,e.LngLatBounds=V,e.LogoControl=Ta,e.Map=class extends ba{constructor(e){var i,r;t.cj.mark(t.ck.create);const o=Object.assign(Object.assign(Object.assign({},Aa),e),{canvasContextAttributes:Object.assign(Object.assign({},Aa.canvasContextAttributes),e.canvasContextAttributes)});if(null!=o.minZoom&&null!=o.maxZoom&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=o.minPitch&&null!=o.maxPitch&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=o.minPitch&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=o.maxPitch&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const a=new Dt,s=new kt;if(void 0!==o.minZoom&&a.setMinZoom(o.minZoom),void 0!==o.maxZoom&&a.setMaxZoom(o.maxZoom),void 0!==o.minPitch&&a.setMinPitch(o.minPitch),void 0!==o.maxPitch&&a.setMaxPitch(o.maxPitch),void 0!==o.renderWorldCopies&&a.setRenderWorldCopies(o.renderWorldCopies),super(a,s,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Pa,this._controls=[],this._mapId=t.a4(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.l("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=!0===o.trackResize,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=!0===o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=!0===o.crossSourceCollisions,this._collectResourceTiming=!0===o.collectResourceTiming,this._locale=Object.assign(Object.assign({},Da),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this.transformCameraUpdate=o.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===o.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=p.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(o.transformRequest),"string"==typeof o.container){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else {if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container;}if(o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})),this.once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=yo((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw());}),50);this._resizeObserver=new ResizeObserver((i=>{e?t(i):e=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new xa(this,o),this._hash=o.hash&&new wo("string"==typeof o.hash&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,t.e({},o.fitBoundsOptions,{duration:0}))));const n="string"==typeof o.style||!("globe"===(null===(r=null===(i=o.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,n),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new wa("boolean"==typeof o.attributionControl?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Ta,o.logoPosition),this.on("style.load",(()=>{if(n||this._resizeTransform(),this.transform.unmodified){const e=t.O(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e);}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.l(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.l("sourcedataabort",e));}));}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return -1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){const[r,o]=this._containerDimensions(),a=this._getClampedPixelRatio(r,o);if(this._resizeCanvas(r,o,a),this.painter.resize(r,o,a),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(r,o);this._resizeCanvas(r,o,t),this.painter.resize(r,o,t);}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e);}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,o=this.getPixelRatio(),a=e*o,s=t*o;return Math.min(a>i?i/a:1,s>r?r/s:1)*o}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(V.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.Q.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e))),s=0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[];s.length?r||(r=!0,i.call(this,new zo(e,this,o.originalEvent,{features:s}))):r=!1;};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e)));(0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[]).length?r=!0:r&&(r=!1,i.call(this,new zo(e,this,o.originalEvent)));},a=t=>{r&&(r=!1,i.call(this,new zo(e,this,t.originalEvent)));};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:a}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),o=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];o.length&&(e.features=o,i.call(this,e),delete e.features);};return {layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t);}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let e=0;et.includes(e)))){for(const e in o.delegates)this.off(e,o.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,o);for(const e in o.delegates)this.on(e,o.delegates[e]);return {unsubscribe:()=>{this._removeDelegatedListener(e,r,i);}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);for(const t in o.delegates){const a=o.delegates[t];o.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),a(...t);};}this._saveDelegatedListener(e,o);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return [];let r;const o=e instanceof t.P||Array.isArray(e),a=o?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(o?{}:e)||{},a instanceof t.P||"number"==typeof a[0])r=[t.P.convert(a)];else {const e=t.P.convert(a[0]),i=t.P.convert(a[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e];}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return !1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new gi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new gi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,"Style");t.j(r,new AbortController).then((e=>{this._updateDiff(e.data,i);})).catch((e=>{e&&this.fire(new t.k(e));}));}else "object"==typeof e&&this._updateDiff(e,i);}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no source with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new Ma(this.painter,i,e),this.painter.renderToTexture=new Ra(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(e,i,r={}){const{pixelRatio:o=1,sdf:a=!1,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:s,data:d}=i,_=i;return this.style.addImage(e,{data:new t.R({width:r,height:s},new Uint8Array(d)),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0,userImage:_}),_.onAdd&&_.onAdd(this,e),this}}{const{width:r,height:d,data:_}=s.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},_),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0});}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||t.b(i)?s.getImageData(i):i,{width:a,height:n,data:l}=o;if(void 0===a||void 0===n)return this.fire(new t.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(a!==r.data.width||n!==r.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e){return p.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,(e=>{e||this._update(!0);})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0);})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const o=this._controlContainer=n.create("div","maplibregl-control-container",e),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{a[e]=n.create("div",`maplibregl-ctrl-${e} `,o);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type);}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new bo(i,this.transform),l.testSupport(i);}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}));}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_render(e){var i,r,o,a,n;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=s.now();this.style.zoomHistory.update(e,i);const r=new t.C(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=r.crossFadingFactor();1===o&&o===this._crossFadingFactor||(h=!0,this._crossFadingFactor=o),this.style.update(r);}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(o=this.style.projection)||void 0===o||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(a=this.style.projection)||void 0===a?void 0:a.transitionState,null===(n=this.style.projection)||void 0===n?void 0:n.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cj.mark(t.ck.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cj.mark(t.ck.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),p.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cj.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(e=>{t.cj.frame(e),this._frameRequest=null;try{this._render(e);}catch(e){if(!t.cl(e)&&!function(e){return e.message===jr}(e))throw e}}),(()=>{})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get version(){return za}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=zo,e.MapTouchEvent=Ao,e.MapWheelEvent=Lo,e.Marker=Za,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`;},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i);},this.options=t.e({},La,e),this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e});})),this._compassIcon=n.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ka(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(e,t){const i=n.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:void 0);},this.remove=()=>(this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._closeButton&&this._closeButton.removeEventListener("click",this._onClose),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point);},this._onMouseMove=e=>{this._update(e.point);},this._onDrag=e=>{this._update(e.point);},this._update=e=>{var t;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?Ba(this._lngLat,this._flatPos,this._map.transform):null===(t=this._lngLat)||void 0===t?void 0:t.wrap(),this._trackPointer&&!e)return;const i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor;const o=Ka(this.options.offset);if(!r){const e=this._container.offsetWidth,t=this._container.offsetHeight;let a;a=i.y+o.bottom.ythis._map.transform.height-t?["bottom"]:[],i.xthis._map.transform.width-e/2&&a.push("right"),r=0===a.length?"bottom":a.join("-");}let a=i.add(o[r]);this.options.subpixelPositioning||(a=a.round()),n.setTransform(this._container,`${Oa[r]} translate(${a.x}px,${a.y}px)`),ja(this._container,r,"popup"),this._updateOpacity();},this._onClose=()=>{this.remove();},this.options=t.e(Object.create($a),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Ha);e&&e.focus();}},e.RasterDEMTileSource=H,e.RasterTileSource=$,e.ScaleControl=class{constructor(e){this._onMove=()=>{qa(this._map,this._container,this.options);},this.setUnit=e=>{this.options.unit=e,qa(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},Va),e);}getDefaultPosition(){return "bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},e.ScrollZoomHandler=la,e.Style=gi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=e;}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},e.TwoFingersTouchPitchHandler=ra,e.TwoFingersTouchRotateHandler=ta,e.TwoFingersTouchZoomHandler=Jo,e.TwoFingersTouchZoomRotateHandler=pa,e.VectorTileSource=W,e.VideoSource=Q,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,(function*(){if(ee(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{J[e]=t;})(e,i);})),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(D),L=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},e.createTileMesh=Wt,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return oe().getRTLTextPluginStatus()},e.getVersion=function(){return Xa},e.getWorkerCount=function(){return z.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return O().broadcast("IS",e)},e.prewarm=function(){F().acquire(D);},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e;},e.setRTLTextPlugin=function(e,t){return oe().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){z.workerCount=e;},e.setWorkerUrl=function(e){t.a.WORKER_URL=e;};})); + +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + + +var maplibregl$1 = maplibregl; + +return maplibregl$1; + +})); +//# sourceMappingURL=maplibre-gl.js.map diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.5.0/LICENSE.txt b/docs/articles/layers-overview_files/maplibre-gl-5.5.0/LICENSE.txt new file mode 100644 index 00000000..1e8acbb5 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.5.0/LICENSE.txt @@ -0,0 +1,116 @@ +Copyright (c) 2023, MapLibre contributors + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of MapLibre GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from mapbox-gl-js v1.13 and earlier + +Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license + +Copyright (c) 2020, Mapbox +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Mapbox GL JS nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +------------------------------------------------------------------------------- + +Contains code from glfx.js + +Copyright (C) 2011 by Evan Wallace + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------------------------------------------------------------------- + +Contains a portion of d3-color https://github.com/d3/d3-color + +Copyright 2010-2016 Mike Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the author nor the names of contributors may be used to + endorse or promote products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.5.0/maplibre-gl.css b/docs/articles/layers-overview_files/maplibre-gl-5.5.0/maplibre-gl.css new file mode 100644 index 00000000..aa4f4650 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.5.0/maplibre-gl.css @@ -0,0 +1 @@ +.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file diff --git a/docs/articles/layers-overview_files/maplibre-gl-5.5.0/maplibre-gl.js b/docs/articles/layers-overview_files/maplibre-gl-5.5.0/maplibre-gl.js new file mode 100644 index 00000000..fd0c3b11 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibre-gl-5.5.0/maplibre-gl.js @@ -0,0 +1,59 @@ +/** + * MapLibre GL JS + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.5.0/LICENSE.txt + */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.maplibregl = factory()); +})(this, (function () { 'use strict'; + +/* eslint-disable */ + +var maplibregl = {}; +var modules = {}; +function define(moduleName, _dependencies, moduleFactory) { + modules[moduleName] = moduleFactory; + + // to get the list of modules see generated dist/maplibre-gl-dev.js file (look for `define(` calls) + if (moduleName !== 'index') { + return; + } + + // we assume that when an index module is initializing then other modules are loaded already + var workerBundleString = 'var sharedModule = {}; (' + modules.shared + ')(sharedModule); (' + modules.worker + ')(sharedModule);' + + var sharedModule = {}; + // the order of arguments of a module factory depends on rollup (it decides who is whose dependency) + // to check the correct order, see dist/maplibre-gl-dev.js file (look for `define(` calls) + // we assume that for our 3 chunks it will generate 3 modules and their order is predefined like the following + modules.shared(sharedModule); + modules.index(maplibregl, sharedModule); + + if (typeof window !== 'undefined') { + maplibregl.setWorkerUrl(window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }))); + } + + return maplibregl; +}; + + + +define("shared",["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t));}catch(t){s(t);}}function o(t){try{l(n.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(a,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n,i;function s(){if(i)return n;function t(t,e){this.x=t,this.y=e;}return i=1,n=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},n}"function"==typeof SuppressedError&&SuppressedError;var a,o,l=r(s()),u=function(){if(o)return a;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return o=1,a=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},a}(),c=r(u);let h,p;function f(){return null==h&&(h="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),h}function d(){if(null==p&&(p=!1,f())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function E(t,e,r,n){const i=new c(t,e,r,n);return t=>i.solve(t)}const T=E(.25,.1,.25,1);function F(t,e,r){return Math.min(r,Math.max(e,t))}function $(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function L(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let O=1;function D(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function j(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function R(t){return Array.isArray(t)?t.map(R):"object"==typeof t&&t?D(t,R):t}const N={};function U(t){N[t]||("undefined"!=typeof console&&console.warn(t),N[t]=!0);}function q(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function G(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let Z=null;function K(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const X="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function H(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,r,n,i){const s=4*Math.max(1,0),a=(Math.max(0,r)-r)*n*4+s,o=4*n,l=Math.max(0,e),u=Math.max(0,r);return {rect:{x:l,y:u,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-u},layout:[{offset:a,stride:o}]}}(t,r,n,i,s)),o)for(let t=0;t{t.removeEventListener(e,r,n);}}}function Q(t){return t*Math.PI/180}function tt(t){return t/Math.PI*180}const et={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},rt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},nt="AbortError";function it(){return new Error(nt)}const st={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function at(t){return st.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const ot="global-dispatcher";class lt extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n;}}const ut=()=>G(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ct=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=at(t.url);if(e)return e(t,r);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:ot},r)}if(!(/^file:/.test(n=t.url)||/^file:/.test(ut())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:ut(),signal:r.signal});let n,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e);}catch(e){throw new lt(0,e.message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new lt(n.status,n.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw it();return {data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:ot},r)}var n;return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new lt(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),n(it());})),s.send(t.body);}))}(t,r)};function ht(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function pt(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function ft(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class dt{constructor(t,e={}){L(this,e),this.type=t;}}class yt extends dt{constructor(t,e={}){super("error",L({error:t},e));}}class mt{on(t,e){return this._listeners=this._listeners||{},pt(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e);}}}off(t,e){return ft(t,e,this._listeners),ft(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},pt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new dt(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)ft(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(L(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof yt&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var gt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const xt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function vt(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return xt.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function bt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Yt=[Et,Tt,Ft,$t,Lt,Ot,Nt,Dt,Xt(jt),Ut,Gt,qt,Zt,Kt];function Jt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Jt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Yt)if(!Jt(t,e))return null}return `Expected ${Ht(t)} but found ${Ht(e)} instead.`}function Wt(t,e){return e.some((e=>e.kind===t.kind))}function Qt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function te(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const ee=.96422,re=.82521,ne=4/29,ie=6/29,se=3*ie*ie,ae=ie*ie*ie,oe=Math.PI/180,le=180/Math.PI;function ue(t){return (t%=360)<0&&(t+=360),t}function ce([t,e,r,n]){let i,s;const a=pe((.2225045*(t=he(t))+.7168786*(e=he(e))+.0606169*(r=he(r)))/1);t===e&&e===r?i=s=a:(i=pe((.4360747*t+.3850649*e+.1430804*r)/ee),s=pe((.0139322*t+.0971045*e+.7141733*r)/re));const o=116*a-16;return [o<0?0:o,500*(i-a),200*(a-s),n]}function he(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pe(t){return t>ae?Math.pow(t,1/3):t/se+ne}function fe([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*ye(i),s=ee*ye(s),a=re*ye(a),[de(3.1338561*s-1.6168667*i-.4906146*a),de(-.9787684*s+1.9161415*i+.033454*a),de(.0719453*s-.2289914*i+1.4052427*a),n]}function de(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ye(t){return t>ie?t*t*t:se*(t-ne)}const me=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function ge(t,e){return me(t,e)?t[e]:void 0}function xe(t){return parseInt(t.padEnd(2,t),16)/255}function ve(t,e){return be(e?t/100:t,0,1)}function be(t,e,r){return Math.min(Math.max(e,t),r)}function we(t){return !t.some(Number.isNaN)}const _e={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Ae(t,e,r){return t+r*(e-t)}function Se(t,e,r){return t.map(((t,n)=>Ae(t,e[n],r)))}class ke{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof ke)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=ge(_e,t);if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [xe(t.slice(r,r+=e)),xe(t.slice(r,r+=e)),xe(t.slice(r,r+=e)),xe(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[be(+r/e,0,1),be(+s/e,0,1),be(+l/e,0,1),h?ve(+h,p):1];if(we(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,be(+i,0,100),be(+a,0,100),l?ve(+l,u):1];if(we(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=ue(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new ke(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=ce(t),s=Math.sqrt(r*r+n*n);return [Math.round(1e4*s)?ue(Math.atan2(n,r)*le):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ce(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}static interpolate(t,e,r,n="rgb"){switch(n){case "rgb":{const[n,i,s,a]=Se(t.rgb,e.rgb,r);return new ke(n,i,s,a,!1)}case "hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*oe,fe([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:Ae(i,l,r),Ae(s,u,r),Ae(a,c,r)]);return new ke(f,d,y,m,!1)}case "lab":{const[n,i,s,a]=fe(Se(t.lab,e.lab,r));return new ke(n,i,s,a,!1)}}}}ke.black=new ke(0,0,0,1),ke.white=new ke(1,1,1,1),ke.transparent=new ke(0,0,0,0),ke.red=new ke(1,0,0,1);class Me{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Ie=["bottom","center","top"];class ze{constructor(t,e,r,n,i,s){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i,this.verticalAlign=s;}}class Pe{constructor(t){this.sections=t;}static fromString(t){return new Pe([new ze(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Pe?t:Pe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Ce{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Ce)return t;if("number"==typeof t)return new Ce([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new Ce(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new Ce(Se(t.values,e.values,r))}}class Be{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Be)return t;if("number"==typeof t)return new Be([t]);if(Array.isArray(t)){for(const e of t)if("number"!=typeof e)return;return new Be(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new Be(Se(t.values,e.values,r))}}class Ve{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Ve)return t;if("string"==typeof t){const e=ke.parse(t);if(!e)return;return new Ve([e])}if(!Array.isArray(t))return;const e=[];for(const r of t){if("string"!=typeof r)return;const t=ke.parse(r);if(!t)return;e.push(t);}return new Ve(e)}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r,n="rgb"){const i=[];if(t.values.length!=e.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${e.values.length}), cannot interpolate.`);for(let s=0;s=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function De(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Le||t instanceof ke||t instanceof Me||t instanceof Pe||t instanceof Ce||t instanceof Be||t instanceof Ve||t instanceof Fe||t instanceof $e)return !0;if(Array.isArray(t)){for(const e of t)if(!De(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!De(t[e]))return !1;return !0}return !1}function je(t){if(null===t)return Et;if("string"==typeof t)return Ft;if("boolean"==typeof t)return $t;if("number"==typeof t)return Tt;if(t instanceof ke)return Lt;if(t instanceof Le)return Ot;if(t instanceof Me)return Rt;if(t instanceof Pe)return Nt;if(t instanceof Ce)return Ut;if(t instanceof Be)return Gt;if(t instanceof Ve)return qt;if(t instanceof Fe)return Kt;if(t instanceof $e)return Zt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=je(e);if(r){if(r===t)continue;r=jt;break}r=t;}return Xt(r||jt,e)}return Dt}function Re(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ke||t instanceof Le||t instanceof Pe||t instanceof Ce||t instanceof Be||t instanceof Ve||t instanceof Fe||t instanceof $e?t.toString():JSON.stringify(t)}class Ne{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!De(t[1]))return e.error("invalid value");const r=t[1];let n=je(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Ne(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}const Ue={string:Ft,number:Tt,boolean:$t,object:Dt};class qe{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in Ue)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Ue[r],n++;}else i=jt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=Xt(i,s);}else {if(!Ue[i])throw new Error(`Types doesn't contain name = ${i}`);r=Ue[i];}const s=[];for(;nt.outputDefined()))}}const Ge={"to-boolean":$t,"to-color":Lt,"to-number":Tt,"to-string":Ft};class Ze{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!Ge[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=Ge[r],i=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Oe(e[0],e[1],e[2],e[3]),!r))return new ke(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ee(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=Ce.parse(e);if(n)return n}throw new Ee(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "numberArray":{let e;for(const r of this.args){e=r.evaluate(t);const n=Be.parse(e);if(n)return n}throw new Ee(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "colorArray":{let e;for(const r of this.args){e=r.evaluate(t);const n=Ve.parse(e);if(n)return n}throw new Ee(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=Fe.parse(e);if(n)return n}throw new Ee(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new Ee(`Could not convert ${JSON.stringify(e)} to number.`)}case "formatted":return Pe.fromString(Re(this.args[0].evaluate(t)));case "resolvedImage":return $e.fromString(Re(this.args[0].evaluate(t)));case "projectionDefinition":return this.args[0].evaluate(t);default:return Re(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ke=["Unknown","Point","LineString","Polygon"];class Xe{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null;}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ke[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=ke.parse(t),this._parseColorCache.set(t,e)),e}}class He{constructor(t,e,r=[],n,i=new Vt,s=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new qe(e,[t]):"coerce"===r?new Ze(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(i.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(i.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(i.kind)||"colorArray"===t.kind&&["value","string","array"].includes(i.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(i.kind))n=r(n,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof Ne)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Xe;try{n=new Ne(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new He(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Bt(r,t));}checkSubtype(t,e){const r=Jt(t,e);return r&&this.error(r),r}}class Ye{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new Ee(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new Ee(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class Qe{constructor(t,e){this.type=$t,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,jt);return r&&n?Wt(r.type,[$t,Ft,Tt,Et,jt])?new Qe(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!Qt(e,["boolean","string","number","null"]))throw new Ee(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(je(e))} instead.`);if(!Qt(r,["string","array"]))throw new Ee(`Expected second argument to be of type array or string, but found ${Ht(je(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class tr{constructor(t,e,r){this.type=Tt,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,jt);if(!r||!n)return null;if(!Wt(r.type,[$t,Ft,Tt,Et,jt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Tt);return i?new tr(r,n,i):null}return new tr(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Qt(e,["boolean","string","number","null"]))throw new Ee(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(je(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),Qt(r,["string"])){const t=r.indexOf(e,n);return -1===t?-1:[...r.slice(0,t)].length}if(Qt(r,["array"]))return r.indexOf(e,n);throw new Ee(`Expected second argument to be of type array or string, but found ${Ht(je(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class er{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,je(t)))return null}else r=je(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,jt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new er(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (je(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class rr{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class nr{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,Tt);if(!r||!n)return null;if(!Wt(r.type,[Xt(jt),Ft,jt]))return e.error(`Expected first argument to be of type array or string, but found ${Ht(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Tt);return i?new nr(r.type,r,n,i):null}return new nr(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),Qt(e,["string"]))return [...e].slice(r,n).join("");if(Qt(e,["array"]))return e.slice(r,n);throw new Ee(`Expected first argument to be of type array or string, but found ${Ht(je(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function ir(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new Ee("Input is not a number.");a=o-1;}return 0}class sr{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,Tt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new sr(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[ir(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function ar(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var or,lr,ur=function(){if(lr)return or;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return lr=1,or=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},or}(),cr=ar(ur);class hr{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=pr(e,t.base,r,n);else if("linear"===t.name)i=pr(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new cr(s[0],s[1],s[2],s[3]).solve(pr(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Tt),!i)return null;const a=[];let o=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||e.expectedType==qt?e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType):o=Lt;for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return te(o,Tt)||te(o,Ot)||te(o,Lt)||te(o,Ut)||te(o,Gt)||te(o,qt)||te(o,Kt)||te(o,Xt(Tt))?new hr(o,r,n,i,a):e.error(`Type ${Ht(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=ir(e,n),a=hr.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case "interpolate":switch(this.type.kind){case "number":return Ae(o,l,a);case "color":return ke.interpolate(o,l,a);case "padding":return Ce.interpolate(o,l,a);case "colorArray":return Ve.interpolate(o,l,a);case "numberArray":return Be.interpolate(o,l,a);case "variableAnchorOffsetCollection":return Fe.interpolate(o,l,a);case "array":return Se(o,l,a);case "projectionDefinition":return Le.interpolate(o,l,a)}case "interpolate-hcl":switch(this.type.kind){case "color":return ke.interpolate(o,l,a,"hcl");case "colorArray":return Ve.interpolate(o,l,a,"hcl")}case "interpolate-lab":switch(this.type.kind){case "color":return ke.interpolate(o,l,a,"lab");case "colorArray":return Ve.interpolate(o,l,a,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function pr(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}const fr={color:ke.interpolate,number:Ae,padding:Ce.interpolate,numberArray:Be.interpolate,colorArray:Ve.interpolate,variableAnchorOffsetCollection:Fe.interpolate,array:Se};class dr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const s=n&&i.some((t=>Jt(n,t.type)));return new dr(s?jt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof $e&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function yr(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function mr(t,e,r,n){return 0===n.compare(e,r)}function gr(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=$t,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,jt);if(!s)return null;if(!yr(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${Ht(s.type)}'.`);let a=e.parse(t[2],2,jt);if(!a)return null;if(!yr(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${Ht(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Ht(s.type)}' and '${Ht(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new qe(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new qe(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Rt),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=je(s),r=je(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ee(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=je(s),r=je(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const xr=gr("==",(function(t,e,r){return e===r}),mr),vr=gr("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !mr(0,e,r,n)})),br=gr("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),_r=gr("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),Ar=gr(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class Sr{constructor(t,e,r){this.type=Rt,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,$t);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,$t);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,Ft),!s)?null:new Sr(n,i,s)}evaluate(t){return new Me(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class kr{constructor(t,e,r,n,i){this.type=Ft,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Tt);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,Ft),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Ft),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Tt),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,Tt),!o)?null:new kr(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class Mr{constructor(t){this.type=Nt,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Tt),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,Xt(Ft)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,Lt),!a))return null;let o=null;if(s["vertical-align"]){if("string"==typeof s["vertical-align"]&&!Ie.includes(s["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(o=e.parse(s["vertical-align"],1,Ft),!o)return null}const l=n[n.length-1];l.scale=t,l.font=r,l.textColor=a,l.verticalAlign=o;}else {const s=e.parse(t[r],1,jt);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null});}}return new Mr(n)}evaluate(t){return new Pe(this.sections.map((e=>{const r=e.content.evaluate(t);return je(r)===Zt?new ze("",r,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new ze(Re(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign);}outputDefined(){return !1}}class Ir{constructor(t){this.type=Zt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Ft);return r?new Ir(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=$e.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class zr{constructor(t){this.type=Tt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${Ht(r.type)} instead.`):new zr(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new Ee(`Expected value to be of type string or array, but found ${Ht(je(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const Pr=8192;function Cr(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*Pr),Math.round(n*i*Pr)]}function Br(t,e){const r=Math.pow(2,e.z);return [(i=(t[0]/Pr+e.x)/r,360*i-180),(n=(t[1]/Pr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i;}function Vr(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function Er(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Tr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Fr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Rr(t,e,r,n)||!Rr(r,n,t,e));var i,s;}function $r(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(a=o[e+1])[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}var i,s,a;return n}function Or(t,e){for(const r of e)if(Lr(t,r))return !0;return !1}function Dr(t,e){for(const r of t)if(!Lr(r,e))return !1;for(let r=0;r0&&o<0||a<0&&o>0}function Nr(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Vr(e,t);}function Gr(t,e,r,n){const i=Math.pow(2,n.z)*Pr,s=[n.x*Pr,n.y*Pr],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];qr(n,e,r,i),a.push(n);}return a}function Zr(t,e,r,n){const i=Math.pow(2,n.z)*Pr,s=[n.x*Pr,n.y*Pr],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Vr(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)qr(n,e,r,i);}var o;return a}class Kr{constructor(t,e){this.type=$t,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(De(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n);}if(t.length)return new Kr(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Kr(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Kr(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Nr(e.coordinates,n,i),a=Gr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Lr(t,s))return !1}if("MultiPolygon"===e.type){const s=Ur(e.coordinates,n,i),a=Gr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Or(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Nr(e.coordinates,n,i),a=Zr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Dr(t,s))return !1}if("MultiPolygon"===e.type){const s=Ur(e.coordinates,n,i),a=Zr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!jr(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let Xr=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}};function Hr(t,e,r=0,n=t.length-1,i=Jr){for(;n>r;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Hr(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(Yr(t,r,e),i(t[n],s)>0&&Yr(t,r,n);a0;)o--;}0===i(t[r],s)?Yr(t,r,o):(o++,Yr(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function Yr(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Jr(t,e){return te?1:0}function Wr(t,e){if(t.length<=1)return [t];const r=[];let n,i;for(const e of t){const t=tn(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e));}if(n&&r.push(n),e>1)for(let t=0;t1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function an(t,e){return e[0]-t[0]}function on(t){return t[1]-t[0]+1}function ln(t,e){return t[1]>=t[0]&&t[1]t[1])return [null,null];const r=on(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return [t,null];const n=Math.floor(r/2)-1;return [[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function cn(t,e){if(!ln(e,t.length))return [1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)Vr(r,t[n]);return r}function hn(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)Vr(e,t);return e}function pn(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function fn(t,e,r){if(!pn(t)||!pn(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Er(i,s)){if(bn(t,e))return 0}else if(bn(e,t))return 0;let a=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=a.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(on(l)<=u){if(!ln(l,t.length))return NaN;if(e){const e=vn(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=xn(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else {const r=un(l,e);_n(a,s,n,t,o,r[0]),_n(a,s,n,t,o,r[1]);}}return s}function kn(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new Xr([[0,[0,t.length-1],[0,r.length-1]]],an);for(;o.length>0;){const s=o.pop();if(s[0]>=a)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(on(l)<=c&&on(u)<=h){if(!ln(l,t.length)&&ln(u,r.length))return NaN;let s;if(e&&n)s=mn(t,l,r,u,i),a=Math.min(a,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=dn(r[t],e,i),a=Math.min(a,s),0===a)return a}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=dn(t[r],e,i),a=Math.min(a,s),0===a)return a}else s=gn(t,l,r,u,i),a=Math.min(a,s);}else {const s=un(l,e),c=un(u,n);An(o,a,i,t,r,s[0],c[0]),An(o,a,i,t,r,s[0],c[1]),An(o,a,i,t,r,s[1],c[0]),An(o,a,i,t,r,s[1],c[1]);}}return a}function Mn(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class In{constructor(t,e){this.type=Tt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(De(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new In(e,e.features.map((t=>Mn(t.geometry))).flat());if("Feature"===e.type)return new In(e,Mn(e.geometry));if("type"in e&&"coordinates"in e)return new In(e,Mn(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>Br([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new sn(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,kn(n,!1,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,kn(n,!1,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,Sn(n,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>Br([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new sn(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,kn(n,!0,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,kn(n,!0,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,Sn(n,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Wr(r,0).map((e=>e.map((e=>e.map((e=>Br([e.x,e.y],t.canonical))))))),i=new sn(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case "Point":s=Math.min(s,Sn([t.coordinates],!1,e,i,s));break;case "LineString":s=Math.min(s,Sn(t.coordinates,!0,e,i,s));break;case "Polygon":s=Math.min(s,wn(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}class zn{constructor(t){this.type=jt,this.key=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=t[1];return null==r?e.error("Global state property must be defined."):"string"!=typeof r?e.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new zn(r)}evaluate(t){var e;const r=null===(e=t.globals)||void 0===e?void 0:e.globalState;return r&&0!==Object.keys(r).length?ge(r,this.key):null}eachChild(){}outputDefined(){return !1}}const Pn={"==":xr,"!=":vr,">":wr,"<":br,">=":Ar,"<=":_r,array:qe,at:We,boolean:qe,case:rr,coalesce:dr,collator:Sr,format:Mr,image:Ir,in:Qe,"index-of":tr,interpolate:hr,"interpolate-hcl":hr,"interpolate-lab":hr,length:zr,let:Ye,literal:Ne,match:er,number:qe,"number-format":kr,object:qe,slice:nr,step:sr,string:qe,"to-boolean":Ze,"to-color":Ze,"to-number":Ze,"to-string":Ze,var:Je,within:Kr,distance:In,"global-state":zn};class Cn{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const r=t[0],n=Cn.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new He(e.registry,Fn,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(Ht).join(", ")})`:`(${Ht(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&Fn(t):r&&t instanceof Ne;})),!!r&&$n(t)&&On(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function $n(t){if(t instanceof Cn){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Kr)return !1;if(t instanceof In)return !1;let e=!0;return t.eachChild((t=>{e&&!$n(t)&&(e=!1);})),e}function Ln(t){if(t instanceof Cn&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!Ln(t)&&(e=!1);})),e}function On(t,e){if(t instanceof Cn&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!On(t,e)&&(r=!1);})),r}function Dn(t){return {result:"success",value:t}}function jn(t){return {result:"error",value:t}}function Rn(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Nn(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Un(t){return !!t.expression&&t.expression.interpolated}function qn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Gn(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)&&je(t)===Dt}function Zn(t){return t}function Kn(t,e){const r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),i=t.type||(Un(e)?"exponential":"interval"),s=function(t){switch(t.type){case "color":return ke.parse;case "padding":return Ce.parse;case "numberArray":return Be.parse;case "colorArray":return Ve.parse;default:return null}}(e);if(s&&((t=Ct({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],s(t[1])]))),t.default=s(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;const o=function(t){switch(t){case "exponential":return Jn;case "interval":return Yn;case "categorical":return Hn;case "identity":return Wn;default:throw new Error(`Unknown function type "${t}"`)}}(i);let l,u;if("categorical"===i){l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}if(r){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Jn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(n){const r="exponential"===i?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:hr.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Xn(t.default,e.default):o(t,e,i,l,u)}}}function Xn(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Hn(t,e,r,n,i){return Xn(typeof r===i?n[r]:void 0,t.default,e.default)}function Yn(t,e,r){if("number"!==qn(r))return Xn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=ir(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Jn(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==qn(r))return Xn(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=ir(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=fr[e.type]||Zn;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function Wn(t,e,r){switch(e.type){case "color":r=ke.parse(r);break;case "formatted":r=Pe.fromString(r.toString());break;case "resolvedImage":r=$e.fromString(r.toString());break;case "padding":r=Ce.parse(r);break;case "colorArray":r=Ve.parse(r);break;case "numberArray":r=Be.parse(r);break;default:qn(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return Xn(r,t.default,e.default)}Cn.register(Pn,{error:[{kind:"error"},[Ft],(t,[e])=>{throw new Ee(e.evaluate(t))}],typeof:[Ft,[jt],(t,[e])=>Ht(je(e.evaluate(t)))],"to-rgba":[Xt(Tt,4),[Lt],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return [255*r,255*n,255*i,s]}],rgb:[Lt,[Tt,Tt,Tt],Bn],rgba:[Lt,[Tt,Tt,Tt,Tt],Bn],has:{type:$t,overloads:[[[Ft],(t,[e])=>Vn(e.evaluate(t),t.properties())],[[Ft,Dt],(t,[e,r])=>Vn(e.evaluate(t),r.evaluate(t))]]},get:{type:jt,overloads:[[[Ft],(t,[e])=>En(e.evaluate(t),t.properties())],[[Ft,Dt],(t,[e,r])=>En(e.evaluate(t),r.evaluate(t))]]},"feature-state":[jt,[Ft],(t,[e])=>En(e.evaluate(t),t.featureState||{})],properties:[Dt,[],t=>t.properties()],"geometry-type":[Ft,[],t=>t.geometryType()],id:[jt,[],t=>t.id()],zoom:[Tt,[],t=>t.globals.zoom],"heatmap-density":[Tt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Tt,[],t=>t.globals.lineProgress||0],accumulated:[jt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Tt,Tn(Tt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[Tt,Tn(Tt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:Tt,overloads:[[[Tt,Tt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Tt],(t,[e])=>-e.evaluate(t)]]},"/":[Tt,[Tt,Tt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Tt,[Tt,Tt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Tt,[],()=>Math.LN2],pi:[Tt,[],()=>Math.PI],e:[Tt,[],()=>Math.E],"^":[Tt,[Tt,Tt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Tt,[Tt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Tt,[Tt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Tt,[Tt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Tt,[Tt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Tt,[Tt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Tt,[Tt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Tt,[Tt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Tt,Tn(Tt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Tt,Tn(Tt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Tt,[Tt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Tt,[Tt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Tt,[Tt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Tt,[Tt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[$t,[Ft,jt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[$t,[jt],(t,[e])=>t.id()===e.value],"filter-type-==":[$t,[Ft],(t,[e])=>t.geometryType()===e.value],"filter-<":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[$t,[jt],(t,[e])=>e.value in t.properties()],"filter-has-id":[$t,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[$t,[Xt(Ft)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[$t,[Xt(jt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[$t,[Ft,Xt(jt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[$t,[Ft,Xt(jt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:$t,overloads:[[[$t,$t],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Tn($t),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:$t,overloads:[[[$t,$t],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Tn($t),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[$t,[$t],(t,[e])=>!e.evaluate(t)],"is-supported-script":[$t,[Ft],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Ft,[Ft],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Ft,[Ft],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Ft,Tn(jt),(t,e)=>e.map((e=>Re(e.evaluate(t)))).join("")],"resolved-locale":[Ft,[Rt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Qn{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Xe,this._defaultValue=e?function(t){if("color"===t.type&&Gn(t.default))return new ke(0,0,0,0);switch(t.type){case "color":return ke.parse(t.default)||null;case "padding":return Ce.parse(t.default)||null;case "numberArray":return Be.parse(t.default)||null;case "colorArray":return Ve.parse(t.default)||null;case "variableAnchorOffsetCollection":return Fe.parse(t.default)||null;case "projectionDefinition":return Le.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ee(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ti(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Pn}function ei(t,e){const r=new He(Pn,Fn,[],e?function(t){const e={color:Lt,string:Ft,number:Tt,enum:Ft,boolean:$t,formatted:Nt,padding:Ut,numberArray:Gt,colorArray:qt,projectionDefinition:Ot,resolvedImage:Zt,variableAnchorOffsetCollection:Kt};return "array"===t.type?Xt(e[t.value]||jt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Dn(new Qn(n,e)):jn(r.errors)}class ri{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Ln(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class ni{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Ln(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?hr.interpolationFactor(this.interpolationType,t,e,r):0}}function ii(t,e){const r=ei(t,e);if("error"===r.result)return r;const n=r.value.expression,i=$n(n);if(!i&&!Rn(e))return jn([new Bt("","data expressions not supported")]);const s=On(n,["zoom"]);if(!s&&!Nn(e))return jn([new Bt("","zoom expressions not supported")]);const a=ai(n);return a||s?a instanceof Bt?jn([a]):a instanceof hr&&!Un(e)?jn([new Bt("",'"interpolate" expressions cannot be used with this property')]):Dn(a?new ni(i?"camera":"composite",r.value,a.labels,a instanceof hr?a.interpolation:void 0):new ri(i?"constant":"source",r.value)):jn([new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class si{constructor(t,e){this._parameters=t,this._specification=e,Ct(this,Kn(this._parameters,this._specification));}static deserialize(t){return new si(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function ai(t){let e=null;if(t instanceof Ye)e=ai(t.result);else if(t instanceof dr){for(const r of t.args)if(e=ai(r),e)break}else (t instanceof sr||t instanceof hr)&&t.input instanceof Cn&&"zoom"===t.input.name&&(e=t);return e instanceof Bt||t.eachChild((t=>{const r=ai(t);r instanceof Bt?e=r:!e&&r?e=new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new Bt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function oi(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case "has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case "in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case "any":case "all":for(const e of t.slice(1))if(!oi(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const li={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ui(t){if(null==t)return {filter:()=>!0,needGeometry:!1};oi(t)||(t=pi(t));const e=ei(t,li);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:hi(t)}}function ci(t,e){return te?1:0}function hi(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?fi(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(pi))):"all"===e?["all"].concat(t.slice(1).map(pi)):"none"===e?["all"].concat(t.slice(1).map(pi).map(mi)):"in"===e?di(t[1],t.slice(2)):"!in"===e?mi(di(t[1],t.slice(2))):"has"===e?yi(t[1]):"!has"!==e||mi(yi(t[1]));var r;}function fi(t,e,r){switch(t){case "$type":return [`filter-type-${r}`,e];case "$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function di(t,e){if(0===e.length)return !1;switch(t){case "$type":return ["filter-type-in",["literal",e]];case "$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ci)]]:["filter-in-small",t,["literal",e]]}}function yi(t){switch(t){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",t]}}function mi(t){return ["!",t]}function gi(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${gi(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new Pt(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function ki(t){const e=t.valueSpec,r=bi(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===qn(t.value.stops)&&"array"===qn(t.value.stops[0])&&"object"===qn(t.value.stops[0][0]),c=_i({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new Pt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(Ai({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===qn(n)&&0===n.length&&e.push(new Pt(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new Pt(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new Pt(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!Un(t.valueSpec)&&c.push(new Pt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Rn(t.valueSpec)?c.push(new Pt(t.key,t.value,"property functions not supported")):o&&!Nn(t.valueSpec)&&c.push(new Pt(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new Pt(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==qn(n))return [new Pt(o,n,`array expected, ${qn(n)} found`)];if(2!==n.length)return [new Pt(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==qn(n[0]))return [new Pt(o,n,`object expected, ${qn(n[0])} found`)];if(void 0===n[0].zoom)return [new Pt(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new Pt(o,n,"object stop key must have value")];if(s&&s>bi(n[0].zoom))return [new Pt(o,n[0].zoom,"stop zoom values must appear in ascending order")];bi(n[0].zoom)!==s&&(s=bi(n[0].zoom),i=void 0,a={}),r=r.concat(_i({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Si,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return ti(wi(n[1]))?r.concat([new Pt(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=qn(t.value),l=bi(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return [new Pt(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new Pt(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return Rn(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Pt(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew Pt(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new Pt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Ln(r))return [new Pt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Ln(r))return [new Pt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!On(r,["zoom","feature-state"]))return [new Pt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!$n(r))return [new Pt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function Ii(t){const e=t.key,r=t.value,n=qn(r);return "string"!==n?[new Pt(e,r,`color expected, ${n} found`)]:ke.parse(String(r))?[]:[new Pt(e,r,`color expected, "${r}" found`)]}function zi(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(bi(r))&&i.push(new Pt(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(bi(r))&&i.push(new Pt(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function Pi(t){return oi(wi(t.value))?Mi(Ct({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ci(t)}function Ci(t){const e=t.value,r=t.key;if("array"!==qn(e))return [new Pt(r,e,`array expected, ${qn(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return [new Pt(r,e,"filter array must have at least 1 element")];switch(s=s.concat(zi({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),bi(e[0])){case "<":case "<=":case ">":case ">=":e.length>=2&&"$type"===bi(e[1])&&s.push(new Pt(r,e,`"$type" cannot be use with operator "${e[0]}"`));case "==":case "!=":3!==e.length&&s.push(new Pt(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case "in":case "!in":e.length>=2&&(i=qn(e[1]),"string"!==i&&s.push(new Pt(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new Pt(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{bi(e.id)===o&&(t=e);})),t?t.ref?e.push(new Pt(n,r.ref,"ref cannot reference another ref layer")):a=bi(t.type):e.push(new Pt(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&bi(t.type);t?"vector"===s&&"raster"===a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new Pt(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new Pt(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Pt(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Pt(n,r.source,`source "${r.source}" not found`));}else e.push(new Pt(n,r,'missing required property "source"'));return e=e.concat(_i({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:Pi,layout:t=>_i({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Ei(Ct({layerType:a},t))}}),paint:t=>_i({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Vi(Ct({layerType:a},t))}})}})),e}function Fi(t){const e=t.value,r=t.key,n=qn(e);return "string"!==n?[new Pt(r,e,`string expected, ${n} found`)]:[]}const $i={promoteId:function({key:t,value:e}){if("string"===qn(e))return Fi({key:t,value:e});{const r=[];for(const n in e)r.push(...Fi({key:`${t}.${n}`,value:e[n]}));return r}}};function Li(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new Pt(r,e,'"type" is required')];const a=bi(e.type);let o;switch(a){case "vector":case "raster":return o=_i({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:$i,validateSpec:s}),o;case "raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=qn(n);if(void 0===n)return o;if("object"!==l)return o.push(new Pt("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===bi(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new Pt(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new Pt(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case "geojson":if(o=_i({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:$i}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],s="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...Mi({key:`${r}.${t}.map`,value:i,expressionContext:"cluster-map"})),o.push(...Mi({key:`${r}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}));}return o;case "video":return _i({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case "image":return _i({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case "canvas":return [new Pt(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return zi({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Oi(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=qn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Pt("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Pt(a,e[a],`unknown property "${a}"`)]);}return s}function Di(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=qn(e);if(void 0===e)return [];if("object"!==s)return [new Pt("sky",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Pt(s,e[s],`unknown property "${s}"`)]);return a}function ji(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=qn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Pt("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Pt(a,e[a],`unknown property "${a}"`)]);return s}function Ri(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new Pt(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new Pt(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(_i({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Fi({key:n,value:r})}function Ni(t){return e=t.value,Boolean(e)&&e.constructor===Object?[]:[new Pt(t.key,t.value,`object expected, ${qn(t.value)} found`)];var e;}const Ui={"*":()=>[],array:Ai,boolean:function(t){const e=t.value,r=t.key,n=qn(e);return "boolean"!==n?[new Pt(r,e,`boolean expected, ${n} found`)]:[]},number:Si,color:Ii,constants:vi,enum:zi,filter:Pi,function:ki,layer:Ti,object:_i,source:Li,light:Oi,sky:Di,terrain:ji,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=qn(e);if(void 0===e)return [];if("object"!==s)return [new Pt("projection",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Pt(s,e[s],`unknown property "${s}"`)]);return a},projectionDefinition:function(t){const e=t.key;let r=t.value;r=r instanceof String?r.valueOf():r;const n=qn(r);return "array"!==n||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(r)||function(t){return !!["interpolate","step","literal"].includes(t[0])}(r)?["array","string"].includes(n)?[]:[new Pt(e,r,`projection expected, invalid type "${n}" found`)]:[new Pt(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:Fi,formatted:function(t){return 0===Fi(t).length?[]:Mi(t)},resolvedImage:function(t){return 0===Fi(t).length?[]:Mi(t)},padding:function(t){const e=t.key,r=t.value;if("array"===qn(r)){if(r.length<1||r.length>4)return [new Pt(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(vi({key:"constants",value:t.constants}))),Xi(r)}function Ki(t){return function(e){return t({...e,validateSpec:qi})}}function Xi(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function Hi(t){return function(...e){return Xi(t.apply(this,e))}}Zi.source=Hi(Ki(Li)),Zi.sprite=Hi(Ki(Ri)),Zi.glyphs=Hi(Ki(Gi)),Zi.light=Hi(Ki(Oi)),Zi.sky=Hi(Ki(Di)),Zi.terrain=Hi(Ki(ji)),Zi.state=Hi(Ki(Ni)),Zi.layer=Hi(Ki(Ti)),Zi.filter=Hi(Ki(Pi)),Zi.paintProperty=Hi(Ki(Vi)),Zi.layoutProperty=Hi(Ki(Ei));const Yi=Zi,Ji=Yi.light,Wi=Yi.sky,Qi=Yi.paintProperty,ts=Yi.layoutProperty;function es(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new yt(new Error(n.message))),r=!0;return r}class rs{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1;}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const s=t[n];i[n]=ns[r].shallow.indexOf(n)>=0?s:ls(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(i.$name=r),i}function us(t){if(os(t))return t;if(Array.isArray(t))return t.map(us);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=as(t)||"Object";if(!ns[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=ns[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=ns[e].shallow.indexOf(r)>=0?i:us(i);}return n}class cs{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Hangul Syllables":t=>t>=44032&&t<=55215,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function ps(t){for(const e of t)if(xs(e.charCodeAt(0)))return !0;return !1}function fs(t){for(const e of t)if(!ms(e.charCodeAt(0)))return !1;return !0}function ds(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const ys=ds(["Arab","Dupl","Mong","Ougr","Syrc"]);function ms(t){return !ys.test(String.fromCodePoint(t))}const gs=ds(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function xs(t){return !(746!==t&&747!==t&&(t<4352||!(hs["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||hs["CJK Compatibility"](t)||hs["CJK Strokes"](t)||!(!hs["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||hs["Enclosed CJK Letters and Months"](t)||hs["Ideographic Description Characters"](t)||hs.Kanbun(t)||hs.Katakana(t)&&12540!==t||!(!hs["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!hs["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||hs["Vertical Forms"](t)||hs["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||gs.test(String.fromCodePoint(t)))))}function vs(t){return !(xs(t)||function(t){return !!(hs["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||hs["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||hs["Letterlike Symbols"](t)||hs["Number Forms"](t)||hs["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||hs["Control Pictures"](t)&&9251!==t||hs["Optical Character Recognition"](t)||hs["Enclosed Alphanumerics"](t)||hs["Geometric Shapes"](t)||hs["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||hs["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||hs["CJK Symbols and Punctuation"](t)||hs.Katakana(t)||hs["Private Use Area"](t)||hs["CJK Compatibility Forms"](t)||hs["Small Form Variants"](t)||hs["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const bs=ds(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function ws(t){return bs.test(String.fromCodePoint(t))}function _s(t,e){return !(!e&&ws(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||hs.Khmer(t))}function As(t){for(const e of t)if(ws(e.charCodeAt(0)))return !0;return !1}const Ss=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{};}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(Ss.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve();}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,r){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((t=>{this.loadScriptResolve=t;}));r(e);const i=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([n,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class ks{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new cs,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!_s(r.charCodeAt(0),e))return !1;return !0}(t,"loaded"===Ss.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class Ms{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Gn(t))return new si(t,e);if(ti(t)){const r=ii(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=ke.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"numberArray"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"colorArray"!==e.type||"string"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?r=Fe.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(r=Le.parse(t)):r=Ve.parse(t):r=Be.parse(t):r=Ce.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class Is{constructor(t){this.property=t,this.value=new Ms(t,void 0);}transitioned(t,e){return new Ps(this.property,this.value,e,L({},t.transition,this.transition),t.now)}untransitioned(){return new Ps(this.property,this.value,null,{},0)}}class zs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return R(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].value=new Ms(this._values[t].property,null===e?void 0:R(e));}getTransition(t){return R(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].transition=R(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new Cs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new Cs(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ps{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(nn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Ls{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new ks(Math.floor(e.zoom-1),e)),t.expression.evaluate(new ks(Math.floor(e.zoom),e)),t.expression.evaluate(new ks(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Os{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class Ds{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new Ms(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Is(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}is("DataDrivenProperty",Fs),is("DataConstantProperty",Ts),is("CrossFadedDataDrivenProperty",$s),is("CrossFadedProperty",Ls),is("ColorRampProperty",Os);const js="-transition";class Rs extends mt{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Bs(e.layout)),e.paint)){this._transitionablePaint=new zs(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Es(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(ts,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(js)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(Qi,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(js))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),j(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&es(this,t.call(Yi,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:gt,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Vs&&Rn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const Ns={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Us{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class qs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Gs(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=Ns[t.type].BYTES_PER_ELEMENT,s=r=Zs(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Zs(r,Math.max(n,e)),alignment:e}}function Zs(t,e){return Math.ceil(t/e)*e}class Ks extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Ks.prototype.bytesPerElement=4,is("StructArrayLayout2i4",Ks);class Xs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}Xs.prototype.bytesPerElement=6,is("StructArrayLayout3i6",Xs);class Hs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Hs.prototype.bytesPerElement=8,is("StructArrayLayout4i8",Hs);class Ys extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Ys.prototype.bytesPerElement=12,is("StructArrayLayout2i4i12",Ys);class Js extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}Js.prototype.bytesPerElement=8,is("StructArrayLayout2i4ub8",Js);class Ws extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Ws.prototype.bytesPerElement=8,is("StructArrayLayout2f8",Ws);class Qs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}Qs.prototype.bytesPerElement=20,is("StructArrayLayout10ui20",Qs);class ta extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}ta.prototype.bytesPerElement=24,is("StructArrayLayout4i4ui4i24",ta);class ea extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}ea.prototype.bytesPerElement=12,is("StructArrayLayout3f12",ea);class ra extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ra.prototype.bytesPerElement=4,is("StructArrayLayout1ul4",ra);class na extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}na.prototype.bytesPerElement=20,is("StructArrayLayout6i1ul2ui20",na);class ia extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}ia.prototype.bytesPerElement=12,is("StructArrayLayout2i2i2i12",ia);class sa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}sa.prototype.bytesPerElement=16,is("StructArrayLayout2f1f2i16",sa);class aa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=16*t,l=4*t,u=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=a,t}}aa.prototype.bytesPerElement=16,is("StructArrayLayout2ub2f2i16",aa);class oa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}oa.prototype.bytesPerElement=6,is("StructArrayLayout3ui6",oa);class la extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}la.prototype.bytesPerElement=48,is("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",la);class ua extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=A,this.uint32[C+12]=S,this.float32[C+13]=k,this.float32[C+14]=M,this.uint16[P+30]=I,this.uint16[P+31]=z,t}}ua.prototype.bytesPerElement=64,is("StructArrayLayout8i15ui1ul2f2ui64",ua);class ca extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}ca.prototype.bytesPerElement=4,is("StructArrayLayout1f4",ca);class ha extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}ha.prototype.bytesPerElement=12,is("StructArrayLayout1ui2f12",ha);class pa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}pa.prototype.bytesPerElement=8,is("StructArrayLayout1ul2ui8",pa);class fa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}fa.prototype.bytesPerElement=4,is("StructArrayLayout2ui4",fa);class da extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}da.prototype.bytesPerElement=2,is("StructArrayLayout1ui2",da);class ya extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}ya.prototype.bytesPerElement=16,is("StructArrayLayout4f16",ya);class ma extends Us{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}ma.prototype.size=20;class ga extends na{get(t){return new ma(this,t)}}is("CollisionBoxArray",ga);class xa extends Us{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}xa.prototype.size=48;class va extends la{get(t){return new xa(this,t)}}is("PlacedSymbolArray",va);class ba extends Us{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}ba.prototype.size=64;class wa extends ua{get(t){return new ba(this,t)}}is("SymbolInstanceArray",wa);class _a extends ca{getoffsetX(t){return this.float32[1*t+0]}}is("GlyphOffsetArray",_a);class Aa extends Xs{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}is("SymbolLineVertexArray",Aa);class Sa extends Us{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Sa.prototype.size=12;class ka extends ha{get(t){return new Sa(this,t)}}is("TextAnchorOffsetArray",ka);class Ma extends Us{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}Ma.prototype.size=8;class Ia extends pa{get(t){return new Ma(this,t)}}is("FeatureIndexArray",Ia);class za extends Ks{}class Pa extends Ks{}class Ca extends Ks{}class Ba extends Ys{}class Va extends Js{}class Ea extends Ws{}class Ta extends Qs{}class Fa extends ta{}class $a extends ea{}class La extends ra{}class Oa extends ia{}class Da extends aa{}class ja extends oa{}class Ra extends fa{}const Na=Gs([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ua}=Na;class qa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t;}prepareSegment(t,e,r,n){const i=this.segments[this.segments.length-1];return t>qa.MAX_VERTEX_ARRAY_LENGTH&&U(`Max vertices per segment is ${qa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${qa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+t>qa.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n?this.createNewSegment(e,r,n):i}createNewSegment(t,e,r){const n={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==r&&(n.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(t,e,r){return this.prepareSegment(0,t,e,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0;}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new qa([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ga(t,e){return 256*(t=F(Math.floor(t),0,255))+F(Math.floor(e),0,255)}qa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,is("SegmentVector",qa);const Za=Gs([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Ka,Xa,Ha,Ya={exports:{}},Ja={exports:{}},Wa={exports:{}},Qa=function(){if(Ha)return Ya.exports;Ha=1;var t=(Ka||(Ka=1,Ja.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Ja.exports),e=(Xa||(Xa=1,Wa.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),Wa.exports);return Ya.exports=t,Ya.exports.murmur3=t,Ya.exports.murmur2=e,Ya.exports}(),to=r(Qa);class eo{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(ro(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=ro(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return no(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new eo;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function ro(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:to(String(t))}function no(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;io(t,s,a),io(e,3*s,3*a),io(e,3*s+1,3*a+1),io(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new lo(t,e):new ao(t,e)}}class po{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new oo(t,e):new ao(t,e)}}class fo{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new ks(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=co(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new ks(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new ks(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=co(r),s=co(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof fo||r instanceof yo)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new go(n,e,r);this.needsUpload=!1,this._featureMap=new eo,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function vo(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function bo(t,e,r){const n={color:{source:Ws,composite:ya},number:{source:ca,composite:Ws}},i=function(t){return {"line-pattern":{source:Ta,composite:Ta},"fill-pattern":{source:Ta,composite:Ta},"fill-extrusion-pattern":{source:Ta,composite:Ta}}[t]}(t);return i&&i[r]||n[e][r]}is("ConstantBinder",ho),is("CrossFadedConstantBinder",po),is("SourceExpressionBinder",fo),is("CrossFadedCompositeBinder",mo),is("CompositeExpressionBinder",yo),is("ProgramConfiguration",go,{omit:["_buffers"]}),is("ProgramConfigurationSet",xo);const wo=Math.pow(2,14)-1,_o=-wo-1;function Ao(t){const e=z/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&U("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function So(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?Ao(t):[]}}const ko=-32768;function Mo(t,e,r,n,i){t.emplaceBack(ko+8*e+n,ko+8*r+i);}class Io{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Pa,this.indexArray=new ja,this.segments=new qa,this.programConfigurations=new xo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1,o="heatmap"===n.type;if("circle"===n.type){const t=n;s=t.layout.get("circle-sort-key"),a=!s.isConstant(),o=o||"map"===t.paint.get("circle-pitch-alignment");}const l=o?e.subdivisionGranularity.circle:1;for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=So(e,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Ao(e),patterns:{},sortKey:c};i.push(h);}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r,l),e.featureIndex.insert(o,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ua),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const a=s.length;for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=z||n<0||n>=z)continue;const i=this.segments.prepareSegment(a*a,this.layoutVertexArray,this.indexArray,t.sortKey),o=i.vertexLength;for(let t=0;t1){if(Vo(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function $o(t,e){for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function Oo(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=q(t,e,r[0]);return s!==q(t,e,r[1])||s!==q(t,e,r[2])||s!==q(t,e,r[3])}function Do(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function jo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ro(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=l.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let e=0;eZo(t,e,r,n)))}(l,i,a,o),p=c?u*s:u;for(const t of n)for(const e of t){const t=c?e:Zo(e,i,a,o);let r=p;const n=i.projectTileCoordinates(e.x,e.y,a,o).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n/i.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=i.cameraToCenterDistance/n),Po(h,t,r))return !0}return !1}}function Zo(t,e,r,n){const i=e.projectTileCoordinates(t.x,t.y,r,n).point;return new l((.5*i.x+.5)*e.width,(.5*-i.y+.5)*e.height)}class Ko extends Io{}let Xo;is("HeatmapBucket",Ko,{omit:["layers"]});var Ho={get paint(){return Xo=Xo||new Ds({"heatmap-radius":new Fs(gt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Fs(gt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ts(gt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Os(gt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ts(gt.paint_heatmap["heatmap-opacity"])})}};function Yo(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function Jo(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Yo({},{width:e,height:r},n);Wo(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function Wo(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a);};if(t.clips)for(let e=0,i=0;e0)for(let i=e;i=e;i-=n)s=El(i/n|0,t[i],t[i+1],s);return s&&Il(s,s.next)&&(Tl(s),s=s.next),s}function pl(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Il(n,n.next)&&0!==Ml(n.prev,n,n.next))n=n.next;else {if(Tl(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function fl(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=wl(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?yl(t,n,i,s):dl(t))e.push(l.i,t.i,u.i),Tl(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?fl(t=ml(pl(t),e),e,r,n,i,s,2):2===a&&gl(t,e,r,n,i,s):fl(pl(t),e,r,n,i,s,1);break}}}function dl(t){const e=t.prev,r=t,n=t.next;if(Ml(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),p=Math.max(i,s,a),f=Math.max(o,l,u);let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&Sl(i,o,s,l,a,u,d.x,d.y)&&Ml(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function yl(t,e,r,n){const i=t.prev,s=t,a=t.next;if(Ml(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=Math.min(o,l,u),d=Math.min(c,h,p),y=Math.max(o,l,u),m=Math.max(c,h,p),g=wl(f,d,e,r,n),x=wl(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Sl(o,c,l,h,u,p,v.x,v.y)&&Ml(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Sl(o,c,l,h,u,p,b.x,b.y)&&Ml(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Sl(o,c,l,h,u,p,v.x,v.y)&&Ml(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Sl(o,c,l,h,u,p,b.x,b.y)&&Ml(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function ml(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Il(n,i)&&zl(n,r,r.next,i)&&Bl(n,i)&&Bl(i,n)&&(e.push(n.i,r.i,i.i),Tl(r),Tl(r.next),r=t=i),r=r.next;}while(r!==t);return pl(r)}function gl(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&kl(a,t)){let o=Vl(a,t);return a=pl(a,a.next),o=pl(o,o.next),fl(a,e,r,n,i,s,0),void fl(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function xl(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function vl(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;if(Il(t,r))return r;do{if(Il(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&Al(is.x||r.x===s.x&&bl(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=Vl(r,t);return pl(n,n.next),pl(r,r.next)}function bl(t,e){return Ml(t.prev,t,e.prev)<0&&Ml(e.next,t,t.next)<0}function wl(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function _l(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function Sl(t,e,r,n,i,s,a,o){return !(t===a&&e===o)&&Al(t,e,r,n,i,s,a,o)}function kl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&zl(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(Bl(t,e)&&Bl(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Ml(t.prev,t,e.prev)||Ml(t,e.prev,e))||Il(t,e)&&Ml(t.prev,t,t.next)>0&&Ml(e.prev,e,e.next)>0)}function Ml(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Il(t,e){return t.x===e.x&&t.y===e.y}function zl(t,e,r,n){const i=Cl(Ml(t,e,r)),s=Cl(Ml(t,e,n)),a=Cl(Ml(r,n,t)),o=Cl(Ml(r,n,e));return i!==s&&a!==o||!(0!==i||!Pl(t,r,e))||!(0!==s||!Pl(t,n,e))||!(0!==a||!Pl(r,t,n))||!(0!==o||!Pl(r,e,n))}function Pl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Cl(t){return t>0?1:t<0?-1:0}function Bl(t,e){return Ml(t.prev,t,t.next)<0?Ml(t,e,t.next)>=0&&Ml(t,t.prev,e)>=0:Ml(t,e,t.prev)<0||Ml(t,t.next,e)<0}function Vl(t,e){const r=Fl(t.i,t.x,t.y),n=Fl(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function El(t,e,r,n){const i=Fl(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Tl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Fl(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class $l{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e;}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const r=0|Math.round(t),n=0|Math.round(e),i=this._getKey(r,n);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(r,n),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const r=[];for(let n=0;n0?(r.push(i),r.push(a),r.push(s)):(r.push(i),r.push(s),r.push(a));}return r}(this._vertexBuffer,t);const e=[],r=t.length;for(let n=0;n=1||v<=0)||y&&(oi)){u>=n&&u<=i&&s.push(r[(t+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(a+p*x,o+f*x));const b=a+p*Math.max(x,0),w=a+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,a,o,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(a+p*v,o+f*v)),(y||u>=n&&u<=i)&&s.push(r[(t+1)%3]),!y&&(u<=n||u>=i)&&this._generateInterEdgeVertices(s,a,o,l,u,c,h,w,n,i);}return s}_generateIntraEdgeVertices(t,e,r,n,i,s,a){const o=n-e,l=i-r,u=0===l,c=u?Math.min(e,n):Math.min(s,a),h=u?Math.max(e,n):Math.max(s,a),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?e=p;n--){const i=n*this._granularityCellSize;t.push(this._vertexToIndex(i,r+l*(i-e)/o));}}_generateInterEdgeVertices(t,e,r,n,i,s,a,o,l,u){const c=i-r,h=s-n,p=a-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=n+h*y;let x=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,b=o=1||m<=0){const t=r-a,n=s+(e-s)*Math.min((l-a)/t,(u-a)/t);x=Math.floor(Math.min(n,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,o)/this._granularityCellSize)-1,b=o0?u:l;if(b)for(let e=x;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,_));else for(let e=v;e>=x;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,_));}_generateOutline(t){const e=[];for(const r of t){const t=Nl(r,this._granularity,!0),n=this._pointArrayToIndices(t),i=[];for(let t=1;ti!=(s===Ol)?(t.push(e),t.push(r),t.push(this._vertexToIndex(n,s)),t.push(r),t.push(this._vertexToIndex(i,s)),t.push(this._vertexToIndex(n,s))):(t.push(r),t.push(e),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(i,s)),t.push(r),t.push(this._vertexToIndex(n,s)));}_fillPoles(t,e,r){const n=this._vertexBuffer,i=z,s=t.length;for(let a=2;a80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return fl(s,a,r,o,l,u,0),a}(r,n),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e);}catch(t){console.error(t);}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(t,e){const r=[];for(let n=0;n0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,e=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(x-t),n=Math.abs(v-e),i=Math.abs(x-c),s=Math.abs(v-h),u=p?r/m:Number.POSITIVE_INFINITY,b=f?n/g:Number.POSITIVE_INFINITY;if((i<=r||!p)&&(s<=n||!f))break;if(u=0?a-1:s-1,i=(o+1)%s,l=t[2*e[n]],u=t[2*e[i]],c=t[2*e[a]],h=t[2*e[a]+1],p=t[2*e[o]+1];let f=!1;if(lu)f=!1;else {const r=p-h,s=-(t[2*e[o]]-c),a=h((u-c)*r+(t[2*e[i]+1]-h)*s)*a&&(f=!0);}if(f){const t=e[n],i=e[a],l=e[o];t!==i&&t!==l&&i!==l&&r.push(l,i,t),a--,a<0&&(a=s-1);}else {const t=e[i],n=e[a],l=e[o];t!==n&&t!==l&&n!==l&&r.push(l,n,t),o++,o>=s&&(o=0);}if(n===i)break}}function ql(t,e,r,n,i,s,a,o,l){const u=i.length/2,c=a&&o&&l;if(uqa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,g=!0,c=0);const x=Gl(a,n,s,o,p,y,u),v=Gl(a,n,s,o,f,m,u),b=Gl(a,n,s,o,d,g,u);r.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++;}}(e,r,n,i,s,t),c&&function(t,e,r,n,i,s){const a=[];for(let t=0;tqa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,d=!0,y=!0,c=0);const m=Gl(a,n,s,o,i,d,u),g=Gl(a,n,s,o,h,y,u);r.emplaceBack(c+m-l,c+g-l),u.primitiveLength++;}}}(a,r,o,i,l,t),e.forceNewSegmentOnNextPrepare(),null==a||a.forceNewSegmentOnNextPrepare();}function Gl(t,e,r,n,i,s,a){if(s){const s=n.count;return r(e[2*i],e[2*i+1]),t[i]=n.count,n.count++,a.vertexLength++,s}return t[i]}class Zl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ca,this.indexArray=new ja,this.indexArray2=new Ra,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.segments2=new qa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=ul("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=So(a,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Ao(a),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=cl("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ll),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s){for(const t of Wr(e,500)){const e=Rl(t,n,s.fill.getGranularityForZoomLevel(n.z)),r=this.layoutVertexArray;ql(((t,e)=>{r.emplaceBack(t,e);}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}}let Kl,Xl;is("FillBucket",Zl,{omit:["layers","patternFeatures"]});var Hl={get paint(){return Xl=Xl||new Ds({"fill-antialias":new Ts(gt.paint_fill["fill-antialias"]),"fill-opacity":new Fs(gt.paint_fill["fill-opacity"]),"fill-color":new Fs(gt.paint_fill["fill-color"]),"fill-outline-color":new Fs(gt.paint_fill["fill-outline-color"]),"fill-translate":new Ts(gt.paint_fill["fill-translate"]),"fill-translate-anchor":new Ts(gt.paint_fill["fill-translate-anchor"]),"fill-pattern":new $s(gt.paint_fill["fill-pattern"])})},get layout(){return Kl=Kl||new Ds({"fill-sort-key":new Fs(gt.layout_fill["fill-sort-key"])})}};class Yl extends Rs{constructor(t){super(t,Hl);}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Zl(t)}queryRadius(){return jo(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:r,pixelsToTileUnits:n}){return Co(Ro(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,n),e)}isTileClipped(){return !0}}const Jl=Gs([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Wl=Gs([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Ql}=Jl;var tu,eu,ru,nu,iu,su,au,ou={};function lu(){if(eu)return tu;eu=1;var t=s();function e(t,e,n,i,s){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=s,t.readFields(r,this,e);}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){for(var r=t.readVarint()+t.pos;t.pos>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(a,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var s,a,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return ru=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},ru}function cu(){return au||(au=1,ou.VectorTile=function(){if(su)return iu;su=1;var t=uu();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return iu=function(t,r){this.layers=t.readFields(e,{},r);},iu}(),ou.VectorTileFeature=lu(),ou.VectorTileLayer=uu()),ou}var hu=r(cu());const pu=hu.VectorTileFeature.types,fu=Math.pow(2,13);function du(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*fu)+a,i*fu*2,s*fu*2,Math.round(o));}class yu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ba,this.centroidVertexArray=new za,this.indexArray=new ja,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=ul("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=So(n,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:Ao(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(cl("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{},e.subdivisionGranularity),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0);}}addFeatures(t,e,r){for(const n of this.features){const{geometry:i}=n;this.addFeature(n,i,n.index,e,r,t.subdivisionGranularity);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ql),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Wl.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i,s){for(const r of Wr(e,500)){const e={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(e,n,t,r,s);const a=this.layoutVertexArray.length-i,o=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t{du(u,t,e,0,0,1,1,0);}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles);}_generateSideFaces(t,e){let r=0;for(let n=1;nqa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const a=i.sub(s)._perp()._unit(),o=s.dist(i);r+o>32768&&(r=0),du(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,0,r),du(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,1,r),r+=o,du(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,0,r),du(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,1,r);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2;}}}function mu(t,e){for(let r=0;rz)||t.y===e.y&&(t.y<0||t.y>z)}function xu(t){return t.every((t=>t.x<0))||t.every((t=>t.x>z))||t.every((t=>t.y<0))||t.every((t=>t.y>z))}let vu;is("FillExtrusionBucket",yu,{omit:["layers","features"]});var bu={get paint(){return vu=vu||new Ds({"fill-extrusion-opacity":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new $s(gt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class wu extends Rs{constructor(t){super(t,bu);}createBucket(t){return new yu(t)}queryRadius(){return jo(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s,pixelPosMatrix:a}){const o=Ro(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-i.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(e,r),c=this.paint.get("fill-extrusion-base").evaluate(e,r),h=function(t,e,r){const n=[];for(const r of t){const t=[r.x,r.y,0,1];S(t,t,e),n.push(new l(t[0]/t[3],t[1]/t[3]));}return n}(o,a),p=function(t,e,r,n){const i=[],s=[],a=n[8]*e,o=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,s=i.y,y=n[0]*e+n[4]*s+n[12],m=n[1]*e+n[5]*s+n[13],g=n[2]*e+n[6]*s+n[14],x=n[3]*e+n[7]*s+n[15],v=g+u,b=x+c,w=y+h,_=m+p,A=g+f,S=x+d,k=new l((y+a)/b,(m+o)/b);k.z=v/b,t.push(k);const M=new l(w/S,_/S);M.z=A/S,r.push(M);}i.push(t),s.push(r);}return [i,s]}(n,c,u,a);return function(t,e,r){let n=1/0;Co(r,e)&&(n=Au(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new Va,this.layoutVertexArray2=new Ea,this.indexArray=new ja,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=ul("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=So(e,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Ao(e),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=cl("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Iu)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ku),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),l=a.get("line-cap"),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,s,a,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Nl(t,a?o.line.getGranularityForZoomLevel(a.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c0;if(w&&e>c){const t=f.dist(d);if(t>2*h){const e=f.sub(f.sub(d)._mult(h/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,m,0,0,p),d=e;}}const A=d&&y;let S=A?r:l?"butt":n;if(A&&"round"===S&&(vi&&(S="bevel"),"bevel"===S&&(v>2&&(S="flipbevel"),v100)a=g.mult(-1);else {const t=v*m.add(g).mag()/m.sub(g).mag();a._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(f,a,0,0,p),this.addCurrentVertex(f,a.mult(-1),0,0,p);}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(d&&this.addCurrentVertex(f,m,e,r,p),"fakeround"===S){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*h){const e=f.add(y.sub(f)._mult(h/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,p),f=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>Cu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s));}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(Cu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let Vu,Eu;is("LineBucket",Bu,{omit:["layers","patternFeatures"]});var Tu={get paint(){return Eu=Eu||new Ds({"line-opacity":new Fs(gt.paint_line["line-opacity"]),"line-color":new Fs(gt.paint_line["line-color"]),"line-translate":new Ts(gt.paint_line["line-translate"]),"line-translate-anchor":new Ts(gt.paint_line["line-translate-anchor"]),"line-width":new Fs(gt.paint_line["line-width"]),"line-gap-width":new Fs(gt.paint_line["line-gap-width"]),"line-offset":new Fs(gt.paint_line["line-offset"]),"line-blur":new Fs(gt.paint_line["line-blur"]),"line-dasharray":new Ls(gt.paint_line["line-dasharray"]),"line-pattern":new $s(gt.paint_line["line-pattern"]),"line-gradient":new Os(gt.paint_line["line-gradient"])})},get layout(){return Vu=Vu||new Ds({"line-cap":new Ts(gt.layout_line["line-cap"]),"line-join":new Fs(gt.layout_line["line-join"]),"line-miter-limit":new Ts(gt.layout_line["line-miter-limit"]),"line-round-limit":new Ts(gt.layout_line["line-round-limit"]),"line-sort-key":new Fs(gt.layout_line["line-sort-key"])})}};class Fu extends Fs{possiblyEvaluate(t,e){return e=new ks(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=L({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let $u;class Lu extends Rs{constructor(t){super(t,Tu),this.gradientVersion=0,$u||($u=new Fu(Tu.paint.properties["line-width"].specification),$u.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof sr,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=$u.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new Bu(t)}queryRadius(t){const e=t,r=Ou(Do("line-width",this,e),Do("line-gap-width",this,e)),n=Do("line-offset",this,e);return r/2+Math.abs(n)+jo(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s}){const a=Ro(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-i.bearingInRadians,s),o=s/2*Ou(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Du=Gs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ju=Gs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Gs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ru=Gs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Gs([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Nu=Gs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Uu=Gs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function qu(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ss.applyArabicShaping&&(t=Ss.applyArabicShaping(t)),t}(t.text,e,r);})),t}Gs([{name:"triangle",components:3,type:"Uint16"}]),Gs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Gs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Gs([{type:"Float32",name:"offsetX"}]),Gs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Gs([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Gu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Zu,Ku,Xu,Hu=24,Yu={};function Ju(){return Zu||(Zu=1,Yu.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},Yu.write=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;}),Yu}function Wu(){if(Xu)return Ku;Xu=1,Ku=e;var t=Ju();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function v(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return a(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=s(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},Ku}var Qu=r(Wu());const tc=3;function ec(t,e,r){1===t&&r.readMessage(rc,e);}function rc(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(nc,{});e.push({id:t,bitmap:new Qo({width:i+2*tc,height:s+2*tc},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}}function nc(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const ic=tc;function sc(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&dc[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new pc;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}getMaxImageSize(t){let e=0,r=0;for(let n=0;n=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function fc(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=pc.fromFeature(e,s);let g;p===t.al.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=Ss;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),_c(m,c,a,r,i,d));for(const e of t){const t=new pc;t.text=e,t.sections=m.sections;for(let r=0;r=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/a,a=t;}return {x1:n,y1:i,x2:n+s,y2:i+a}}function Vc(t,e,r,n,i,s){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-a.displaySize[1])/2,p=c+a.displaySize[1]),{image:a,top:c,right:h,bottom:p,left:f,collisionPadding:o}}const Ec=255,Tc=128,Fc=Ec*Tc;function $c(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new ks(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=$c(this.zoom,r["text-size"]),this.iconSizeData=$c(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap="never"!==Lc(n,"text-overlap","text-allow-overlap")||"never"!==Lc(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.al[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Uc(new xo(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Uc(new xo(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new _a,this.lineVertexArray=new Aa,this.symbolInstances=new wa,this.textAnchorOffsets=new ka;}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new ks(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=So(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=Ao(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=Pe.factory(t),r=this.hasRTLText=this.hasRTLText||Nc(e);(!r||"unavailable"===Ss.getRTLTextPluginStatus()||r&&Ss.isParsed())&&(x=qu(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof $e?t:$e.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:Oc[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=a.evaluate(g,{},n).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.al.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=ps(x.toString()),i=t.fontStack||e,s=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,s,r,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Zc,Kc;is("SymbolBucket",Gc,{omit:["layers","collisionBoxArray","features","compareText"]}),Gc.MAX_GLYPHS=65535,Gc.addDynamicAttributes=Rc;var Xc={get paint(){return Kc=Kc||new Ds({"icon-opacity":new Fs(gt.paint_symbol["icon-opacity"]),"icon-color":new Fs(gt.paint_symbol["icon-color"]),"icon-halo-color":new Fs(gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Fs(gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Fs(gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ts(gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ts(gt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Fs(gt.paint_symbol["text-opacity"]),"text-color":new Fs(gt.paint_symbol["text-color"],{runtimeType:Lt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Fs(gt.paint_symbol["text-halo-color"]),"text-halo-width":new Fs(gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Fs(gt.paint_symbol["text-halo-blur"]),"text-translate":new Ts(gt.paint_symbol["text-translate"]),"text-translate-anchor":new Ts(gt.paint_symbol["text-translate-anchor"])})},get layout(){return Zc=Zc||new Ds({"symbol-placement":new Ts(gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ts(gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ts(gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Fs(gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ts(gt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ts(gt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ts(gt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ts(gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ts(gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ts(gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Fs(gt.layout_symbol["icon-size"]),"icon-text-fit":new Ts(gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ts(gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Fs(gt.layout_symbol["icon-image"]),"icon-rotate":new Fs(gt.layout_symbol["icon-rotate"]),"icon-padding":new Fs(gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ts(gt.layout_symbol["icon-keep-upright"]),"icon-offset":new Fs(gt.layout_symbol["icon-offset"]),"icon-anchor":new Fs(gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ts(gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ts(gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ts(gt.layout_symbol["text-rotation-alignment"]),"text-field":new Fs(gt.layout_symbol["text-field"]),"text-font":new Fs(gt.layout_symbol["text-font"]),"text-size":new Fs(gt.layout_symbol["text-size"]),"text-max-width":new Fs(gt.layout_symbol["text-max-width"]),"text-line-height":new Ts(gt.layout_symbol["text-line-height"]),"text-letter-spacing":new Fs(gt.layout_symbol["text-letter-spacing"]),"text-justify":new Fs(gt.layout_symbol["text-justify"]),"text-radial-offset":new Fs(gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ts(gt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Fs(gt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Fs(gt.layout_symbol["text-anchor"]),"text-max-angle":new Ts(gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ts(gt.layout_symbol["text-writing-mode"]),"text-rotate":new Fs(gt.layout_symbol["text-rotate"]),"text-padding":new Ts(gt.layout_symbol["text-padding"]),"text-keep-upright":new Ts(gt.layout_symbol["text-keep-upright"]),"text-transform":new Fs(gt.layout_symbol["text-transform"]),"text-offset":new Fs(gt.layout_symbol["text-offset"]),"text-allow-overlap":new Ts(gt.layout_symbol["text-allow-overlap"]),"text-overlap":new Ts(gt.layout_symbol["text-overlap"]),"text-ignore-placement":new Ts(gt.layout_symbol["text-ignore-placement"]),"text-optional":new Ts(gt.layout_symbol["text-optional"])})}};class Hc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Et,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}is("FormatSectionOverride",Hc,{omit:["defaultValue"]});class Yc extends Rs{constructor(t){super(t,Xc);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||ti(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Gc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Xc.paint.overridableProperties){if(!Yc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Hc(e),n=new Qn(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new ri("source",n):new ni("composite",n,e.value.zoomStops),this.paint._values[t]=new Vs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&Yc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Xc.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Pe)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof Ne&&je(e.value)===Nt?s(e.value.sections):e instanceof Mr?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Jc;var Wc={get paint(){return Jc=Jc||new Ds({"background-color":new Ts(gt.paint_background["background-color"]),"background-pattern":new Ls(gt.paint_background["background-pattern"]),"background-opacity":new Ts(gt.paint_background["background-opacity"])})}};class Qc extends Rs{constructor(t){super(t,Wc);}}let th;var eh={get paint(){return th=th||new Ds({"raster-opacity":new Ts(gt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ts(gt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ts(gt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ts(gt.paint_raster["raster-brightness-max"]),"raster-saturation":new Ts(gt.paint_raster["raster-saturation"]),"raster-contrast":new Ts(gt.paint_raster["raster-contrast"]),"raster-resampling":new Ts(gt.paint_raster["raster-resampling"]),"raster-fade-duration":new Ts(gt.paint_raster["raster-fade-duration"])})}};class rh extends Rs{constructor(t){super(t,eh);}}class nh extends Rs{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class ih{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle();}),0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const sh={once:!0},ah=6371008.8;class oh{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new oh($(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return ah*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof oh)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new oh(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new oh(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const lh=2*Math.PI*ah;function uh(t){return lh*Math.cos(t*Math.PI/180)}function ch(t){return (180+t)/360}function hh(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function ph(t,e){return t/uh(e)}function fh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function dh(t,e){return t*uh(fh(e))}class yh{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=oh.convert(t);return new yh(ch(r.lng),hh(r.lat),ph(e,r.lat))}toLngLat(){return new oh(360*this.x-180,fh(this.y))}toAltitude(){return dh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/lh*(t=fh(this.y),1/Math.cos(t*Math.PI/180));var t;}}function mh(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class gh{constructor(t,e,r){if(!function(t,e,r){return !(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=bh(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=mh(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=mh(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*z,(t.y*e-this.y)*z)}toString(){return `${this.z}/${this.x}/${this.y}`}}class xh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=bh(t,e.z,e.z,e.x,e.y);}}class vh{constructor(t,e,r,n,i){if(this.terrainRttPosMatrix32f=null,t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new gh(r,+n,+i),this.key=bh(e,t,r,n,i);}clone(){return new vh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new vh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?bh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):bh(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new vh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new vh(e,this.wrap,e,r,n),new vh(e,this.wrap,e,r+1,n),new vh(e,this.wrap,e,r,n+1),new vh(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new tl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Ah{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class Sh{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new rs(z,16,0),this.grid3D=new rs(z,16,0),this.featureIndexArray=new Ia,this.promoteId=e;}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new hu.VectorTile(new Qu(this.rawTileData)).layers,this.sourceLayerCoder=new _h(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params,s=z/t.tileSize/t.scale,a=ui(i.filter),o=t.queryGeometry,u=t.queryPadding*s,c=Mh(o),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=Mh(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new l(e,r),new l(e,i),new l(n,i),new l(n,r)];if(t.length>2)for(const e of s)if(Lo(t,e))return !0;for(let e=0;e(p||(p=Ao(e)),r.queryIntersectsFeature({queryGeometry:o,feature:e,featureState:n,geometry:p,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))));}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!h.some((t=>s.has(t))))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=So(f,!0);if(!i.filter(new ks(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new ks(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const a=e instanceof Es?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function Mh(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {minX:e,minY:r,maxX:n,maxY:i}}function Ih(t,e){return e-t}function zh(t,e,r,n,i){const s=[];for(let a=0;a=n&&c.x>=n||(a.x>=n?a=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=n&&(c=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=i&&c.y>=i||(a.y>=i?a=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y>=i&&(c=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),u&&a.equals(u[u.length-1])||(u=[a],s.push(u)),u.push(c)))));}}return s}is("FeatureIndex",Sh,{omit:["rawTileData","sourceLayerCoder"]});class Ph extends l{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new Ph(this.x,this.y,this.angle,this.segment)}}function Ch(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function Bh(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=fr.number(n.x,i.x,c),p=fr.number(n.y,i.y,c),f=new Ph(h,p,i.angleTo(n),r);return f._round(),!a||Ch(t,f,o,a,e)?f:void 0}l+=s;}}function Fh(t,e,r,n,i,s,a,o,l){const u=Vh(n,s,a),c=Eh(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new Ph(g,x,y,e);r._round(),n&&!Ch(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=$h(t,h/2,r,n,i,s,a,!0,l)),f}is("Anchor",Ph);const Lh=ac;function Oh(t,e,r,n){const i=[],s=t.image,a=s.pixelRatio,o=s.paddedRect.w-2*Lh,u=s.paddedRect.h-2*Lh;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=s.stretchX||[[0,o]],p=s.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=o-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,A=m,S=0,k=g;if(s.content&&n){const e=s.content,r=e[2]-e[0],n=e[3]-e[1];(s.textFitWidth||s.textFitHeight)&&(c=Bc(t)),x=Dh(h,0,e[0]),b=Dh(p,0,e[1]),v=Dh(h,e[0],e[2]),w=Dh(p,e[1],e[3]),_=e[0]-x,S=e[1]-b,A=r-v,k=n-w;}const M=c.x1,I=c.y1,z=c.x2-M,P=c.y2-I,C=(t,n,i,o)=>{const u=Rh(t.stretch-x,v,z,M),c=Nh(t.fixed-_,A,t.stretch,d),h=Rh(n.stretch-b,w,P,I),p=Nh(n.fixed-S,k,n.stretch,y),f=Rh(i.stretch-x,v,z,M),m=Nh(i.fixed-_,A,i.stretch,d),g=Rh(o.stretch-b,w,P,I),C=Nh(o.fixed-S,k,o.stretch,y),B=new l(u,h),V=new l(f,h),E=new l(f,g),T=new l(u,g),F=new l(c/a,p/a),$=new l(m/a,C/a),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),r=[e,-t,t,e];B._matMult(r),V._matMult(r),T._matMult(r),E._matMult(r);}const O=t.stretch+t.fixed,D=n.stretch+n.fixed;return {tl:B,tr:V,bl:T,br:E,tex:{x:s.paddedRect.x+Lh+O,y:s.paddedRect.y+Lh+D,w:i.stretch+i.fixed-O,h:o.stretch+o.fixed-D},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:$,minFontScaleX:A/a/z,minFontScaleY:k/a/P,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=jh(h,m,d),e=jh(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {const u=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?Bc(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};u.y1=u.y1*a-o[0],u.y2=u.y2*a+o[2],u.x1=u.x1*a-o[3],u.x2=u.x2*a+o[1];const p=s.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const t=new l(u.x1,u.y1),e=new l(u.x2,u.y1),r=new l(u.x1,u.y2),n=new l(u.x2,u.y2),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,i);}this.boxEndIndex=t.length;}}class qh{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}function Gh(t,e=1,r=!1){let n=1/0,i=1/0,s=-1/0,a=-1/0;const o=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const u=Math.min(s-n,a-i);let c=u/2;const h=new qh([],Zh);if(0===u)return new l(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Kh(n.p.x-c,n.p.y-c,c,t)),h.push(new Kh(n.p.x+c,n.p.y-c,c,t)),h.push(new Kh(n.p.x-c,n.p.y+c,c,t)),h.push(new Kh(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Zh(t,e){return e.max-t.max}function Kh(t,e,r,n){this.p=new l(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Fo(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var Xh;t.aB=void 0,(Xh=t.aB||(t.aB={}))[Xh.center=1]="center",Xh[Xh.left=2]="left",Xh[Xh.right=3]="right",Xh[Xh.top=4]="top",Xh[Xh.bottom=5]="bottom",Xh[Xh["top-left"]=6]="top-left",Xh[Xh["top-right"]=7]="top-right",Xh[Xh["bottom-left"]=8]="bottom-left",Xh[Xh["bottom-right"]=9]="bottom-right";const Hh=7,Yh=Number.POSITIVE_INFINITY;function Jh(t,e){return e[1]!==Yh?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case "top-right":case "top-left":case "top":i=r-Hh;break;case "bottom-right":case "bottom-left":case "bottom":i=-r+Hh;}switch(t){case "top-right":case "bottom-right":case "right":n=-e;break;case "top-left":case "bottom-left":case "left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case "top-right":case "top-left":n=i-Hh;break;case "bottom-right":case "bottom-left":n=-i+Hh;break;case "bottom":n=-e+Hh;break;case "top":n=e-Hh;}switch(t){case "top-right":case "bottom-right":r=-i;break;case "top-left":case "bottom-left":r=i;break;case "left":r=e;break;case "right":r=-e;}return [r,n]}(t,e[0])}function Wh(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*Hu));n.startsWith("top")?i[1]-=Hh:n.startsWith("bottom")&&(i[1]+=Hh),e[r+1]=i;}return new Fe(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Hu,Yh]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Hu));const s=[];for(const t of a)s.push(t,Jh(t,n));return new Fe(s)}return null}function Qh(t){switch(t){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function tp(e,r,n,i,s,a,o,l,u,c,h,p){let f=a.textMaxSize.evaluate(r,{});void 0===f&&(f=o);const d=e.layers[0].layout,y=d.get("icon-offset").evaluate(r,{},h),m=rp(n.horizontal),g=o/24,x=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*d.get("symbol-spacing"),_=d.get("text-padding")*e.tilePixelRatio,A=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),s=i&&i.values;return [s[0]*n,s[1]*n,s[2]*n,s[3]*n]}(d,r,h,e.tilePixelRatio),S=d.get("text-max-angle")/180*Math.PI,k="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),M="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),I=d.get("symbol-placement"),P=w/2,C=d.get("icon-text-fit");let B;i&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(B=Vc(i,n.vertical,C,d.get("icon-text-fit-padding"),y,g)),m&&(i=Vc(i,m,C,d.get("icon-text-fit-padding"),y,g)));const V=h?p.line.getGranularityForZoomLevel(h.z):1,E=(l,p)=>{p.x<0||p.x>=z||p.y<0||p.y>=z||function(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k){const M=e.addToLineVertexArray(r,n);let I,z,P,C,B=0,V=0,E=0,T=0,F=-1,$=-1;const L={};let O=to("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},S)+90;P=new Uh(u,r,c,h,p,i.vertical,f,d,y,t),o&&(C=new Uh(u,r,c,h,p,o,g,x,y,t));}if(s){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),a=Oh(s,n,A,i),f=o?Oh(o,n,A,i):void 0;z=new Uh(u,r,c,h,p,s,g,x,!1,n),B=4*a.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[Tc*l.layout.get("icon-size").evaluate(w,{})],y[0]>Fc&&U(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ec}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[Tc*_.compositeIconSizes[0].evaluate(w,{},S),Tc*_.compositeIconSizes[1].evaluate(w,{},S)],(y[0]>Fc||y[1]>Fc)&&U(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ec}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,y,b,v,w,t.al.none,r,M.lineStartIndex,M.lineLength,-1,S),F=e.icon.placedSymbolArray.length-1,f&&(V=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.al.vertical,r,M.lineStartIndex,M.lineLength,-1,S),$=e.icon.placedSymbolArray.length-1);}const D=Object.keys(i.horizontal);for(const n of D){const s=i.horizontal[n];if(!I){O=to(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},S);I=new Uh(u,r,c,h,p,s,f,d,y,t);}const o=1===s.positionedLines.length;if(E+=ep(e,r,s,a,l,y,w,m,M,i.vertical?t.al.horizontal:t.al.horizontalOnly,o?D:[n],L,F,_,S),o)break}i.vertical&&(T+=ep(e,r,i.vertical,a,l,y,w,m,M,t.al.vertical,["vertical"],L,$,_,S));const j=I?I.boxStartIndex:e.collisionBoxArray.length,R=I?I.boxEndIndex:e.collisionBoxArray.length,N=P?P.boxStartIndex:e.collisionBoxArray.length,q=P?P.boxEndIndex:e.collisionBoxArray.length,G=z?z.boxStartIndex:e.collisionBoxArray.length,Z=z?z.boxEndIndex:e.collisionBoxArray.length,K=C?C.boxStartIndex:e.collisionBoxArray.length,X=C?C.boxEndIndex:e.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(I,H),H=Y(P,H),H=Y(z,H),H=Y(C,H);const J=H>-1?1:0;J&&(H*=k/Hu),e.glyphOffsetArray.length>=Gc.MAX_GLYPHS&&U("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=Wh(l,w,S),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,F,$,O,j,R,N,q,G,Z,K,X,c,E,T,B,V,J,0,f,H,Q,tt);}(e,p,l,n,i,s,B,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,x,[_,_,_,_],k,u,b,A,M,y,r,a,c,h,o);};if("line"===I)for(const t of zh(r.geometry,0,0,z,z)){const r=Nl(t,V),s=Fh(r,w,S,n.vertical||m,i,24,v,e.overscaling,z);for(const t of s)m&&np(e,m.text,P,t)||E(r,t);}else if("line-center"===I){for(const t of r.geometry)if(t.length>1){const e=Nl(t,V),r=Th(e,S,n.vertical||m,i,24,v);r&&E(e,r);}}else if("Polygon"===r.type)for(const t of Wr(r.geometry,0)){const e=Gh(t,16);E(Nl(t[0],V,!0),new Ph(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry){const e=Nl(t,V);E(e,new Ph(e[0].x,e[0].y,0));}else if("Point"===r.type)for(const t of r.geometry)for(const e of t)E([e],new Ph(e.x,e.y,0));}function ep(t,e,r,n,i,s,a,o,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,s,a,o){const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=ic+1,p=!0,f=1,d=0;const y=(i||o)&&n.vertical,m=n.metrics.advance*n.scale/2;if(o&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Hu-n.metrics.width*n.scale)/2:(n.scale-1)*Hu)),n.imageName){const t=a[n.imageName];p=t.sdf,f=t.pixelRatio,h=ac/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],A=w+s.w/b*n.scale/f,S=_+s.h/b*n.scale/f,k=new l(w,_),M=new l(A,_),I=new l(w,S),z=new l(A,S);if(y){const t=new l(-m,m-cc),e=-Math.PI/2,r=Hu/2-m,i=new l(5-cc-r,-(n.imageName?r:0)),s=new l(...v);k._rotateAround(e,t)._add(i)._add(s),M._rotateAround(e,t)._add(i)._add(s),I._rotateAround(e,t)._add(i)._add(s),z._rotateAround(e,t)._add(i)._add(s);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),M._matMult(r),I._matMult(r),z._matMult(r);}const P=new l(0,0),C=new l(0,0);c.push({tl:k,tr:M,bl:I,br:z,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,o,i,s,a,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[Tc*i.layout.get("text-size").evaluate(a,{})],x[0]>Fc&&U(`${t.layerIds[0]}: Value for "text-size" is >= ${Ec}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[Tc*d.compositeTextSizes[0].evaluate(a,{},y),Tc*d.compositeTextSizes[1].evaluate(a,{},y)],(x[0]>Fc||x[1]>Fc)&&U(`${t.layerIds[0]}: Value for "text-size" is >= ${Ec}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,o,s,a,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function rp(t){for(const e in t)return t[e];return null}function np(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=ip[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new sp(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=ip.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ap(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)cp(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];cp(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function ap(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;op(t,e,a,n,i,s),ap(t,e,r,n,a-1,1-s),ap(t,e,r,a+1,i,1-s);}function op(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);op(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(lp(t,e,n,r),e[2*i+s]>a&&lp(t,e,n,i);oa;)l--;}e[2*n+s]===a?lp(t,e,n,l):(l++,lp(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function lp(t,e,r,n){up(t,r,n),up(e,2*r,2*n),up(e,2*r+1,2*n+1);}function up(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function cp(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}var hp;t.co=void 0,(hp=t.co||(t.co={})).create="create",hp.load="load",hp.fullLoad="fullLoad";let pp=null,fp=[];const dp=1e3/60,yp="loadTime",mp="fullLoadTime",gp={mark(t){performance.mark(t);},frame(t){const e=t;null!=pp&&fp.push(e-pp),pp=e;},clearMetrics(){pp=null,fp=[],performance.clearMeasures(yp),performance.clearMeasures(mp);for(const e in t.co)performance.clearMarks(t.co[e]);},getPerformanceMetrics(){performance.measure(yp,t.co.create,t.co.load),performance.measure(mp,t.co.create,t.co.fullLoad);const e=performance.getEntriesByName(yp)[0].duration,r=performance.getEntriesByName(mp)[0].duration,n=fp.length,i=1/(fp.reduce(((t,e)=>t+e),0)/n/1e3),s=fp.filter((t=>t>dp)).reduce(((t,e)=>t+(e-dp)/dp),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:s/(n+s)*100,totalFrames:n}}};t.$=yh,t.A=m,t.B=fr,t.C=ks,t.D=Ts,t.E=mt,t.F=Wi,t.G=function(t){if(null==Z){const e=t.navigator?t.navigator.userAgent:null;Z=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return Z},t.H=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ih((()=>this.process())),this.subscription=W(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=G(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=e?W(e.signal,"abort",(()=>{null==s||s.unsubscribe(),delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),sh):null;this.resolveRejects[i]={resolve:t=>{null==s||s.unsubscribe(),r(t);},reject:t=>{null==s||s.unsubscribe(),n(t);}};const a=[],o=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:ls(t.data,a)});this.target.postMessage(o,{transfer:a});}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(G(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(us(r.error)):e.resolve(us(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=us(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i);}catch(e){this.completeTask(t,e);}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?ls(e):null,data:ls(r,n)};this.target.postMessage(i,{transfer:n});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.I=oc,t.J=ot,t.K=function(){var t=new m(16);return m!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.L=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=a*y+c*m+d*g+e[15]),t},t.M=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.N=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*o+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*s+b*u+w*f+_*g,t[3]=v*a+b*c+w*d+_*x,t[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*s+b*u+w*f+_*g,t[7]=v*a+b*c+w*d+_*x,t[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*s+b*u+w*f+_*g,t[11]=v*a+b*c+w*d+_*x,t[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*s+b*u+w*f+_*g,t[15]=v*a+b*c+w*d+_*x,t},t.O=function(t,e){const r={};for(let n=0;n{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e);};for(const r of t){const t=window.document.createElement("source");ht(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t);}}))},t.a3=Pt,t.a4=function(){return O++},t.a5=ga,t.a6=Gc,t.a7=ui,t.a8=So,t.a9=Ah,t.aA=function(t,e,r,n,i=!1){if(!r[0]&&!r[1])return [0,0];const s=i?"map"===n?-t.bearingInRadians:0:"viewport"===n?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e];}return [i?r[0]:P(e,r[0],t.zoom),i?r[1]:P(e,r[1],t.zoom)]},t.aC=Lc,t.aD=Qh,t.aE=Ac,t.aF=sp,t.aG=Gs,t.aH=Ll,t.aI=za,t.aJ=qa,t.aK=ja,t.aL=$,t.aM=tt,t.aN=dh,t.aO=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},t.aP=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},t.aQ=function(t){var e=new m(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aR=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},t.aS=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},t.aT=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.aU=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},t.aV=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aW=xh,t.aX=bh,t.aY=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.aZ=function(t){var e=new m(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.a_=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.aa=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.ab=Q,t.ac=function(t){return Math.pow(2,t)},t.ad=x,t.ae=F,t.af=85.051129,t.ag=ph,t.ah=function(t){return Math.log(t)/Math.LN2},t.ai=function(t){var e=t[0],r=t[1];return e*e+r*r},t.aj=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ak=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:a}=t,o=i?F(hr.interpolationFactor(i,e,s,a),0,1):0;"camera"===t.kind?n=fr.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.am=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/Tc:"composite"===t.kind?fr.number(n/Tc,i/Tc,r):e},t.an=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,A=i*u-s*l,S=c*y-h*d,k=c*m-p*d,M=c*g-f*d,I=h*m-p*y,z=h*g-f*y,P=p*g-f*m,C=x*P-v*z+b*I+w*M-_*k+A*S;return C?(t[0]=(o*P-l*z+u*I)*(C=1/C),t[1]=(i*z-n*P-s*I)*C,t[2]=(y*A-m*_+g*w)*C,t[3]=(p*_-h*A-f*w)*C,t[4]=(l*M-a*P-u*k)*C,t[5]=(r*P-i*M+s*k)*C,t[6]=(m*b-d*A-g*v)*C,t[7]=(c*A-p*b+f*v)*C,t[8]=(a*z-o*M+u*S)*C,t[9]=(n*M-r*z-s*S)*C,t[10]=(d*_-y*b+g*x)*C,t[11]=(h*b-c*_-f*x)*C,t[12]=(o*k-a*I-l*S)*C,t[13]=(r*I-n*k+i*S)*C,t[14]=(y*v-d*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null},t.ao=M,t.ap=function(t){return Math.hypot(t[0],t[1])},t.aq=function(t){return t[0]=0,t[1]=0,t},t.ar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},t.as=Rc,t.at=S,t.au=function(t,e,r,n){const i=e.y-t.y,s=e.x-t.x,a=n.y-r.y,o=n.x-r.x,u=a*s-o*i;if(0===u)return null;const c=(o*(t.y-r.y)-a*(t.x-r.x))/u;return new l(t.x+c*s,t.y+c*i)},t.av=zh,t.aw=zo,t.ax=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return [e,r,n,i]},t.ay=Hu,t.az=P,t.b=K,t.b$=class extends da{},t.b0=function(){const t=new Float32Array(16);return x(t),t},t.b1=function(){const t=new Float64Array(16);return x(t),t},t.b2=function(){return new Float64Array(16)},t.b3=function(t,e,r){const n=new Float64Array(4);return function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u;}(n,t,e-90,r),n},t.b4=function(t,e,r,n){var i,s,a,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],m=r[2],g=r[3];return (s=u*f+c*d+h*m+p*g)<0&&(s=-s,f=-f,d=-d,m=-m,g=-g),1-s>y?(i=Math.acos(s),a=Math.sin(i),o=Math.sin((1-n)*i)/a,l=Math.sin(n*i)/a):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*m,t[3]=o*p+l*g,t},t.b5=function(t){const e=new Float64Array(9);var r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v;h=(i=(n=t)[0])*(l=i+i),p=(s=n[1])*l,d=(a=n[2])*l,y=a*(u=s+s),g=(o=n[3])*l,x=o*u,v=o*(c=a+a),(r=e)[0]=1-(f=s*u)-(m=a*c),r[3]=p-v,r[6]=d+x,r[1]=p+v,r[4]=1-h-m,r[7]=y-g,r[2]=d-x,r[5]=y+g,r[8]=1-h-f;const b=tt(-Math.asin(F(e[2],-1,1)));let w,_;return Math.hypot(e[5],e[8])<.001?(w=0,_=-tt(Math.atan2(e[3],e[4]))):(w=tt(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),_=tt(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:w,pitch:b+90,bearing:_}},t.b6=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b7=ke,t.b8=ao,t.b9=Ol,t.bA=function(t){if("custom"===t.type)return new nh(t);switch(t.type){case "background":return new Qc(t);case "circle":return new Go(t);case "fill":return new Yl(t);case "fill-extrusion":return new wu(t);case "heatmap":return new nl(t);case "hillshade":return new al(t);case "line":return new Lu(t);case "raster":return new rh(t);case "symbol":return new Yc(t)}},t.bB=R,t.bC=function(t,e){if(!t)return [{command:"setStyle",args:[e]}];let r=[];try{if(!bt(t.version,e.version))return [{command:"setStyle",args:[e]}];bt(t.center,e.center)||r.push({command:"setCenter",args:[e.center]}),bt(t.state,e.state)||r.push({command:"setGlobalState",args:[e.state]}),bt(t.centerAltitude,e.centerAltitude)||r.push({command:"setCenterAltitude",args:[e.centerAltitude]}),bt(t.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),bt(t.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),bt(t.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),bt(t.roll,e.roll)||r.push({command:"setRoll",args:[e.roll]}),bt(t.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),bt(t.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),bt(t.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),bt(t.light,e.light)||r.push({command:"setLight",args:[e.light]}),bt(t.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),bt(t.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),bt(t.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const n={},i=[];!function(t,e,r,n){let i;for(i in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)||At(i,r,n));for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)?bt(t[i],e[i])||("geojson"===t[i].type&&"geojson"===e[i].type&&kt(t,e,i)?wt(r,{command:"setGeoJSONSourceData",args:[i,e[i].data]}):St(i,e,r,n)):_t(i,e,r));}(t.sources,e.sources,i,n);const s=[];t.layers&&t.layers.forEach((t=>{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):s.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(It),i=e.map(It),s=t.reduce(zt,{}),a=e.reduce(zt,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;tr?i-360:i+360;return Math.abs(i)0?a:-a},t.bt=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bu=ah,t.bv=function(t,e){const r=C(t,2*Math.PI),n=C(e,2*Math.PI);return Math.min(Math.abs(r-n),Math.abs(r-n+2*Math.PI),Math.abs(r-n-2*Math.PI))},t.bw=function(){const t={},e=gt.$version;for(const r in gt.$root){const n=gt.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.bx=cs,t.by=ut,t.bz=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r"symbol"===t.type,t.c4=t=>"circle"===t.type,t.c5=t=>"heatmap"===t.type,t.c6=t=>"line"===t.type,t.c7=t=>"fill"===t.type,t.c8=t=>"fill-extrusion"===t.type,t.c9=t=>"hillshade"===t.type,t.cA=Zl,t.cB=yu,t.cC=hu,t.cD=Qu,t.cE=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start);}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.cF=function(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if(d())try{return yield H(t,r,n,i,s)}catch(t){}return function(t,e,r,n,i){const s=t.width,a=t.height;Y&&J||(Y=new OffscreenCanvas(s,a),J=Y.getContext("2d",{willReadFrequently:!0})),Y.width=s,Y.height=a,J.drawImage(t,0,0,s,a);const o=J.getImageData(e,r,n,i);return J.clearRect(0,0,s,a),o.data}(t,r,n,i,s)}))},t.cG=wh,t.cH=r,t.cI=s,t.cJ=cu,t.cK=Wu,t.cL=ei,t.cM=Ss,t.ca=t=>"raster"===t.type,t.cb=t=>"background"===t.type,t.cc=t=>"custom"===t.type,t.cd=E,t.ce=function(t,e,r){const n=I(e.x-r.x,e.y-r.y),i=I(t.x-r.x,t.y-r.y);var s,a;return tt(Math.atan2(n[0]*i[1]-n[1]*i[0],(s=n)[0]*(a=i)[0]+s[1]*a[1]))},t.cf=T,t.cg=function(t,e){return rt[e]&&(t instanceof MouseEvent||t instanceof WheelEvent)},t.ch=function(t,e){return et[e]&&"touches"in t},t.ci=function(t){return et[t]||rt[t]},t.cj=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},t.ck=function(t,e){const{x:r,y:n}=yh.fromLngLat(e);return !(t<0||t>25||n<0||n>=1||r<0||r>=1)},t.cl=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cm=class extends Xs{},t.cn=gp,t.cp=function(t){return t.message===nt},t.cq=lt,t.cr=function(t,e){st.REGISTERED_PROTOCOLS[t]=e;},t.cs=function(t){delete st.REGISTERED_PROTOCOLS[t];},t.ct=function(t,e){const r={};for(let n=0;nt*Hu));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(i,{},e.canonical)*Hu:1/0,w=()=>{e.bucket.allowVerticalPlacement&&ps(s)&&(d.vertical=fc(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,b,a,m,"left",f,g,t.al.vertical,!0,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.g=at,t.h=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=X;}));},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):X;})),t.i=G,t.j=(t,e)=>ct(L(t,{type:"json"}),e),t.k=yt,t.l=dt,t.m=ct,t.n=(t,e)=>ct(L(t,{type:"arrayBuffer"}),e),t.o=function(t){return new Qu(t).readFields(ec,[])},t.p=sc,t.q=Qo,t.r=Ds,t.s=W,t.t=Ji,t.u=hs,t.v=gt,t.w=U,t.x=es,t.y=Yi,t.z=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}};})); + +define("worker",["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const o of t){this._layerConfigs[o.id]=o;const t=this._layers[o.id]=e.bA(o);t._featureFilter=e.a7(t.filter),this.keyCache[o.id]&&delete this.keyCache[o.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=e.ct(Object.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let r=this.familiesBySource[i];r||(r=this.familiesBySource[i]={});const s=o.sourceLayer||"_geojsonTileLayer";let n=r[s];n||(n=r[s]=[]),n.push(t);}}}class o{constructor(t){const o={},i=[];for(const e in t){const r=t[e],s=o[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};i.push(o),s[e]={rect:o,metrics:t.metrics};}}const{w:r,h:s}=e.p(i),n=new e.q({width:r||1,height:s||1});for(const i in t){const r=t[i];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=o[i][t].rect;e.q.copy(s.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap);}}this.image=n,this.positions=o;}}e.cu("GlyphAtlas",o);class i{constructor(t){this.tileID=new e.Y(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,i,s,n,a){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a5;const l=new e.cv(Object.keys(t.layers).sort()),c=new e.cw(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:s,subdivisionGranularity:a},d=i.familiesBySource[this.source];for(const o in d){const i=t.layers[o];if(!i)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(o),a=[];for(let e=0;e=o.maxzoom||"none"!==o.visibility&&(r(t,this.zoom,s),(u[o.id]=o.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}const f=e.bF(h.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let g=Promise.resolve({});if(Object.keys(f).length){const e=new AbortController;this.inFlightDependencies.push(e),g=n.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const p=Object.keys(h.iconDependencies);let m=Promise.resolve({});if(p.length){const e=new AbortController;this.inFlightDependencies.push(e),m=n.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},e);}const y=Object.keys(h.patternDependencies);let v=Promise.resolve({});if(y.length){const e=new AbortController;this.inFlightDependencies.push(e),v=n.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const[w,x,_]=yield Promise.all([g,m,v]),b=new o(w),M=new e.cx(x,_);for(const t in u){const o=u[t];o instanceof e.a6?(r(o.layers,this.zoom,s),e.cy({bucket:o,glyphMap:w,glyphPositions:b.positions,imageMap:x,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):o.hasPattern&&(o instanceof e.cz||o instanceof e.cA||o instanceof e.cB)&&(r(o.layers,this.zoom,s),o.addFeatures(h,this.tileID.canonical,M.patternPositions));}return this.status="done",{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:M,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function r(t,o,i){const r=new e.C(o);for(const e of t)e.recalculate(r,i);}class s{constructor(e,t,o){this.actor=e,this.layerIndex=t,this.availableImages=o,this.fetching={},this.loading={},this.loaded={};}loadVectorTile(t,o){return e._(this,void 0,void 0,(function*(){const i=yield e.n(t.request,o);try{return {vectorTile:new e.cC.VectorTile(new e.cD(i.data)),rawData:i.data,cacheControl:i.cacheControl,expires:i.expires}}catch(e){const o=new Uint8Array(i.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cE(t.request),s=new i(t);this.loading[o]=s;const n=new AbortController;s.abort=n;try{const i=yield this.loadVectorTile(t,n);if(delete this.loading[o],!i)return null;const a=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}s.vectorTile=i.vectorTile;const u=s.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[o]=s,this.fetching[o]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[o];}}catch(e){throw delete this.loading[o],s.status="done",this.loaded[o]=s,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid;if(!this.loaded||!this.loaded[o])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const i=this.loaded[o];if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=yield i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let s;if(this.fetching[o]){const{rawTileData:t,cacheControl:i,resourceTiming:n}=this.fetching[o];delete this.fetching[o],s=e.e({rawTileData:t.slice(0)},r,i,n);}else s=r;return s}if("done"===i.status&&i.vectorTile)return i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){const e=this.loading,o=t.uid;e&&e[o]&&e[o].abort&&(e[o].abort.abort(),delete e[o]);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid];}))}}class n{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:i,rawImageData:r,redFactor:s,greenFactor:n,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cF(r,-1,-1,c,u)):r,d=new e.cG(o,h,i,s,n,a,l);return this.loaded=this.loaded||{},this.loaded[o]=d,d}))}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}var a,l,c=function(){if(l)return a;function e(e,o){if(0!==e.length){t(e[0],o);for(var i=1;i=Math.abs(a)?o-l+a:a-l+o,o=l;}o+i>=0!=!!t&&e.reverse();}return l=1,a=function t(o,i){var r,s=o&&o.type;if("FeatureCollection"===s)for(r=0;r>31}function c(e,t){for(var o=e.loadGeometry(),i=e.type,r=0,s=0,n=o.length,c=0;ce},_=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;const M=3,S=5,I=6;class P{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const s=[];for(let t=0;t=o;e--){const o=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,r=180;else if(o>r){const e=this.getClusters([o,i,180,s],t),n=this.getClusters([-180,i,r,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(D(o),C(s),D(r),C(i)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+S]>1?k(l,t,this.clusterProps):this.points[l[t+M]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(i);const s=r.data;if(t*this.stride>=s.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const o=t*this.stride;s[o+4]===e&&l.push(s[o+S]>1?k(s,o,this.clusterProps):this.points[s[o+M]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(o-a)/r,c=(o+1+a)/r,u={features:[]};return this._addTileFeatures(i.range((t-a)/r,l,(t+1+a)/r,c),i.data,t,o,r,u),0===t&&this._addTileFeatures(i.range(1-a/r,l,1,c),i.data,r,o,r,u),t===r-1&&this._addTileFeatures(i.range(0,l,a/r,c),i.data,-1,o,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=i?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,o,i,r):r1;let l,c,u;if(a)l=T(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+M]];l=o.properties;const[i,r]=o.geometry.coordinates;c=D(i),u=C(r);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-o)),Math.round(this.options.extent*(u*r-i))]],tags:l};let d;d=a||this.options.generateId?t[e+M]:this.points[t[e+M]].id,void 0!==d&&(h.id=d),s.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:r,minPoints:s}=this.options,n=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+S]);}if(f>d&&f>=s){let e,s=i*d,n=u*d,g=-1;const p=((o/c|0)<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+S];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=p,r&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)));}a[o+4]=p,l.push(s/f,n/f,1/0,p,-1,f),r&&l.push(g);}else {for(let e=0;e1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+S]>1){const i=this.clusterProps[e[t+I]];return o?Object.assign({},i):i}const i=this.points[e[t+M]].properties,r=this.options.map(i);return o&&r===i?Object.assign({},r):r}}function k(e,t,o){return {type:"Feature",id:e[t+M],properties:T(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),O(e[t+1])]}};var i;}function T(e,t,o){const i=e[t+S],r=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,s=e[t+I],n=-1===s?{}:Object.assign({},o[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+M],point_count:i,point_count_abbreviated:r})}function D(e){return e/360+.5}function C(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function O(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function L(e,t,o,i){let r=i;const s=t+(o-t>>1);let n,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;ir)n=i,r=t;else if(t===r){const e=Math.abs(i-s);ei&&(n-t>3&&L(e,t,n,i),e[n+2]=r,o-n>3&&L(e,n,o,i));}function F(e,t,o,i,r,s){let n=r-o,a=s-i;if(0!==n||0!==a){const l=((e-o)*n+(t-i)*a)/(n*n+a*a);l>1?(o=r,i=s):l>0&&(o+=n*l,i+=a*l);}return n=e-o,a=t-i,n*n+a*a}function G(e,t,o,i){const r={id:null==e?null:e,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)z(r,o);else if("Polygon"===t)z(r,o[0]);else if("MultiLineString"===t)for(const e of o)z(r,e);else if("MultiPolygon"===t)for(const e of o)z(r,e[0]);return r}function z(e,t){for(let o=0;o0&&(n+=i?(r*l-a*s)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-s,2))),r=a,s=l;}const a=t.length-3;t[2]=1,L(t,0,a,o),t[a+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function Z(e,t,o,i){for(let r=0;r1?1:o}function W(e,t,o,i,r,s,n,a){if(i/=t,s>=(o/=t)&&n=i)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const n=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(n>=o&&c=i)continue;let u=[];if("Point"===s||"MultiPoint"===s)R(e,u,o,i,r);else if("LineString"===s)Y(e,u,o,i,r,!1,a.lineMetrics);else if("MultiLineString"===s)q(e,u,o,i,r,!1);else if("Polygon"===s)q(e,u,o,i,r,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];q(t,e,o,i,r,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(G(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(G(t.id,s,u,t.tags));}}return l.length?l:null}function R(e,t,o,i,r){for(let s=0;s=o&&n<=i&&H(t,e[s],e[s+1],e[s+2]);}}function Y(e,t,o,i,r,s,n){let a=V(e);const l=0===r?X:B;let c,u,h=e.start;for(let d=0;do&&(u=l(a,f,g,m,y,o),n&&(a.start=h+c*u)):v>i?w=o&&(u=l(a,f,g,m,y,o),x=!0),w>i&&v<=i&&(u=l(a,f,g,m,y,i),x=!0),!s&&x&&(n&&(a.end=h+c*u),t.push(a),a=V(e)),n&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===r?f:g;p>=o&&p<=i&&H(a,f,g,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&H(a,a[0],a[1],a[2]),a.length&&t.push(a);}function V(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function q(e,t,o,i,r,s){for(const n of e)Y(n,t,o,i,r,s,!1);}function H(e,t,o,i){e.push(t,o,i);}function X(e,t,o,i,r,s){const n=(s-t)/(i-t);return H(e,s,o+(r-o)*n,1),n}function B(e,t,o,i,r,s){const n=(s-o)/(r-o);return H(e,t+(i-t)*n,s,1),n}function $(e,t){const o=[];for(let i=0;i0&&t.size<(r?n:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;en)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;r&&function(e,t){let o=0;for(let t=0,i=e.length,r=i-2;t0===t)for(let t=0,o=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=ee(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(o!==s>>e||i!==n>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,v=null,w=null,x=null,_=W(e,u,o-f,o+p,0,d.minX,d.maxX,l),b=W(e,u,o+g,o+m,0,d.minX,d.maxX,l);e=null,_&&(y=W(_,u,i-f,i+p,1,d.minY,d.maxY,l),v=W(_,u,i+g,i+m,1,d.minY,d.maxY,l),_=null),b&&(w=W(b,u,i-f,i+p,1,d.minY,d.maxY,l),x=W(b,u,i+g,i+m,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(v||[],t+1,2*o,2*i+1),a.push(w||[],t+1,2*o+1,2*i),a.push(x||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:r,debug:s}=i;if(e<0||e>24)return null;const n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[se(c,u,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),s>1&&console.timeEnd("drilling down"),this.tiles[a]?K(this.tiles[a],r):null):null}}function se(e,t,o){return 32*((1<{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,n);},t}(t)).load((yield this._pendingData).features):(r=yield this._pendingData,new re(r,t.geojsonVtOptions)),this.loaded={};const o={};if(i){const e=i.finish();e&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}return o}catch(t){if(delete this._pendingRequest,e.cp(t))return {abandoned:!0};throw t}var r;}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){let i=yield this.loadGeoJSON(t,o);if(delete this._pendingRequest,"object"!=typeof i)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(i,!0),t.filter){const o=e.cL(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const r=i.features.filter((e=>o.value.evaluate({zoom:0},e)));i={type:"FeatureCollection",features:r};}return i}))}loadGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){const{promoteId:i}=t;if(t.request){const r=yield e.j(t.request,o);return this._dataUpdateable=ae(r.data,i)?le(r.data,i):void 0,r.data}if("string"==typeof t.data)try{const e=JSON.parse(t.data);return this._dataUpdateable=ae(e,i)?le(e,i):void 0,e}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return function(e,t,o){var i,r,s,n;if(t.removeAll&&e.clear(),t.remove)for(const o of t.remove)e.delete(o);if(t.add)for(const i of t.add){const t=ne(i,o);null!=t&&e.set(t,i);}if(t.update)for(const o of t.update){let t=e.get(o.id);if(null==t)continue;const a=!o.removeAllProperties&&((null===(i=o.removeProperties)||void 0===i?void 0:i.length)>0||(null===(r=o.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((o.newGeometry||o.removeAllProperties||a)&&(t=Object.assign({},t),e.set(o.id,t),a&&(t.properties=Object.assign({},t.properties))),o.newGeometry&&(t.geometry=o.newGeometry),o.removeAllProperties)t.properties={};else if((null===(s=o.removeProperties)||void 0===s?void 0:s.length)>0)for(const e of o.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:i}of o.addOrUpdateProperties)t.properties[e]=i;}}(this._dataUpdateable,t.dataDiff,i),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class ue{constructor(t){this.self=t,this.actor=new e.H(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.cr,this.self.removeProtocol=e.cs,this.self.registerRTLTextPlugin=t=>{e.cM.setMethods(t);},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,o)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,o.source).removeTile(o);})))),this.actor.registerMessageHandler("GCEZ",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterExpansionZoom(o)})))),this.actor.registerMessageHandler("GCC",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterChildren(o)})))),this.actor.registerMessageHandler("GCL",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterLeaves(o)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,o)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][o.type]||!this.workerSources[t][o.type][o.source])return;const e=this.workerSources[t][o.type][o.source];delete this.workerSources[t][o.type][o.source],void 0!==e.removeSource&&e.removeSource(o);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t];})))),this.actor.registerMessageHandler("SR",((t,o)=>e._(this,void 0,void 0,(function*(){this.referrer=o;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,o)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(o);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(o.layers,o.removedIds);})))),this.actor.registerMessageHandler("SL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(o);}))));}_setImages(t,o){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=o;for(const e in this.workerSources[t]){const i=this.workerSources[t][e];for(const e in i)i[e].availableImages=o;}}))}_syncRTLPluginState(t,o){return e._(this,void 0,void 0,(function*(){return yield e.cM.syncState(o,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let o=this.layerIndexes[e];return o||(o=this.layerIndexes[e]=new t),o}_getWorkerSource(e,t,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][o]){const i={sendAsync:(t,o)=>(t.targetMapId=e,this.actor.sendAsync(t,o))};switch(t){case "vector":this.workerSources[e][t][o]=new s(i,this._getLayerIndex(e),this._getAvailableImages(e));break;case "geojson":this.workerSources[e][t][o]=new ce(i,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][o]=new this.externalWorkerSourceTypes[t](i,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][o]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue})); + +define("index",["exports","./shared"],(function(e,t){"use strict";var i="5.5.0";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let o,a;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,i,r){const o=requestAnimationFrame((e=>{a(),i(e);})),{unsubscribe:a}=t.s(e.signal,"abort",(()=>{a(),cancelAnimationFrame(o),r(t.c());}),!1);},frameAsync(e){return new Promise(((t,i)=>{this.frame(e,t,i);}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(o||(o=document.createElement("a")),o.href=e,o.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==a&&(a=matchMedia("(prefers-reduced-motion: reduce)")),a.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",n.suppressClickInternal,!0);}),0);}static getScale(e){const t=e.getBoundingClientRect();return {x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const o=i.boundingClientRect;return new t.P((r.clientX-o.left)/i.x-e.clientLeft,(r.clientY-o.top)/i.y-e.clientTop)}static mousePos(e,t){const i=n.getScale(e);return n.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=n.getScale(e);for(let o=0;o{c&&_(c),c=null,d=!0;},h.onerror=()=>{u=!0,c=null;},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,r,o,a;e.resetRequestQueue=()=>{i=[],r=0,o=0,a={};},e.addThrottleControl=e=>{const t=o++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],n();},e.getImage=(e,r,o=!0)=>new Promise(((a,s)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:o,state:"queued",onError:e=>{s(e);},onSuccess:e=>{a(e);}}),n();}));const s=e=>t._(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:i,supportImageRefresh:o,onError:a,onSuccess:s,abortController:l}=e,h=!1===o&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((e,t)=>e&&"accept"===t),!0));r++;const u=h?c(i,l):t.m(i,l);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(t){delete e.abortController,a(t);}finally{r--,n();}var d;})),n=()=>{const e=(()=>{for(const e of Object.keys(a))if(a[e]())return !0;return !1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e);}},c=(e,i)=>new Promise(((r,o)=>{const a=new Image,s=e.url,n=e.credentials;n&&"include"===n?a.crossOrigin="use-credentials":(n&&"same-origin"===n||!t.d(s))&&(a.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{a.src="",o(t.c());})),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,r({data:a});},a.onerror=()=>{a.onerror=a.onload=null,i.signal.aborted||o(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},a.src=s;}));}(p||(p={})),p.resetRequestQueue();class m{constructor(e){this._transformRequestFn=e;}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e;}}function f(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:o}of e){const e=`${r}${o}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:o}));}}return t}function g(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}class v{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:o,height:a}=e,s=!(this.size&&this.size[0]===o&&this.size[1]===a||r),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),s)this.size=[o,a],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,o,a,0,this.format,l.UNSIGNED_BYTE,e.data);else {const{x:i,y:s}=r||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,s,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,s,o,a,l.RGBA,l.UNSIGNED_BYTE,e.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D),n.pixelStoreUnpackFlipY.setDefault(),n.pixelStoreUnpack.setDefault(),n.pixelStoreUnpackPremultiplyAlpha.setDefault();}bind(e,t,i){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),i!==o.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=o.LINEAR),e!==this.filter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,t),this.wrap=t);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t);}_validate(e,i){let r=!0;const o=i.data||i.spriteData;return this._validateStretch(i.stretchX,o&&o.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,o&&o.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return !0;let i=0;for(const r of e){if(r[0]{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t});}))}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.l("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return {width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else {const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},o=new t.I(i,r);this.patterns[e]={bin:i,position:o};}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new v(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE);}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),o=this.atlasImage;o.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,a=i.y+1,s=this.getImage(e).data,n=s.width,l=s.height;t.R.copy(s,o,{x:0,y:0},{x:r,y:a},{width:n,height:l}),t.R.copy(s,o,{x:0,y:l-1},{x:r,y:a-1},{width:n,height:1}),t.R.copy(s,o,{x:0,y:0},{x:r,y:a+l},{width:n,height:1}),t.R.copy(s,o,{x:n-1,y:0},{x:r-1,y:a},{width:1,height:l}),t.R.copy(s,o,{x:0,y:0},{x:r+n,y:a},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e);}}}const y=1e20;function w(e,t,i,r,o,a,s,n,l){for(let c=t;c-1);l++,a[l]=n,s[l]=c,s[l+1]=y;}for(let n=0,l=0;n65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[o])return {stack:e,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[o]){const i=P.loadGlyphRange(e,o,this.url,this.requestManager);t.requests[o]=i;}const a=yield t.requests[o];for(const e in a)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=a[+e]);return t.ranges[o]=!0,{stack:e,id:i,glyph:a[i]||null}}))}_doesCharSupportLocalGlyph(e){return !!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||t.u["CJK Unified Ideographs"](e)||t.u["Hangul Syllables"](e)||t.u.Hiragana(e)||t.u.Katakana(e)||t.u["CJK Symbols and Punctuation"](e)||t.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,i,r){const o=this.localIdeographFontFamily;if(!o)return;if(!this._doesCharSupportLocalGlyph(r))return;let a=e.tinySDF;if(!a){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),a=e.tinySDF=new P.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:t});}const s=a.draw(String.fromCharCode(r));return {id:r,bitmap:new t.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}P.loadGlyphRange=function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=256*i,s=a+255,n=o.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${a}-${s}`),"Glyphs"),l=yield t.n(n,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${a}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c}))},P.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:a="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const n=this.size=e+4*t,l=this._createCanvas(n),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${a} ${e}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:a}=this.ctx.measureText(e),s=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-o))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=n+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),_={data:d,width:c,height:h,glyphWidth:n,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(e,m,m+s);const v=p.getImageData(m,m,n,l);g.fill(y,0,u),f.fill(0,0,u);for(let e=0;e0?e*e:0,f[r]=e<0?e*e:0;}}w(g,0,0,c,h,c,this.f,this.v,this.z),w(f,m,m,n,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++a]);const l=Math.abs(n-s.left),c=Math.abs(n-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.data[o+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let o=0,a=e[o];for(let t=0;t1&&(a=e[++o]);const i=Math.abs(t-a.left),s=Math.abs(t-a.right),n=Math.min(i,s);this.data[r+t]=Math.max(0,Math.min(255,(a.isDash?n:-n)+128));}}addDash(e,i){const r=i?7:0,o=2*r+1;if(this.nextRow+o>this.height)return t.w("LineAtlas out of space"),null;let a=0;for(let t=0;t{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[z]}numActive(){return Object.keys(this.active).length}}const A=Math.floor(s.hardwareConcurrency/2);let L,k;function F(){return L||(L=new D),L}D.workerCount=t.G(globalThis)?Math.max(Math.min(A,3),1):1;class B{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let e=0;e{e.remove();})),this.actors=[],e&&this.workerPool.release(this.id);}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t);}}function O(){return k||(k=new B(F(),t.J),k.registerMessageHandler("GR",((e,i,r)=>t.m(i,r)))),k}function j(e,i){const r=t.K();return t.L(r,r,[1,1,0]),t.M(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.N(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function Z(e,t,i,r,o,a,s){var n;const l=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return !0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return !0}return !1}(null!==(n=null==o?void 0:o.layers)&&void 0!==n?n:null,t,e.id),c=a.maxPitchScaleFactor(),h=e.tilesIn(r,c,l);h.sort(N);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,o,a,c,j(e.transform,r.tileID),s?(e,t)=>s(r.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const r of e[i])U(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,o=r.wrappedTileID,a=i[o]=i[o]||{};for(const i in e){const r=e[i],o=a[i]=a[i]||{},s=t[i]=t[i]||[];for(const e of r)o[e.featureIndex]||(o[e.featureIndex]=!0,s.push(e));}}return t}(u),e)}function N(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function U(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r;}function G(e,i,r){return t._(this,void 0,void 0,(function*(){let o=e;if(e.url?o=(yield t.j(i.transformRequest(e.url,"Source"),r)).data:yield s.frameAsync(r),!o)return null;const a=t.O(t.e(o,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in o&&o.vector_layers&&(a.vectorLayerIds=o.vector_layers.map((e=>e.id))),a}))}class V{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])));}setNorthEast(e){return this._ne=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}extend(e){const i=this._sw,r=this._ne;let o,a;if(e instanceof t.Q)o=e,a=e;else {if(!(e instanceof V))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(V.convert(e)):this.extend(t.Q.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.Q.convert(e)):this;if(o=e._sw,a=e._ne,!o||!a)return this}return i||r?(i.lng=Math.min(o.lng,i.lng),i.lat=Math.min(o.lat,i.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)):(this._sw=new t.Q(o.lng,o.lat),this._ne=new t.Q(a.lng,a.lat)),this}getCenter(){return new t.Q((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.Q(this.getWest(),this.getNorth())}getSouthEast(){return new t.Q(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:r}=t.Q.convert(e);let o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&o}static convert(e){return e instanceof V?e:e?new V(e):e}static fromLngLat(e,i=0){const r=360*i/40075017,o=r/Math.cos(Math.PI/180*e.lat);return new V(new t.Q(e.lng-o,e.lat-r),new t.Q(e.lng+o,e.lat+r))}adjustAntiMeridian(){const e=new t.Q(this._sw.lng,this._sw.lat),i=new t.Q(this._ne.lng,this._ne.lat);return new V(e,e.lng>i.lng?new t.Q(i.lng+360,i.lat):i)}}class q{constructor(e,t,i){this.bounds=V.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.U(this.bounds.getWest())*i),o=Math.floor(t.S(this.bounds.getNorth())*i),a=Math.ceil(t.U(this.bounds.getEast())*i),s=Math.ceil(t.S(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((t,i)=>{e.reloadPromise={resolve:t,reject:i};}))}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null);}}))}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject);}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class H extends t.E{constructor(e,i,r,o){super(),this.id=e,this.dispatcher=r,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.O(i,["url","scheme","tileSize"]));}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield G(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e));}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}serialize(){return t.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const i=yield p.getImage(this.map._requestManager.transformRequest(t,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const t=this.map.painter.context,r=t.gl,o=i.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new v(t,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController);}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture);}))}hasTransition(){return !1}}class $ extends H{constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield p.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const o=t.b(r)&&t.V()?r:yield this.readImageNow(r),a={type:this.type,uid:e.uid,source:this.id,rawImageData:o,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:a});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded";}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.W()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.X(e,-1,-1,i,r))}catch(e){}}return s.getImageData(e,1)}))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,a=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,n=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.Y(e.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.Y(e.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return t._(this,void 0,void 0,(function*(){const e=new V,t=yield this.getData();let i;switch(t.type){case "FeatureCollection":i=t.features.map((e=>this.getCoordinatesFromGeometry(e.geometry))).flat(1/0);break;case "Feature":i=this.getCoordinatesFromGeometry(t.geometry);break;default:i=this.getCoordinatesFromGeometry(t);}if(0==i.length)return e;for(let t=0;t0&&t.e(o,{resourceTiming:r}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content"})));}catch(e){if(this._pendingLoads--,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e));}}))}loaded(){return 0===this._pendingLoads}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t);}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0;}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}}class K extends t.E{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t;}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield p.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading());}catch(e){this._request=null,this._loaded=!0,this.fire(new t.k(e));}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.$.fromLngLat);var r;return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s=Math.max(o-i,a-r),n=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,n);return new t.a1(n,Math.floor((i+o)/2*l),Math.floor((r+a)/2*l))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new v(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}_getOverlappingTileRanges(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s={};for(let e=0;e<=t.a0;e++){const t=Math.pow(2,e),n=Math.floor(i*t),l=Math.floor(r*t),c=Math.floor(o*t),h=Math.floor(a*t);s[e]={minTileX:n,minTileY:l,maxTileX:c,maxTileY:h};}return s}}class Q extends K{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a2(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading();}catch(e){this.fire(new t.k(e));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.a3(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new v(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Y extends K{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.a3(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new v(i,this.canvas,r.RGBA,{premultiply:!0});let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}}const J={},ee=e=>{switch(e){case "geojson":return X;case "image":return K;case "raster":return H;case "raster-dem":return $;case "vector":return W;case "video":return Q;case "canvas":return Y}return J[e]},te="RTLPluginLoaded";class ie extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=O();}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(te));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let re=null;function oe(){return re||(re=new ie),re}class ae{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a4(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r;}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6&&i.hasRTLText){this.hasRTLText=!0,oe().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage);}else this.collisionBoxArray=new t.a5;}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new v(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new v(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null);}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture);}queryRenderedFeatures(e,t,i,r,o,a,s,n,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:o,scale:a,tileSize:this.tileSize,pixelPosMatrix:c,transform:n,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const o=r.loadVTLayers(),a=i&&i.sourceLayer?i.sourceLayer:"",s=o._geojsonTileLayer||o[a];if(!s)return;const n=t.a7(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,o);}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class ne{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,i,r){const o=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},t.e(this.stateChanges[e][o],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null);}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,i){const r=String(i),o=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete o[e];}return o}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,i){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}r[e]=r[e]||{},t.e(r[e],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i);}}const le=89.25;function ce(e,i){const r=t.ae(i.lat,-85.051129,t.af);return new t.P(t.U(i.lng)*e,t.S(r)*e)}function he(e,i){return new t.$(i.x/e,i.y/e).toLngLat()}function ue(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.ab(90-e.pitch)),Math.tan(t.ab(le-e.pitch)))}function de(e,i){const r=e.canonical,o=i/t.ac(r.z),a=r.x+Math.pow(2,r.z)*e.wrap,s=t.ad(new Float64Array(16));return t.L(s,s,[a*o,r.y*o,0]),t.M(s,s,[o/t.Z,o/t.Z,1]),s}function _e(e,i,r,o,a){const s=t.$.fromLngLat(e,i),n=a*t.ag(1,e.lat),l=n*Math.cos(t.ab(r)),c=Math.sqrt(n*n-l*l),h=c*Math.sin(t.ab(-o)),u=c*Math.cos(t.ab(-o));return new t.$(s.x+h,s.y+u,s.z+l)}function pe(e,t,i){const r=t.intersectsFrustum(e);if(!i)return r;const o=t.intersectsPlane(i);return 0===r||0===o?0:2===r&&2===o?2:1}function me(e,t,i){let r=0;const o=(i-t)/10;for(let a=0;a<10;a++)r+=o*Math.pow(Math.cos(t+(a+.5)/10*(i-t)),e);return r}function fe(e,i){return function(r,o,a,s,n){const l=2*((e-1)/t.ah(Math.cos(t.ab(le-n))/Math.cos(t.ab(le)))-1),c=Math.acos(a/s),h=2*me(l-1,0,t.ab(n/2)),u=Math.min(t.ab(le),c+t.ab(n/2)),d=me(l-1,Math.min(u,c-t.ab(n/2)),u),_=Math.atan(o/a),p=Math.hypot(o,a);let m=r;return m+=t.ah(s/p/Math.max(.5,Math.cos(t.ab(n/2)))),m+=l*t.ah(Math.cos(_))/2,m-=t.ah(Math.max(1,d/h/i))/2,m}}const ge=fe(9.314,3);function ve(e,i){const r=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ah(e.tileSize/i.tileSize));return Math.max(0,r)}function xe(e,i){const r=e.getCameraFrustum(),o=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.$.fromLngLat(e.center,e.elevation);a.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const n=e.getCoveringTilesDetailsProvider(),l=n.allowVariableZoom(e,i),c=ve(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),_=Math.pow(2,d),p=[_*a.x,_*a.y,0],m=[_*s.x,_*s.y,0],f=Math.hypot(s.x-a.x,s.y-a.y),g=Math.abs(s.z-a.z),v=Math.hypot(f,g),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],y=[];if(e.renderWorldCopies&&n.allowWorldCopies())for(let e=1;e<=3;e++)b.push(x(-e)),b.push(x(e));for(b.push(x(0));b.length>0;){const _=b.pop(),f=_.x,x=_.y;let w=_.fullyVisible;const T={x:f,y:x,z:_.zoom},P=n.getTileAABB(T,_.wrap,e.elevation,i);if(!w){const e=pe(r,P,o);if(0===e)continue;w=2===e;}const C=n.distanceToTile2d(a.x,a.y,T,P);let M=c;l&&(M=(i.calculateTileZoom||ge)(e.zoom+t.ah(e.tileSize/i.tileSize),C,g,v,e.fov)),M=(i.roundZoom?Math.round:Math.floor)(M),M=Math.max(0,M);const I=Math.min(M,u);if(_.wrap=n.getWrap(s,T,_.wrap),_.zoom>=I){if(_.zoom>1),wrap:_.wrap,fullyVisible:w});}return y.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}class be extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((e,t,i,r)=>{const o=new(ee(t.type))(e,t,i,r);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return o})(e,t,i,this),this._tiles={},this._cache=new se(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ne,this._didEmitContent=!1,this._updated=!1;}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e);}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(e,i,r){return t._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,r);}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain);}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e);}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(ye).map((e=>e.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,o=i.tileID,a=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(o.canonical.x,o.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-o.overscaledZ||s.y-a.y||s.x-a.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(ye).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)(e||"errored"!==this._tiles[t].state)&&this._reloadTile(t,"reloading");}}_reloadTile(e,i){return t._(this,void 0,void 0,(function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i));}))}_tileLoaded(e,i,r){e.timeAdded=s.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[a]&&(e.neighboringTiles[a].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const o in this._tiles){let a=this._tiles[o];if(r[o]||!a.hasData()||a.tileID.overscaledZ<=t||a.tileID.overscaledZ>i)continue;let s=a.tileID;for(;a&&a.tileID.overscaledZ>t+1;){const e=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[e.key],a&&a.hasData()&&(s=e);}let n=s;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]||e[n.canonical.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e]);}}_updateCoveredAndRetainedTiles(e,t,i,r,o,a){const n={},l={},c=Object.keys(e),h=s.now();for(const i of c){const r=e[i],o=this._tiles[i];if(!o||0!==o.fadeEndTime&&o.fadeEndTime<=h)continue;const a=this.findLoadedParent(r,t),s=this.findLoadedSibling(r),c=a||s||null;c&&(this._addTile(c.tileID),n[c.tileID.key]=c.tileID),l[i]=r;}this._retainLoadedChildren(l,r,i,e);for(const t in n)e[t]||(this._coveredTiles[t]=!0,e[t]=n[t]);if(a){const t={},i={};for(const e of o)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const r in i){const o=i[r].children(this._source.maxzoom);this._tiles[o[0].key]&&this._tiles[o[1].key]&&this._tiles[o[2].key]&&this._tiles[o[3].key]&&(t[o[0].key]=e[o[0].key]=o[0],t[o[1].key]=e[o[1].key]=o[1],t[o[2].key]=e[o[2].key]=o[2],t[o[3].key]=e[o[3].key]=o[3],delete i[r]);}for(const r in i){const o=i[r],a=this.findLoadedParent(o,this._source.minzoom),s=this.findLoadedSibling(o),n=a||s||null;if(n){t[n.tileID.key]=e[n.tileID.key]=n.tileID;for(const e in t)t[e].isChildOf(n.tileID)&&delete t[e];}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0);}}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.Y(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=xe(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const o=ve(e,this._source),a=Math.max(o-be.maxOverzooming,this._source.minzoom),s=Math.max(o+be.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of r)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const r=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[r.key]=r;}r=r.concat(Object.values(e));}const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,o);we(this._source.type)&&this._updateCoveredAndRetainedTiles(l,a,s,o,r,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.aj(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e);}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e);}_updateRetainedTiles(e,t){var i;const r={},o={},a=Math.max(t-be.maxOverzooming,this._source.minzoom),s=Math.max(t+be.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);r[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=s.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){r[e.key]=e;continue}}else {const e=s.children(this._source.maxzoom);if(r[e[0].key]&&r[e[1].key]&&r[e[2].key]&&r[e[3].key])continue}let n=e.wasRequested();for(let t=s.overscaledZ-1;t>=a;--t){const a=s.scaledTo(t);if(o[a.key])break;if(o[a.key]=!0,e=this.getTile(a),!e&&n&&(e=this._addTile(a)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=e.wasRequested(),t)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i;}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new ae(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}refreshTiles(e){for(const t in this._tiles)this._isIdRenderable(t)&&e.some((e=>e.equals(this._tiles[t].tileID.canonical)))&&this._reloadTile(t,"expired");}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset();}tilesIn(e,i,r){const o=[],a=this.transform;if(!a)return o;const s=r?a.getCameraQueryGeometry(e):e,n=e.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),l=s.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),c=this.getIds();let h=1/0,u=1/0,d=-1/0,_=-1/0;for(const e of l)h=Math.min(h,e.x),u=Math.min(u,e.y),d=Math.max(d,e.x),_=Math.max(_,e.y);for(let e=0;e=0&&f[1].y+m>=0){const e=n.map((e=>s.getTilePoint(e))),t=l.map((e=>s.getTilePoint(e)));o.push({tile:r,tileID:s,queryGeometry:e,cameraQueryGeometry:t,scale:p});}}return o}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return !0;if(we(this._source.type)){const e=s.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}}function ye(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function we(e){return "raster"===e||"image"===e||"video"===e}be.maxOverzooming=10,be.maxUnderzooming=3;class Te{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(o-s)/n:0;return this.points[a].mult(1-l).add(this.points[i].mult(l))}}function Pe(e,t){let i=!0;return "always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Ce{constructor(e,t,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return [];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(o)return [{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e0}hitTestCircle(e,t,i,r,o){const a=e-i,s=e+i,n=t-i,l=t+i;if(s<0||a>this.width||l<0||n>this.height)return !1;const c=[];return this._forEachCell(a,n,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},o),c.length>0}_queryCell(e,t,i,r,o,a,s,n){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const o=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,d=this.boxKeys[s];if(e<=o[u+2]&&t<=o[u+3]&&i>=o[u+0]&&r>=o[u+1]&&(!n||n(d))&&(!c||!Pe(h,d.overlapMode))&&(a.push({key:d,x1:o[u],y1:o[u+1],x2:o[u+2],y2:o[u+3]}),c))return !0}}const d=this.circleCells[o];if(null!==d){const o=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],e,t,i,r)&&(!n||n(d))&&(!c||!Pe(h,d.overlapMode))){const e=o[u],t=o[u+1],i=o[u+2];if(a.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return !0}}}return !1}_queryCellCircle(e,t,i,r,o,a,s,n){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(r))&&!Pe(h,r.overlapMode))return a.push(!0),!0}}const d=this.circleCells[o];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!n||n(r))&&!Pe(h,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,i,r,o,a,s,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(o.call(this,e,t,i,r,this.xCellCount*l+d,a,s,n))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,o,a){const s=r-e,n=o-t,l=i+a;return l*l>s*s+n*n}_circleAndRectCollide(e,t,i,r,o,a,s){const n=(a-r)/2,l=Math.abs(e-(r+n));if(l>n+i)return !1;const c=(s-o)/2,h=Math.abs(t-(o+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}function Me(e,i,o){const a=t.K();if(!e){const{vecSouth:e,vecEast:t}=Ee(i),o=r();o[0]=t[0],o[1]=t[1],o[2]=e[0],o[3]=e[1],s=o,(d=(l=(n=o)[0])*(u=n[3])-(h=n[2])*(c=n[1]))&&(s[0]=u*(d=1/d),s[1]=-c*d,s[2]=-h*d,s[3]=l*d),a[0]=o[0],a[1]=o[1],a[4]=o[2],a[5]=o[3];}var s,n,l,c,h,u,d;return t.M(a,a,[1/o,1/o,1]),a}function Ie(e,i,r,o){if(e){const e=t.K();if(!i){const{vecSouth:t,vecEast:i}=Ee(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1];}return t.M(e,e,[o,o,1]),e}return r.pixelsToClipSpaceMatrix}function Ee(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),o=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),n=t.ao();n[0]=-a*o*r-s*i,n[1]=-s*o*r+a*i;const l=t.ap(n);l<1e-9?t.aq(n):t.ar(n,n,1/l);const c=t.ao();c[0]=a*o*i-s*r,c[1]=s*o*i+a*r;const h=t.ap(c);return h<1e-9?t.aq(c):t.ar(c,c,1/h),{vecEast:c,vecSouth:n}}function Se(e,i,r,o){let a;o?(a=[e,i,o(e,i),1],t.at(a,a,r)):(a=[e,i,0,1],We(a,a,r));const s=a[3];return {point:new t.P(a[0]/s,a[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Re(e,t){return .5+e/t*.5}function ze(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function De(e,i,r,o,a,s,n,l,c,h,u,d,_){const p=r?e.textSizeData:e.iconSizeData,m=t.ak(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const v=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let y=!1;for(let r=0;rMath.abs(r.x-i.x)*o?{useVertical:!0}:(e===t.al.vertical?i.yr.x)?{needsFlipping:!0}:null}function ke(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:o,fontSize:a,flip:s,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=a/24,_=o.lineOffsetX*d,p=o.lineOffsetY*d;let m;if(o.numGlyphs>1){const e=o.glyphStartIndex+o.numGlyphs,t=o.lineStartIndex,a=o.lineStartIndex+o.lineLength,c=Ae(d,l,_,p,s,o,u,i);if(!c)return {notEnoughRoom:!0};const f=je(c.first.point.x,c.first.point.y,i,r),g=je(c.last.point.x,c.last.point.y,i,r);if(n&&!s){const e=Le(o.writingMode,f,g,h);if(e)return e}m=[c.first];for(let r=o.glyphStartIndex+1;r0?n.point:Fe(i.tileAnchorPoint,s,e,1,i),c=je(e.x,e.y,i,r),u=je(l.x,l.y,i,r),d=Le(o.writingMode,c,u,h);if(d)return d}const e=Ge(d*l.getoffsetX(o.glyphStartIndex),_,p,s,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[e];}for(const e of m)t.as(c,e.point,e.angle);return {}}function Fe(e,t,i,r,o){const a=e.add(e.sub(t)._unit()),s=Oe(a.x,a.y,o).point,n=i.sub(s);return i.add(n._mult(r/n.mag()))}function Be(e,i,r){const o=i.projectionCache;if(o.projections[e])return o.projections[e];const a=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Oe(a.x,a.y,i);if(s.signedDistanceFromCamera>0)return o.projections[e]=s.point,o.anyProjectionOccluded=o.anyProjectionOccluded||s.isOccluded,s.point;const n=e-r.direction;return Fe(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),a,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Oe(e,t,i){const r=e+i.translation[0],o=t+i.translation[1];let a;return i.pitchWithMap?(a=Se(r,o,i.pitchedLabelPlaneMatrix,i.getElevation),a.isOccluded=!1):(a=i.transform.projectTileCoordinates(r,o,i.unwrappedTileID,i.getElevation),a.point.x=(.5*a.point.x+.5)*i.width,a.point.y=(.5*-a.point.y+.5)*i.height),a}function je(e,i,r,o){if(r.pitchWithMap){const a=[e,i,0,1];return t.at(a,a,o),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}return {x:e/r.width*2-1,y:i/r.height*2-1}}function Ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ne(e,t,i){return e._unit()._perp()._mult(t*i)}function Ue(e,i,r,o,a,s,n,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=r.add(i);if(e+c.direction=a)return l.projectionCache.offsets[e]=h,h;const u=Be(e+c.direction,l,c),d=Ne(u.sub(r),n,c.direction),_=r.add(d),p=u.add(d);return l.projectionCache.offsets[e]=t.au(s,h,_,p)||h,l.projectionCache.offsets[e]}function Ge(e,t,i,r,o,a,s,n,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,_=h>0?a+o:a+o+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=Oe(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const b=Math.abs(c),y=[];let w;for(;v+x<=b;){if(_+=h,_=s)return null;v+=x,g=f,m=p;const e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:g};if(f=Be(_,n,e),0===i)y.push(g),w=f.sub(g);else {let t;const r=f.sub(g);t=0===r.mag()?Ne(Be(_+h,n,e).sub(f),i,h):Ne(r,i,h),m||(m=g.add(t)),p=Ue(_,t,f,a,s,m,i,n,e),y.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((b-v)/x)._add(m||g),P=u+Math.atan2(f.y-g.y,f.x-g.x);return y.push(T),{point:T,angle:l?P:0,path:y}}const Ve=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function qe(e,t){for(let i=0;i=1;e--)_.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let f=[];if(_.length>0){const e=_[0].clone(),i=_[0].clone();for(let t=1;t<_.length;t++)e.x=Math.min(e.x,_[t].x),e.y=Math.min(e.y,_[t].y),i.x=Math.max(i.x,_[t].x),i.y=Math.max(i.y,_[t].y);f=e.x>=r.x&&i.x<=o.x&&e.y>=r.y&&i.y<=o.y?[_]:i.xo.x||i.yo.y?[]:t.av([_],r.x,r.y,o.x,o.y);}for(const t of f){a.reset(t,.25*i);let r=0;r=a.length<=.5*i?1:Math.ceil(a.paddedLength/p)+1;for(let t=0;t{const t=Se(e.x,e.y,r,i.getElevation),o=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height,o}))}(e,i);return function(e){let t=0,i=0,r=0,o=0;for(let a=0;ai&&(i=o,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let r=1/0,o=1/0,a=-1/0,s=-1/0;for(const n of e){const e=new t.P(n.x+He,n.y+He);r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y),i.push(e);}const n=this.grid.query(r,o,a,s).concat(this.ignoredGrid.query(r,o,a,s)),l={},c={};for(const e of n){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const o=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aw(i,o)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex));}return c}insertCollisionBox(e,t,i,r,o,a){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,r,o,a){const s=i?this.ignoredGrid:this.grid,n={bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t};for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,o,c,u)));S=e.some((e=>!e.isOccluded)),E=e.map((e=>new t.P(e.x,e.y)));}else S=!0;return {box:t.ax(E),allPointsOccluded:!S}}}class Xe{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Ke{constructor(e,t,i,r,o){this.text=new Xe(e?e.text:null,t,i,o),this.icon=new Xe(e?e.icon:null,t,r,o);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Qe{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i;}}class Ye{constructor(e,t,i,r,o){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=o;}}class Je{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function et(e,i,r,o,a){const{horizontalAlign:s,verticalAlign:n}=t.aE(e);return new t.P(-(s-.5)*i+o[0]*a,-(n-.5)*r+o[1]*a)}class tt{constructor(e,t,i,r,o){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new $e(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Je(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,o){const a=r.getBucket(i),s=r.latestFeatureIndex;if(!a||!s||i.id!==a.layerIds[0])return;const n=r.collisionBoxArray,l=a.layers[0].layout,c=a.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.Z,d=r.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=t.az(r,1,this.transform.zoom),m=t.aA(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),f=t.aA(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),g=Me(_,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new Ye(a.bucketInstanceId,s,a.sourceLayerIndex,a.index,r.tileID);const v={bucket:a,layout:l,translationText:m,translationIcon:f,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.ak(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(o)for(const t of a.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:v});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v});}attemptAnchorPlacement(e,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v,x,b){const y=t.aB[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=et(y,r,o,w,a),P=this.collisionIndex.placeCollisionBox(i,d,l,c,h,n,s,f,u.predicate,x,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,c,h,n,s,g,u.predicate,x,T,b).placeable)&&P.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID].text&&(e=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:w,width:r,height:o,anchor:y,textBoxScale:a,prevAnchor:e},this.markUsedJustification(p,y,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:T,placedGlyphBoxes:P}}}placeLayerBucketPart(e,i,r){const{bucket:o,layout:a,translationText:s,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=e.parameters,m=a.get("text-optional"),f=a.get("icon-optional"),g=t.aC(a,"text-overlap","text-allow-overlap"),v="always"===g,x=t.aC(a,"icon-overlap","icon-allow-overlap"),b="always"===x,y="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),T="none"!==a.get("icon-text-fit"),P="viewport-y"===a.get("symbol-z-order"),C=v&&(b||!o.hasIconData()||f),M=b&&(v||!o.hasTextData()||m);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d);const I=this.retainedQueryData[o.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(I),S=this.transform.getFastPathSimpleProjectionMatrix(I),R=(e,d,b)=>{var P,R;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new Qe(!1,!1,!1));let z=!1,D=!1,A=!0,L=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,j=null,Z=0,N=0,U=0;d.textFeatureIndex?Z=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(Z=e.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let r=t.al.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(o,r,e));}return r},a=(i,r)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===t.al.vertical?(k=r(),F=k):k=i(),k&&k.placeable)break}else k=i();},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,h,I,l,w,y,s,p.predicate,E,void 0,S);return r&&r.placeable&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),r};a((()=>r(G,t.al.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.al.vertical):{box:null,offscreen:null}})),i(k&&k.placeable);}else {let _=t.aB[null===(R=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[e.crossTileID])||void 0===R?void 0:R.anchor];const m=(t,i,a)=>{const d=t.x2-t.x1,m=t.y2-t.y1,f=e.textBoxScale,v=T&&"never"===x?i:null;let b=null,P="never"===g?1:2,C="never";_&&P++;for(let i=0;im(G,d.iconBox,t.al.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.al.vertical):{box:null,occluded:!0,offscreen:null}})),k&&(z=k.placeable,A=k.offscreen);const f=i(k&&k.placeable);if(!z&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,f));}}}if(B=k,z=B&&B.placeable,A=B&&B.offscreen,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),n=t.am(o.textSizeData,_,i),h=a.get("text-padding");O=this.collisionIndex.placeCollisionCircles(g,i,o.lineVertexArray,o.glyphOffsetArray,n,l,c,r,w,p.predicate,e.collisionCircleDiameter,h,s,E),O.circles.length&&O.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),z=v||O.circles.length>0&&!O.collisionDetected,A=A&&O.offscreen;}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,I,l,w,y,n,p.predicate,E,T&&L?L:void 0,S);F&&F.placeable&&d.verticalIconBox?(j=e(d.verticalIconBox),D=j.placeable):(j=e(d.iconBox),D=j.placeable),A=A&&j.offscreen;}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,q=f||0===e.numIconVertices;V||q?q?V||(D=D&&z):z=D&&z:D=z=D&&z;const W=D&&j.placeable;if(z&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,a.get("text-ignore-placement"),o.bucketInstanceId,F&&F.placeable&&N?N:Z,p.ID),W&&this.collisionIndex.insertCollisionBox(j.box,x,a.get("icon-ignore-placement"),o.bucketInstanceId,U,p.ID),O&&z&&this.collisionIndex.insertCollisionCircles(O.circles,g,a.get("text-ignore-placement"),o.bucketInstanceId,Z,p.ID),r&&this.storeCollisionData(o.bucketInstanceId,b,d,B,j,O),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===o.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Qe((z||C)&&!(null==B?void 0:B.occluded),(D||M)&&!(null==j?void 0:j.occluded),A||o.justReloaded),i[e.crossTileID]=!0;};if(P){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=o.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];R(o.symbolInstances.get(i),o.collisionArrays[i],i);}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID);}markUsedOrientation(e,i,r){const o=i===t.al.horizontal||i===t.al.horizontalOnly?i:0,a=i===t.al.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,o=t?t.opacities:{},a=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],a=o[e];a?(this.opacities[e]=new Ke(a,r,t.text,t.icon),i=i||t.text!==a.text.placed||t.icon!==a.icon.placed):(this.opacities[e]=new Ke(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon);}for(const e in o){const t=o[e];if(!this.opacities[e]){const o=new Ke(t,r,!1,!1);o.isHidden()||(this.opacities[e]=o,i=i||t.text.placed||t.icon.placed);}}for(const e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray);}}updateBucketOpacities(e,i,r,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const a=e.layers[0],s=a.layout,n=new Ke(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),_="none"!==s.get("icon-text-fit"),p=new Ke(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const m=(e,t,i)=>{for(let r=0;r0,v=this.placedOrientations[o.crossTileID],x=v===t.al.vertical,b=v===t.al.horizontal||v===t.al.horizontalOnly;if(a>0||s>0){const t=ht(c.text);m(e.text,a,x?ut:t),m(e.text,s,b?ut:t);const i=c.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||x?1:0);})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||b?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o));}if(g){const t=ht(c.icon),i=!(_&&o.verticalPlacedIconSymbolIndex&&x);o.placedIconSymbolIndex>=0&&(m(e.icon,o.numIconVertices,i?t:ut),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=c.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,o.numVerticalIconVertices,i?ut:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden());}const y=f&&f.has(i)?f.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const r=e.collisionArrays[i];if(r){let i=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(i=et(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1;}if(r.textBox||r.verticalTextBox){let o;r.textBox&&(o=x),r.verticalTextBox&&(o=b),it(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||o,y.text,i.x,i.y);}}if(r.iconBox||r.verticalIconBox){const t=Boolean(!b&&r.verticalIconBox);let o;r.iconBox&&(o=t),r.verticalIconBox&&(o=!t),it(e.iconCollisionBox.collisionVertexArray,c.icon.placed,o,y.icon,_?i.x:0,_?i.y:0);}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId]);}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function it(e,t,i,r,o,a){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-He,n=r[1]-He,l=r[2]-He,c=r[3]-He;e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,c),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,c);}const rt=Math.pow(2,25),ot=Math.pow(2,24),at=Math.pow(2,17),st=Math.pow(2,16),nt=Math.pow(2,9),lt=Math.pow(2,8),ct=Math.pow(2,1);function ht(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*rt+t*ot+i*at+t*st+i*nt+t*lt+i*ct+t}const ut=0;class dt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,r,o){const a=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex!this._forceFullPlacement&&s.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=a)&&(!r.maxzoom||r.maxzoom>a)){if(this._inProgressLayer||(this._inProgressLayer=new dt(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const pt=512/t.Z/2;class mt{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const o=new Map;for(let e=0;e({x:Math.floor(e.anchorX*pt),y:Math.floor(e.anchorY*pt)}))),crossTileIDs:i.map((e=>e.crossTileID))};if(r.positions.length>128){const e=new t.aF(r.positions.length,16,Uint16Array);for(const{x:t,y:i}of r.positions)e.add(t,i);e.finish(),delete r.positions,r.index=e;}this._symbolsByKey[e]=r;}}getScaledCoordinates(e,i){const{x:r,y:o,z:a}=this.tileID.canonical,{x:s,y:n,z:l}=i.canonical,c=pt/Math.pow(2,l-a),h=(n*t.Z+e.anchorY)*c,u=o*t.Z*pt;return {x:Math.floor((s*t.Z+e.anchorX)*c-r*t.Z*pt),y:Math.floor(h-u)}}findMatches(e,t,i){const r=this.tileID.canonical.ze))}}class ft{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class gt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const o=i[e];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),r[o.tileID.key]=o;}this.indexes[e]=r;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in o){const a=o[i];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,r);}else {const a=o[e.scaledTo(Number(i)).key];a&&a.findMatches(t.symbolInstances,e,r);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var xt="void main() {fragColor=vec4(1.0);}";const bt={prelude:yt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:yt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:yt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:yt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:yt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:yt("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:yt(xt,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:yt("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:yt("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:yt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:yt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:yt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:yt(xt,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:yt("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:yt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:yt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:yt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:yt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:yt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;switch(u_method){case BASIC:\nbasic_hillshade(deriv);break;case COMBINED:\ncombined_hillshade(deriv);break;case IGOR:\nigor_hillshade(deriv);break;case MULTIDIRECTIONAL:\nmultidirectional_hillshade(deriv);break;case STANDARD:\ndefault:\nstandard_hillshade(deriv);break;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:yt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:yt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:yt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:yt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:yt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:yt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:yt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:yt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:yt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:yt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:yt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:yt("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:yt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function yt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=a?a.concat(o):o,n={};return {fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\nout ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,staticUniforms:s}}class wt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}var Tt=t.aG([{name:"a_pos",type:"Int16",components:2}]);const Pt="#define PROJECTION_MERCATOR",Ct="mercator";class Mt{constructor(){this._cachedMesh=null;}get name(){return "mercator"}get useSubdivision(){return !1}get shaderVariantName(){return Ct}get shaderDefine(){return Pt}get shaderPreludeCode(){return bt.projectionMercator}get vertexShaderPreludeCode(){return bt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aH.noSubdivision}get useGlobeControls(){return !1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,o,a){if(this._cachedMesh)return this._cachedMesh;const s=new t.aI;s.emplaceBack(0,0),s.emplaceBack(t.Z,0),s.emplaceBack(0,t.Z),s.emplaceBack(t.Z,t.Z);const n=e.createVertexBuffer(s,Tt.members),l=t.aJ.simpleSegment(0,0,4,2),c=new t.aK;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new wt(n,h,l),this._cachedMesh}recalculate(){}hasTransition(){return !1}setErrorQueryLatitudeDegrees(e){}}class It{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r;}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.B.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.B.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.B.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.B.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.ae((this.left+e-this.right)/2,0,e),o=t.ae((this.top+i-this.bottom)/2,0,i);return new t.P(r,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new It(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Et(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0;}function St(e){return Math.max(0,Math.floor(e))}class Rt{constructor(e,i,r,o,a,s){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==o?0:o,this._maxPitch=null==a?60:a,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.Q(0,0),this._elevation=0,this._zoom=0,this._tileZoom=St(this._zoom),this._scale=t.ac(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new It,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0;}apply(e,i,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=St(this._zoom),this._scale=t.ac(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new It(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices();}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e;}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)));}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)));}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aL(e,-180,180)*Math.PI/180;var o,a,s,n,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),o=this._rotationMatrix,s=-this._bearingInRadians,n=(a=this._rotationMatrix)[0],l=a[1],c=a[2],h=a[3],u=Math.sin(s),d=Math.cos(s),o[0]=n*d+c*u,o[1]=l*d+h*u,o[2]=n*-u+c*d,o[3]=l*-u+h*d);}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ae(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices());}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices());}get fovInRadians(){return this._fovInRadians}get fov(){return t.aM(this._fovInRadians)}setFov(e){e=t.ae(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ab(e),this._calcMatrices());}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.ac(i),this._constrain(),this._calcMatrices());}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices();}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices();}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices();}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new V([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-85.051129,t.af]);}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return [i[0],e];{let r=e.x,o=e.y,a=e.x,s=e.y;for(const e of i)r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y);return [new t.P(r,o),new t.P(a,o),new t.P(a,s),new t.P(r,s),new t.P(r,o)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1;}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ad(new Float64Array(16));t.M(e,e,[this._width/2,-this._height/2,1]),t.L(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ad(new Float64Array(16)),t.M(e,e,[1,-1,1]),t.L(e,e,[-1,-1,0]),t.M(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height;}this._callbacks.calcMatrices();}calculateCenterFromCameraLngLatAlt(e,i,r,o){const a=void 0!==r?r:this.bearing,s=o=void 0!==o?o:this.pitch,n=t.$.fromLngLat(e,i),l=-Math.cos(t.ab(s)),c=Math.sin(t.ab(s)),h=c*Math.sin(t.ab(a)),u=-c*Math.cos(t.ab(a));let d=this.elevation;const _=i-d;let p;l*_>=0||Math.abs(l)<.1?(p=1e4,d=i+p*l):p=-_/l;let m,f,g=t.aN(1,n.y),v=0;do{if(v+=1,v>10)break;f=p/g,m=new t.$(n.x+h*f,n.y+u*f),g=1/m.meterInMercatorCoordinateUnits();}while(Math.abs(p-f*g)>1e-12);return {center:m.toLngLat(),elevation:d,zoom:t.ah(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.ag(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,o=t.$.fromLngLat(this.center,this.elevation),a=_e(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(a.toLngLat(),t.aN(a.z,o.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom);}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.ag(1,this.center.lat)*this.worldSize;return _e(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return [0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class Dt{distanceToTile2d(e,t,i,r){const o=r.distanceX([e,t]),a=r.distanceY([e,t]);return Math.hypot(o,a)}getWrap(e,t,i){return i}getTileAABB(e,i,r,o){var a,s;let n=r,l=r;if(o.terrain){const c=new t.Y(e.z,i,e.z,e.x,e.y),h=o.terrain.getMinMaxElevation(c);n=null!==(a=h.minElevation)&&void 0!==a?a:r,l=null!==(s=h.maxElevation)&&void 0!==s?s:r;}const c=1<o}allowWorldCopies(){return !0}recalculateCache(){}}class At{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i;}static fromInvProjectionMatrix(e,i=1,r=0){const o=Math.pow(2,r),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const a=1/(r=t.at([],r,e))[3]/i*o;return t.aR(r,r,[a,a,1/r[3],a])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.aS([],a[e[0]],a[e[1]]),r=t.aS([],a[e[2]],a[e[1]]),o=t.aT([],t.aU([],i,r)),s=-t.aV(o,a[e[1]]);return o.concat(s)})),n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of a)for(let t=0;t<3;t++)n[t]=Math.min(n[t],e[t]),l[t]=Math.max(l[t],e[t]);return new At(a,s,new zt(n,l))}}class Lt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,r,o){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,r,o),this._coveringTilesDetailsProvider=new Dt;}clone(){const e=new Lt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i);}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.aW(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),n=Math.floor(Math.min(r.x,o.x,a.x,s.x)),l=Math.floor(Math.max(r.x,o.x,a.x,s.x)),c=1;for(let r=n-c;r<=l+c;r++)0!==r&&i.push(new t.aW(r,e));}return i}getCameraFrustum(){return At.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i);}setLocationAtPoint(e,i){const r=t.ag(this.elevation,this.center.lat),o=this.screenPointToMercatorCoordinateAtZ(i,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),s=t.$.fromLngLat(e),n=new t.$(s.x-(o.x-a.x),s.y-(o.y-a.y));this.setCenter(null==n?void 0:n.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap());}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.$.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.$.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,o=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.at(o,o,this._pixelMatrixInverse),t.at(a,a,this._pixelMatrixInverse);const s=o[3],n=a[3],l=o[1]/s,c=a[1]/n,h=o[2]/s,u=a[2]/n,d=h===u?0:(r-h)/(u-h);return new t.$(t.B.number(o[0]/s,a[0]/n,d)/this.worldSize,t.B.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.at(o,o,r),new t.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this._helper._height/2-ue(this));return (new V).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-ue(this)}calculatePosMatrix(e,i=!1,r){var o;const a=null!==(o=e.key)&&void 0!==o?o:t.aX(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(a)){const e=s.get(a);return r?e.f32:e.f64}const n=de(e,this.worldSize);t.N(n,i?this._alignedProjMatrix:this._viewProjMatrix,n);const l={f64:n,f32:new Float32Array(n)};return s.set(a,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const o=de(e,this.worldSize);return t.N(o,this._fogMatrix,o),r.set(i,new Float32Array(o)),r.get(i)}getConstrained(e,i){i=t.ae(+i,this.minZoom,this.maxZoom);const r={center:new t.Q(e.lng,e.lat),zoom:i};let o=this._helper._lngRange;this._helper._renderWorldCopies||null!==o||(o=[-179.9999999999,180-1e-10]);const a=this.tileSize*t.ac(r.zoom);let s=0,n=a,l=0,c=a,h=0,u=0;const{x:d,y:_}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.S(e[1])*a,n=t.S(e[0])*a,n-s<_&&(h=_/(n-s));}o&&(l=t.aL(t.U(o[0])*a,0,a),c=t.aL(t.U(o[1])*a,0,a),cn&&(g=n-e);}if(o){const e=(l+c)/2;let i=p;this._helper._renderWorldCopies&&(i=t.aL(p,e-a/2,e+a/2));const r=d/2;i-rc&&(f=c-r);}if(void 0!==f||void 0!==g){const e=new t.P(null!=f?f:p,null!=g?g:m);r.center=he(a,e).wrap();}return r}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const o=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-o*this._helper._pixelPerMeter/Math.cos(i),s=o<0?a:e,n=Math.PI/2+this.pitchInRadians,l=t.ab(this.fov)*(Math.abs(Math.cos(t.ab(this.roll)))*this.height+Math.abs(Math.sin(t.ab(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*s/Math.sin(t.ae(Math.PI-n-l,.01,Math.PI-.01)),h=ue(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.ab(.75),_=u>d?2*u*(.5+r.y/(2*h)):d,p=Math.sin(_)*s/Math.sin(t.ae(Math.PI-n-_,.01,Math.PI-.01)),m=Math.min(c,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50;}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=ce(this.worldSize,this.center),r=i.x,o=i.y;this._helper._pixelPerMeter=t.ag(1,this.center.lat)*this.worldSize;const a=t.ab(Math.min(this.pitch,le)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a));let n;this._calculateNearFarZIfNeeded(s,a,e),n=new Float64Array(16),t.aY(n,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.an(this._invProjMatrix,n),n[8]=2*-e.x/this._helper._width,n[9]=2*e.y/this._helper._height,this._projectionMatrix=t.aZ(n),t.M(n,n,[1,-1,1]),t.L(n,n,[0,0,-this._helper.cameraToCenterDistance]),t.a_(n,n,-this.rollInRadians),t.a$(n,n,this.pitchInRadians),t.a_(n,n,-this.bearingInRadians),t.L(n,n,[-r,-o,0]),this._mercatorMatrix=t.M([],n,[this.worldSize,this.worldSize,this.worldSize]),t.M(n,n,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n),t.L(n,n,[0,0,-this.elevation]),this._viewProjMatrix=n,this._invViewProjMatrix=t.an([],n);const l=[0,0,-1,1];t.at(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.aY(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.M(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.a_(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.a$(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.a_(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.L(this._fogMatrix,this._fogMatrix,[-r,-o,0]),t.M(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),_=r-Math.round(r)+u*c+d*h,p=o-Math.round(o)+u*h+d*c,m=new Float64Array(n);if(t.L(m,m,[_>.5?_-1:_,p>.5?p-1:p,0]),this._alignedProjMatrix=m,n=t.an(new Float64Array(16),this._pixelMatrix),!n)throw new Error("failed to invert matrix");this._pixelMatrixInverse=n,this._clearMatrixCaches();}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear();}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.at(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.ag(1,this.center.lat)*this.worldSize;return _e(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.$.fromLngLat(e),o=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.at(o,o,this._viewProjMatrix),o[2]/o[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:o}=e,a=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;let n;return n=i&&i.terrainRttPosMatrix32f&&o?i.terrainRttPosMatrix32f:s||t.b0(),{mainMatrix:n,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n}}isLocationOccluded(e){return !1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aQ(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,o){const a=this.calculatePosMatrix(r);let s;o?(s=[e,i,o(e,i),1],t.at(s,s,a)):(s=[e,i,0,1],We(s,s,a));const n=s[3];return {point:new t.P(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t);}getMatrixForModel(e,i){const r=t.$.fromLngLat(e,i),o=r.meterInMercatorCoordinateUnits(),a=t.b1();return t.L(a,a,[r.x,r.y,r.z]),t.a_(a,a,Math.PI),t.a$(a,a,Math.PI/2),t.M(a,a,[-o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=new t.Y(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),o=de(i,this.worldSize);t.N(o,this._viewProjMatrix,o),r.tileMercatorCoords=[0,0,1,1];const a=[t.Z,t.Z,this.worldSize/this._helper.pixelsPerMeter],s=t.b2();return t.M(s,o,a),r.fallbackMatrix=s,r.mainMatrix=s,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function kt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");}function Ft(e){if(e.useSlerp)if(e.k<1){const i=t.b3(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.b3(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),o=new Float64Array(4);t.b4(o,i,r,e.k);const a=t.b5(o);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing);}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.B.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.B.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.B.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k));}function Bt(e,i,r,o,a){const s=a.padding,n=ce(a.worldSize,r.getNorthWest()),l=ce(a.worldSize,r.getNorthEast()),c=ce(a.worldSize,r.getSouthEast()),h=ce(a.worldSize,r.getSouthWest()),u=t.ab(-o),d=n.rotate(u),_=l.rotate(u),p=c.rotate(u),m=h.rotate(u),f=new t.P(Math.max(d.x,_.x,m.x,p.x),Math.max(d.y,_.y,m.y,p.y)),g=new t.P(Math.min(d.x,_.x,m.x,p.x),Math.min(d.y,_.y,m.y,p.y)),v=f.sub(g),x=(a.width-(s.left+s.right+i.left+i.right))/v.x,b=(a.height-(s.top+s.bottom+i.top+i.bottom))/v.y;if(b<0||x<0)return void kt();const y=Math.min(t.ah(a.scale*Math.min(x,b)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ab(o)),P=w.add(T).mult(a.scale/t.ac(y));return {center:he(a.worldSize,n.add(c).div(2).sub(P)),zoom:y,bearing:o}}class Ot{get useGlobeControls(){return !1}handlePanInertia(e,t){return {easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around);}cameraForBoxAndBearing(e,t,i,r,o){return Bt(e,t,i,r,o)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.Q.convert(i.center));}handleEaseTo(e,i){const r=e.zoom,o=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},n=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=n?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:_,zoom:p}=e.getConstrained(t.Q.convert(i.center||d),null!=h?h:r);Et(e,_);const m=ce(e.worldSize,d),f=ce(e.worldSize,_).sub(m),g=t.ac(p-r);return c=p!==r,{easeFunc:n=>{if(c&&e.setZoom(t.B.number(r,p,n)),t.b6(a,s)||Ft({startEulerAngles:a,endEulerAngles:s,tr:e,k:n,useSlerp:a.roll!=s.roll}),l&&(e.interpolatePadding(o,i.padding,n),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else {const i=t.ac(e.zoom-r),o=p>r?Math.min(2,g):Math.max(.5,g),a=Math.pow(o,1-n),s=he(e.worldSize,m.add(f.mult(n*a)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,u);}},isZooming:c,elevationCenter:_}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.zoom,a=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),r?+i.zoom:o),s=a.center,n=a.zoom;Et(e,s);const l=ce(e.worldSize,i.locationAtOffset),c=ce(e.worldSize,s).sub(l),h=c.mag(),u=t.ac(n-o);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,o,n),a=e.getConstrained(s,r).zoom;d=t.ac(a-o);}return {easeFunc:(i,r,a,h)=>{e.setZoom(1===i?n:o+t.ah(r));const u=1===i?s:he(e.worldSize,l.add(c.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h);},scaleOfZoom:u,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:h}}}class jt{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i;}}jt.Replace=[1,0],jt.disabled=new jt(jt.Replace,t.b7.transparent,[!1,!1,!1,!1]),jt.unblended=new jt(jt.Replace,t.b7.transparent,[!0,!0,!0,!0]),jt.alphaBlended=new jt([1,771],t.b7.transparent,[!0,!0,!0,!0]);const Zt=2305;class Nt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Nt.disabled=new Nt(!1,1029,Zt),Nt.backCCW=new Nt(!0,1029,Zt),Nt.frontCCW=new Nt(!0,1028,Zt);class Ut{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Ut.ReadOnly=!1,Ut.ReadWrite=!0,Ut.disabled=new Ut(519,Ut.ReadOnly,[0,1]);const Gt=7680;class Vt{constructor(e,t,i,r,o,a){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=o,this.pass=a;}}Vt.disabled=new Vt({func:519,mask:0},0,0,Gt,Gt,Gt);const qt=new WeakMap;function Wt(e){var t;if(qt.has(e))return qt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return qt.set(e,i),i}}class Ht{get awaitingQuery(){return !!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const o=new t.aI;o.emplaceBack(-1,-1),o.emplaceBack(2,-1),o.emplaceBack(-1,2);const a=new t.aK;a.emplaceBack(0,1,2),this._fullscreenTriangle=new wt(i.createVertexBuffer(o,Tt.members),i.createIndexBuffer(a),t.aJ.simpleSegment(0,0,o.length,a.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Wt(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null));}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null;}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer);}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,o=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.b7.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,o.TRIANGLES,Ut.disabled,Vt.disabled,jt.unblended,Nt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Wt(o)){o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.readBuffer(o.COLOR_ATTACHMENT0),o.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const e=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);o.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e};}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null};}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Wt(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Ht._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount;}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const $t=t.Z/128;function Xt(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,o=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=o+1,n=a+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=r+(e.generateBorders?1:0),u=r+(e.generateBorders||e.extendToSouthPole?1:0),d=s*n,_=o*a*6,p=s*n>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,f=new Int16Array(2*d);let g=0;for(let i=c;i<=u;i++)for(let o=l;o<=h;o++){let a=o/r*t.Z;-1===o&&(a=-64),o===r+1&&(a=t.Z+$t);let s=i/r*t.Z;-1===i&&(s=e.extendToNorthPole?t.b9:-64),i===r+1&&(s=e.extendToSouthPole?t.ba:t.Z+$t),f[g++]=a,f[g++]=s;}const v=m?new Uint32Array(_):new Uint16Array(_);let x=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return "globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy();}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e);}getMeshFromTileID(e,t,i,r,o){return this.currentProjection.getMeshFromTileID(e,t,i,r,o)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator");}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e);}}function ei(e){const t=ri(e.worldSize,e.center.lat);return 2*Math.PI*t}function ti(e,i,r,o,a){const s=1/(1<1e-6){const o=e[0]/r,a=Math.acos(e[2]/r),s=(o>0?a:-a)/Math.PI*180;return new t.Q(t.aL(s,-180,180),i)}return new t.Q(0,i)}function ai(e){return Math.cos(e*Math.PI/180)}function si(e,i){const r=ai(e),o=ai(i);return t.ah(o/r)}function ni(e,i){const r=e.rotate(i.bearingInRadians),o=i.zoom+si(i.center.lat,0),a=t.bc(1/ai(i.center.lat),1/ai(Math.min(Math.abs(i.center.lat),60)),t.bf(o,7,3,0,1)),s=360/ei({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.Q(i.center.lng-r.x*s*a,t.ae(i.center.lat+r.y*s,-85.051129,t.af))}function li(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function ci(e,i,r,o){const a=e.lat+r*o;if(Math.abs(r)>1){const s=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,n=Math.abs(e.lat+r)*Math.PI/180,l=li(s+o*(n-s)),c=li(s),h=li(n);return new t.Q(e.lng+i*((l-c)/(h-c)),a)}return new t.Q(e.lng+i*o,a)}class hi{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=e;}recalculateCache(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1;}getTileAABB(e,t,i,r){const o=`${e.z}_${e.x}_${e.y}`,a=this._cache.get(o);if(a)return a;const s=this._cachePrevious.get(o);if(s)return this._cache.set(o,s),s;const n=this._aabbFactory(e,t,i,r);return this._cache.set(o,n),this._hadAnyChanges=!0,n}}function ui(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function di(e,t,i,r,o){const a=e-i;let s;return s=a<0?Math.min(-a,1+a-o):a>1?Math.min(Math.max(a-o,0),1-a):0,Math.max(s,ui(t,r,o))}class _i{constructor(){this._aabbCache=new hi(this._computeTileAABB);}recalculateCache(){this._aabbCache.recalculateCache();}distanceToTile2d(e,t,i,r){const o=1<4}allowWorldCopies(){return !1}getTileAABB(e,t,i,r){return this._aabbCache.getTileAABB(e,t,i,r)}_computeTileAABB(e,i,r,o){if(e.z<=0)return new zt([-1,-1,-1],[1,1,1]);if(1===e.z)return new zt([0===e.x?-1:0,0===e.y?0:-1,-1],[0===e.x?0:1,0===e.y?1:0,1]);{const i=[ti(0,0,e.x,e.y,e.z),ti(t.Z,0,e.x,e.y,e.z),ti(t.Z,t.Z,e.x,e.y,e.z),ti(0,t.Z,e.x,e.y,e.z)],r=[1,1,1],o=[-1,-1,-1];for(const e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);if(0===e.y||e.y===(1<{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new _i;}clone(){const e=new pi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e);}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bh();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return {mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,o=Math.sin(i)*r,a=Math.cos(i)*r+1,s=1/Math.sqrt(o*o+a*a)*1;let n=-o,l=a;const c=Math.sqrt(n*n+l*l);n/=c,l/=c;const h=[0,n,l];t.bl(h,h,[0,0,0],-this.bearingInRadians),t.bm(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bn(h,h,[0,0,0],this.center.lng*Math.PI/180);const u=1/t.bo(h);return t.aO(h,h,u),[...h,-s*u]}isLocationOccluded(e){return !this.isSurfacePointVisible(ii(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,o=Math.cos(r),a=[Math.sin(i)*o,Math.sin(r),Math.cos(i)*o],s=[a[2],0,-a[0]],n=[0,0,0];t.aU(n,s,a),t.aT(s,s),t.aT(n,n);const l=[0,0,0];return t.aT(l,[s[0]*e[0]+n[0]*e[1]+a[0]*e[2],s[1]*e[0]+n[1]*e[1]+a[1]*e[2],s[2]*e[0]+n[2]*e[1]+a[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const o=function(e,i,r){const o=1/(1<a&&(a=i),rn&&(n=r);}const h=[c.lng+s,c.lat+l,c.lng+a,c.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new V(h)}getConstrained(e,i){const r=t.ae(e.lat,-85.051129,t.af),o=t.ae(+i,this.minZoom+si(0,r),this.maxZoom);return {center:new t.Q(e.lng,r),zoom:o}}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=ii(this.unprojectScreenPoint(i)),o=ii(e),a=t.bh();t.br(a);const s=t.bh();t.bn(s,r,a,-this.center.lng*Math.PI/180),t.bm(s,s,a,this.center.lat*Math.PI/180);const n=o[0]*o[0]+o[2]*o[2],l=s[0]*s[0];if(n=-g&&p<=g,x=f>=-g&&f<=g;let b,y;if(v&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bv(u,e)+t.bv(p,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return !1;const i=t.bk();return t.at(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.aV(e,i),o=t.bh(),a=t.bh();t.aO(a,i,r),t.aS(o,e,a);const s=1-t.aV(o,o);if(s<0)return null;const n=t.aV(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(s),c=n/l,h=l;return {tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),o=this.rayPlanetIntersection(i,r);if(o){const e=t.bh();t.aP(e,i,[r[0]*o.tMin,r[1]*o.tMin,r[2]*o.tMin]);const a=t.bh();return t.aT(a,e),oi(a)}const a=this._cachedClippingPlane,s=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],n=-t.bt(a,i)/s,l=t.bh();if(n>0)t.aP(l,i,[r[0]*n,r[1]*n,r[2]*n]);else {const e=t.bh();t.aP(e,i,[2*r[0],2*r[1],2*r[2]]);const o=t.bt(this._cachedClippingPlane,e);t.aS(l,e,[this._cachedClippingPlane[0]*o,this._cachedClippingPlane[1]*o,this._cachedClippingPlane[2]*o]);}const c=function(e){const i=t.bh();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(a);return oi(function(e,i,r){const o=t.bh();t.aS(o,r,e);const a=t.bh();return t.bi(a,e,o,i/t.bj(o)),a}(c.center,c.radius,l))}getMatrixForModel(e,i){const r=t.Q.convert(e),o=1/t.bu,a=t.b1();return t.bp(a,a,r.lng/180*Math.PI),t.a$(a,a,-r.lat/180*Math.PI),t.L(a,a,[0,0,1+i/t.bu]),t.a$(a,a,.5*Math.PI),t.M(a,a,[o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.Y(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class mi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache();}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Lt,this._verticalPerspectiveTransform=new pi;}clone(){const e=new mi;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians);}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return {mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bc(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bc(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const o=this._mercatorTransform.getPitchedTextCorrection(e,i,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.bc(o,a,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ);}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e);}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e);}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform);}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class fi{get useGlobeControls(){return !0}handlePanInertia(e,i){const r=ni(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,o=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const a=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-a;if(0===s)return;const n=t.bq(i.center.lng,o.lng),l=n/(Math.abs(n/180)+1),c=t.bq(i.center.lat,o.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*t.aV(u,h),_=t.bh();t.aP(_,u,[h[0]*d,h[1]*d,h[2]*d]);const p=t.bo(_)-1,m=Math.exp(.5*-Math.max(p-.3,0)),f=ri(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=t.bf(f,.9,.5,1,.25),v=(1-t.ac(-s))*Math.min(m,g),x=i.center.lat,b=i.zoom,y=new t.Q(i.center.lng+l*v,t.ae(i.center.lat+c*v,-85.051129,t.af));i.setLocationAtPoint(o,r);const w=i.center,T=t.bf(Math.abs(n),45,85,0,1),P=t.bf(f,.75,.35,0,1),C=Math.pow(Math.max(T,P),.25),M=t.bq(w.lng,y.lng),I=t.bq(w.lat,y.lat);i.setCenter(new t.Q(w.lng+M*C,w.lat+I*C).wrap()),i.setZoom(b+si(x,i.center.lat));}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,o=t.zoom;t.setCenter(ni(e.panDelta,t).wrap()),t.setZoom(o+si(r,t.center.lat));}cameraForBoxAndBearing(e,i,r,o,a){const s=Bt(e,i,r,o,a),n=i.left/a.width*2-1,l=(a.width-i.right)/a.width*2-1,c=i.top/a.height*-2+1,h=(a.height-i.bottom)/a.height*-2+1,u=t.bq(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),_=u?r.getWest():r.getEast(),p=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),f=d+.5*t.bq(d,_),g=p+.5*t.bq(p,m),v=a.clone();v.setCenter(s.center),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);const x=v.modelViewProjectionMatrix,b=[ii(r.getNorthWest()),ii(r.getNorthEast()),ii(r.getSouthWest()),ii(r.getSouthEast()),ii(new t.Q(_,g)),ii(new t.Q(d,g)),ii(new t.Q(f,p)),ii(new t.Q(f,m))],y=ii(s.center);let w=Number.POSITIVE_INFINITY;for(const e of b)n<0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"x",n))),l>0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"x",l))),c>0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"y",c))),h<0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"y",h)));if(Number.isFinite(w)&&0!==w)return s.zoom=v.zoom+t.ah(w),s;kt();}handleJumpToCenterZoom(e,i){const r=e.center.lat,o=e.getConstrained(i.center?t.Q.convert(i.center):e.center,e.zoom).center;e.setCenter(o.wrap());const a=void 0!==i.zoom?+i.zoom:e.zoom+si(r,o.lat);e.zoom!==a&&e.setZoom(a);}handleEaseTo(e,i){const r=e.zoom,o=e.center,a=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.Q.convert(i.center):o,d=e.getConstrained(u,r).center;Et(e,d);const _=e.clone();_.setCenter(d),_.setZoom(l?+i.zoom:r+si(o.lat,u.lat)),_.setBearing(i.bearing);const p=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));_.setLocationAtPoint(d,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,f=l?+i.zoom:r+si(o.lat,m.lat),g=r+si(o.lat,0),v=f+si(m.lat,0),x=t.bq(o.lng,m.lng),b=t.bq(o.lat,m.lat),y=t.ac(v-g);return h=f!==r,{easeFunc:r=>{if(t.b6(s,n)||Ft({startEulerAngles:s,endEulerAngles:n,tr:e,k:r,useSlerp:s.roll!=n.roll}),c&&e.interpolatePadding(a,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else {const t=v>g?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-r),a=ci(o,x,b,r*i);e.setCenter(a.wrap());}if(h){const i=t.B.number(g,v,r)+si(0,e.center.lat);e.setZoom(i);}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.center,a=e.zoom,s=e.padding,n=!e.isPaddingEqual(i.padding),l=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),a).center,c=r?+i.zoom:e.zoom+si(e.center.lat,l.lat),h=e.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(l,u);const d=h.center;Et(e,d);const _=function(e,i,r){const o=ii(i),a=ii(r),s=t.aV(o,a),n=Math.acos(s),l=ei(e);return n/(2*Math.PI)*l}(e,o,d),p=a+si(o.lat,0),m=c+si(d.lat,0),f=t.ac(m-p);let g;if("number"==typeof i.minZoom){const r=+i.minZoom+si(d.lat,0),o=Math.min(r,p,m)+si(0,d.lat),a=e.getConstrained(d,o).zoom+si(d.lat,0);g=t.ac(a-p);}const v=t.bq(o.lng,d.lng),x=t.bq(o.lat,d.lat);return {easeFunc:(r,a,l,h)=>{const u=ci(o,v,x,l);n&&e.interpolatePadding(s,i.padding,r);const _=1===r?d:u;e.setCenter(_.wrap());const m=p+t.ah(a);e.setZoom(1===r?c:m+si(0,_.lat));},scaleOfZoom:f,targetCenter:d,scaleOfMinZoom:g,pixelPathLength:_}}static solveVectorScale(e,t,i,r,o){const a="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],n=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],h=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+o*l===n+o*h||s[3]*(n-c)+a[3]*(h-l)+n*h==c*l?null:(c+a[3]-o*h-o*s[3])/(c-n-o*h+o*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.x(e,i&&i.filter((e=>"source.canvas"!==e.identifier))),xi=t.bw();class bi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload();}},this.map=e,this.dispatcher=new B(F(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler("GI",((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new P(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new R(256,512),this.crossTileSymbolIndex=new vt,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bx,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",t.by()),oe().on(te,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t);}}));}loadURL(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const a=this._loadStyleRequest;t.j(o,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,i,r);})).catch((e=>{this._loadStyleRequest=null,e&&!a.signal.aborted&&this.fire(new t.k(e));}));}loadJSON(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r);})).catch((()=>{}));}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(xi,{validate:!1});}_load(e,i,r){var o,a;const s=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!vi(this,t.y(s))){this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new I(this.stylesheet.light),this._setProjectionInternal((null===(o=this.stylesheet.projection)||void 0===o?void 0:o.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(a=this.stylesheet.terrain)&&void 0!==a?a:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"));}}_createLayers(){const e=t.bz(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.bA(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e;}}_loadSprite(e,i=!1,r=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=f(e),n=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of a){const a=i.transformRequest(g(r,n,".json"),"SpriteJSON");l[e]=t.j(a,o);const s=i.transformRequest(g(r,n,".png"),"SpriteImage");c[e]=p.getImage(s,o);}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,(function*(){const t={};for(const r in e){t[r]={};const o=s.getImageCanvasContext((yield i[r]).data),a=(yield e[r]).data;for(const e in a){const{width:i,height:s,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=a[e];t[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:s,x:n,y:l,context:o}};}}return t}))}(l,c)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[t]){const o="default"===t?r:`${t}:${r}`;this._spritesImagesIds[t].push(o),o in this.imageManager.images?this.imageManager.updateImage(o,e[t][r],!1):this.imageManager.addImage(o,e[t][r]),i&&(this._changedImages[o]=!0);}}})).catch((e=>{this._spriteRequest=null,o=e,this.fire(new t.k(o));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),r&&r(o);}));}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const o=i.getSource();("geojson"===o.type||o.vectorLayerIds&&-1===o.vectorLayerIds.indexOf(r))&&this.fire(new t.k(new Error(`Source layer "${r}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bB(r):r);const o=[];for(const a of e)if(r[a]){const e=i?t.bB(r[a]):r[a];o.push(e);}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize());}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return !0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return !0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return !0;for(const e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else {if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates();}const r={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const e in r){const i=this.sourceCaches[e];!!r[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){var r;this._checkLoaded();const o=this.serialize();if(e=i.transformStyle?i.transformStyle(o,e):e,(null===(r=i.validate)||void 0===r||r)&&vi(this,t.y(e)))return !1;(e=t.bB(e)).layers=t.bz(e.layers);const a=t.bC(o,e),s=this._getOperationsToPerform(a);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return !1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case "setCenter":case "setZoom":case "setBearing":case "setPitch":case "setRoll":continue;case "addLayer":t.push((()=>this.addLayer.apply(this,r.args)));break;case "removeLayer":t.push((()=>this.removeLayer.apply(this,r.args)));break;case "setPaintProperty":t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case "setLayoutProperty":t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case "setFilter":t.push((()=>this.setFilter.apply(this,r.args)));break;case "addSource":t.push((()=>this.addSource.apply(this,r.args)));break;case "removeSource":t.push((()=>this.removeSource.apply(this,r.args)));break;case "setLayerZoomRange":t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case "setLight":t.push((()=>this.setLight.apply(this,r.args)));break;case "setGeoJSONSourceData":t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case "setGlyphs":t.push((()=>this.setGlyphs.apply(this,r.args)));break;case "setSprite":t.push((()=>this.setSprite.apply(this,r.args)));break;case "setTerrain":t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case "setSky":t.push((()=>this.setSky.apply(this,r.args)));break;case "setProjection":this.setProjection.apply(this,r.args);break;case "setTransition":t.push((()=>{}));break;default:i.push(r.command);}return {operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(e,t){this.imageManager.updateImage(e,t);}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.y.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=this.sourceCaches[e]=new be(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,(()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e}))),o.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0;}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.k(new Error(`Layer "${o}" already exists on this map.`)));let a;if("custom"===e.type){if(vi(this,t.bD(e)))return;a=t.bA(e);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(o,e.source),e=t.bB(e),e=t.e(e,{source:o})),this._validate(t.y.layer,`layers.${o}`,e,{arrayIndex:-1},r))return;a=t.bA(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:o}});}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));else {if(this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=a,this._removedLayers[o]&&a.source&&"custom"!==a.type){const e=this._removedLayers[o];delete this._removedLayers[o],e.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause());}this._updateLayer(a),a.onAdd&&a.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(e){return this._layers[e]}getLayersOrder(){return [...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!t.bE(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.y.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.bB(i),this._updateLayer(o)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.bB(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bE(a.getLayoutProperty(i),r)||(a.setLayoutProperty(i,r,o),this._updateLayer(a)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bE(a.getPaintProperty(i),r)||(a.setPaintProperty(i,r,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,a=this.sourceCaches[r];if(void 0===a)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=a.getSource().type;"geojson"===s&&o?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||o?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),a.setFeatureState(o,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.getSource().type,s="vector"===a?e.sourceLayer:void 0;"vector"!==a||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.sourceCaches[i];if(void 0!==o)return "vector"!==o.getSource().type||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.getFeatureState(r,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bF(this.sourceCaches,(e=>e.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,o=this.stylesheet;return t.bG({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,projection:o.projection,sources:e,layers:i,terrain:r},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a)){i[a]=o;for(const t of e){const e=t[a];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let a=this._order.length-1;a>=0;a--){const s=this._order[a];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&a.push(function(e,t,i,r,o,a,s){const n={},l=a.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(N);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,o.filter,o.layers,o.availableImages,e);for(const e in r){const t=n[e]=n[e]||[],o=r[e];o.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of o)t.push(e);}}return function(e,t,i){for(const r in e)for(const o of e[r])U(o,i[t[r].source]);return e}(n,e,i)}(this._layers,s,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.y.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],o={};for(let e=0;ee.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);a=a||r;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),e.zoom))&&(this.pauseablePlacement=new _t(e,this.map.terrain,this._order,o,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.now()),n=!0),a&&this.pauseablePlacement.placement.setStale()),n||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles();}getImages(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e}))}getGlyphs(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.y.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}addSprite(e,i,r={},o){this._checkLoaded();const a=[{id:e,url:i}],s=[...f(this.stylesheet.sprite),...a];this._validate(t.y.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(a,!0,o));}removeSprite(e){this._checkLoaded();const i=f(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return f(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.y.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)));}}var yi=t.aG([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class wi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(e,t,i,r,o,a,s,n,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.b7.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(o):0,u_horizon_color:r?r.properties.get("horizon-color"):t.b7.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:a?1:0}),Pi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Ci(e){const t=[];for(let i=0;i({u_depth:new t.bH(e,i.u_depth),u_terrain:new t.bH(e,i.u_terrain),u_terrain_dim:new t.b8(e,i.u_terrain_dim),u_terrain_matrix:new t.bJ(e,i.u_terrain_matrix),u_terrain_unpack:new t.bK(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.b8(e,i.u_terrain_exaggeration)}))(e,C),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bJ(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bK(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bK(e,i.u_projection_clipping_plane),u_projection_transition:new t.b8(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bJ(e,i.u_projection_fallback_matrix)}))(e,C),this.binderUniforms=r?r.getUniforms(e,C):[];}draw(e,t,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v){const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(o),e.setCullFace(a),n){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,n.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,n.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(n[e]);}if(l)for(const e in l)this.projectionUniforms[Pi[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,_,{zoom:p});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1;}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new wi)).bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,f,g,v),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2);}}}function Ii(e,i,r){const o=1/t.az(r,1,i.transform.tileZoom),a=Math.pow(2,r.tileID.overscaledZ),s=r.tileSize*Math.pow(2,i.transform.tileZoom)/a,n=s*(r.tileID.canonical.x+r.tileID.wrap*a),l=s*r.tileID.canonical.y;return {u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[o,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}const Ei=(e,i,r,o)=>{const a=e.style.light,s=a.properties.get("position"),n=[s.x,s.y,s.z],l=t.bN();"viewport"===a.properties.get("anchor")&&t.bO(l,e.transform.bearingInRadians),t.bP(n,n,l);const c=e.transform.transformLightDirection(n),h=a.properties.get("color");return {u_lightpos:n,u_lightpos_globe:c,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:o}},Si=(e,i,r,o,a,s,n)=>t.e(Ei(e,i,r,o),Ii(s,e,n),{u_height_factor:-Math.pow(2,a.overscaledZ)/n.tileSize/8}),Ri=(e,i,r,o)=>t.e(Ii(i,e,r),{u_fill_translate:o}),zi=(e,t)=>({u_world:e,u_fill_translate:t}),Di=(e,i,r,o,a)=>t.e(Ri(e,i,r,a),{u_world:o}),Ai=(e,i,r,o,a)=>{const s=e.transform;let n,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.az(i,1,s.zoom);n=!0,l=[e,e],c=e/(t.Z*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*a;}else n=!1,l=s.pixelsToGLUnits;return {u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:o}},Li=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),ki=e=>({u_viewport_size:[e.width,e.height]}),Fi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Bi=(e,i,r,o)=>{const a=t.az(e,1,i)/(t.Z*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*o;return {u_extrude_scale:t.az(e,1,i),u_intensity:r,u_globe_extrude_scale:a}},Oi=(e,i,r,o)=>{const a=t.K();t.bQ(a,0,e.width,e.height,0,0,1);const s=e.context.gl;return {u_matrix:a,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:r,u_color_ramp:o,u_opacity:i.paint.get("heatmap-opacity")}},ji=(e,t,i)=>{const r=i.paint.get("hillshade-accent-color");let o;switch(i.paint.get("hillshade-method")){case "basic":o=4;break;case "combined":o=1;break;case "igor":o=2;break;case "multidirectional":o=3;break;default:o=0;}const a=i.getIlluminationProperties();for(let t=0;t{const r=i.stride,o=t.K();return t.bQ(o,0,t.Z,-8192,0,0,1),t.L(o,o,[0,-8192,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Ni(e,i){const r=Math.pow(2,i.canonical.z),o=i.canonical.y;return [new t.$(0,o/r).toLngLat().lat,new t.$(0,(o+1)/r).toLngLat().lat]}const Ui=(e,i,r,o)=>{const a=e.transform;return {u_translation:Hi(e,i,r),u_ratio:o/t.az(i,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Gi=(e,i,r,o,a)=>t.e(Ui(e,i,r,o),{u_image:0,u_image_height:a}),Vi=(e,i,r,o,a)=>{const s=e.transform,n=Wi(i,s);return {u_translation:Hi(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:o/t.az(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[n,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},qi=(e,i,r,o,a,s)=>{const n=e.lineAtlas,l=Wi(i,e.transform),c="round"===r.layout.get("line-cap"),h=n.getDash(a.from,c),u=n.getDash(a.to,c),d=h.width*s.fromScale,_=u.width*s.toScale;return t.e(Ui(e,i,r,o),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:s.t})};function Wi(e,i){return 1/t.az(e,1,i.tileZoom)}function Hi(e,i,r){return t.aA(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const $i=(e,t,i,r,o)=>{return {u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=r.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Xi(r.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]};var a,s;};function Xi(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Ki=(e,t,i,r,o,a,s,n,l,c,h,u,d)=>{const _=s.transform;return {u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_pitch:_.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:o,u_is_variable_anchor:a,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},Qi=(e,i,r,o,a,s,n,l,c,h,u,d,_,p)=>{const m=n.transform;return t.e(Ki(e,i,r,o,a,s,n,l,c,h,u,d,p),{u_gamma_scale:o?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:1})},Yi=(e,i,r,o,a,s,n,l,c,h,u,d,_)=>t.e(Qi(e,i,r,o,a,s,n,l,c,h,!0,u,0,_),{u_texsize_icon:d,u_texture_icon:1}),Ji=(e,t)=>({u_opacity:e,u_color:t}),er=(e,i,r,o,a)=>t.e(function(e,i,r,o){const a=r.imageManager.getPattern(e.from.toString()),s=r.imageManager.getPattern(e.to.toString()),{width:n,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(o.tileID.canonical.x+o.tileID.wrap*c),d=h*o.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.az(o,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,a,i,o),{u_opacity:e}),tr=(e,t)=>{},ir={fillExtrusion:(e,i)=>({u_lightpos:new t.bL(e,i.u_lightpos),u_lightpos_globe:new t.bL(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bL(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bL(e,i.u_lightpos),u_lightpos_globe:new t.bL(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bL(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_height_factor:new t.b8(e,i.u_height_factor),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bM(e,i.u_fill_translate),u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bM(e,i.u_world),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bM(e,i.u_world),u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bM(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bH(e,i.u_scale_with_map),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_extrude_scale:new t.bM(e,i.u_extrude_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale),u_translate:new t.bM(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bM(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bM(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bI(e,i.u_color),u_overlay:new t.bH(e,i.u_overlay),u_overlay_scale:new t.b8(e,i.u_overlay_scale)}),depth:tr,clippingMask:tr,heatmap:(e,i)=>({u_extrude_scale:new t.b8(e,i.u_extrude_scale),u_intensity:new t.b8(e,i.u_intensity),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bJ(e,i.u_matrix),u_world:new t.bM(e,i.u_world),u_image:new t.bH(e,i.u_image),u_color_ramp:new t.bH(e,i.u_color_ramp),u_opacity:new t.b8(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bH(e,i.u_image),u_latrange:new t.bM(e,i.u_latrange),u_exaggeration:new t.b8(e,i.u_exaggeration),u_altitudes:new t.bS(e,i.u_altitudes),u_azimuths:new t.bS(e,i.u_azimuths),u_accent:new t.bI(e,i.u_accent),u_method:new t.bH(e,i.u_method),u_shadows:new t.bR(e,i.u_shadows),u_highlights:new t.bR(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bJ(e,i.u_matrix),u_image:new t.bH(e,i.u_image),u_dimension:new t.bM(e,i.u_dimension),u_zoom:new t.b8(e,i.u_zoom),u_unpack:new t.bK(e,i.u_unpack)}),line:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_image:new t.bH(e,i.u_image),u_image_height:new t.b8(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_texsize:new t.bM(e,i.u_texsize),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_image:new t.bH(e,i.u_image),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_patternscale_a:new t.bM(e,i.u_patternscale_a),u_patternscale_b:new t.bM(e,i.u_patternscale_b),u_sdfgamma:new t.b8(e,i.u_sdfgamma),u_image:new t.bH(e,i.u_image),u_tex_y_a:new t.b8(e,i.u_tex_y_a),u_tex_y_b:new t.b8(e,i.u_tex_y_b),u_mix:new t.b8(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bM(e,i.u_tl_parent),u_scale_parent:new t.b8(e,i.u_scale_parent),u_buffer_scale:new t.b8(e,i.u_buffer_scale),u_fade_t:new t.b8(e,i.u_fade_t),u_opacity:new t.b8(e,i.u_opacity),u_image0:new t.bH(e,i.u_image0),u_image1:new t.bH(e,i.u_image1),u_brightness_low:new t.b8(e,i.u_brightness_low),u_brightness_high:new t.b8(e,i.u_brightness_high),u_saturation_factor:new t.b8(e,i.u_saturation_factor),u_contrast_factor:new t.b8(e,i.u_contrast_factor),u_spin_weights:new t.bL(e,i.u_spin_weights),u_coords_top:new t.bK(e,i.u_coords_top),u_coords_bottom:new t.bK(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texture:new t.bH(e,i.u_texture),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texture:new t.bH(e,i.u_texture),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bH(e,i.u_is_halo),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texsize_icon:new t.bM(e,i.u_texsize_icon),u_texture:new t.bH(e,i.u_texture),u_texture_icon:new t.bH(e,i.u_texture_icon),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bH(e,i.u_is_halo),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_color:new t.bI(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_image:new t.bH(e,i.u_image),u_pattern_tl_a:new t.bM(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bM(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bM(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bM(e,i.u_pattern_br_b),u_texsize:new t.bM(e,i.u_texsize),u_mix:new t.b8(e,i.u_mix),u_pattern_size_a:new t.bM(e,i.u_pattern_size_a),u_pattern_size_b:new t.bM(e,i.u_pattern_size_b),u_scale_a:new t.b8(e,i.u_scale_a),u_scale_b:new t.b8(e,i.u_scale_b),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.b8(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bH(e,i.u_texture),u_ele_delta:new t.b8(e,i.u_ele_delta),u_fog_matrix:new t.bJ(e,i.u_fog_matrix),u_fog_color:new t.bI(e,i.u_fog_color),u_fog_ground_blend:new t.b8(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.b8(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bI(e,i.u_horizon_color),u_horizon_fog_blend:new t.b8(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.b8(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.b8(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bH(e,i.u_texture),u_terrain_coords_id:new t.b8(e,i.u_terrain_coords_id),u_ele_delta:new t.b8(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.b8(e,i.u_input),u_output_expected:new t.b8(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bL(e,i.u_sun_pos),u_atmosphere_blend:new t.b8(e,i.u_atmosphere_blend),u_globe_position:new t.bL(e,i.u_globe_position),u_globe_radius:new t.b8(e,i.u_globe_radius),u_inv_proj_matrix:new t.bJ(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bI(e,i.u_sky_color),u_horizon_color:new t.bI(e,i.u_horizon_color),u_horizon:new t.bM(e,i.u_horizon),u_horizon_normal:new t.bM(e,i.u_horizon_normal),u_sky_horizon_blend:new t.b8(e,i.u_sky_horizon_blend),u_sky_blend:new t.b8(e,i.u_sky_blend)})};class rr{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const or={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ar{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const o=e.gl;this.buffer=o.createBuffer(),e.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&(h.push({circleArray:f,circleOffset:d,coord:_}),u+=f.length/4,d=u),m&&c.draw(s,l.LINES,Ut.disabled,Vt.disabled,e.colorModeForRenderPass(),Nt.disabled,Li(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(_),n.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer);}if(!a||!h.length)return;const _=e.useProgram("collisionCircle"),p=new t.bT;p.resize(4*u),p._trim();let m=0;for(const e of h)for(let t=0;t=0&&(f[g.associatedIconIndex]={shiftedAnchor:E,angle:S});}else qe(g.numGlyphs,p);}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");De(c,e,a,O,j,v,h,i,l.toUnwrapped(),f.width,f.height,N,t);}const q=a&&P||V,W=x||q?Hr:v?O:e.transform.clipSpaceToPixelsMatrix,H=p&&0!==r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let $;$=p?c.iconsInText?Yi(T.kind,S,b,v,x,q,e,W,Z,N,z,k,M):Qi(T.kind,S,b,v,x,q,e,W,Z,N,a,z,0,M):Ki(T.kind,S,b,v,x,q,e,W,Z,N,a,z,M);const X={program:E,buffers:u,uniformValues:$,projectionData:U,atlasTexture:D,atlasTextureIcon:F,atlasInterpolation:A,atlasInterpolationIcon:L,isSDF:p,hasHalo:H};if(y&&c.canOverlap){w=!0;const e=u.segments.get();for(const i of e)C.push({segments:new t.aJ([i]),sortKey:i.sortKey,state:X,terrainData:R});}else C.push({segments:u.segments,sortKey:0,state:X,terrainData:R});}w&&C.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of C){const i=t.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,Jr(i.buffers,t.segments,r,e,i.program,T,u,d,o,i.projectionData,t.terrainData)),o.u_is_halo=0;}Jr(i.buffers,t.segments,r,e,i.program,T,u,d,i.uniformValues,i.projectionData,t.terrainData);}}function Jr(e,t,i,r,o,a,s,n,l,c,h){const u=r.context;o.draw(u,u.gl.TRIANGLES,a,s,n,Nt.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer);}function eo(e,i,r,o,a){const s=e.context,n=s.gl,l=Vt.disabled,c=new jt([n.ONE,n.ONE],t.b7.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=o.key;let d=r.heatmapFbos.get(u);d||(d=io(s,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.b7.transparent});const _=h.programConfigurations.get(r.id),p=e.useProgram("heatmap",_,!a),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),f=e.style.map.terrain.getTerrainData(o);p.draw(s,n.TRIANGLES,Ut.disabled,l,c,Nt.disabled,Bi(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),f,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,_);}function to(e,t,i,r,o){const a=e.context,s=a.gl,n=e.transform;a.setColorMode(e.colorModeForRenderPass());const l=ro(a,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),a.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=n.getProjectionData({overscaledTileID:i,applyTerrainMatrix:o,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(a,s.TRIANGLES,Ut.disabled,Vt.disabled,e.colorModeForRenderPass(),Nt.disabled,Oi(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,n.zoom),h.destroy(),t.heatmapFbos.delete(c);}function io(e,t,i){var r,o;const a=e.gl,s=a.createTexture();a.bindTexture(a.TEXTURE_2D,s),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);const n=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:a.UNSIGNED_BYTE,l=null!==(o=e.RGBA16F)&&void 0!==o?o:a.RGBA;a.texImage2D(a.TEXTURE_2D,0,l,t,i,0,a.RGBA,n,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function ro(e,t){return t.colorRampTexture||(t.colorRampTexture=new v(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function oo(e,t,i,r,o){if(!i||!r||!r.imageAtlas)return;const a=r.imageAtlas.patternPositions;let s=a[i.to.toString()],n=a[i.from.toString()];if(!s&&n&&(s=n),!n&&s&&(n=s),!s||!n){const e=o.getPaintProperty(t);s=a[e],n=a[e];}s&&n&&e.setConstantPatternPositions(s,n);}function ao(e,i,r,o,a,s,n,l){const c=e.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),_=r.getCrossfadeParameters();let p,m,f,g,v;const x=e.transform,b=r.paint.get("fill-translate"),y=r.paint.get("fill-translate-anchor");n?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=c.LINES):(m=d?"fillPattern":"fill",p=c.TRIANGLES);const w=u.constantOr(null);for(const u of o){const o=i.getTile(u);if(d&&!o.patternsLoaded())continue;const T=o.getBucket(r);if(!T)continue;const P=T.programConfigurations.get(r.id),C=e.useProgram(m,P),M=e.style.map.terrain&&e.style.map.terrain.getTerrainData(u);d&&(e.context.activeTexture.set(c.TEXTURE0),o.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),P.updatePaintBuffers(_)),oo(P,h,w,o,r);const I=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),E=t.aA(x,o,b,y);if(n){g=T.indexBuffer2,v=T.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];f="fillOutlinePattern"===m&&d?Di(e,_,o,t,E):zi(t,E);}else g=T.indexBuffer,v=T.segments,f=d?Ri(e,_,o,E):{u_fill_translate:E};const S=e.stencilModeForClipping(u);C.draw(e.context,p,a,S,s,Nt.backCCW,f,M,I,r.id,T.layoutVertexBuffer,g,v,r.paint,e.transform.zoom,P);}}function so(e,i,r,o,a,s,n,l){const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),_=d.constantOr(1),p=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),f=d.constantOr(null),g=e.transform;for(const d of o){const o=i.getTile(d),v=o.getBucket(r);if(!v)continue;const x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),b=v.programConfigurations.get(r.id),y=e.useProgram(_?"fillExtrusionPattern":"fillExtrusion",b);_&&(e.context.activeTexture.set(h.TEXTURE0),o.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const w=g.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});oo(b,u,f,o,r);const T=t.aA(g,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),C=_?Si(e,P,m,T,d,p,o):Ei(e,P,m,T);y.draw(c,c.gl.TRIANGLES,a,s,n,Nt.backCCW,C,x,w,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer);}}function no(e,t,i,r,o,a,s,n,l){var c;const h=e.style.projection,u=e.context,d=e.transform,_=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,p),f=!e.options.moving;for(const p of r){const r=t.getTile(p),g=r.fbo;if(!g)continue;const v=h.getMeshFromTileID(u,p.canonical,n,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(p);u.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,g.colorAttachment.get());const b=d.getProjectionData({overscaledTileID:p,aligned:f,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(u,_.TRIANGLES,a,o[p.overscaledZ],s,Nt.backCCW,ji(e,r,i),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments);}}const lo=[new t.P(0,0),new t.P(t.Z,0),new t.P(t.Z,t.Z),new t.P(0,t.Z)];function co(e,t,i,r,o,a,s,n,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=e.context,d=u.gl,_=e.useProgram("raster"),p=e.transform,m=e.style.projection,f=e.colorModeForRenderPass(),g=!e.options.moving;for(const v of r){const r=e.getDepthModeForSublayer(v.overscaledZ-h,1===i.paint.get("raster-opacity")?Ut.ReadWrite:Ut.ReadOnly,d.LESS),x=t.getTile(v);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const b=t.findLoadedParent(v,0),y=t.findLoadedSibling(v),w=ho(x,b||y||null,t,i,e.transform,e.style.map.terrain);let T,P;const C="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),b?(b.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,b.tileID.overscaledZ-x.tileID.overscaledZ),P=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const M=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),I=p.getProjectionData({overscaledTileID:v,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),E=$i(P||[0,0],T||1,w,i,n),S=m.getMeshFromTileID(u,v.canonical,a,s,"raster");_.draw(u,d.TRIANGLES,r,o?o[v.overscaledZ]:Vt.disabled,f,l?Nt.frontCCW:Nt.backCCW,E,M,I,i.id,S.vertexBuffer,S.indexBuffer,S.segments);}}function ho(e,i,r,o,a,n){const l=o.paint.get("raster-fade-duration");if(!n&&l>0){const o=s.now(),n=(o-e.timeAdded)/l,c=i?(o-i.timeAdded)/l:-1,h=r.getSource(),u=ve(a,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),_=d&&e.refreshedUponExpiration?1:t.ae(d?n:1-c,0,1);return e.refreshedUponExpiration&&n>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-_}:{opacity:_,mix:0}}return {opacity:1,mix:0}}const uo=new t.b7(1,0,0,1),_o=new t.b7(0,1,0,1),po=new t.b7(0,0,1,1),mo=new t.b7(1,0,1,1),fo=new t.b7(0,1,1,1);function go(e,t,i,r){xo(e,0,t+i/2,e.transform.width,i,r);}function vo(e,t,i,r){xo(e,t-i/2,0,i,e.transform.height,r);}function xo(e,t,i,r,o,a){const s=e.context,n=s.gl;n.enable(n.SCISSOR_TEST),n.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,o*e.pixelRatio),s.clear({color:a}),n.disable(n.SCISSOR_TEST);}function bo(e,i,r){const o=e.context,a=o.gl,s=e.useProgram("debug"),n=Ut.disabled,l=Vt.disabled,c=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);o.activeTexture.set(a.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,_=Math.floor((d&&d.byteLength||0)/1024),p=i.getTile(r).tileSize,m=512/Math.min(p,512)*(r.overscaledZ/e.transform.zoom)*.5;let f=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(f+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,o=e.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(t,5,5),o.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,`${f} ${_}kB`);const g=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(o,a.TRIANGLES,n,l,jt.alphaBlended,Nt.disabled,Fi(t.b7.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(o,a.LINE_STRIP,n,l,c,Nt.disabled,Fi(t.b7.red),u,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function yo(e,t,i,r){const{isRenderingGlobe:o}=r,a=e.context,s=a.gl,n=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),u=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const _=t.getMeshFrameDelta(n.zoom),p=n.calculateFogMatrix(r.tileID.toUnwrapped()),m=Ti(_,p,e.style.sky,n.pitch,o),f=n.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(a,s.TRIANGLES,c,Vt.disabled,l,Nt.backCCW,m,d,f,"terrain",i.vertexBuffer,i.indexBuffer,i.segments);}}function wo(e,i){if(!i.mesh){const r=new t.aI;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const o=new t.aK;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),i.mesh=new wt(e.createVertexBuffer(r,Tt.members),e.createIndexBuffer(o),t.aJ.simpleSegment(0,0,r.length,o.length));}return i.mesh}class To{constructor(e,i){this.context=new Vr(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ad(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=be.maxUnderzooming+be.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new vt;}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize();}setup(){const e=this.context,i=new t.aI;i.emplaceBack(0,0),i.emplaceBack(t.Z,0),i.emplaceBack(0,t.Z),i.emplaceBack(t.Z,t.Z),this.tileExtentBuffer=e.createVertexBuffer(i,Tt.members),this.tileExtentSegments=t.aJ.simpleSegment(0,0,4,2);const r=new t.aI;r.emplaceBack(0,0),r.emplaceBack(t.Z,0),r.emplaceBack(0,t.Z),r.emplaceBack(t.Z,t.Z),this.debugBuffer=e.createVertexBuffer(r,Tt.members),this.debugSegments=t.aJ.simpleSegment(0,0,4,5);const o=new t.b_;o.emplaceBack(0,0,0,0),o.emplaceBack(t.Z,0,t.Z,0),o.emplaceBack(0,t.Z,0,t.Z),o.emplaceBack(t.Z,t.Z,t.Z,t.Z),this.rasterBoundsBuffer=e.createVertexBuffer(o,yi.members),this.rasterBoundsSegments=t.aJ.simpleSegment(0,0,4,2);const a=new t.aI;a.emplaceBack(0,0),a.emplaceBack(t.Z,0),a.emplaceBack(0,t.Z),a.emplaceBack(t.Z,t.Z),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,Tt.members),this.rasterBoundsSegmentsPosOnly=t.aJ.simpleSegment(0,0,4,5);const s=new t.aI;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Tt.members),this.viewportSegments=t.aJ.simpleSegment(0,0,4,2);const n=new t.b$;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);const l=new t.aK;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Vt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new wt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.K();t.bQ(r,0,this.width,this.height,0,0,1),t.M(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const o={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,Ut.disabled,this.stencilClearMode,jt.disabled,Nt.disabled,null,null,o,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(jt.disabled),r.setDepthMode(Ut.disabled);const o={};for(const e of t)o[e.key]=this.nextStencilID++;this._renderTileMasks(o,t,i,!0),this._renderTileMasks(o,t,i,!1),this._tileClippingMaskIDs=o;}_renderTileMasks(e,t,i,r){const o=this.context,a=o.gl,s=this.style.projection,n=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=s.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=n.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(o,a.TRIANGLES,Ut.disabled,new Vt({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),jt.disabled,i?Nt.disabled:Nt.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments);}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,o=this.useProgram("depth"),a=this.getDepthModeFor3D(),s=xe(r,{tileSize:r.tileSize});for(const n of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(n),l=i.getMeshFromTileID(this.context,n.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(e,t.TRIANGLES,a,Vt.disabled,jt.disabled,Nt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Vt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Vt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(this.clearStencil(),o>1){const e={},a={};for(let i=0;i0};for(const e in n){const t=n[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse();}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.b7.black:t.b7.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,o=((e,t,i)=>{const r=Math.cos(t.rollInRadians),o=Math.sin(t.rollInRadians),a=ue(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return {u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-a*o)*i,(t.height/2+a*r)*i],u_horizon_normal:[-o,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),a=new Ut(r.LEQUAL,Ut.ReadWrite,[0,1]),s=Vt.disabled,n=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=wo(i,t);l.draw(i,r.TRIANGLES,a,s,n,Nt.disabled,o,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments);}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[a[this.currentLayer]],t=n[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,u);}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:o}))(c,u,[p[0],p[1],p[2]],d,_),f=wo(o,i);s.draw(o,a.TRIANGLES,n,Vt.disabled,jt.alphaBlended,Nt.disabled,m,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments);}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[])),o=r.filter((e=>"vector"===e.getSource().type)),a=r.filter((e=>"vector"!==e.getSource().type)),s=e=>{(!i||i.getSource().maxzooms(e))),i||a.forEach((e=>s(e))),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;ru.getElevation(a,e,t):null;Kr(s,d,_,c,h,f,i,p,g,t.aA(h,e,n,l),a.toUnwrapped(),r);}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),a),0!==r.paint.get("icon-opacity").constantOr(1)&&Yr(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,n),0!==r.paint.get("text-opacity").constantOr(1)&&Yr(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,n),i.map.showCollisionBoxes&&(Wr(e,i,r,o,!0),Wr(e,i,r,o,!1));}(e,i,r,o,this.style.placement.variableOffsets,a):t.c4(r)?function(e,i,r,o,a){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=a,n=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===n.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,_=e.transform,p=e.getDepthModeForSublayer(0,Ut.ReadOnly),m=Vt.disabled,f=e.colorModeForRenderPass(),g=[],v=_.getCircleRadiusCorrection();for(let a=0;ae.sortKey-t.sortKey));for(const t of g){const{programConfiguration:i,program:o,layoutVertexBuffer:a,indexBuffer:s,uniformValues:n,terrainData:l,projectionData:c}=t.state;o.draw(u,d.TRIANGLES,p,m,f,Nt.backCCW,n,l,c,r.id,a,s,t.segments,r.paint,e.transform.zoom,i);}}(e,i,r,o,a):t.c5(r)?function(e,i,r,o,a){if(0===r.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:n,isRenderingGlobe:l}=a;if(e.style.map.terrain){for(const t of o){const o=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?eo(e,o,r,t,l):"translucent"===e.renderPass&&to(e,r,t,n,l));}s.viewport.set([0,0,e.width,e.height]);}else "offscreen"===e.renderPass?function(e,i,r,o){const a=e.context,s=a.gl,n=e.transform,l=Vt.disabled,c=new jt([s.ONE,s.ONE],t.b7.transparent,[!0,!0,!0,!0]);((function(e,i,r){const o=e.gl;e.activeTexture.set(o.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let a=r.heatmapFbos.get(t.bW);a?(o.bindTexture(o.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=io(e,i.width/4,i.height/4),r.heatmapFbos.set(t.bW,a));}))(a,e,r),a.clear({color:t.b7.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return !1;if(!e.from||!e.to)return !0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return !t||!i}useProgram(e,t,i=!1,r=[]){this.cache=this.cache||{};const o=!!this.style.map.terrain,a=this.style.projection,s=i?bt.projectionMercator:a.shaderPreludeCode,n=i?Pt:a.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Ct:a.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(o?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||(this.cache[l]=new Mi(this.context,bt[e],t,ir[e],this._showOverdrawInspector,o,s,n,r)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new v(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Po(e,t){let i,r=!1,o=null,a=null;const s=()=>{o=null,r&&(e.apply(a,i),o=setTimeout(s,t),r=!1);};return (...e)=>(r=!0,a=this,i=e,o||s(),o)}class Co{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return !1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e);},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let o=window.location.href.replace(/(#.+)?$/,r);o=o.replace("&&","&"),window.history.replaceState(window.history.state,null,o);},this._updateHash=Po(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e);}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),a=Math.round(t.lng*o)/o,s=Math.round(t.lat*o)/o,n=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${a}/${s}/${i}`:`${i}/${s}/${a}`,(n||l)&&(c+="/"+Math.round(10*n)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return `#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return !1;try{new t.Q(+e[2],+e[1]);}catch(e){return !1}const i=+e[0],r=+(e[3]||0),o=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&o>=this._map.getMinPitch()&&o<=this._map.getMaxPitch()}}const Mo={linearity:.3,easing:t.cd(0,0,.3,1)},Io=t.e({deceleration:2500,maxSpeed:1400},Mo),Eo=t.e({deceleration:20,maxSpeed:1400},Mo),So=t.e({deceleration:1e3,maxSpeed:360},Mo),Ro=t.e({deceleration:1e3,maxSpeed:90},Mo),zo=t.e({deceleration:1e3,maxSpeed:360},Mo);class Do{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=s.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const a=Lo(i.pan.mag(),r,t.e({},Io,e||{})),s=i.pan.mult(a.amount/i.pan.mag()),n=this._map.cameraHelper.handlePanInertia(s,this._map.transform);o.center=n.easingCenter,o.offset=n.easingOffset,Ao(o,a);}if(i.zoom){const e=Lo(i.zoom,r,Eo);o.zoom=this._map.transform.zoom+e.amount,Ao(o,e);}if(i.bearing){const e=Lo(i.bearing,r,So);o.bearing=this._map.transform.bearing+t.ae(e.amount,-179,179),Ao(o,e);}if(i.pitch){const e=Lo(i.pitch,r,Ro);o.pitch=this._map.transform.pitch+e.amount,Ao(o,e);}if(i.roll){const e=Lo(i.roll,r,zo);o.roll=this._map.transform.roll+t.ae(e.amount,-179,179),Ao(o,e);}if(o.zoom||o.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;o.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),t.e(o,{noMoveStart:!0})}}function Ao(e,t){(!e.duration||e.durationi.unproject(e))),l=a.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1;}}class Bo extends t.l{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class Oo{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){delete this._mousedownPos;}wheel(e){return this._firePreventable(new Bo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ko(e.type,this._map,e))}mouseup(e){this._map.fire(new ko(e.type,this._map,e));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ko(e.type,this._map,e));}dblclick(e){return this._firePreventable(new ko(e.type,this._map,e))}mouseover(e){this._map.fire(new ko(e.type,this._map,e));}mouseout(e){this._map.fire(new ko(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Fo(e.type,this._map,e))}touchmove(e){this._map.fire(new Fo(e.type,this._map,e));}touchend(e){this._map.fire(new Fo(e.type,this._map,e));}touchcancel(e){this._map.fire(new Fo(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class jo{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(e){this._map.fire(new ko(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ko("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ko(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Zo{constructor(e){this._map=e;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class No{constructor(e,t){this._map=e,this._tr=new Zo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(r,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function Uo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=Uo(r,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=Uo(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Vo{constructor(e){this.singleTap=new Go(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class qo{constructor(e){this._tr=new Zo(e),this._zoomIn=new Vo({numTouches:1,numTaps:2}),this._zoomOut=new Vo({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),o=this._zoomOut.touchend(e,t,i),a=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(r)},{originalEvent:e})}):o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(o)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Wo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset();}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e);}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return !this._moved&&r.dist(i)!0}),t=new Xo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t;}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)));}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)));}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Qo=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault();};};class Yo{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0);}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const o=Uo(r,i),a=new t.P(0,0),s=new t.P(0,0);let n=0;for(const e in o){const t=o[e],i=this._touches[e];i&&(a._add(t),s._add(t.sub(i)),n++,o[e]=t);}if(this._touches=o,this._shouldBePrevented(n)||!s.mag())return;const l=s.div(n);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class sa extends Jo{constructor(e){super(),this._currentTouchCount=0,this._map=e;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length;}_start(e){this._lastPoints=e,aa(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),o=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,o=t.mag()>=2;if(!r&&!o)return;if(!r||!o)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const a=e.y>0==t.y>0;return aa(e)&&aa(t)&&a}}const na={panStep:100,bearingStep:15,pitchStep:10};class la{constructor(e){this._tr=new Zo(e);const t=na;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,o=0,a=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),o=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),o=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const n=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:ca,zoom:t?Math.round(n.zoom)+t*(e.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+r*this._pitchStep,offset:[-o*this._panStep,-a*this._panStep],center:n.center},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function ca(e){return e*(2-e)}const ha=4.000244140625;class ua{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);},this._map=e,this._tr=new Zo(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(e){return !!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=s.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%ha==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=n.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.Q.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t);}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>ha?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const o="number"!=typeof this._targetZoom?e.scale:t.ac(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),t.ah(o*r)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,o=this._easing;let a,n=!1;if("wheel"===this._type&&r&&o){const e=s.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=o(l);a=t.B.number(r,i,c),l<1?this._frameId||(this._frameId=!0):n=!0;}else a=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout;}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!n,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cf;if(this._prevEase){const e=this._prevEase,r=(s.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(o*o+1e-4)*.01,n=Math.sqrt(.0729-a*a);i=t.cd(a,n,.25,1);}return this._prevEase={start:s.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class da{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class _a{constructor(e){this._tr=new Zo(e),this.reset();}reset(){this._active=!1;}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class pa{constructor(){this._tap=new Vo({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],o=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;o&&a?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(e,t,i);}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ma{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class fa{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class ga{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class va{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=n.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const o=document.createElement("div");o.className="maplibregl-mobile-message",o.textContent=i,this._container.appendChild(o),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(n.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const xa=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class ba extends t.l{}function ya(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class wa{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`);},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===e.type?void 0:e,o={needsRenderFrame:!1},a={},s={};for(const{handlerName:l,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(s,h,l))c.reset();else if(c[i||e.type]){if(t.cg(e,i||e.type)){const t=n.mousePos(this._map.getCanvas(),e);u=c[i||e.type](e,t);}else if(t.ch(e,i||e.type)){const t=this._getMapTouches(e.touches),r=n.touchPos(this._map.getCanvas(),t);u=c[i||e.type](e,r,t);}else t.ci(i||e.type)||(u=c[i||e.type](e));this.mergeHandlerResult(o,a,u,l,r),u&&u.needsRenderFrame&&this._triggerRenderFrame();}(u||c.isActive())&&(s[l]=c);}const l={};for(const e in this._previousActiveHandlers)s[e]||(l[e]=r);this._previousActiveHandlers=s,(Object.keys(l).length||ya(o))&&(this._changes.push([o,a,l]),this._triggerRenderFrame()),(Object.keys(s).length||ya(o))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=o;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map));},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Do(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)n.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[e,t,i]of this._listeners)n.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new Oo(i,e));const o=i.boxZoom=new No(i,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const a=i.cooperativeGestures=new va(i,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();const s=new qo(i),l=new _a(i);i.doubleClickZoom=new da(l,s),this._add("tapZoom",s),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new pa;this._add("tapDragZoom",c);const h=i.touchPitch=new sa(i);this._add("touchPitch",h),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:o=100,rotateDegreesPerPixelMoved:a=.8},s){const l=new $o({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Wo({clickTolerance:i,move:(e,i)=>{const n=s();if(r&&Math.abs(n.y-e.y)>o)return {bearingDelta:t.ce(new t.P(e.x,i.y),i,n)};let l=(i.x-e.x)*a;return r&&i.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Wo({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:Qo})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const o=new $o({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Wo({clickTolerance:t,move:(e,t)=>{const o=r();let a=(t.x-e.x)*i;return t.y0===n.mouseButton(e)&&!e.ctrlKey});return new Wo({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Qo})}(e),f=new Yo(e,i);i.dragPan=new ma(r,m,f),this._add("mousePan",m),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new oa,v=new ia;i.touchZoomRotate=new ga(r,v,g,c),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",v,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const x=i.scrollZoom=new ua(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const b=i.keyboard=new la(i);this._add("keyboard",b),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new jo(i));}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[];}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(xa(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,o,a){if(!r)return;t.e(e,r);const s={handlerName:o,originalEvent:r.originalEvent||a};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s);}_applyChanges(){const e={},i={},r={};for(const[o,a,s]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(e.rollDelta=(e.rollDelta||0)+o.rollDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.e(i,a),t.e(r,s);this._updateMapTransform(e,i,r),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,o=r._getTransformForUpdate(),a=r.terrain;if(!(ya(e)||a&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:n,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u=u||r.transform.centerPoint,a&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const _={panDelta:s,zoomDelta:n,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const p=u.distSqr(o.centerPoint)<.01?o.center:o.screenPointToLocation(s?u.sub(s):u);a?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?o.setCenter(o.screenPointToLocation(o.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(_,o,p):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(_,o,p))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._map.cameraHelper.handleMapControlsPan(_,o,p)),r._applyUpdatedTransform(o),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,i,r){const o=xa(this._eventsInProgress),a=xa(e),n={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(n[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!o&&a&&this._fireEvent("movestart",a.originalEvent);for(const e in n)this._fireEvent(e,n[e]);a&&this._fireEvent("move",a.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||r,l[`${e}end`]=c);}for(const e in l)this._fireEvent(e,l[e]);const h=xa(this._eventsInProgress),u=(o||a)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e);}if(r&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ba("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class Ta extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState;}));}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t;}getCenter(){return new t.Q(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e;}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){f.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.l("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.l("rollstart",e));}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.setElevation(t.B.number(this._elevationStart,this._elevationTarget,e));}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return {};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:o,roll:a,pitch:s,bearing:n,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==o&&t.setZoom(o),void 0!==a&&t.setRoll(a),void 0!==s&&t.setPitch(s),void 0!==n&&t.setBearing(n),i.apply(t);}this.transform.apply(i);}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,o=this._rotating,a=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l("zoomend",e)),o&&this.fire(new t.l("rotateend",e)),a&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e));}flyTo(e,i){if(!e.essential&&s.prefersReducedMotion){const r=t.O(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cf},e);const r=this._getTransformForUpdate(),o=r.bearing,a=r.pitch,n=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:a,u="roll"in e?this._normalizeBearing(e.roll,n):n,d="padding"in e?e.padding:r.padding,_=t.P.convert(e.offset);let p=r.centerPoint.add(_);const m=r.screenPointToLocation(p),f=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:_,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let g=e.curve;const v=Math.max(r.width,r.height),x=v/f.scaleOfZoom,b=f.pixelPathLength;"number"==typeof f.scaleOfMinZoom&&(g=Math.sqrt(v/f.scaleOfMinZoom/b*2));const y=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*y*y*b*b)/(2*(e?x:v)*y*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const C=w(!1);let M=function(e){return P(C)/P(C+g*e)},I=function(e){return v*((P(C)*(T(t=C+g*e)/P(t))-T(C))/y)/b;var t;},E=(w(!0)-C)/g;if(Math.abs(b)<2e-6||!isFinite(E)){if(Math.abs(v-x)<1e-6)return this.easeTo(e,i);const t=x0,M=e=>Math.exp(t*g*e);}return e.duration="duration"in e?+e.duration:1e3*E/("screenSpeed"in e?+e.screenSpeed/g:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==a,this._rolling=u!==n,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease((s=>{const m=s*E,g=1/M(m),v=I(m);this._rotating&&r.setBearing(t.B.number(o,c,s)),this._pitching&&r.setPitch(t.B.number(a,h,s)),this._rolling&&r.setRoll(t.B.number(n,u,s)),this._padding&&(r.interpolatePadding(l,d,s),p=r.centerPoint.add(_)),f.easeFunc(s,g,v,p),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t);}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.aL(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class Ca{constructor(e=Pa){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=e;}getDefaultPosition(){return "bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style.sourceCaches;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return !1;return !0}));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=n.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class Ma{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact");}},this.options=e;}getDefaultPosition(){return "bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=n.create("div","maplibregl-ctrl");const t=n.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class Ia{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var Ea=t.aG([{name:"a_pos3d",type:"Int16",components:3}]);class Sa extends t.E{constructor(e){super(),this._lastTilesetChange=s.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const r={};for(const o of xe(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float64Array(16),t.bQ(o.terrainRttPosMatrix32f,0,t.Z,t.Z,0,0,1),this._tiles[o.key]=new ae(o,this.tileSize),this._lastTilesetChange=s.now());for(const e in this._tiles)r[e]||delete this._tiles[e];}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID,a=e.clone(),s=t.b2();if(o.canonical.equals(e.canonical))t.bQ(s,0,t.Z,t.Z,0,0,1);else if(o.canonical.isChildOf(e.canonical)){const i=o.canonical.z-e.canonical.z,r=o.canonical.x-(o.canonical.x>>i<>i<>i;t.bQ(s,0,n,n,0,0,1),t.L(s,s,[-r*n,-a*n,0]);}else {if(!e.canonical.isChildOf(o.canonical))continue;{const i=e.canonical.z-o.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bQ(s,0,t.Z,t.Z,0,0,1),t.L(s,s,[r*n,a*n,0]),t.M(s,s,[1/2**i,1/2**i,0]);}}a.terrainRttPosMatrix32f=new Float32Array(s),i[r]=a;}return i}_getTerrainCoordsForTileRanges(e,i){const r={};for(const o of this._renderableTilesKeys){const a=this._tiles[o].tileID;if(!this._isWithinTileRanges(a,i))continue;const s=e.clone(),n=t.b2();if(a.canonical.z===e.canonical.z){const i=e.canonical.x-a.canonical.x,r=e.canonical.y-a.canonical.y;t.bQ(n,0,t.Z,t.Z,0,0,1),t.L(n,n,[i*t.Z,r*t.Z,0]);}else if(a.canonical.z>e.canonical.z){const i=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>i<>i<>i),l=e.canonical.y-(a.canonical.y>>i),c=t.Z>>i;t.bQ(n,0,c,c,0,0,1),t.L(n,n,[-r*c+s*t.Z,-o*c+l*t.Z,0]);}else {const i=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i)-a.canonical.x,l=(e.canonical.y>>i)-a.canonical.y,c=t.Z<i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!o||!o.dem);)o=this.sourceCache.getTileByID(e.scaledTo(r--).key);return o}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Ra{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Sa(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(e,i,r,o=t.Z){var a;if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?o=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=e.canonical.x-(e.canonical.x>>o<>o<>8<<4|e>>8,i[t+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),o=new v(e,r,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,o=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(a,n-s-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,_=(1<0,o=r&&0===e.canonical.y,a=r&&e.canonical.y===(1<e.id!==t)),this._recentlyUsed.push(e.id);}stampObject(e){e.stamp=++this._stamp;}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1;}freeAllObjects(){for(const e of this._objects)this.freeObject(e);}isFull(){return !(this._objects.length!e.inUse))}}const Da={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Aa{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new za(e.context,30,t.sourceCache.tileSize*t.qualityFactor);}destruct(){this.pool.destruct();}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates(),r=e.sourceCaches[t].getSource(),o=r instanceof K?r.terrainTileRanges:null;for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e,o);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e]);}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],r=i.source;if(Da[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join();}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[]);}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return !1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),o=e.type,a=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Da[o]&&(this._prevType&&Da[this._prevType]||this._stacks.push([]),this._prevType=o,this._stacks[this._stacks.length-1].push(e.id),!s))return !0;if(Da[this._prevType]||Da[o]&&s){this._prevType=o;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const o of this._renderableTiles){if(this.pool.isFull()&&(yo(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(o),o.rtt[e]){const t=this.pool.getObjectForId(o.rtt[e].id);if(t.stamp===o.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),o.rtt[e]={id:s.id,stamp:s.stamp},a.context.bindFramebuffer.set(s.fbo.framebuffer),a.context.clear({color:t.b7.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=e=>{this.move(e,n.mousePos(this.element,e));},this.mouseup=e=>{this._rotatePitchHanlder.dragEnd(e),this.offTemp();},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend));},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos));},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10,this.element=i;const o=new Ko;this._rotatePitchHanlder=new Wo({clickTolerance:3,move:(e,o)=>{const a=i.getBoundingClientRect(),s=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return {bearingDelta:t.ce(new t.P(e.x,o.y),o,s),pitchDelta:r?-.5*(o.y-e.y):void 0}},moveStateManager:o,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(i,"mousedown",this.mousedown),n.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(i,"touchcancel",this.reset);}startMove(e,t){this._rotatePitchHanlder.dragStart(e,t),n.disableDrag();}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:o}=this._rotatePitchHanlder.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),o&&i.setPitch(i.getPitch()+o);}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp();}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend);}}let ja;function Za(e,i,r,o=!1){if(o||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const a=new t.Q(e.lng,e.lat);if(e=new t.Q(e.lng,e.lat),i){const o=new t.Q(e.lng-360,e.lat),a=new t.Q(e.lng+360,e.lat),s=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(o).distSqr(i)180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360;}return e.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:a}const Na={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Ua(e,t,i){const r=e.classList;for(const e in Na)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`);}class Ga extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=Za(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${Na[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`),s.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type);})).catch((()=>{}));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive";},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=n.create("div");const i=n.createNS("http://www.w3.org/2000/svg","svg"),r=41,o=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${o}px`),i.setAttributeNS(null,"viewBox",`0 0 ${o} ${r}`);const a=n.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");const s=n.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=n.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=n.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t);}const h=n.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=n.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=n.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=n.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=n.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=n.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=n.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),s.appendChild(l),s.appendChild(h),s.appendChild(d),s.appendChild(p),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();})),Ua(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-13.5,-1*(t-i)]}:this._offset;}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;const o=null===(i=this._map)||void 0===i?void 0:i.terrain,a=this._map.transform.isLocationOccluded(this._lngLat);if(!o||a){const e=a?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const s=this._map,n=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-n<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,h=Math.sin(s.getPitch()*Math.PI/180)*c,u=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+h)-u>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity;}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e);}removeClassName(e){this._element.classList.remove(e);}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return (void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Va={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let qa=0,Wa=!1;const Ha={maxWidth:100,unit:"metric"};function $a(e,t,i){const r=i&&i.maxWidth||100,o=e._container.clientHeight/2,a=e._container.clientWidth/2,s=e.unproject([a-r/2,o]),n=e.unproject([a+r/2,o]),l=Math.round(e.project(n).x-e.project(s).x),c=Math.min(r,l,e._container.clientWidth),h=s.distanceTo(n);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Xa(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Xa(t,c,i,e._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?Xa(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Xa(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):Xa(t,c,h,e._getUIString("ScaleControl.Meters"));}function Xa(e,t,i,r){const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(o/i)+"px",e.innerHTML=`${o} ${r}`;}const Ka={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Qa=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ya(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Ya(new t.P(0,0))}const Ja=i;e.AJAXError=t.cq,e.Event=t.l,e.Evented=t.E,e.LngLat=t.Q,e.MercatorCoordinate=t.$,e.Point=t.P,e.addProtocol=t.cr,e.config=t.a,e.removeProtocol=t.cs,e.AttributionControl=Ca,e.BoxZoomHandler=No,e.CanvasSource=Y,e.CooperativeGesturesHandler=va,e.DoubleClickZoomHandler=da,e.DragPanHandler=ma,e.DragRotateHandler=fa,e.EdgeInsets=It,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},e.GeoJSONSource=X,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "BACKGROUND":case "BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.Q(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),a=t.e({bearing:o},this.options.fitBoundsOptions),s=V.fromLngLat(i,r);this._map.fitBounds(s,a,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.Q(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&Wa)return;this.options.trackUserLocation&&this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ga({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ga({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")));}));}},this.options=t.e({},Va,e);}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(void 0!==ja&&!e)return ja;if(void 0===window.navigator.permissions)return ja=!!window.navigator.geolocation,ja;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ja="denied"!==e.state;}catch(e){ja=!!window.navigator.geolocation;}return ja}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,qa=0,Wa=!1;}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case "ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),r=t.distanceTo(i),o=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.l("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":qa--,Wa=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case "BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case "WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),qa++,qa>1?(e={maximumAge:6e5,timeout:0},Wa=!0):(e=this.options.positionOptions,Wa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon();},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"));};}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0;}},e.Hash=Co,e.ImageSource=K,e.KeyboardHandler=la,e.LngLatBounds=V,e.LogoControl=Ma,e.Map=class extends Ta{constructor(e){var i,r;t.cn.mark(t.co.create);const o=Object.assign(Object.assign(Object.assign({},Fa),e),{canvasContextAttributes:Object.assign(Object.assign({},Fa.canvasContextAttributes),e.canvasContextAttributes)});if(null!=o.minZoom&&null!=o.maxZoom&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=o.minPitch&&null!=o.maxPitch&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=o.minPitch&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=o.maxPitch&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const a=new Lt,s=new Ot;if(void 0!==o.minZoom&&a.setMinZoom(o.minZoom),void 0!==o.maxZoom&&a.setMaxZoom(o.maxZoom),void 0!==o.minPitch&&a.setMinPitch(o.minPitch),void 0!==o.maxPitch&&a.setMaxPitch(o.maxPitch),void 0!==o.renderWorldCopies&&a.setRenderWorldCopies(o.renderWorldCopies),super(a,s,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ia,this._controls=[],this._mapId=t.a4(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.l("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=!0===o.trackResize,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=!0===o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=!0===o.crossSourceCollisions,this._collectResourceTiming=!0===o.collectResourceTiming,this._locale=Object.assign(Object.assign({},La),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this.transformCameraUpdate=o.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===o.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=p.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(o.transformRequest),"string"==typeof o.container){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else {if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container;}if(o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})),this.once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Po((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw());}),50);this._resizeObserver=new ResizeObserver((i=>{e?t(i):e=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new wa(this,o),this._hash=o.hash&&new Co("string"==typeof o.hash&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,t.e({},o.fitBoundsOptions,{duration:0}))));const n="string"==typeof o.style||!("globe"===(null===(r=null===(i=o.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,n),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new Ca("boolean"==typeof o.attributionControl?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Ma,o.logoPosition),this.on("style.load",(()=>{if(n||this._resizeTransform(),this.transform.unmodified){const e=t.O(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e);}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.l(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.l("sourcedataabort",e));}));}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return -1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){const[r,o]=this._containerDimensions(),a=this._getClampedPixelRatio(r,o);if(this._resizeCanvas(r,o,a),this.painter.resize(r,o,a),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(r,o);this._resizeCanvas(r,o,t),this.painter.resize(r,o,t);}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e);}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,o=this.getPixelRatio(),a=e*o,s=t*o;return Math.min(a>i?i/a:1,s>r?r/s:1)*o}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(V.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.Q.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e))),s=0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[];s.length?r||(r=!0,i.call(this,new ko(e,this,o.originalEvent,{features:s}))):r=!1;};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e)));(0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[]).length?r=!0:r&&(r=!1,i.call(this,new ko(e,this,o.originalEvent)));},a=t=>{r&&(r=!1,i.call(this,new ko(e,this,t.originalEvent)));};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:a}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),o=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];o.length&&(e.features=o,i.call(this,e),delete e.features);};return {layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t);}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let e=0;et.includes(e)))){for(const e in o.delegates)this.off(e,o.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,o);for(const e in o.delegates)this.on(e,o.delegates[e]);return {unsubscribe:()=>{this._removeDelegatedListener(e,r,i);}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);for(const t in o.delegates){const a=o.delegates[t];o.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),a(...t);};}this._saveDelegatedListener(e,o);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return [];let r;const o=e instanceof t.P||Array.isArray(e),a=o?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(o?{}:e)||{},a instanceof t.P||"number"==typeof a[0])r=[t.P.convert(a)];else {const e=t.P.convert(a[0]),i=t.P.convert(a[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e];}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return !1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new bi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new bi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,"Style");t.j(r,new AbortController).then((e=>{this._updateDiff(e.data,i);})).catch((e=>{e&&this.fire(new t.k(e));}));}else "object"==typeof e&&this._updateDiff(e,i);}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no source with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new Ra(this.painter,i,e),this.painter.renderToTexture=new Aa(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=fe(Math.max(1,e),Math.max(1,t));}else for(const i in this.style.sourceCaches)this.style.sourceCaches[i].getSource().calculateTileZoom=fe(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const r=this.style.sourceCaches[e];if(!r)throw new Error(`There is no source cache with ID "${e}", cannot refresh tile`);void 0===i?r.reload():r.refreshTiles(i.map((e=>new t.a1(e.z,e.x,e.y))));}addImage(e,i,r={}){const{pixelRatio:o=1,sdf:a=!1,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:s,data:d}=i,_=i;return this.style.addImage(e,{data:new t.R({width:r,height:s},new Uint8Array(d)),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0,userImage:_}),_.onAdd&&_.onAdd(this,e),this}}{const{width:r,height:d,data:_}=s.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},_),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0});}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||t.b(i)?s.getImageData(i):i,{width:a,height:n,data:l}=o;if(void 0===a||void 0===n)return this.fire(new t.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(a!==r.data.width||n!==r.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e){return p.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,(e=>{e||this._update(!0);})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0);})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const o=this._controlContainer=n.create("div","maplibregl-control-container",e),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{a[e]=n.create("div",`maplibregl-ctrl-${e} `,o);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type);}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new To(i,this.transform),l.testSupport(i);}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}));}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_render(e){var i,r,o,a,n;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=s.now();this.style.zoomHistory.update(e,i);const r=new t.C(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=r.crossFadingFactor();1===o&&o===this._crossFadingFactor||(h=!0,this._crossFadingFactor=o),this.style.update(r);}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(o=this.style.projection)||void 0===o||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(a=this.style.projection)||void 0===a?void 0:a.transitionState,null===(n=this.style.projection)||void 0===n?void 0:n.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cn.mark(t.co.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cn.mark(t.co.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),p.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cn.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(e=>{t.cn.frame(e),this._frameRequest=null;try{this._render(e);}catch(e){if(!t.cp(e)&&!function(e){return e.message===Ur}(e))throw e}}),(()=>{})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get version(){return ka}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=ko,e.MapTouchEvent=Fo,e.MapWheelEvent=Bo,e.Marker=Ga,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`;},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i);},this.options=t.e({},Ba,e),this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e});})),this._compassIcon=n.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Oa(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(e,t){const i=n.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:void 0);},this.remove=()=>(this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point);},this._onMouseMove=e=>{this._update(e.point);},this._onDrag=e=>{this._update(e.point);},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Za(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const r=Ya(this.options.offset);if(!i){const e=this._container.offsetWidth,o=this._container.offsetHeight;let a;a=t.y+r.bottom.ythis._map.transform.height-o?["bottom"]:[],t.xthis._map.transform.width-e/2&&a.push("right"),i=0===a.length?"bottom":a.join("-");}let o=t.add(r[i]);this.options.subpixelPositioning||(o=o.round()),n.setTransform(this._container,`${Na[i]} translate(${o.x}px,${o.y}px)`),Ua(this._container,i,"popup"),this._updateOpacity();},this._onClose=()=>{this.remove();},this.options=t.e(Object.create(Ka),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Qa);e&&e.focus();}},e.RasterDEMTileSource=$,e.RasterTileSource=H,e.ScaleControl=class{constructor(e){this._onMove=()=>{$a(this._map,this._container,this.options);},this.setUnit=e=>{this.options.unit=e,$a(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},Ha),e);}getDefaultPosition(){return "bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},e.ScrollZoomHandler=ua,e.Style=bi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=e;}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},e.TwoFingersTouchPitchHandler=sa,e.TwoFingersTouchRotateHandler=oa,e.TwoFingersTouchZoomHandler=ia,e.TwoFingersTouchZoomRotateHandler=ga,e.VectorTileSource=W,e.VideoSource=Q,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,(function*(){if(ee(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{J[e]=t;})(e,i);})),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(z),L=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},e.createTileMesh=Xt,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return oe().getRTLTextPluginStatus()},e.getVersion=function(){return Ja},e.getWorkerCount=function(){return D.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return O().broadcast("IS",e)},e.prewarm=function(){F().acquire(z);},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e;},e.setRTLTextPlugin=function(e,t){return oe().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){D.workerCount=e;},e.setWorkerUrl=function(e){t.a.WORKER_URL=e;};})); + +// +// Our custom intro provides a specialized "define()" function, called by the +// AMD modules below, that sets up the worker blob URL and then executes the +// main module, storing its exported value as 'maplibregl' + + +var maplibregl$1 = maplibregl; + +return maplibregl$1; + +})); +//# sourceMappingURL=maplibre-gl.js.map diff --git a/docs/articles/layers-overview_files/maplibregl-binding-0.1.4.9000/maplibregl.js b/docs/articles/layers-overview_files/maplibregl-binding-0.1.4.9000/maplibregl.js new file mode 100644 index 00000000..01895aae --- /dev/null +++ b/docs/articles/layers-overview_files/maplibregl-binding-0.1.4.9000/maplibregl.js @@ -0,0 +1,1932 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/maplibregl-binding-0.2.0.9000/maplibregl.js b/docs/articles/layers-overview_files/maplibregl-binding-0.2.0.9000/maplibregl.js new file mode 100644 index 00000000..4ea4f853 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibregl-binding-0.2.0.9000/maplibregl.js @@ -0,0 +1,2135 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[layer.popup]; + + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), + ); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/maplibregl-binding-0.2.0/maplibregl.js b/docs/articles/layers-overview_files/maplibregl-binding-0.2.0/maplibregl.js new file mode 100644 index 00000000..01895aae --- /dev/null +++ b/docs/articles/layers-overview_files/maplibregl-binding-0.2.0/maplibregl.js @@ -0,0 +1,1932 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/maplibregl-binding-0.2.1/maplibregl.js b/docs/articles/layers-overview_files/maplibregl-binding-0.2.1/maplibregl.js new file mode 100644 index 00000000..4ea4f853 --- /dev/null +++ b/docs/articles/layers-overview_files/maplibregl-binding-0.2.1/maplibregl.js @@ -0,0 +1,2135 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[layer.popup]; + + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), + ); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/layers-overview_files/maplibregl-binding-0.2.2.9000/maplibregl.js b/docs/articles/layers-overview_files/maplibregl-binding-0.2.2.9000/maplibregl.js new file mode 100644 index 00000000..b43114cf --- /dev/null +++ b/docs/articles/layers-overview_files/maplibregl-binding-0.2.2.9000/maplibregl.js @@ -0,0 +1,3133 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case 'get': + return properties[expression[1]]; + case 'concat': + return expression.slice(1).map(item => evaluateExpression(item, properties)).join(''); + case 'to-string': + return String(evaluateExpression(expression[1], properties)); + case 'to-number': + return Number(evaluateExpression(expression[1], properties)); + case 'number-format': + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || 'en-US'; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty('min-fraction-digits')) { + formatOptions.minimumFractionDigits = options['min-fraction-digits']; + } + if (options.hasOwnProperty('max-fraction-digits')) { + formatOptions.maximumFractionDigits = options['max-fraction-digits']; + } + if (options.hasOwnProperty('min-integer-digits')) { + formatOptions.minimumIntegerDigits = options['min-integer-digits']; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty('useGrouping')) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(tooltipProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + window._mapboxPopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layerId] === popup) { + delete window._mapboxPopups[layerId]; + } + }); +} + +// Helper function to generate draw styles based on parameters +function generateDrawStyles(styling) { + if (!styling) return null; + + return [ + // Point styles + { + 'id': 'gl-draw-point-active', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'true']], + 'paint': { + 'circle-radius': styling.vertex_radius + 2, + 'circle-color': styling.active_color + } + }, + { + 'id': 'gl-draw-point', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'false']], + 'paint': { + 'circle-radius': styling.vertex_radius, + 'circle-color': styling.point_color + } + }, + // Line styles + { + 'id': 'gl-draw-line', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'LineString']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Polygon fill + { + 'id': 'gl-draw-polygon-fill', + 'type': 'fill', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'paint': { + 'fill-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-outline-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-opacity': styling.fill_opacity + } + }, + // Polygon outline + { + 'id': 'gl-draw-polygon-stroke', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Midpoints + { + 'id': 'gl-draw-polygon-midpoint', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'midpoint']], + 'paint': { + 'circle-radius': 3, + 'circle-color': styling.active_color + } + }, + // Vertex point halos + { + 'id': 'gl-draw-vertex-halo-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 4, + styling.vertex_radius + 2 + ], + 'circle-color': '#FFF' + } + }, + // Vertex points + { + 'id': 'gl-draw-vertex-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 2, + styling.vertex_radius + ], + 'circle-color': styling.active_color + } + } + ]; +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, layer.popup, layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + // Check if the feature has an id + const featureId = e.features[0].id; + + // Only proceed if the feature has an id + if (featureId !== undefined && featureId !== null) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = featureId; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: true }, + ); + } + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), + ); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe control if enabled + if (x.globe_control) { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, x.globe_control.position); + map.controls.push(globeControl); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + // Generate styles if styling parameters provided + if (x.draw_control.styling) { + const generatedStyles = generateDrawStyles(x.draw_control.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + // Fix MapLibre compatibility - ensure we always have custom styles + if (!drawOptions.styles) { + drawOptions.styles = generateDrawStyles({ + vertex_radius: 5, + active_color: '#fbb03b', + point_color: '#3bb2d0', + line_color: '#3bb2d0', + fill_color: '#3bb2d0', + fill_opacity: 0.1, + line_width: 2 + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (x.draw_control.source) { + addSourceFeaturesToDraw(draw, x.draw_control.source, map); + } + + // Process any queued features + if (x.draw_features_queue) { + x.draw_features_queue.forEach(function(data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn('Source not found or has no data:', sourceId); + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + // Initialize with empty object, will be populated after map loads + let initialView = {}; + + // Capture the initial view after the map has loaded and all view operations are complete + map.once('load', function() { + initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + }); + + resetControl.onclick = function () { + // Only reset if we have captured the initial view + if (initialView.center) { + map.easeTo(initialView); + } + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDraw: function () { + return draw; // Return the draw instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + + // Helper function to update drawn features + function updateDrawnFeatures() { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + var drawnFeatures = drawControl.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(drawnFeatures) + ); + } + // Store drawn features in the widget's data + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, message.layer.popup, message.layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + // Check if the feature has an id + const featureId = e.features[0].id; + + // Only proceed if the feature has an id + if (featureId !== undefined && featureId !== null) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = featureId; + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: true }, + ); + } + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + // Check both message.layer and message.layer.id as keys due to different message formats + if (window._mapboxPopups) { + // First check if we have a popup stored with message.layer key + if (window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + // Also check if we have a popup stored with message.layer.id key, which happens when added via add_layer + if (message.layer && message.layer.id && window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + delete window._mapboxPopups[message.layer.id]; + } + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if (window._mapboxClickHandlers) { + // First check for handlers stored with message.layer key + if (window._mapboxClickHandlers[message.layer]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Also check for handlers stored with message.layer.id key from add_layer + if (message.layer && message.layer.id && window._mapboxClickHandlers[message.layer.id]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer.id] + ); + delete window._mapboxClickHandlers[message.layer.id]; + } + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + console.log("[MapGL Debug] Current style sources:", Object.keys(currentStyle.sources)); + console.log("[MapGL Debug] Current style layers:", currentStyle.layers.map(l => l.id)); + + // Store layer IDs we know were added by the user via R code + // This is the most reliable way to identify user-added layers + const knownUserLayerIds = []; + + // For each layer in the current style, determine if it's a user-added layer + currentStyle.layers.forEach(function(layer) { + const layerId = layer.id; + + // Critical: Check for nc_counties specifically since we know that's used in the test app + if (layerId === "nc_counties") { + console.log("[MapGL Debug] Found explicit test layer:", layerId); + knownUserLayerIds.push(layerId); + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found source from test layer:", layer.source); + userSourceIds.push(layer.source); + } + return; // Skip other checks for this layer + } + + // These are common patterns for user-added layers from R code + if ( + // Specific layer IDs from the R package + layerId.endsWith("_counties") || + layerId.endsWith("_label") || + layerId.endsWith("_layer") || + + // Look for hover handlers - only user-added layers have these + (window._mapboxHandlers && window._mapboxHandlers[layerId]) || + + // If the layer ID contains these strings, it's likely user-added + layerId.includes("user") || + layerId.includes("custom") || + + // If the paint property has a hover case, it's user-added + (layer.paint && Object.values(layer.paint).some(value => + Array.isArray(value) && + value[0] === "case" && + Array.isArray(value[1]) && + value[1][1] && + Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && + value[1][1][1] === "hover")) + ) { + console.log("[MapGL Debug] Found user layer:", layerId); + knownUserLayerIds.push(layerId); + // Also include its source + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found user source from layer:", layer.source); + userSourceIds.push(layer.source); + } + } + }); + + // For each source, determine if it's a user-added source + for (const sourceId in currentStyle.sources) { + const source = currentStyle.sources[sourceId]; + + // Strategy 1: All GeoJSON sources are likely user-added + if (source.type === "geojson") { + console.log("[MapGL Debug] Found user GeoJSON source:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 2: Check for source data URL patterns typical of R-generated data + else if (source.url && typeof source.url === 'string' && + (source.url.includes("data:application/json") || + source.url.includes("blob:"))) { + console.log("[MapGL Debug] Found user source with data URL:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 3: Standard filtering - exclude common base map sources + else if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") && + sourceId !== "openmaptiles" && // Common in MapLibre styles + !(sourceId.startsWith("carto") && sourceId !== "carto-source") && // Filter CARTO base sources but keep user ones + !(sourceId.startsWith("maptiler") && !sourceId.includes("user")) && // Filter MapTiler sources but keep user ones + !sourceId.includes("terrain") && // Common terrain sources + !sourceId.includes("hillshade") && // Common hillshade sources + !(sourceId.includes("basemap") && !sourceId.includes("user")) // Filter basemap sources but keep user ones + ) { + console.log("[MapGL Debug] Found user source via filtering:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + + // Identify layers using user-added sources or known user layer IDs + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source) || knownUserLayerIds.includes(layer.id)) { + userLayers.push(layer); + } + }); + + // Log detected user sources and layers + console.log("[MapGL Debug] Detected user sources:", userSourceIds); + console.log("[MapGL Debug] Detected user layers:", userLayers.map(l => l.id)); + + // Store them for potential use outside the onStyleLoad event + // This helps in case the event timing is different in MapLibre + if (!window._mapglPreservedData) { + window._mapglPreservedData = {}; + } + window._mapglPreservedData[map.getContainer().id] = { + sources: userSourceIds.map(id => ({id, source: currentStyle.sources[id]})), + layers: userLayers + }; + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + console.log("[MapGL Debug] style.load event fired"); + + try { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + try { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + console.log("[MapGL Debug] Re-adding source:", sourceId); + map.addSource(sourceId, source); + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding source:", sourceId, err); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Re-adding layer:", layer.id); + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + console.log("[MapGL Debug] Re-adding mousemove handler for:", layer.id); + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + console.log("[MapGL Debug] Re-adding mouseleave handler for:", layer.id); + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Check if we need to restore tooltip handlers + const layerId = layer.id; + if (layerId === "nc_counties" || layer.tooltip) { + console.log("[MapGL Debug] Restoring tooltip for:", layerId); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = layer.tooltip || "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding layer:", layer.id, err); + } + }); + } catch (err) { + console.error("[MapGL Debug] Error in style.load handler:", err); + } + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + + // Add a backup mechanism specific to MapLibre + // Some MapLibre styles or versions may have different event timing + if (userLayers.length > 0) { + // Set a timeout to check if layers were added after a reasonable delay + setTimeout(function() { + try { + console.log("[MapGL Debug] Running backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Backup restoration needed for layers"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding layer", layer.id, err); + } + }); + } else { + console.log("[MapGL Debug] Backup check: layers already restored properly"); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in backup restoration:", err); + } + }, 500); // 500ms delay - faster recovery + + // Add a second backup with a bit more delay in case the first one fails + setTimeout(function() { + try { + console.log("[MapGL Debug] Running second backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Second backup restoration needed"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Second backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Second backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Second backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Second backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding layer", layer.id, err); + } + }); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in second backup:", err); + } + }, 1000); // 1 second delay for second backup + } + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + // Create the draw control + var drawControl = new MapboxDraw(drawOptions); + map.addControl(drawControl, message.position); + map.controls.push(drawControl); + + // Store the draw control on the widget for later access + widget.drawControl = drawControl; + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(drawControl, message.source, map); + } + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + const features = drawControl.getAll(); + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + drawControl.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_features_to_draw") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + if (message.data.clear_existing) { + drawControl.deleteAll(); + } + addSourceFeaturesToDraw(drawControl, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn('Draw control not initialized'); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_popup") { + const layerId = message.layer; + const newPopupProperty = message.popup; + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + delete window._mapboxPopups[layerId]; + } + + // Remove old click handler if any + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + delete window._mapboxClickHandlers[layerId]; + } + + // Remove old hover handlers for cursor change + map.off("mouseenter", layerId); + map.off("mouseleave", layerId); + + // Create new click handler + const clickHandler = function (e) { + onClickPopup(e, map, newPopupProperty, layerId); + }; + + // Add the new event handler + map.on("click", layerId, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } else if (message.type === "add_globe_control") { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, message.position); + map.controls.push(globeControl); + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } + }); +} diff --git a/docs/articles/layers-overview_files/maplibregl-binding-0.2.2/maplibregl.js b/docs/articles/layers-overview_files/maplibregl-binding-0.2.2/maplibregl.js new file mode 100644 index 00000000..212c00db --- /dev/null +++ b/docs/articles/layers-overview_files/maplibregl-binding-0.2.2/maplibregl.js @@ -0,0 +1,2758 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "maplibregl", + + type: "output", + + factory: function (el, width, height) { + let map; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + + map = new maplibregl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.maplibreglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[layer.popup]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[layer.id]) { + window._mapboxPopups[layer.id].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layer.id] === popup) { + delete window._mapboxPopups[layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), + ); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe control if enabled + if (x.globe_control) { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, x.globe_control.position); + map.controls.push(globeControl); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new maplibregl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, async (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + const zoom = await map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId); + map.easeTo({ + center: features[0].geometry.coordinates, + zoom, + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("maplibre-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[message.layer.popup]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[message.layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[message.layer.id] === popup) { + delete window._mapboxPopups[message.layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + // Check both message.layer and message.layer.id as keys due to different message formats + if (window._mapboxPopups) { + // First check if we have a popup stored with message.layer key + if (window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + // Also check if we have a popup stored with message.layer.id key, which happens when added via add_layer + if (message.layer && message.layer.id && window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + delete window._mapboxPopups[message.layer.id]; + } + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if (window._mapboxClickHandlers) { + // First check for handlers stored with message.layer key + if (window._mapboxClickHandlers[message.layer]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Also check for handlers stored with message.layer.id key from add_layer + if (message.layer && message.layer.id && window._mapboxClickHandlers[message.layer.id]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer.id] + ); + delete window._mapboxClickHandlers[message.layer.id]; + } + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "query_rendered_features") { + const features = map.queryRenderedFeatures(message.geometry, { + layers: message.layers, + filter: message.filter, + }); + Shiny.setInputValue(el.id + "_feature_query", features); + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + console.log("[MapGL Debug] Current style sources:", Object.keys(currentStyle.sources)); + console.log("[MapGL Debug] Current style layers:", currentStyle.layers.map(l => l.id)); + + // Store layer IDs we know were added by the user via R code + // This is the most reliable way to identify user-added layers + const knownUserLayerIds = []; + + // For each layer in the current style, determine if it's a user-added layer + currentStyle.layers.forEach(function(layer) { + const layerId = layer.id; + + // Critical: Check for nc_counties specifically since we know that's used in the test app + if (layerId === "nc_counties") { + console.log("[MapGL Debug] Found explicit test layer:", layerId); + knownUserLayerIds.push(layerId); + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found source from test layer:", layer.source); + userSourceIds.push(layer.source); + } + return; // Skip other checks for this layer + } + + // These are common patterns for user-added layers from R code + if ( + // Specific layer IDs from the R package + layerId.endsWith("_counties") || + layerId.endsWith("_label") || + layerId.endsWith("_layer") || + + // Look for hover handlers - only user-added layers have these + (window._mapboxHandlers && window._mapboxHandlers[layerId]) || + + // If the layer ID contains these strings, it's likely user-added + layerId.includes("user") || + layerId.includes("custom") || + + // If the paint property has a hover case, it's user-added + (layer.paint && Object.values(layer.paint).some(value => + Array.isArray(value) && + value[0] === "case" && + Array.isArray(value[1]) && + value[1][1] && + Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && + value[1][1][1] === "hover")) + ) { + console.log("[MapGL Debug] Found user layer:", layerId); + knownUserLayerIds.push(layerId); + // Also include its source + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found user source from layer:", layer.source); + userSourceIds.push(layer.source); + } + } + }); + + // For each source, determine if it's a user-added source + for (const sourceId in currentStyle.sources) { + const source = currentStyle.sources[sourceId]; + + // Strategy 1: All GeoJSON sources are likely user-added + if (source.type === "geojson") { + console.log("[MapGL Debug] Found user GeoJSON source:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 2: Check for source data URL patterns typical of R-generated data + else if (source.url && typeof source.url === 'string' && + (source.url.includes("data:application/json") || + source.url.includes("blob:"))) { + console.log("[MapGL Debug] Found user source with data URL:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 3: Standard filtering - exclude common base map sources + else if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") && + sourceId !== "openmaptiles" && // Common in MapLibre styles + !(sourceId.startsWith("carto") && sourceId !== "carto-source") && // Filter CARTO base sources but keep user ones + !(sourceId.startsWith("maptiler") && !sourceId.includes("user")) && // Filter MapTiler sources but keep user ones + !sourceId.includes("terrain") && // Common terrain sources + !sourceId.includes("hillshade") && // Common hillshade sources + !(sourceId.includes("basemap") && !sourceId.includes("user")) // Filter basemap sources but keep user ones + ) { + console.log("[MapGL Debug] Found user source via filtering:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + + // Identify layers using user-added sources or known user layer IDs + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source) || knownUserLayerIds.includes(layer.id)) { + userLayers.push(layer); + } + }); + + // Log detected user sources and layers + console.log("[MapGL Debug] Detected user sources:", userSourceIds); + console.log("[MapGL Debug] Detected user layers:", userLayers.map(l => l.id)); + + // Store them for potential use outside the onStyleLoad event + // This helps in case the event timing is different in MapLibre + if (!window._mapglPreservedData) { + window._mapglPreservedData = {}; + } + window._mapglPreservedData[map.getContainer().id] = { + sources: userSourceIds.map(id => ({id, source: currentStyle.sources[id]})), + layers: userLayers + }; + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + console.log("[MapGL Debug] style.load event fired"); + + try { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + try { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + console.log("[MapGL Debug] Re-adding source:", sourceId); + map.addSource(sourceId, source); + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding source:", sourceId, err); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Re-adding layer:", layer.id); + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + console.log("[MapGL Debug] Re-adding mousemove handler for:", layer.id); + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + console.log("[MapGL Debug] Re-adding mouseleave handler for:", layer.id); + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Check if we need to restore tooltip handlers + const layerId = layer.id; + if (layerId === "nc_counties" || layer.tooltip) { + console.log("[MapGL Debug] Restoring tooltip for:", layerId); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = layer.tooltip || "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding layer:", layer.id, err); + } + }); + } catch (err) { + console.error("[MapGL Debug] Error in style.load handler:", err); + } + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + + // Add a backup mechanism specific to MapLibre + // Some MapLibre styles or versions may have different event timing + if (userLayers.length > 0) { + // Set a timeout to check if layers were added after a reasonable delay + setTimeout(function() { + try { + console.log("[MapGL Debug] Running backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Backup restoration needed for layers"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding layer", layer.id, err); + } + }); + } else { + console.log("[MapGL Debug] Backup check: layers already restored properly"); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in backup restoration:", err); + } + }, 500); // 500ms delay - faster recovery + + // Add a second backup with a bit more delay in case the first one fails + setTimeout(function() { + try { + console.log("[MapGL Debug] Running second backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Second backup restoration needed"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Second backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Second backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Second backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Second backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding layer", layer.id, err); + } + }); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in second backup:", err); + } + }, 1000); // 1 second delay for second backup + } + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreMarkers) { + window.maplibreMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreMarkers) { + window.maplibreMarkers.forEach(function (marker) { + marker.remove(); + }); + window.maplibreglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_geolocate_control") { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - feature.bbox[0]) / 2, + feature.bbox[1] + + (feature.bbox[3] - feature.bbox[1]) / 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: feature.properties.display_name, + properties: feature.properties, + text: feature.properties.display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoder = new MaplibreGeocoder(geocoderApi, { + maplibregl: maplibregl, + placeholder: message.options.placeholder, + collapsed: message.options.collapsed, + }); + map.addControl(geocoder, message.options.position); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url) + .then((image) => { + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + }); + } else if (message.url) { + map.loadImage(message.url) + .then((image) => { + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image.data, + message.options, + ); + } + }) + .catch((error) => { + console.error("Error loading image:", error); + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } else if (message.type === "add_globe_control") { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, message.position); + map.controls.push(globeControl); + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } + }); +} diff --git a/docs/articles/layers-overview_files/pmtiles-3.2.0/pmtiles.js b/docs/articles/layers-overview_files/pmtiles-3.2.0/pmtiles.js new file mode 100644 index 00000000..d3d188da --- /dev/null +++ b/docs/articles/layers-overview_files/pmtiles-3.2.0/pmtiles.js @@ -0,0 +1,1738 @@ +"use strict"; +var pmtiles = (() => { + var __defProp = Object.defineProperty; + var __getOwnPropDesc = Object.getOwnPropertyDescriptor; + var __getOwnPropNames = Object.getOwnPropertyNames; + var __hasOwnProp = Object.prototype.hasOwnProperty; + var __pow = Math.pow; + var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; + }; + var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + var __async = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); + }; + + // index.ts + var js_exports = {}; + __export(js_exports, { + Compression: () => Compression, + EtagMismatch: () => EtagMismatch, + FetchSource: () => FetchSource, + FileSource: () => FileSource, + PMTiles: () => PMTiles, + Protocol: () => Protocol, + ResolvedValueCache: () => ResolvedValueCache, + SharedPromiseCache: () => SharedPromiseCache, + TileType: () => TileType, + bytesToHeader: () => bytesToHeader, + findTile: () => findTile, + getUint64: () => getUint64, + leafletRasterLayer: () => leafletRasterLayer, + readVarint: () => readVarint, + tileIdToZxy: () => tileIdToZxy, + tileTypeExt: () => tileTypeExt, + zxyToTileId: () => zxyToTileId + }); + + // node_modules/fflate/esm/browser.js + var u8 = Uint8Array; + var u16 = Uint16Array; + var i32 = Int32Array; + var fleb = new u8([ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 3, + 3, + 3, + 3, + 4, + 4, + 4, + 4, + 5, + 5, + 5, + 5, + 0, + /* unused */ + 0, + 0, + /* impossible */ + 0 + ]); + var fdeb = new u8([ + 0, + 0, + 0, + 0, + 1, + 1, + 2, + 2, + 3, + 3, + 4, + 4, + 5, + 5, + 6, + 6, + 7, + 7, + 8, + 8, + 9, + 9, + 10, + 10, + 11, + 11, + 12, + 12, + 13, + 13, + /* unused */ + 0, + 0 + ]); + var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); + var freb = function(eb, start) { + var b = new u16(31); + for (var i = 0; i < 31; ++i) { + b[i] = start += 1 << eb[i - 1]; + } + var r = new i32(b[30]); + for (var i = 1; i < 30; ++i) { + for (var j = b[i]; j < b[i + 1]; ++j) { + r[j] = j - b[i] << 5 | i; + } + } + return { b, r }; + }; + var _a = freb(fleb, 2); + var fl = _a.b; + var revfl = _a.r; + fl[28] = 258, revfl[258] = 28; + var _b = freb(fdeb, 0); + var fd = _b.b; + var revfd = _b.r; + var rev = new u16(32768); + for (i = 0; i < 32768; ++i) { + x = (i & 43690) >> 1 | (i & 21845) << 1; + x = (x & 52428) >> 2 | (x & 13107) << 2; + x = (x & 61680) >> 4 | (x & 3855) << 4; + rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1; + } + var x; + var i; + var hMap = function(cd, mb, r) { + var s = cd.length; + var i = 0; + var l = new u16(mb); + for (; i < s; ++i) { + if (cd[i]) + ++l[cd[i] - 1]; + } + var le = new u16(mb); + for (i = 1; i < mb; ++i) { + le[i] = le[i - 1] + l[i - 1] << 1; + } + var co; + if (r) { + co = new u16(1 << mb); + var rvb = 15 - mb; + for (i = 0; i < s; ++i) { + if (cd[i]) { + var sv = i << 4 | cd[i]; + var r_1 = mb - cd[i]; + var v = le[cd[i] - 1]++ << r_1; + for (var m = v | (1 << r_1) - 1; v <= m; ++v) { + co[rev[v] >> rvb] = sv; + } + } + } + } else { + co = new u16(s); + for (i = 0; i < s; ++i) { + if (cd[i]) { + co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i]; + } + } + } + return co; + }; + var flt = new u8(288); + for (i = 0; i < 144; ++i) + flt[i] = 8; + var i; + for (i = 144; i < 256; ++i) + flt[i] = 9; + var i; + for (i = 256; i < 280; ++i) + flt[i] = 7; + var i; + for (i = 280; i < 288; ++i) + flt[i] = 8; + var i; + var fdt = new u8(32); + for (i = 0; i < 32; ++i) + fdt[i] = 5; + var i; + var flrm = /* @__PURE__ */ hMap(flt, 9, 1); + var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1); + var max = function(a) { + var m = a[0]; + for (var i = 1; i < a.length; ++i) { + if (a[i] > m) + m = a[i]; + } + return m; + }; + var bits = function(d, p, m) { + var o = p / 8 | 0; + return (d[o] | d[o + 1] << 8) >> (p & 7) & m; + }; + var bits16 = function(d, p) { + var o = p / 8 | 0; + return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7); + }; + var shft = function(p) { + return (p + 7) / 8 | 0; + }; + var slc = function(v, s, e) { + if (s == null || s < 0) + s = 0; + if (e == null || e > v.length) + e = v.length; + var n = new u8(e - s); + n.set(v.subarray(s, e)); + return n; + }; + var ec = [ + "unexpected EOF", + "invalid block type", + "invalid length/literal", + "invalid distance", + "stream finished", + "no stream handler", + , + "no callback", + "invalid UTF-8 data", + "extra field too long", + "date not in range 1980-2099", + "filename too long", + "stream finishing", + "invalid zip data" + // determined by unknown compression method + ]; + var err = function(ind, msg, nt) { + var e = new Error(msg || ec[ind]); + e.code = ind; + if (Error.captureStackTrace) + Error.captureStackTrace(e, err); + if (!nt) + throw e; + return e; + }; + var inflt = function(dat, st, buf, dict) { + var sl = dat.length, dl = dict ? dict.length : 0; + if (!sl || st.f && !st.l) + return buf || new u8(0); + var noBuf = !buf || st.i != 2; + var noSt = st.i; + if (!buf) + buf = new u8(sl * 3); + var cbuf = function(l2) { + var bl = buf.length; + if (l2 > bl) { + var nbuf = new u8(Math.max(bl * 2, l2)); + nbuf.set(buf); + buf = nbuf; + } + }; + var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n; + var tbts = sl * 8; + do { + if (!lm) { + final = bits(dat, pos, 1); + var type = bits(dat, pos + 1, 3); + pos += 3; + if (!type) { + var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l; + if (t > sl) { + if (noSt) + err(0); + break; + } + if (noBuf) + cbuf(bt + l); + buf.set(dat.subarray(s, t), bt); + st.b = bt += l, st.p = pos = t * 8, st.f = final; + continue; + } else if (type == 1) + lm = flrm, dm = fdrm, lbt = 9, dbt = 5; + else if (type == 2) { + var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4; + var tl = hLit + bits(dat, pos + 5, 31) + 1; + pos += 14; + var ldt = new u8(tl); + var clt = new u8(19); + for (var i = 0; i < hcLen; ++i) { + clt[clim[i]] = bits(dat, pos + i * 3, 7); + } + pos += hcLen * 3; + var clb = max(clt), clbmsk = (1 << clb) - 1; + var clm = hMap(clt, clb, 1); + for (var i = 0; i < tl; ) { + var r = clm[bits(dat, pos, clbmsk)]; + pos += r & 15; + var s = r >> 4; + if (s < 16) { + ldt[i++] = s; + } else { + var c = 0, n = 0; + if (s == 16) + n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1]; + else if (s == 17) + n = 3 + bits(dat, pos, 7), pos += 3; + else if (s == 18) + n = 11 + bits(dat, pos, 127), pos += 7; + while (n--) + ldt[i++] = c; + } + } + var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit); + lbt = max(lt); + dbt = max(dt); + lm = hMap(lt, lbt, 1); + dm = hMap(dt, dbt, 1); + } else + err(1); + if (pos > tbts) { + if (noSt) + err(0); + break; + } + } + if (noBuf) + cbuf(bt + 131072); + var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1; + var lpos = pos; + for (; ; lpos = pos) { + var c = lm[bits16(dat, pos) & lms], sym = c >> 4; + pos += c & 15; + if (pos > tbts) { + if (noSt) + err(0); + break; + } + if (!c) + err(2); + if (sym < 256) + buf[bt++] = sym; + else if (sym == 256) { + lpos = pos, lm = null; + break; + } else { + var add = sym - 254; + if (sym > 264) { + var i = sym - 257, b = fleb[i]; + add = bits(dat, pos, (1 << b) - 1) + fl[i]; + pos += b; + } + var d = dm[bits16(dat, pos) & dms], dsym = d >> 4; + if (!d) + err(3); + pos += d & 15; + var dt = fd[dsym]; + if (dsym > 3) { + var b = fdeb[dsym]; + dt += bits16(dat, pos) & (1 << b) - 1, pos += b; + } + if (pos > tbts) { + if (noSt) + err(0); + break; + } + if (noBuf) + cbuf(bt + 131072); + var end = bt + add; + if (bt < dt) { + var shift2 = dl - dt, dend = Math.min(dt, end); + if (shift2 + bt < 0) + err(3); + for (; bt < dend; ++bt) + buf[bt] = dict[shift2 + bt]; + } + for (; bt < end; bt += 4) { + buf[bt] = buf[bt - dt]; + buf[bt + 1] = buf[bt + 1 - dt]; + buf[bt + 2] = buf[bt + 2 - dt]; + buf[bt + 3] = buf[bt + 3 - dt]; + } + bt = end; + } + } + st.l = lm, st.p = lpos, st.b = bt, st.f = final; + if (lm) + final = 1, st.m = lbt, st.d = dm, st.n = dbt; + } while (!final); + return bt == buf.length ? buf : slc(buf, 0, bt); + }; + var et = /* @__PURE__ */ new u8(0); + var gzs = function(d) { + if (d[0] != 31 || d[1] != 139 || d[2] != 8) + err(6, "invalid gzip data"); + var flg = d[3]; + var st = 10; + if (flg & 4) + st += (d[10] | d[11] << 8) + 2; + for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]) + ; + return st + (flg & 2); + }; + var gzl = function(d) { + var l = d.length; + return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0; + }; + var zls = function(d, dict) { + if ((d[0] & 15) != 8 || d[0] >> 4 > 7 || (d[0] << 8 | d[1]) % 31) + err(6, "invalid zlib data"); + if ((d[1] >> 5 & 1) == +!dict) + err(6, "invalid zlib data: " + (d[1] & 32 ? "need" : "unexpected") + " dictionary"); + return (d[1] >> 3 & 4) + 2; + }; + function inflateSync(data, opts) { + return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary); + } + function gunzipSync(data, opts) { + var st = gzs(data); + if (st + 8 > data.length) + err(6, "invalid gzip data"); + return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary); + } + function unzlibSync(data, opts) { + return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary); + } + function decompressSync(data, opts) { + return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzipSync(data, opts) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflateSync(data, opts) : unzlibSync(data, opts); + } + var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder(); + var tds = 0; + try { + td.decode(et, { stream: true }); + tds = 1; + } catch (e) { + } + + // v2.ts + var shift = (n, shift2) => { + return n * __pow(2, shift2); + }; + var unshift = (n, shift2) => { + return Math.floor(n / __pow(2, shift2)); + }; + var getUint24 = (view, pos) => { + return shift(view.getUint16(pos + 1, true), 8) + view.getUint8(pos); + }; + var getUint48 = (view, pos) => { + return shift(view.getUint32(pos + 2, true), 16) + view.getUint16(pos, true); + }; + var compare = (tz, tx, ty, view, i) => { + if (tz !== view.getUint8(i)) + return tz - view.getUint8(i); + const x = getUint24(view, i + 1); + if (tx !== x) + return tx - x; + const y = getUint24(view, i + 4); + if (ty !== y) + return ty - y; + return 0; + }; + var queryLeafdir = (view, z, x, y) => { + const offsetLen = queryView(view, z | 128, x, y); + if (offsetLen) { + return { + z, + x, + y, + offset: offsetLen[0], + length: offsetLen[1], + isDir: true + }; + } + return null; + }; + var queryTile = (view, z, x, y) => { + const offsetLen = queryView(view, z, x, y); + if (offsetLen) { + return { + z, + x, + y, + offset: offsetLen[0], + length: offsetLen[1], + isDir: false + }; + } + return null; + }; + var queryView = (view, z, x, y) => { + let m = 0; + let n = view.byteLength / 17 - 1; + while (m <= n) { + const k = n + m >> 1; + const cmp = compare(z, x, y, view, k * 17); + if (cmp > 0) { + m = k + 1; + } else if (cmp < 0) { + n = k - 1; + } else { + return [getUint48(view, k * 17 + 7), view.getUint32(k * 17 + 13, true)]; + } + } + return null; + }; + var entrySort = (a, b) => { + if (a.isDir && !b.isDir) { + return 1; + } + if (!a.isDir && b.isDir) { + return -1; + } + if (a.z !== b.z) { + return a.z - b.z; + } + if (a.x !== b.x) { + return a.x - b.x; + } + return a.y - b.y; + }; + var parseEntry = (dataview, i) => { + const zRaw = dataview.getUint8(i * 17); + const z = zRaw & 127; + return { + z, + x: getUint24(dataview, i * 17 + 1), + y: getUint24(dataview, i * 17 + 4), + offset: getUint48(dataview, i * 17 + 7), + length: dataview.getUint32(i * 17 + 13, true), + isDir: zRaw >> 7 === 1 + }; + }; + var sortDir = (a) => { + const entries = []; + const view = new DataView(a); + for (let i = 0; i < view.byteLength / 17; i++) { + entries.push(parseEntry(view, i)); + } + return createDirectory(entries); + }; + var createDirectory = (entries) => { + entries.sort(entrySort); + const buffer = new ArrayBuffer(17 * entries.length); + const arr = new Uint8Array(buffer); + for (let i = 0; i < entries.length; i++) { + const entry = entries[i]; + let z = entry.z; + if (entry.isDir) + z = z | 128; + arr[i * 17] = z; + arr[i * 17 + 1] = entry.x & 255; + arr[i * 17 + 2] = entry.x >> 8 & 255; + arr[i * 17 + 3] = entry.x >> 16 & 255; + arr[i * 17 + 4] = entry.y & 255; + arr[i * 17 + 5] = entry.y >> 8 & 255; + arr[i * 17 + 6] = entry.y >> 16 & 255; + arr[i * 17 + 7] = entry.offset & 255; + arr[i * 17 + 8] = unshift(entry.offset, 8) & 255; + arr[i * 17 + 9] = unshift(entry.offset, 16) & 255; + arr[i * 17 + 10] = unshift(entry.offset, 24) & 255; + arr[i * 17 + 11] = unshift(entry.offset, 32) & 255; + arr[i * 17 + 12] = unshift(entry.offset, 48) & 255; + arr[i * 17 + 13] = entry.length & 255; + arr[i * 17 + 14] = entry.length >> 8 & 255; + arr[i * 17 + 15] = entry.length >> 16 & 255; + arr[i * 17 + 16] = entry.length >> 24 & 255; + } + return buffer; + }; + var deriveLeaf = (view, tile) => { + if (view.byteLength < 17) + return null; + const numEntries = view.byteLength / 17; + const entry = parseEntry(view, numEntries - 1); + if (entry.isDir) { + const leafLevel = entry.z; + const levelDiff = tile.z - leafLevel; + const leafX = Math.trunc(tile.x / (1 << levelDiff)); + const leafY = Math.trunc(tile.y / (1 << levelDiff)); + return { z: leafLevel, x: leafX, y: leafY }; + } + return null; + }; + function getHeader(source) { + return __async(this, null, function* () { + const resp = yield source.getBytes(0, 512e3); + const dataview = new DataView(resp.data); + const jsonSize = dataview.getUint32(4, true); + const rootEntries = dataview.getUint16(8, true); + const dec = new TextDecoder("utf-8"); + const jsonMetadata = JSON.parse( + dec.decode(new DataView(resp.data, 10, jsonSize)) + ); + let tileCompression = 0 /* Unknown */; + if (jsonMetadata.compression === "gzip") { + tileCompression = 2 /* Gzip */; + } + let minzoom = 0; + if ("minzoom" in jsonMetadata) { + minzoom = +jsonMetadata.minzoom; + } + let maxzoom = 0; + if ("maxzoom" in jsonMetadata) { + maxzoom = +jsonMetadata.maxzoom; + } + let centerLon = 0; + let centerLat = 0; + let centerZoom = 0; + let minLon = -180; + let minLat = -85; + let maxLon = 180; + let maxLat = 85; + if (jsonMetadata.bounds) { + const split = jsonMetadata.bounds.split(","); + minLon = +split[0]; + minLat = +split[1]; + maxLon = +split[2]; + maxLat = +split[3]; + } + if (jsonMetadata.center) { + const split = jsonMetadata.center.split(","); + centerLon = +split[0]; + centerLat = +split[1]; + centerZoom = +split[2]; + } + const header = { + specVersion: dataview.getUint16(2, true), + rootDirectoryOffset: 10 + jsonSize, + rootDirectoryLength: rootEntries * 17, + jsonMetadataOffset: 10, + jsonMetadataLength: jsonSize, + leafDirectoryOffset: 0, + leafDirectoryLength: void 0, + tileDataOffset: 0, + tileDataLength: void 0, + numAddressedTiles: 0, + numTileEntries: 0, + numTileContents: 0, + clustered: false, + internalCompression: 1 /* None */, + tileCompression, + tileType: 1 /* Mvt */, + minZoom: minzoom, + maxZoom: maxzoom, + minLon, + minLat, + maxLon, + maxLat, + centerZoom, + centerLon, + centerLat, + etag: resp.etag + }; + return header; + }); + } + function getZxy(header, source, cache, z, x, y, signal) { + return __async(this, null, function* () { + let rootDir = yield cache.getArrayBuffer( + source, + header.rootDirectoryOffset, + header.rootDirectoryLength, + header + ); + if (header.specVersion === 1) { + rootDir = sortDir(rootDir); + } + const entry = queryTile(new DataView(rootDir), z, x, y); + if (entry) { + const resp = yield source.getBytes(entry.offset, entry.length, signal); + let tileData = resp.data; + const view = new DataView(tileData); + if (view.getUint8(0) === 31 && view.getUint8(1) === 139) { + tileData = decompressSync(new Uint8Array(tileData)); + } + return { + data: tileData + }; + } + const leafcoords = deriveLeaf(new DataView(rootDir), { z, x, y }); + if (leafcoords) { + const leafdirEntry = queryLeafdir( + new DataView(rootDir), + leafcoords.z, + leafcoords.x, + leafcoords.y + ); + if (leafdirEntry) { + let leafDir = yield cache.getArrayBuffer( + source, + leafdirEntry.offset, + leafdirEntry.length, + header + ); + if (header.specVersion === 1) { + leafDir = sortDir(leafDir); + } + const tileEntry = queryTile(new DataView(leafDir), z, x, y); + if (tileEntry) { + const resp = yield source.getBytes( + tileEntry.offset, + tileEntry.length, + signal + ); + let tileData = resp.data; + const view = new DataView(tileData); + if (view.getUint8(0) === 31 && view.getUint8(1) === 139) { + tileData = decompressSync(new Uint8Array(tileData)); + } + return { + data: tileData + }; + } + } + } + return void 0; + }); + } + var v2_default = { + getHeader, + getZxy + }; + + // adapters.ts + var leafletRasterLayer = (source, options) => { + let loaded = false; + let mimeType = ""; + const cls = L.GridLayer.extend({ + createTile: (coord, done) => { + const el = document.createElement("img"); + const controller = new AbortController(); + const signal = controller.signal; + el.cancel = () => { + controller.abort(); + }; + if (!loaded) { + source.getHeader().then((header) => { + if (header.tileType === 1 /* Mvt */) { + console.error( + "Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details." + ); + } else if (header.tileType === 2) { + mimeType = "image/png"; + } else if (header.tileType === 3) { + mimeType = "image/jpeg"; + } else if (header.tileType === 4) { + mimeType = "image/webp"; + } else if (header.tileType === 5) { + mimeType = "image/avif"; + } + }); + loaded = true; + } + source.getZxy(coord.z, coord.x, coord.y, signal).then((arr) => { + if (arr) { + const blob = new Blob([arr.data], { type: mimeType }); + const imageUrl = window.URL.createObjectURL(blob); + el.src = imageUrl; + el.cancel = void 0; + done(void 0, el); + } + }).catch((e) => { + if (e.name !== "AbortError") { + throw e; + } + }); + return el; + }, + _removeTile: function(key) { + const tile = this._tiles[key]; + if (!tile) { + return; + } + if (tile.el.cancel) + tile.el.cancel(); + tile.el.width = 0; + tile.el.height = 0; + tile.el.deleted = true; + L.DomUtil.remove(tile.el); + delete this._tiles[key]; + this.fire("tileunload", { + tile: tile.el, + coords: this._keyToTileCoords(key) + }); + } + }); + return new cls(options); + }; + var v3compat = (v4) => (requestParameters, arg2) => { + if (arg2 instanceof AbortController) { + return v4(requestParameters, arg2); + } + const abortController = new AbortController(); + v4(requestParameters, abortController).then( + (result) => { + return arg2( + void 0, + result.data, + result.cacheControl || "", + result.expires || "" + ); + }, + (err2) => { + return arg2(err2); + } + ).catch((e) => { + return arg2(e); + }); + return { cancel: () => abortController.abort() }; + }; + var Protocol = class { + /** + * Initialize the MapLibre PMTiles protocol. + * + * * metadata: also load the metadata section of the PMTiles. required for some "inspect" functionality + * and to automatically populate the map attribution. Requires an extra HTTP request. + */ + constructor(options) { + /** @hidden */ + this.tilev4 = (params, abortController) => __async(this, null, function* () { + if (params.type === "json") { + const pmtilesUrl2 = params.url.substr(10); + let instance2 = this.tiles.get(pmtilesUrl2); + if (!instance2) { + instance2 = new PMTiles(pmtilesUrl2); + this.tiles.set(pmtilesUrl2, instance2); + } + if (this.metadata) { + return { + data: yield instance2.getTileJson(params.url) + }; + } + const h = yield instance2.getHeader(); + return { + data: { + tiles: [`${params.url}/{z}/{x}/{y}`], + minzoom: h.minZoom, + maxzoom: h.maxZoom, + bounds: [h.minLon, h.minLat, h.maxLon, h.maxLat] + } + }; + } + const re = new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/); + const result = params.url.match(re); + if (!result) { + throw new Error("Invalid PMTiles protocol URL"); + } + const pmtilesUrl = result[1]; + let instance = this.tiles.get(pmtilesUrl); + if (!instance) { + instance = new PMTiles(pmtilesUrl); + this.tiles.set(pmtilesUrl, instance); + } + const z = result[2]; + const x = result[3]; + const y = result[4]; + const header = yield instance.getHeader(); + const resp = yield instance == null ? void 0 : instance.getZxy(+z, +x, +y, abortController.signal); + if (resp) { + return { + data: new Uint8Array(resp.data), + cacheControl: resp.cacheControl, + expires: resp.expires + }; + } + if (header.tileType === 1 /* Mvt */) { + return { data: new Uint8Array() }; + } + return { data: null }; + }); + this.tile = v3compat(this.tilev4); + this.tiles = /* @__PURE__ */ new Map(); + this.metadata = (options == null ? void 0 : options.metadata) || false; + } + /** + * Add a {@link PMTiles} instance to the global protocol instance. + * + * For remote fetch sources, references in MapLibre styles like pmtiles://http://... + * will resolve to the same instance if the URLs match. + */ + add(p) { + this.tiles.set(p.source.getKey(), p); + } + /** + * Fetch a {@link PMTiles} instance by URL, for remote PMTiles instances. + */ + get(url) { + return this.tiles.get(url); + } + }; + + // index.ts + function toNum(low, high) { + return (high >>> 0) * 4294967296 + (low >>> 0); + } + function readVarintRemainder(l, p) { + const buf = p.buf; + let b = buf[p.pos++]; + let h = (b & 112) >> 4; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 3; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 10; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 17; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 24; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 1) << 31; + if (b < 128) + return toNum(l, h); + throw new Error("Expected varint not more than 10 bytes"); + } + function readVarint(p) { + const buf = p.buf; + let b = buf[p.pos++]; + let val = b & 127; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 7; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 14; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 21; + if (b < 128) + return val; + b = buf[p.pos]; + val |= (b & 15) << 28; + return readVarintRemainder(val, p); + } + function rotate(n, xy, rx, ry) { + if (ry === 0) { + if (rx === 1) { + xy[0] = n - 1 - xy[0]; + xy[1] = n - 1 - xy[1]; + } + const t = xy[0]; + xy[0] = xy[1]; + xy[1] = t; + } + } + function idOnLevel(z, pos) { + const n = __pow(2, z); + let rx = pos; + let ry = pos; + let t = pos; + const xy = [0, 0]; + let s = 1; + while (s < n) { + rx = 1 & t / 2; + ry = 1 & (t ^ rx); + rotate(s, xy, rx, ry); + xy[0] += s * rx; + xy[1] += s * ry; + t = t / 4; + s *= 2; + } + return [z, xy[0], xy[1]]; + } + var tzValues = [ + 0, + 1, + 5, + 21, + 85, + 341, + 1365, + 5461, + 21845, + 87381, + 349525, + 1398101, + 5592405, + 22369621, + 89478485, + 357913941, + 1431655765, + 5726623061, + 22906492245, + 91625968981, + 366503875925, + 1466015503701, + 5864062014805, + 23456248059221, + 93824992236885, + 375299968947541, + 1501199875790165 + ]; + function zxyToTileId(z, x, y) { + if (z > 26) { + throw Error("Tile zoom level exceeds max safe number limit (26)"); + } + if (x > __pow(2, z) - 1 || y > __pow(2, z) - 1) { + throw Error("tile x/y outside zoom level bounds"); + } + const acc = tzValues[z]; + const n = __pow(2, z); + let rx = 0; + let ry = 0; + let d = 0; + const xy = [x, y]; + let s = n / 2; + while (s > 0) { + rx = (xy[0] & s) > 0 ? 1 : 0; + ry = (xy[1] & s) > 0 ? 1 : 0; + d += s * s * (3 * rx ^ ry); + rotate(s, xy, rx, ry); + s = s / 2; + } + return acc + d; + } + function tileIdToZxy(i) { + let acc = 0; + const z = 0; + for (let z2 = 0; z2 < 27; z2++) { + const numTiles = (1 << z2) * (1 << z2); + if (acc + numTiles > i) { + return idOnLevel(z2, i - acc); + } + acc += numTiles; + } + throw Error("Tile zoom level exceeds max safe number limit (26)"); + } + var Compression = /* @__PURE__ */ ((Compression2) => { + Compression2[Compression2["Unknown"] = 0] = "Unknown"; + Compression2[Compression2["None"] = 1] = "None"; + Compression2[Compression2["Gzip"] = 2] = "Gzip"; + Compression2[Compression2["Brotli"] = 3] = "Brotli"; + Compression2[Compression2["Zstd"] = 4] = "Zstd"; + return Compression2; + })(Compression || {}); + function defaultDecompress(buf, compression) { + return __async(this, null, function* () { + if (compression === 1 /* None */ || compression === 0 /* Unknown */) { + return buf; + } + if (compression === 2 /* Gzip */) { + if (typeof globalThis.DecompressionStream === "undefined") { + return decompressSync(new Uint8Array(buf)); + } + const stream = new Response(buf).body; + if (!stream) { + throw Error("Failed to read response stream"); + } + const result = stream.pipeThrough( + // biome-ignore lint: needed to detect DecompressionStream in browser+node+cloudflare workers + new globalThis.DecompressionStream("gzip") + ); + return new Response(result).arrayBuffer(); + } + throw Error("Compression method not supported"); + }); + } + var TileType = /* @__PURE__ */ ((TileType2) => { + TileType2[TileType2["Unknown"] = 0] = "Unknown"; + TileType2[TileType2["Mvt"] = 1] = "Mvt"; + TileType2[TileType2["Png"] = 2] = "Png"; + TileType2[TileType2["Jpeg"] = 3] = "Jpeg"; + TileType2[TileType2["Webp"] = 4] = "Webp"; + TileType2[TileType2["Avif"] = 5] = "Avif"; + return TileType2; + })(TileType || {}); + function tileTypeExt(t) { + if (t === 1 /* Mvt */) + return ".mvt"; + if (t === 2 /* Png */) + return ".png"; + if (t === 3 /* Jpeg */) + return ".jpg"; + if (t === 4 /* Webp */) + return ".webp"; + if (t === 5 /* Avif */) + return ".avif"; + return ""; + } + var HEADER_SIZE_BYTES = 127; + function findTile(entries, tileId) { + let m = 0; + let n = entries.length - 1; + while (m <= n) { + const k = n + m >> 1; + const cmp = tileId - entries[k].tileId; + if (cmp > 0) { + m = k + 1; + } else if (cmp < 0) { + n = k - 1; + } else { + return entries[k]; + } + } + if (n >= 0) { + if (entries[n].runLength === 0) { + return entries[n]; + } + if (tileId - entries[n].tileId < entries[n].runLength) { + return entries[n]; + } + } + return null; + } + var FileSource = class { + constructor(file) { + this.file = file; + } + getKey() { + return this.file.name; + } + getBytes(offset, length) { + return __async(this, null, function* () { + const blob = this.file.slice(offset, offset + length); + const a = yield blob.arrayBuffer(); + return { data: a }; + }); + } + }; + var FetchSource = class { + constructor(url, customHeaders = new Headers()) { + this.url = url; + this.customHeaders = customHeaders; + this.mustReload = false; + let userAgent = ""; + if ("navigator" in globalThis) { + userAgent = globalThis.navigator.userAgent || ""; + } + const isWindows = userAgent.indexOf("Windows") > -1; + const isChromiumBased = /Chrome|Chromium|Edg|OPR|Brave/.test(userAgent); + this.chromeWindowsNoCache = false; + if (isWindows && isChromiumBased) { + this.chromeWindowsNoCache = true; + } + } + getKey() { + return this.url; + } + /** + * Mutate the custom [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) set for all requests to the remote archive. + */ + setHeaders(customHeaders) { + this.customHeaders = customHeaders; + } + getBytes(offset, length, passedSignal, etag) { + return __async(this, null, function* () { + let controller; + let signal; + if (passedSignal) { + signal = passedSignal; + } else { + controller = new AbortController(); + signal = controller.signal; + } + const requestHeaders = new Headers(this.customHeaders); + requestHeaders.set("range", `bytes=${offset}-${offset + length - 1}`); + let cache; + if (this.mustReload) { + cache = "reload"; + } else if (this.chromeWindowsNoCache) { + cache = "no-store"; + } + let resp = yield fetch(this.url, { + signal, + cache, + headers: requestHeaders + //biome-ignore lint: "cache" is incompatible between cloudflare workers and browser + }); + if (offset === 0 && resp.status === 416) { + const contentRange = resp.headers.get("Content-Range"); + if (!contentRange || !contentRange.startsWith("bytes */")) { + throw Error("Missing content-length on 416 response"); + } + const actualLength = +contentRange.substr(8); + resp = yield fetch(this.url, { + signal, + cache: "reload", + headers: { range: `bytes=0-${actualLength - 1}` } + //biome-ignore lint: "cache" is incompatible between cloudflare workers and browser + }); + } + let newEtag = resp.headers.get("Etag"); + if (newEtag == null ? void 0 : newEtag.startsWith("W/")) { + newEtag = null; + } + if (resp.status === 416 || etag && newEtag && newEtag !== etag) { + this.mustReload = true; + throw new EtagMismatch( + `Server returned non-matching ETag ${etag} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.` + ); + } + if (resp.status >= 300) { + throw Error(`Bad response code: ${resp.status}`); + } + const contentLength = resp.headers.get("Content-Length"); + if (resp.status === 200 && (!contentLength || +contentLength > length)) { + if (controller) + controller.abort(); + throw Error( + "Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving." + ); + } + const a = yield resp.arrayBuffer(); + return { + data: a, + etag: newEtag || void 0, + cacheControl: resp.headers.get("Cache-Control") || void 0, + expires: resp.headers.get("Expires") || void 0 + }; + }); + } + }; + function getUint64(v, offset) { + const wh = v.getUint32(offset + 4, true); + const wl = v.getUint32(offset + 0, true); + return wh * __pow(2, 32) + wl; + } + function bytesToHeader(bytes, etag) { + const v = new DataView(bytes); + const specVersion = v.getUint8(7); + if (specVersion > 3) { + throw Error( + `Archive is spec version ${specVersion} but this library supports up to spec version 3` + ); + } + return { + specVersion, + rootDirectoryOffset: getUint64(v, 8), + rootDirectoryLength: getUint64(v, 16), + jsonMetadataOffset: getUint64(v, 24), + jsonMetadataLength: getUint64(v, 32), + leafDirectoryOffset: getUint64(v, 40), + leafDirectoryLength: getUint64(v, 48), + tileDataOffset: getUint64(v, 56), + tileDataLength: getUint64(v, 64), + numAddressedTiles: getUint64(v, 72), + numTileEntries: getUint64(v, 80), + numTileContents: getUint64(v, 88), + clustered: v.getUint8(96) === 1, + internalCompression: v.getUint8(97), + tileCompression: v.getUint8(98), + tileType: v.getUint8(99), + minZoom: v.getUint8(100), + maxZoom: v.getUint8(101), + minLon: v.getInt32(102, true) / 1e7, + minLat: v.getInt32(106, true) / 1e7, + maxLon: v.getInt32(110, true) / 1e7, + maxLat: v.getInt32(114, true) / 1e7, + centerZoom: v.getUint8(118), + centerLon: v.getInt32(119, true) / 1e7, + centerLat: v.getInt32(123, true) / 1e7, + etag + }; + } + function deserializeIndex(buffer) { + const p = { buf: new Uint8Array(buffer), pos: 0 }; + const numEntries = readVarint(p); + const entries = []; + let lastId = 0; + for (let i = 0; i < numEntries; i++) { + const v = readVarint(p); + entries.push({ tileId: lastId + v, offset: 0, length: 0, runLength: 1 }); + lastId += v; + } + for (let i = 0; i < numEntries; i++) { + entries[i].runLength = readVarint(p); + } + for (let i = 0; i < numEntries; i++) { + entries[i].length = readVarint(p); + } + for (let i = 0; i < numEntries; i++) { + const v = readVarint(p); + if (v === 0 && i > 0) { + entries[i].offset = entries[i - 1].offset + entries[i - 1].length; + } else { + entries[i].offset = v - 1; + } + } + return entries; + } + function detectVersion(a) { + const v = new DataView(a); + if (v.getUint16(2, true) === 2) { + console.warn( + "PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade" + ); + return 2; + } + if (v.getUint16(2, true) === 1) { + console.warn( + "PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade" + ); + return 1; + } + return 3; + } + var EtagMismatch = class extends Error { + }; + function getHeaderAndRoot(source, decompress) { + return __async(this, null, function* () { + const resp = yield source.getBytes(0, 16384); + const v = new DataView(resp.data); + if (v.getUint16(0, true) !== 19792) { + throw new Error("Wrong magic number for PMTiles archive"); + } + if (detectVersion(resp.data) < 3) { + return [yield v2_default.getHeader(source)]; + } + const headerData = resp.data.slice(0, HEADER_SIZE_BYTES); + const header = bytesToHeader(headerData, resp.etag); + const rootDirData = resp.data.slice( + header.rootDirectoryOffset, + header.rootDirectoryOffset + header.rootDirectoryLength + ); + const dirKey = `${source.getKey()}|${header.etag || ""}|${header.rootDirectoryOffset}|${header.rootDirectoryLength}`; + const rootDir = deserializeIndex( + yield decompress(rootDirData, header.internalCompression) + ); + return [header, [dirKey, rootDir.length, rootDir]]; + }); + } + function getDirectory(source, decompress, offset, length, header) { + return __async(this, null, function* () { + const resp = yield source.getBytes(offset, length, void 0, header.etag); + const data = yield decompress(resp.data, header.internalCompression); + const directory = deserializeIndex(data); + if (directory.length === 0) { + throw new Error("Empty directory is invalid"); + } + return directory; + }); + } + var ResolvedValueCache = class { + constructor(maxCacheEntries = 100, prefetch = true, decompress = defaultDecompress) { + this.cache = /* @__PURE__ */ new Map(); + this.maxCacheEntries = maxCacheEntries; + this.counter = 1; + this.decompress = decompress; + } + getHeader(source) { + return __async(this, null, function* () { + const cacheKey = source.getKey(); + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = cacheValue.data; + return data; + } + const res = yield getHeaderAndRoot(source, this.decompress); + if (res[1]) { + this.cache.set(res[1][0], { + lastUsed: this.counter++, + data: res[1][2] + }); + } + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: res[0] + }); + this.prune(); + return res[0]; + }); + } + getDirectory(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = cacheValue.data; + return data; + } + const directory = yield getDirectory( + source, + this.decompress, + offset, + length, + header + ); + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: directory + }); + this.prune(); + return directory; + }); + } + // for v2 backwards compatibility + getArrayBuffer(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const resp = yield source.getBytes(offset, length, void 0, header.etag); + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: resp.data + }); + this.prune(); + return resp.data; + }); + } + prune() { + if (this.cache.size > this.maxCacheEntries) { + let minUsed = Infinity; + let minKey = void 0; + this.cache.forEach((cacheValue, key) => { + if (cacheValue.lastUsed < minUsed) { + minUsed = cacheValue.lastUsed; + minKey = key; + } + }); + if (minKey) { + this.cache.delete(minKey); + } + } + } + invalidate(source) { + return __async(this, null, function* () { + this.cache.delete(source.getKey()); + }); + } + }; + var SharedPromiseCache = class { + constructor(maxCacheEntries = 100, prefetch = true, decompress = defaultDecompress) { + this.cache = /* @__PURE__ */ new Map(); + this.invalidations = /* @__PURE__ */ new Map(); + this.maxCacheEntries = maxCacheEntries; + this.counter = 1; + this.decompress = decompress; + } + getHeader(source) { + return __async(this, null, function* () { + const cacheKey = source.getKey(); + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + getHeaderAndRoot(source, this.decompress).then((res) => { + if (res[1]) { + this.cache.set(res[1][0], { + lastUsed: this.counter++, + data: Promise.resolve(res[1][2]) + }); + } + resolve(res[0]); + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + getDirectory(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + getDirectory(source, this.decompress, offset, length, header).then((directory) => { + resolve(directory); + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + // for v2 backwards compatibility + getArrayBuffer(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + source.getBytes(offset, length, void 0, header.etag).then((resp) => { + resolve(resp.data); + if (this.cache.has(cacheKey)) { + } + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + prune() { + if (this.cache.size >= this.maxCacheEntries) { + let minUsed = Infinity; + let minKey = void 0; + this.cache.forEach((cacheValue, key) => { + if (cacheValue.lastUsed < minUsed) { + minUsed = cacheValue.lastUsed; + minKey = key; + } + }); + if (minKey) { + this.cache.delete(minKey); + } + } + } + invalidate(source) { + return __async(this, null, function* () { + const key = source.getKey(); + if (this.invalidations.get(key)) { + return yield this.invalidations.get(key); + } + this.cache.delete(source.getKey()); + const p = new Promise((resolve, reject) => { + this.getHeader(source).then((h) => { + resolve(); + this.invalidations.delete(key); + }).catch((e) => { + reject(e); + }); + }); + this.invalidations.set(key, p); + }); + } + }; + var PMTiles = class { + constructor(source, cache, decompress) { + if (typeof source === "string") { + this.source = new FetchSource(source); + } else { + this.source = source; + } + if (decompress) { + this.decompress = decompress; + } else { + this.decompress = defaultDecompress; + } + if (cache) { + this.cache = cache; + } else { + this.cache = new SharedPromiseCache(); + } + } + /** + * Return the header of the archive, + * including information such as tile type, min/max zoom, bounds, and summary statistics. + */ + getHeader() { + return __async(this, null, function* () { + return yield this.cache.getHeader(this.source); + }); + } + /** @hidden */ + getZxyAttempt(z, x, y, signal) { + return __async(this, null, function* () { + const tileId = zxyToTileId(z, x, y); + const header = yield this.cache.getHeader(this.source); + if (header.specVersion < 3) { + return v2_default.getZxy(header, this.source, this.cache, z, x, y, signal); + } + if (z < header.minZoom || z > header.maxZoom) { + return void 0; + } + let dO = header.rootDirectoryOffset; + let dL = header.rootDirectoryLength; + for (let depth = 0; depth <= 3; depth++) { + const directory = yield this.cache.getDirectory( + this.source, + dO, + dL, + header + ); + const entry = findTile(directory, tileId); + if (entry) { + if (entry.runLength > 0) { + const resp = yield this.source.getBytes( + header.tileDataOffset + entry.offset, + entry.length, + signal, + header.etag + ); + return { + data: yield this.decompress(resp.data, header.tileCompression), + cacheControl: resp.cacheControl, + expires: resp.expires + }; + } + dO = header.leafDirectoryOffset + entry.offset; + dL = entry.length; + } else { + return void 0; + } + } + throw Error("Maximum directory depth exceeded"); + }); + } + /** + * Primary method to get a single tile's bytes from an archive. + * + * Returns undefined if the tile does not exist in the archive. + */ + getZxy(z, x, y, signal) { + return __async(this, null, function* () { + try { + return yield this.getZxyAttempt(z, x, y, signal); + } catch (e) { + if (e instanceof EtagMismatch) { + this.cache.invalidate(this.source); + return yield this.getZxyAttempt(z, x, y, signal); + } + throw e; + } + }); + } + /** @hidden */ + getMetadataAttempt() { + return __async(this, null, function* () { + const header = yield this.cache.getHeader(this.source); + const resp = yield this.source.getBytes( + header.jsonMetadataOffset, + header.jsonMetadataLength, + void 0, + header.etag + ); + const decompressed = yield this.decompress( + resp.data, + header.internalCompression + ); + const dec = new TextDecoder("utf-8"); + return JSON.parse(dec.decode(decompressed)); + }); + } + /** + * Return the arbitrary JSON metadata of the archive. + */ + getMetadata() { + return __async(this, null, function* () { + try { + return yield this.getMetadataAttempt(); + } catch (e) { + if (e instanceof EtagMismatch) { + this.cache.invalidate(this.source); + return yield this.getMetadataAttempt(); + } + throw e; + } + }); + } + /** + * Construct a [TileJSON](https://github.com/mapbox/tilejson-spec) object. + * + * baseTilesUrl is the desired tiles URL, excluding the suffix `/{z}/{x}/{y}.{ext}`. + * For example, if the desired URL is `http://example.com/tileset/{z}/{x}/{y}.mvt`, + * the baseTilesUrl should be `https://example.com/tileset`. + */ + getTileJson(baseTilesUrl) { + return __async(this, null, function* () { + const header = yield this.getHeader(); + const metadata = yield this.getMetadata(); + const ext = tileTypeExt(header.tileType); + return { + tilejson: "3.0.0", + scheme: "xyz", + tiles: [`${baseTilesUrl}/{z}/{x}/{y}${ext}`], + // biome-ignore lint: TileJSON spec + vector_layers: metadata.vector_layers, + attribution: metadata.attribution, + description: metadata.description, + name: metadata.name, + version: metadata.version, + bounds: [header.minLon, header.minLat, header.maxLon, header.maxLat], + center: [header.centerLon, header.centerLat, header.centerZoom], + minzoom: header.minZoom, + maxzoom: header.maxZoom + }; + }); + } + }; + return __toCommonJS(js_exports); +})(); diff --git a/docs/articles/map-design.html b/docs/articles/map-design.html index 6509facb..9d1a9cfd 100644 --- a/docs/articles/map-design.html +++ b/docs/articles/map-design.html @@ -6,16 +6,15 @@ Fundamentals of map design with mapgl • mapgl - - - - - - + + + + + - - + + @@ -26,7 +25,7 @@ mapgl - 0.1.4 + 0.2.2.9000

@@ -59,16 +62,16 @@ - - - - + + + +
@@ -144,7 +147,7 @@

Continuous styling= c("lightblue", "darkblue") )

- +

Categorical styling @@ -239,7 +242,7 @@

Pop-ups, tooltips, and highlighting colors = c("lightblue", "darkblue") )

- + @@ -252,7 +255,7 @@

Pop-ups, tooltips, and highlighting diff --git a/docs/articles/map-design_files/layers-control-1.0.0/filter-control.css b/docs/articles/map-design_files/layers-control-1.0.0/filter-control.css new file mode 100644 index 00000000..e6096c34 --- /dev/null +++ b/docs/articles/map-design_files/layers-control-1.0.0/filter-control.css @@ -0,0 +1,65 @@ +.filter-control { + background: #fff; + position: absolute; + z-index: 1; + border-radius: 3px; + width: 200px; + border: 1px solid rgba(0, 0, 0, 0.4); + font-family: 'Open Sans', sans-serif; + margin: 10px; + padding: 10px; +} + +.filter-control .filter-title { + font-weight: bold; + margin-bottom: 10px; + text-align: center; +} + +.filter-control input[type="range"] { + width: 100%; + margin: 10px 0; +} + +.filter-control .range-value { + text-align: center; + margin-top: 5px; +} + +.filter-control .checkbox-group { + display: flex; + flex-direction: column; + gap: 5px; +} + +.filter-control .checkbox-group label { + display: flex; + align-items: center; + gap: 5px; +} + +.filter-control .toggle-button { + background: darkgrey; + color: #ffffff; + text-align: center; + cursor: pointer; + padding: 5px 0; + border-radius: 3px 3px 0 0; + margin: -10px -10px 10px -10px; +} + +.filter-control .toggle-button:hover { + background: grey; +} + +.filter-control .filter-content { + display: block; +} + +.filter-control.collapsible .filter-content { + display: none; +} + +.filter-control.collapsible.open .filter-content { + display: block; +} \ No newline at end of file diff --git a/docs/articles/map-design_files/layers-control-1.0.0/layers-control.css b/docs/articles/map-design_files/layers-control-1.0.0/layers-control.css index 07ebdcc1..85512288 100644 --- a/docs/articles/map-design_files/layers-control-1.0.0/layers-control.css +++ b/docs/articles/map-design_files/layers-control-1.0.0/layers-control.css @@ -2,11 +2,14 @@ background: #fff; position: absolute; z-index: 1; - border-radius: 3px; + border-radius: 4px; width: 120px; - border: 1px solid rgba(0, 0, 0, 0.4); - font-family: 'Open Sans', sans-serif; - margin: 10px; + border: 1px solid rgba(0, 0, 0, 0.15); + font-family: "Open Sans", sans-serif; + margin: 0px; + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); + overflow: hidden; + transition: all 0.2s ease-in-out; } .layers-control a { @@ -14,11 +17,12 @@ color: #404040; display: block; margin: 0; - padding: 0; padding: 10px; text-decoration: none; - border-bottom: 1px solid rgba(0, 0, 0, 0.25); + border-bottom: 1px solid rgba(0, 0, 0, 0.1); text-align: center; + transition: all 0.15s ease-in-out; + font-weight: normal; } .layers-control a:last-child { @@ -27,32 +31,35 @@ .layers-control a:hover { background-color: #f8f8f8; - color: #404040; + color: #1a1a1a; } .layers-control a.active { - background-color: darkgrey; + background-color: #4a90e2; color: #ffffff; + font-weight: 500; } .layers-control a.active:hover { - background: grey; + background: #3b7ed2; } .layers-control .toggle-button { display: none; - background: darkgrey; + background: #4a90e2; color: #ffffff; text-align: center; cursor: pointer; - padding: 5px 0; - border-radius: 3px 3px 0 0; - + padding: 8px 0; + border-radius: 4px 4px 0 0; + font-weight: 500; + letter-spacing: 0.3px; + box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05) inset; + transition: all 0.15s ease-in-out; } - .layers-control .toggle-button:hover { - background: grey; + background: #3b7ed2; } .layers-control .layers-list { @@ -66,8 +73,51 @@ .layers-control.collapsible .layers-list { display: none; + opacity: 0; + max-height: 0; + transition: + opacity 0.25s ease, + max-height 0.25s ease; } .layers-control.collapsible.open .layers-list { display: block; + opacity: 1; + max-height: 500px; /* Large enough value to accommodate all content */ +} + +/* Compact icon styling */ +.layers-control.collapsible.icon-only { + width: auto; + min-width: 36px; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); + transform: translateZ( + 0 + ); /* Force hardware acceleration for smoother animations */ +} + +.layers-control.collapsible.icon-only .toggle-button { + border-radius: 4px; + padding: 8px; + width: 36px; + height: 36px; + box-sizing: border-box; + margin: 0; + border-bottom: none; + display: flex; + align-items: center; + justify-content: center; + box-shadow: none; +} + +.layers-control.collapsible.icon-only.open { + width: 120px; + box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25); +} + +.layers-control.collapsible.icon-only.open .toggle-button { + border-radius: 4px 4px 0 0; + border-bottom: 1px solid rgba(0, 0, 0, 0.1); + width: 100%; } diff --git a/docs/articles/map-design_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js b/docs/articles/map-design_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js new file mode 100644 index 00000000..510cfcca --- /dev/null +++ b/docs/articles/map-design_files/mapboxgl-binding-0.1.4.9000/mapboxgl.js @@ -0,0 +1,1897 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/map-design_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js b/docs/articles/map-design_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js new file mode 100644 index 00000000..1a2fb15e --- /dev/null +++ b/docs/articles/map-design_files/mapboxgl-binding-0.2.0.9000/mapboxgl.js @@ -0,0 +1,2102 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/map-design_files/mapboxgl-binding-0.2.0/mapboxgl.js b/docs/articles/map-design_files/mapboxgl-binding-0.2.0/mapboxgl.js new file mode 100644 index 00000000..510cfcca --- /dev/null +++ b/docs/articles/map-design_files/mapboxgl-binding-0.2.0/mapboxgl.js @@ -0,0 +1,1897 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[ + x.layers_control.position || "top-right" + ] = "10px"; + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + layersControl.style[message.position || "top-right"] = "10px"; + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/map-design_files/mapboxgl-binding-0.2.1/mapboxgl.js b/docs/articles/map-design_files/mapboxgl-binding-0.2.1/mapboxgl.js new file mode 100644 index 00000000..1a2fb15e --- /dev/null +++ b/docs/articles/map-design_files/mapboxgl-binding-0.2.1/mapboxgl.js @@ -0,0 +1,2102 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + map.on("click", message.layer.id, function (e) { + const description = + e.features[0].properties[message.layer.popup]; + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + if (map.getLayer(message.layer)) { + // Check if we have stored handlers for this layer + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + } + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/map-design_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js b/docs/articles/map-design_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js new file mode 100644 index 00000000..fc5462ee --- /dev/null +++ b/docs/articles/map-design_files/mapboxgl-binding-0.2.2.9000/mapboxgl.js @@ -0,0 +1,2684 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case 'get': + return properties[expression[1]]; + case 'concat': + return expression.slice(1).map(item => evaluateExpression(item, properties)).join(''); + case 'to-string': + return String(evaluateExpression(expression[1], properties)); + case 'to-number': + return Number(evaluateExpression(expression[1], properties)); + case 'number-format': + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || 'en-US'; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty('min-fraction-digits')) { + formatOptions.minimumFractionDigits = options['min-fraction-digits']; + } + if (options.hasOwnProperty('max-fraction-digits')) { + formatOptions.maximumFractionDigits = options['max-fraction-digits']; + } + if (options.hasOwnProperty('min-integer-digits')) { + formatOptions.minimumIntegerDigits = options['min-integer-digits']; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty('useGrouping')) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(tooltipProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + window._mapboxPopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layerId] === popup) { + delete window._mapboxPopups[layerId]; + } + }); +} + +// Helper function to generate draw styles based on parameters +function generateDrawStyles(styling) { + if (!styling) return null; + + return [ + // Point styles + { + 'id': 'gl-draw-point-active', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'true']], + 'paint': { + 'circle-radius': styling.vertex_radius + 2, + 'circle-color': styling.active_color + } + }, + { + 'id': 'gl-draw-point', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'false']], + 'paint': { + 'circle-radius': styling.vertex_radius, + 'circle-color': styling.point_color + } + }, + // Line styles + { + 'id': 'gl-draw-line', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'LineString']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Polygon fill + { + 'id': 'gl-draw-polygon-fill', + 'type': 'fill', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'paint': { + 'fill-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-outline-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-opacity': styling.fill_opacity + } + }, + // Polygon outline + { + 'id': 'gl-draw-polygon-stroke', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Midpoints + { + 'id': 'gl-draw-polygon-midpoint', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'midpoint']], + 'paint': { + 'circle-radius': 3, + 'circle-color': styling.active_color + } + }, + // Vertex point halos + { + 'id': 'gl-draw-vertex-halo-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 4, + styling.vertex_radius + 2 + ], + 'circle-color': '#FFF' + } + }, + // Vertex points + { + 'id': 'gl-draw-vertex-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 2, + styling.vertex_radius + ], + 'circle-color': styling.active_color + } + } + ]; +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, layer.popup, layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + // Set rain effect if provided + if (x.rain) { + map.setRain(x.rain); + } + + // Set snow effect if provided + if (x.snow) { + map.setSnow(x.snow); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + // Generate styles if styling parameters provided + if (x.draw_control.styling) { + const generatedStyles = generateDrawStyles(x.draw_control.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (x.draw_control.source) { + addSourceFeaturesToDraw(draw, x.draw_control.source, map); + } + + // Process any queued features + if (x.draw_features_queue) { + x.draw_features_queue.forEach(function(data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn('Source not found or has no data:', sourceId); + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + // Initialize with empty object, will be populated after map loads + let initialView = {}; + + // Capture the initial view after the map has loaded and all view operations are complete + map.once('load', function() { + initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + }); + + resetControl.onclick = function () { + // Only reset if we have captured the initial view + if (initialView.center) { + map.easeTo(initialView); + } + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDraw: function () { + return draw; // Return the draw instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + + // Helper function to update drawn features + function updateDrawnFeatures() { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + var drawnFeatures = drawControl.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(drawnFeatures) + ); + } + // Store drawn features in the widget's data + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, message.layer.popup, message.layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + if (window._mapboxPopups && window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer] + ) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll('style[data-mapgl-legend-css]'); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + // Identify user-added sources (those not in the original style) + // We'll assume any source that's not "composite", "mapbox", or starts with "mapbox-" is user-added + for (const sourceId in currentStyle.sources) { + if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") + ) { + userSourceIds.push(sourceId); + const source = currentStyle.sources[sourceId]; + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + } + + // Identify layers using user-added sources + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source)) { + userLayers.push(layer); + } + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + }); + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + // Create the draw control + var drawControl = new MapboxDraw(drawOptions); + map.addControl(drawControl, message.position); + map.controls.push(drawControl); + + // Store the draw control on the widget for later access + widget.drawControl = drawControl; + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(drawControl, message.source, map); + } + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + const features = drawControl.getAll(); + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + drawControl.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_features_to_draw") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + if (message.data.clear_existing) { + drawControl.deleteAll(); + } + addSourceFeaturesToDraw(drawControl, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn('Draw control not initialized'); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + // Remove all legend elements + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + + // Clean up any legend styles associated with this map + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => { + style.remove(); + }); + } + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_popup") { + const layerId = message.layer; + const newPopupProperty = message.popup; + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + delete window._mapboxPopups[layerId]; + } + + // Remove old click handler if any + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + delete window._mapboxClickHandlers[layerId]; + } + + // Remove old hover handlers for cursor change + map.off("mouseenter", layerId); + map.off("mouseleave", layerId); + + // Create new click handler + const clickHandler = function (e) { + onClickPopup(e, map, newPopupProperty, layerId); + }; + + // Add the new event handler + map.on("click", layerId, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_rain") { + if (message.rain) { + map.setRain(message.rain); + } else { + map.setRain(null); + } + } else if (message.type === "set_snow") { + if (message.snow) { + map.setSnow(message.snow); + } else { + map.setSnow(null); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/map-design_files/mapboxgl-binding-0.2.2/mapboxgl.js b/docs/articles/map-design_files/mapboxgl-binding-0.2.2/mapboxgl.js new file mode 100644 index 00000000..faedbb1b --- /dev/null +++ b/docs/articles/map-design_files/mapboxgl-binding-0.2.2/mapboxgl.js @@ -0,0 +1,2367 @@ +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +HTMLWidgets.widget({ + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + map.addSource(source.id, { + type: "vector", + url: source.url, + }); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; + + // Add additional options + for (const [key, value] of Object.entries( + source, + )) { + if ( + ![ + "id", + "type", + "data", + "generateId", + ].includes(key) + ) { + sourceOptions[key] = value; + } + } + + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[ + layer.popup + ]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[layer.id]) { + window._mapboxPopups[layer.id].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layer.id] === popup) { + delete window._mapboxPopups[layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; + + // Add the click handler + map.on("click", layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + layer.id, + key, + ) || layer.paint[key]; + map.setPaintProperty( + layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer: ", + layer, + e, + ); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + // Set rain effect if provided + if (x.rain) { + map.setRain(x.rain); + } + + // Set snow effect if provided + if (x.snow) { + map.setSnow(x.snow); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap( + globeMinimapOptions, + ); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = + el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = + x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: + x.geolocate_control.positionOptions, + trackUserLocation: + x.geolocate_control.trackUserLocation, + showAccuracyCircle: + x.geolocate_control.showAccuracyCircle, + showUserLocation: + x.geolocate_control.showUserLocation, + showUserHeading: + x.geolocate_control.showUserHeading, + fitBoundsOptions: + x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue( + el.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: + x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: x.center, + zoom: x.zoom, + pitch: x.pitch, + bearing: x.bearing, + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage( + imageInfo.url, + function (error, image) { + if (error) { + console.error( + "Error loading image:", + error, + ); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }, + ); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures( + e.point, + { + layers: [layer.id], + }, + ); + const clusterId = + features[0].properties.cluster_id; + map.getSource( + layer.source, + ).getClusterExpansionZoom( + clusterId, + (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry + .coordinates, + zoom: zoom, + }); + }, + ); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_click", + null, + ); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, +}); + +if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + map.addSource(message.source.id, { + type: "vector", + url: message.source.url, + }); + } else if (message.source.type === "geojson") { + map.addSource(message.source.id, { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }); + } else if (message.source.type === "raster") { + if (message.source.url) { + map.addSource(message.source.id, { + type: "raster", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.tiles) { + map.addSource(message.source.id, { + type: "raster", + tiles: message.source.tiles, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } + } else if (message.source.type === "raster-dem") { + map.addSource(message.source.id, { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + maxzoom: message.source.maxzoom, + }); + } else if (message.source.type === "image") { + map.addSource(message.source.id, { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }); + } else if (message.source.type === "video") { + map.addSource(message.source.id, { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + const description = + e.features[0].properties[message.layer.popup]; + + // Remove any existing popup for this layer + if (window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + window._mapboxPopups[message.layer.id] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[message.layer.id] === popup) { + delete window._mapboxPopups[message.layer.id]; + } + }); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + if (window._mapboxPopups && window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer] + ) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll('style[data-mapgl-legend-css]'); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + // Identify user-added sources (those not in the original style) + // We'll assume any source that's not "composite", "mapbox", or starts with "mapbox-" is user-added + for (const sourceId in currentStyle.sources) { + if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") + ) { + userSourceIds.push(sourceId); + const source = currentStyle.sources[sourceId]; + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + } + + // Identify layers using user-added sources + currentStyle.layers.forEach(function(layer) { + if (userSourceIds.includes(layer.source)) { + userLayers.push(layer); + } + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + }); + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + } + + // Change the style + map.setStyle(message.style, { diff: message.diff }); + + if (message.config) { + Object.keys(message.config).forEach(function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }); + } + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if ( + map.controls && + map.controls.some( + (control) => control instanceof MapboxDraw, + ) + ) { + const drawControl = map.controls.find( + (control) => control instanceof MapboxDraw, + ); + const features = drawControl ? drawControl.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML( + marker.popup, + ), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error( + `Cannot find map container with ID ${data.id}`, + ); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + } else { + // Remove all legend elements + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + + // Clean up any legend styles associated with this map + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => { + style.remove(); + }); + } + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image, + imageInfo.options, + ); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(message.imageId)) { + map.addImage( + message.imageId, + image, + message.options, + ); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_rain") { + if (message.rain) { + map.setRain(message.rain); + } else { + map.setRain(null); + } + } else if (message.type === "set_snow") { + if (message.snow) { + map.setSnow(message.snow); + } else { + map.setSnow(null); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); +} diff --git a/docs/articles/shiny.html b/docs/articles/shiny.html index 653d473f..e34fc5f7 100644 --- a/docs/articles/shiny.html +++ b/docs/articles/shiny.html @@ -6,16 +6,15 @@ Using mapgl with Shiny • mapgl - - - - - - + + + + + - - + + @@ -26,7 +25,7 @@ mapgl - 0.1.4 + 0.2.2.9000 @@ -65,7 +68,7 @@

Using mapgl with Shiny

- + Source: vignettes/shiny.Rmd
shiny.Rmd
@@ -88,7 +91,7 @@ library(mapgl) library(sf) -nc <- st_read(system.file("shape/nc.shp", package="sf")) +nc <- st_read(system.file("shape/nc.shp", package="sf")) ui <- page_sidebar( title = "mapgl with Shiny", @@ -242,6 +245,22 @@

Shiny-specific functions shinyApp(ui, server)

+ +
+

Comparison maps in Shiny +

+

Because of the way that side-by-side maps generated with the +compare() function work in mapgl, +comparison maps require their own rendering functions. For Mapbox maps, +you can use mapboxglCompareOutput(), +renderMapboxglCompare(); and +mapboxgl_compare_proxy(); for MapLibre, use +maplibreCompareOutput(); +renderMaplibreCompare(); and +maplibre_compare_proxy(). For compare proxies, you can +target the side of the map you want to modify with the argument +map_side = "before" (left or top) or +map_side = "after" (right or bottom).

@@ -254,7 +273,7 @@

Shiny-specific functions diff --git a/docs/articles/story-maps.html b/docs/articles/story-maps.html new file mode 100644 index 00000000..30b0066e --- /dev/null +++ b/docs/articles/story-maps.html @@ -0,0 +1,549 @@ + + + + + + + +Building story maps with mapgl • mapgl + + + + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + +

Story maps are effective tools for communicating map-based +narratives. In a story map, users typically scroll through a web page in +which different map views and elements of the “story” are shown as the +user scrolls down. The mapgl package brings story maps +in Shiny to R users, and supports both Mapbox and MapLibre backends as +well as Leaflet.

+

This tutorial will help you learn how to build a basic story map +Shiny app with mapgl. You’ll rely on the following three functions when +building your story:

+
    +
  • story_map() sets up the user interface component for +your story map. You’ll wrap this in a Shiny layout function; it is +recommended to use fluidPage() (or +bslib::page_fluid()) which will get you a standard +full-screen story map template. story_map() defaults to +Mapbox maps; you can use story_maplibre() for MapLibre +maps, and story_leaflet() for Leaflet.

  • +
  • Within story_map(), you’ll define a named list of +sections to be passed to the sections parameter. You’ll use +the story_section() function to build each section. In +story_section(), you’ll specify a title (set +to NULL or "" to omit it) as well as content, +which will be a list of UI elements you want to put in your section +panel. This can be HTML elements (defined with tags$p(), +tags$a(), tags$img(), etc.) as well as Shiny +inputs or outputs.

  • +
  • Within your server function, you’ll then use the +on_section() function to bring your story map to life. +on_section() allows you to link Shiny events to specific +story sections. This means that you can trigger map movements, add data, +or even perform analyses on user scroll.

  • +
+
+

Moving the map on scroll +

+

Let’s take a look at how this works with a basic example. We’ll build +a story map with two sections: an introductory section, and a second +section where the map “flies to” a location when the user scrolls.

+

To get started, let’s build a basic user interface without any map +actions. In ui, we set up story_map() inside a +fluid page with two sections. In server, we’ll create a +Mapbox globe with mapboxgl() and +renderMapboxgl(). In most cases you’ll want to set the +option scrollZoom = FALSE when you initialize your map so +map scrolling behavior doesn’t interfere with story scrolling.

+
+library(shiny)
+library(mapgl)
+
+ui <- fluidPage(
+  story_map(
+    map_id = "map",
+    sections = list(
+      "intro" = story_section(
+        "Introduction",
+        "This is a story map."
+      ),
+      "location" = story_section(
+        "Location",
+        "Check out this interesting location."
+      )
+    )
+  )
+)
+
+server <- function(input, output, session) {
+  output$map <- renderMapboxgl({
+    mapboxgl(scrollZoom = FALSE)
+  })
+}
+
+shinyApp(ui, server)
+

+

You’ll note that scrolling will transition between story sections, +and that you can still interact with the map by clicking and panning. +However, because we haven’t set up any actions in server, +nothing else happens when you scroll between sections.

+

We can change this by using the on_section() function. +In on_section(), you’ll specify the map ID (in this case, +"map") and the section ID to link to an action; the section +ID is the name of the corresponding list element defined in the list +passed to sections in the UI. You’ll then define an +expression, much like you would in observeEvent() in Shiny, +to be executed when a given section appears.

+
+library(shiny)
+library(mapgl)
+
+ui <- fluidPage(
+  story_map(
+    map_id = "map",
+    sections = list(
+      "intro" = story_section(
+        "Introduction",
+        "This is a story map."
+      ),
+      "location" = story_section(
+        "Location",
+        "Check out this interesting location."
+      )
+    )
+  )
+)
+
+server <- function(input, output, session) {
+  output$map <- renderMapboxgl({
+    mapboxgl(scrollZoom = FALSE)
+  })
+  
+  on_section("map", "location", {
+    mapboxgl_proxy("map") |> 
+      fly_to(center = c(12.49257, 41.890233), 
+             zoom = 17.5,
+             pitch = 49,
+             bearing = 12.8)
+  })
+  
+}
+
+shinyApp(ui, server)
+

+

The map zooms into the Colosseum in Rome on user scroll. If you +scroll back up to the top, however, you’ll notice that the view does not +return to the original globe. This can be remedied by tying an +on_section() event to the introductory section.

+
+library(shiny)
+library(mapgl)
+
+ui <- fluidPage(
+  story_map(
+    map_id = "map",
+    sections = list(
+      "intro" = story_section(
+        "Introduction",
+        "This is a story map."
+      ),
+      "location" = story_section(
+        "Location",
+        "Check out this interesting location."
+      )
+    )
+  )
+)
+
+server <- function(input, output, session) {
+  output$map <- renderMapboxgl({
+    mapboxgl(scrollZoom = FALSE)
+  })
+  
+  on_section("map", "intro", {
+    mapboxgl_proxy("map") |> 
+      fly_to(center = c(0, 0),
+             zoom = 0,
+             pitch = 0,
+             bearing = 0)
+  })
+  
+  on_section("map", "location", {
+    mapboxgl_proxy("map") |> 
+      fly_to(center = c(12.49257, 41.890233), 
+             zoom = 17.5,
+             pitch = 49,
+             bearing = 12.8)
+  })
+  
+}
+
+shinyApp(ui, server)
+

+

For map transitions, in addition to fly_to(), you might +consider using ease_to() and jump_to() +depending on your use case. Map transition functions support camera +options and animation +options as keyword arguments when applicable.

+
+
+

Adding data and modifying story appearance +

+

In many cases, you’ll want to use story maps to visualize data that +you’ll add to a Mapbox / MapLibre basemap. Let’s build an example of how +a real estate firm might use a story map to market a property.

+
+library(shiny)
+library(mapgl)
+library(mapboxapi)
+
+property <- c(-97.71326, 30.402550)
+isochrone <- mb_isochrone(property, profile = "driving", time = 20)
+
+ui <- fluidPage(
+  tags$link(href = "https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap", rel="stylesheet"),
+  story_map(
+    map_id = "map",
+    font_family = "Poppins",
+    sections = list(
+      "intro" = story_section(
+        title = "MULTIFAMILY INVESTMENT OPPORTUNITY",
+        content = list(
+          p("New Class A Apartments in Austin, Texas"),
+          img(src = "apartment.png", width = "300px")
+        ),
+        position = "center"
+      ),
+      "marker" = story_section(
+        title = "PROPERTY LOCATION",
+        content = list(
+          p("The property will be located in the thriving Domain district of north Austin, home to some of the city's best shopping, dining, and entertainment.")
+        )
+      ),
+      "isochrone" = story_section(
+        title = "AUSTIN AT YOUR FINGERTIPS",
+        content = list(
+          p("The property is within a 20-minute drive of downtown Austin, the University of Texas, and the city's major employers.")
+        )
+      )
+    )
+  )
+)
+
+server <- function(input, output, session) {
+  output$map <- renderMapboxgl({
+    mapboxgl(scrollZoom = FALSE,
+             center = c(-97.7301093, 30.288647),
+             zoom = 12)
+  })
+
+  on_section("map", "intro", {
+    mapboxgl_proxy("map") |>
+      clear_markers() |>
+      fly_to(center = c(-97.7301093, 30.288647),
+             zoom = 12,
+             pitch = 0,
+             bearing = 0)
+
+  })
+
+  on_section("map", "marker", {
+    mapboxgl_proxy("map") |>
+      clear_layer("isochrone") |>
+      add_markers(data = property, color = "#CC5500") |>
+      fly_to(center = property,
+             zoom = 16,
+             pitch = 45,
+             bearing = -90)
+  })
+
+  on_section("map", "isochrone", {
+    mapboxgl_proxy("map") |>
+      add_fill_layer(
+        id = "isochrone",
+        source = isochrone,
+        fill_color = "#CC5500",
+        fill_opacity = 0.5
+      ) |>
+      fit_bounds(
+        isochrone,
+        animate = TRUE,
+        duration = 8000,
+        pitch = 75
+      )
+  })
+
+}
+
+shinyApp(ui, server)
+

+

Let’s break down some key elements of this story map.

+
    +
  • We’re loading a Google font, “Poppins”, into our Shiny app with +tags$link(). This allows us to use Poppins as our font +globally in story_map() by passing it as an argument to +font_family. The appearance of panels can also be modified +section-by-section if you prefer.

  • +
  • In each story section panel, we are passing a list of HTML items +to content. The introductory section shows how to include a +local image (which should be in a www folder local to your +app); you can also reference remotely-hosted images or include all other +HTML elements supported by Shiny. Also note the +position = "center" argument to position the introductory +panel in the center of the screen; "left" is the default, +and "right" is also supported without the need for +additional CSS customization.

  • +
  • As in the first example, all of our story actions defined in +calls to on_section() operate on the Mapbox GL proxy +object, "map". In this example, we use +add_markers() to add a marker at a location, and +add_fill_layer() to add a 20-minute drivetime isochrone +created with the Mapbox API. Transitions between the views are handled +with fly_to() and fit_bounds(), and +clear_layer() and clear_markers() calls are +used to control which data layers are visible as the user goes forward +and backward through the story.

  • +
+
+
+

Integrating Shiny inputs and outputs +

+

While the story map feature in mapgl is built in a +unique way to accommodate map-based scrollytelling, it is still creating +an R Shiny app. This means that all of Shiny’s functionality and +interactivity is available to you as you build your story maps. The list +of items you pass to content in any given story section +panel can include both Shiny inputs as well as Shiny +outputs which can correspond to the content visible on your +story maps.

+

Let’s set up a scenario that adds interactivity to the data displayed +in the Fundamentals +of map design with mapgl vignette. We’ll make a map of median age in +Florida, which will display with the introductory story panel. The user +selects a county to display; on scroll, the story will then zoom to the +selected county and show a histogram of values for Census tracts in that +county.

+
+library(shiny)
+library(mapgl)
+library(tidycensus)
+library(tidyverse)
+library(sf)
+
+fl_age <- get_acs(
+  geography = "tract",
+  variables = "B01002_001",
+  state = "FL",
+  year = 2023,
+  geometry = TRUE
+) |>
+  separate_wider_delim(NAME, delim = "; ", names = c("tract", "county", "state")) %>%
+  st_sf()
+
+ui <- fluidPage(
+  story_maplibre(
+    map_id = "map",
+    sections = list(
+      "intro" = story_section(
+        "Median Age in Florida",
+        content = list(
+          selectInput(
+            "county",
+            "Select a county",
+            choices = sort(unique(fl_age$county))
+          ),
+          p("Scroll down to view the median age distribution in the selected county.")
+        )
+      ),
+      "county" = story_section(
+        title = NULL,
+        content = list(
+          uiOutput("county_text"),
+          plotOutput("county_plot")
+        )
+      )
+    )
+  )
+)
+
+server <- function(input, output, session) {
+
+  sel_county <- reactive({
+    filter(fl_age, county == input$county)
+  })
+
+  output$map <- renderMaplibre({
+    maplibre(
+      carto_style("positron"),
+      bounds = fl_age,
+      scrollZoom = FALSE
+    ) |>
+      add_fill_layer(
+        id = "fl_tracts",
+        source = fl_age,
+        fill_color = interpolate(
+          column = "estimate",
+          values = c(20, 80),
+          stops = c("lightblue", "darkblue"),
+          na_color = "lightgrey"
+        ),
+        fill_opacity = 0.5
+      ) |>
+      add_legend(
+        "Median age in Florida",
+        values = c(20, 80),
+        colors = c("lightblue", "darkblue"),
+        position = "bottom-right"
+      )
+  })
+
+  output$county_text <- renderUI({
+    h2(toupper(input$county))
+  })
+
+  output$county_plot <- renderPlot({
+    ggplot(sel_county(), aes(x = estimate)) +
+      geom_histogram(fill = "lightblue", color = "black", bins = 10) +
+      theme_minimal() +
+      labs(x = "Median Age", y = "")
+  })
+
+  on_section("map", "intro", {
+    maplibre_proxy("map") |>
+      set_filter("fl_tracts", NULL) |>
+      fit_bounds(fl_age, animate = TRUE)
+  })
+
+  on_section("map", "county", {
+    maplibre_proxy("map") |>
+      set_filter("fl_tracts", filter = list("==", "county", input$county)) |>
+      fit_bounds(sel_county(), animate = TRUE)
+  })
+
+}
+
+shinyApp(ui, server)
+

+

Let’s walk through how this works.

+
    +
  • The UI code will be familiar, though we are now using the +MapLibre backend with story_maplibre(). The main difference +is our inclusion of a Shiny selectInput() in the first +story panel and two Shiny outputs in the second story panel. As we’ve +set it up, users can select a county at the beginning of the story, and +then get a different output when they scroll down.

  • +
  • A reactive object sel_county() will be used to get +county-specific values for the second story panel, and will help us +determine the map’s extent as we want to zoom to the selected +county.

  • +
  • That said, we don’t use sel_county() directly on the +map. Instead, we use mapgl’s set_filter() function, which +is more performant than filtering data by clearing a layer and re-adding +it. This allows us to invoke the underlying setFilter() +JavaScript method (see +here for more documentation) and operate directly on the map layer +itself. Setting the filter to NULL clears the filter and +gives us back the entire state of Florida.

  • +
  • We note that the content of the second panel is entirely Shiny +outputs: an h2 header that corresponds to the selected county, and a +histogram of median age values for Census tracts in that county drawn +with ggplot2.

  • +
+
+
+

Sharing your stories / next steps +

+

As your story map is a Shiny app, you’ll need to publish it to a +Shiny server to share it. Posit’s ShinyApps.io and Connect Cloud products are nice +options if you don’t want to set up your own Shiny server.

+

If you are building story maps with mapgl, please let me know about +it! I’m also planning some trainings / workshops on this feature, so +please do reach out if you are interested.

+
+
+
+ + + + +
+ + + + + + + diff --git a/docs/authors.html b/docs/authors.html index 5a076fbd..4ed393c0 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,5 +1,5 @@ -Authors and Citation • mapgl +Authors and Citation • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -47,17 +50,17 @@

Authors

Citation

-

+

Source: DESCRIPTION

-

Walker K (2024). +

Walker K (2025). mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS'. -R package version 0.1.4, https://walker-data.com/mapgl/. +R package version 0.2.2.9000, https://walker-data.com/mapgl/.

@Manual{,
   title = {mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS'},
   author = {Kyle Walker},
-  year = {2024},
-  note = {R package version 0.1.4},
+  year = {2025},
+  note = {R package version 0.2.2.9000},
   url = {https://walker-data.com/mapgl/},
 }
@@ -71,7 +74,7 @@

Citation

diff --git a/docs/deps/bootstrap-5.3.1/bootstrap.min.css b/docs/deps/bootstrap-5.3.1/bootstrap.min.css index 74ede34f..ba616f24 100644 --- a/docs/deps/bootstrap-5.3.1/bootstrap.min.css +++ b/docs/deps/bootstrap-5.3.1/bootstrap.min.css @@ -2,4 +2,4 @@ * Bootstrap v5.3.1 (https://getbootstrap.com/) * Copyright 2011-2023 The Bootstrap Authors * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - */:root,[data-bs-theme="light"]{--bs-blue: #3459e6;--bs-indigo: #6610f2;--bs-purple: #6f42c1;--bs-pink: #d63384;--bs-red: #da292e;--bs-orange: #f8765f;--bs-yellow: #f4bd61;--bs-green: #2fb380;--bs-teal: #20c997;--bs-cyan: #287bb5;--bs-black: #000;--bs-white: #fff;--bs-gray: #6c757d;--bs-gray-dark: #343a40;--bs-gray-100: #f8f9fa;--bs-gray-200: #e9ecef;--bs-gray-300: #dee2e6;--bs-gray-400: #ced4da;--bs-gray-500: #adb5bd;--bs-gray-600: #6c757d;--bs-gray-700: #495057;--bs-gray-800: #343a40;--bs-gray-900: #212529;--bs-default: #fff;--bs-primary: #3459e6;--bs-secondary: #fff;--bs-success: #2fb380;--bs-info: #287bb5;--bs-warning: #f4bd61;--bs-danger: #da292e;--bs-light: #f8f9fa;--bs-dark: #212529;--bs-default-rgb: 255,255,255;--bs-primary-rgb: 52,89,230;--bs-secondary-rgb: 255,255,255;--bs-success-rgb: 47,179,128;--bs-info-rgb: 40,123,181;--bs-warning-rgb: 244,189,97;--bs-danger-rgb: 218,41,46;--bs-light-rgb: 248,249,250;--bs-dark-rgb: 33,37,41;--bs-primary-text-emphasis: #15245c;--bs-secondary-text-emphasis: #666;--bs-success-text-emphasis: #134833;--bs-info-text-emphasis: #103148;--bs-warning-text-emphasis: #624c27;--bs-danger-text-emphasis: #571012;--bs-light-text-emphasis: #495057;--bs-dark-text-emphasis: #495057;--bs-primary-bg-subtle: #d6defa;--bs-secondary-bg-subtle: #fff;--bs-success-bg-subtle: #d5f0e6;--bs-info-bg-subtle: #d4e5f0;--bs-warning-bg-subtle: #fdf2df;--bs-danger-bg-subtle: #f8d4d5;--bs-light-bg-subtle: #fcfcfd;--bs-dark-bg-subtle: #ced4da;--bs-primary-border-subtle: #aebdf5;--bs-secondary-border-subtle: #fff;--bs-success-border-subtle: #ace1cc;--bs-info-border-subtle: #a9cae1;--bs-warning-border-subtle: #fbe5c0;--bs-danger-border-subtle: #f0a9ab;--bs-light-border-subtle: #e9ecef;--bs-dark-border-subtle: #adb5bd;--bs-white-rgb: 255,255,255;--bs-black-rgb: 0,0,0;--bs-font-sans-serif: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--bs-gradient: linear-gradient(180deg, rgba(255,255,255,0.15), rgba(255,255,255,0));--bs-body-font-family: var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight: 400;--bs-body-line-height: 1.5;--bs-body-color: #495057;--bs-body-color-rgb: 73,80,87;--bs-body-bg: #fff;--bs-body-bg-rgb: 255,255,255;--bs-emphasis-color: #000;--bs-emphasis-color-rgb: 0,0,0;--bs-secondary-color: rgba(73,80,87,0.75);--bs-secondary-color-rgb: 73,80,87;--bs-secondary-bg: #e9ecef;--bs-secondary-bg-rgb: 233,236,239;--bs-tertiary-color: rgba(73,80,87,0.5);--bs-tertiary-color-rgb: 73,80,87;--bs-tertiary-bg: #f8f9fa;--bs-tertiary-bg-rgb: 248,249,250;--bs-heading-color: #212529;--bs-link-color: #3459e6;--bs-link-color-rgb: 52,89,230;--bs-link-decoration: underline;--bs-link-hover-color: #2a47b8;--bs-link-hover-color-rgb: 42,71,184;--bs-code-color: RGB(var(--bs-emphasis-color-rgb, 0, 0, 0));--bs-highlight-bg: #fdf2df;--bs-border-width: 1px;--bs-border-style: solid;--bs-border-color: #dee2e6;--bs-border-color-translucent: rgba(0,0,0,0.175);--bs-border-radius: .375rem;--bs-border-radius-sm: .25rem;--bs-border-radius-lg: .5rem;--bs-border-radius-xl: 1rem;--bs-border-radius-xxl: 2rem;--bs-border-radius-2xl: var(--bs-border-radius-xxl);--bs-border-radius-pill: 50rem;--bs-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-box-shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,0.075);--bs-box-shadow-lg: 0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06);--bs-box-shadow-inset: inset 0 1px 2px rgba(0,0,0,0.075);--bs-focus-ring-width: .25rem;--bs-focus-ring-opacity: .25;--bs-focus-ring-color: rgba(52,89,230,0.25);--bs-form-valid-color: #2fb380;--bs-form-valid-border-color: #2fb380;--bs-form-invalid-color: #da292e;--bs-form-invalid-border-color: #da292e}[data-bs-theme="dark"]{color-scheme:dark;--bs-body-color: #dee2e6;--bs-body-color-rgb: 222,226,230;--bs-body-bg: #212529;--bs-body-bg-rgb: 33,37,41;--bs-emphasis-color: #fff;--bs-emphasis-color-rgb: 255,255,255;--bs-secondary-color: rgba(222,226,230,0.75);--bs-secondary-color-rgb: 222,226,230;--bs-secondary-bg: #343a40;--bs-secondary-bg-rgb: 52,58,64;--bs-tertiary-color: rgba(222,226,230,0.5);--bs-tertiary-color-rgb: 222,226,230;--bs-tertiary-bg: #2b3035;--bs-tertiary-bg-rgb: 43,48,53;--bs-primary-text-emphasis: #859bf0;--bs-secondary-text-emphasis: #fff;--bs-success-text-emphasis: #82d1b3;--bs-info-text-emphasis: #7eb0d3;--bs-warning-text-emphasis: #f8d7a0;--bs-danger-text-emphasis: #e97f82;--bs-light-text-emphasis: #f8f9fa;--bs-dark-text-emphasis: #dee2e6;--bs-primary-bg-subtle: #0a122e;--bs-secondary-bg-subtle: #333;--bs-success-bg-subtle: #09241a;--bs-info-bg-subtle: #081924;--bs-warning-bg-subtle: #312613;--bs-danger-bg-subtle: #2c0809;--bs-light-bg-subtle: #343a40;--bs-dark-bg-subtle: #1a1d20;--bs-primary-border-subtle: #1f358a;--bs-secondary-border-subtle: #999;--bs-success-border-subtle: #1c6b4d;--bs-info-border-subtle: #184a6d;--bs-warning-border-subtle: #92713a;--bs-danger-border-subtle: #83191c;--bs-light-border-subtle: #495057;--bs-dark-border-subtle: #343a40;--bs-heading-color: inherit;--bs-link-color: #859bf0;--bs-link-hover-color: #9daff3;--bs-link-color-rgb: 133,155,240;--bs-link-hover-color-rgb: 157,175,243;--bs-code-color: RGB(var(--bs-emphasis-color-rgb, 0, 0, 0));--bs-border-color: #495057;--bs-border-color-translucent: rgba(255,255,255,0.15);--bs-form-valid-color: #82d1b3;--bs-form-valid-border-color: #82d1b3;--bs-form-invalid-color: #e97f82;--bs-form-invalid-border-color: #e97f82}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion: no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0)}hr{margin:1rem 0;color:inherit;border:0;border-top:var(--bs-border-width) solid;opacity:.25}h6,.h6,h5,.h5,h4,.h4,h3,.h3,h2,.h2,h1,.h1{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2;color:var(--bs-heading-color)}h1,.h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width: 1200px){h1,.h1{font-size:2.5rem}}h2,.h2{font-size:calc(1.325rem + .9vw)}@media (min-width: 1200px){h2,.h2{font-size:2rem}}h3,.h3{font-size:calc(1.3rem + .6vw)}@media (min-width: 1200px){h3,.h3{font-size:1.75rem}}h4,.h4{font-size:calc(1.275rem + .3vw)}@media (min-width: 1200px){h4,.h4{font-size:1.5rem}}h5,.h5{font-size:1.25rem}h6,.h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[title]{text-decoration:underline dotted;-webkit-text-decoration:underline dotted;-moz-text-decoration:underline dotted;-ms-text-decoration:underline dotted;-o-text-decoration:underline dotted;cursor:help;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}ol,ul,dl{margin-top:0;margin-bottom:1rem}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem;padding:.625rem 1.25rem;border-left:.25rem solid #e9ecef}blockquote p:last-child,blockquote ul:last-child,blockquote ol:last-child{margin-bottom:0}b,strong{font-weight:bolder}small,.small{font-size:.875em}mark,.mark{padding:.1875em;background-color:var(--bs-highlight-bg)}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 1));text-decoration:underline;-webkit-text-decoration:underline;-moz-text-decoration:underline;-ms-text-decoration:underline;-o-text-decoration:underline}a:hover{--bs-link-color-rgb: var(--bs-link-hover-color-rgb)}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}pre,code,kbd,samp{font-family:var(--bs-font-monospace);font-size:1em}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em;color:RGB(var(--bs-emphasis-color-rgb, 0, 0, 0));background-color:RGBA(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.04);padding:.5rem;border:1px solid var(--bs-border-color, #dee2e6);border-radius:.375rem}pre code{background-color:transparent;font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:var(--bs-code-color);background-color:RGBA(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.04);border-radius:.375rem;padding:.125rem .25rem;word-wrap:break-word}a>code{color:inherit}kbd{padding:.1875rem .375rem;font-size:.875em;color:var(--bs-body-bg);background-color:var(--bs-body-color);border-radius:.25rem}kbd kbd{padding:0;font-size:1em}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:1rem;padding-bottom:1rem;color:var(--bs-secondary-color);text-align:left}th{font-weight:500;text-align:inherit;text-align:-webkit-match-parent}thead,tbody,tfoot,tr,td,th{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}input,button,select,optgroup,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role="button"]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]:not([type="date"]):not([type="datetime-local"]):not([type="month"]):not([type="week"]):not([type="time"])::-webkit-calendar-picker-indicator{display:none !important}button,[type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button:not(:disabled),[type="button"]:not(:disabled),[type="reset"]:not(:disabled),[type="submit"]:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width: 1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-text,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none !important}.lead{font-size:1.25rem;font-weight:300}.display-1{font-size:calc(1.625rem + 4.5vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-1{font-size:5rem}}.display-2{font-size:calc(1.575rem + 3.9vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-2{font-size:4.5rem}}.display-3{font-size:calc(1.525rem + 3.3vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-3{font-size:4rem}}.display-4{font-size:calc(1.475rem + 2.7vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-4{font-size:3.5rem}}.display-5{font-size:calc(1.425rem + 2.1vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-5{font-size:3rem}}.display-6{font-size:calc(1.375rem + 1.5vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-6{font-size:2.5rem}}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none}.list-inline-item{display:inline-block}.list-inline-item:not(:last-child){margin-right:.5rem}.initialism{font-size:.875em;text-transform:uppercase}.blockquote{margin-bottom:1rem;font-size:1.25rem}.blockquote>:last-child{margin-bottom:0}.blockquote-footer{margin-top:-1rem;margin-bottom:1rem;font-size:.875em;color:#6c757d}.blockquote-footer::before{content:"\2014\00A0"}.img-fluid{max-width:100%;height:auto}.img-thumbnail{padding:.25rem;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color);border-radius:var(--bs-border-radius);box-shadow:var(--bs-box-shadow-sm);max-width:100%;height:auto}.figure{display:inline-block}.figure-img{margin-bottom:.5rem;line-height:1}.figure-caption{font-size:.875em;color:var(--bs-secondary-color)}.container,.container-fluid,.container-xxl,.container-xl,.container-lg,.container-md,.container-sm{--bs-gutter-x: 1.5rem;--bs-gutter-y: 0;width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5);margin-right:auto;margin-left:auto}@media (min-width: 576px){.container-sm,.container{max-width:540px}}@media (min-width: 768px){.container-md,.container-sm,.container{max-width:720px}}@media (min-width: 992px){.container-lg,.container-md,.container-sm,.container{max-width:960px}}@media (min-width: 1200px){.container-xl,.container-lg,.container-md,.container-sm,.container{max-width:1140px}}@media (min-width: 1400px){.container-xxl,.container-xl,.container-lg,.container-md,.container-sm,.container{max-width:1320px}}:root{--bs-breakpoint-xs: 0;--bs-breakpoint-sm: 576px;--bs-breakpoint-md: 768px;--bs-breakpoint-lg: 992px;--bs-breakpoint-xl: 1200px;--bs-breakpoint-xxl: 1400px}.row{--bs-gutter-x: 1.5rem;--bs-gutter-y: 0;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;margin-top:calc(-1 * var(--bs-gutter-y));margin-right:calc(-.5 * var(--bs-gutter-x));margin-left:calc(-.5 * var(--bs-gutter-x))}.row>*{flex-shrink:0;-webkit-flex-shrink:0;width:100%;max-width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5);margin-top:var(--bs-gutter-y)}.grid{display:grid;grid-template-rows:repeat(var(--bs-rows, 1), 1fr);grid-template-columns:repeat(var(--bs-columns, 12), 1fr);gap:var(--bs-gap, 1.5rem)}.grid .g-col-1{grid-column:auto/span 1}.grid .g-col-2{grid-column:auto/span 2}.grid .g-col-3{grid-column:auto/span 3}.grid .g-col-4{grid-column:auto/span 4}.grid .g-col-5{grid-column:auto/span 5}.grid .g-col-6{grid-column:auto/span 6}.grid .g-col-7{grid-column:auto/span 7}.grid .g-col-8{grid-column:auto/span 8}.grid .g-col-9{grid-column:auto/span 9}.grid .g-col-10{grid-column:auto/span 10}.grid .g-col-11{grid-column:auto/span 11}.grid .g-col-12{grid-column:auto/span 12}.grid .g-start-1{grid-column-start:1}.grid .g-start-2{grid-column-start:2}.grid .g-start-3{grid-column-start:3}.grid .g-start-4{grid-column-start:4}.grid .g-start-5{grid-column-start:5}.grid .g-start-6{grid-column-start:6}.grid .g-start-7{grid-column-start:7}.grid .g-start-8{grid-column-start:8}.grid .g-start-9{grid-column-start:9}.grid .g-start-10{grid-column-start:10}.grid .g-start-11{grid-column-start:11}@media (min-width: 576px){.grid .g-col-sm-1{grid-column:auto/span 1}.grid .g-col-sm-2{grid-column:auto/span 2}.grid .g-col-sm-3{grid-column:auto/span 3}.grid .g-col-sm-4{grid-column:auto/span 4}.grid .g-col-sm-5{grid-column:auto/span 5}.grid .g-col-sm-6{grid-column:auto/span 6}.grid .g-col-sm-7{grid-column:auto/span 7}.grid .g-col-sm-8{grid-column:auto/span 8}.grid .g-col-sm-9{grid-column:auto/span 9}.grid .g-col-sm-10{grid-column:auto/span 10}.grid .g-col-sm-11{grid-column:auto/span 11}.grid .g-col-sm-12{grid-column:auto/span 12}.grid .g-start-sm-1{grid-column-start:1}.grid .g-start-sm-2{grid-column-start:2}.grid .g-start-sm-3{grid-column-start:3}.grid .g-start-sm-4{grid-column-start:4}.grid .g-start-sm-5{grid-column-start:5}.grid .g-start-sm-6{grid-column-start:6}.grid .g-start-sm-7{grid-column-start:7}.grid .g-start-sm-8{grid-column-start:8}.grid .g-start-sm-9{grid-column-start:9}.grid .g-start-sm-10{grid-column-start:10}.grid .g-start-sm-11{grid-column-start:11}}@media (min-width: 768px){.grid .g-col-md-1{grid-column:auto/span 1}.grid .g-col-md-2{grid-column:auto/span 2}.grid .g-col-md-3{grid-column:auto/span 3}.grid .g-col-md-4{grid-column:auto/span 4}.grid .g-col-md-5{grid-column:auto/span 5}.grid .g-col-md-6{grid-column:auto/span 6}.grid .g-col-md-7{grid-column:auto/span 7}.grid .g-col-md-8{grid-column:auto/span 8}.grid .g-col-md-9{grid-column:auto/span 9}.grid .g-col-md-10{grid-column:auto/span 10}.grid .g-col-md-11{grid-column:auto/span 11}.grid .g-col-md-12{grid-column:auto/span 12}.grid .g-start-md-1{grid-column-start:1}.grid .g-start-md-2{grid-column-start:2}.grid .g-start-md-3{grid-column-start:3}.grid .g-start-md-4{grid-column-start:4}.grid .g-start-md-5{grid-column-start:5}.grid .g-start-md-6{grid-column-start:6}.grid .g-start-md-7{grid-column-start:7}.grid .g-start-md-8{grid-column-start:8}.grid .g-start-md-9{grid-column-start:9}.grid .g-start-md-10{grid-column-start:10}.grid .g-start-md-11{grid-column-start:11}}@media (min-width: 992px){.grid .g-col-lg-1{grid-column:auto/span 1}.grid .g-col-lg-2{grid-column:auto/span 2}.grid .g-col-lg-3{grid-column:auto/span 3}.grid .g-col-lg-4{grid-column:auto/span 4}.grid .g-col-lg-5{grid-column:auto/span 5}.grid .g-col-lg-6{grid-column:auto/span 6}.grid .g-col-lg-7{grid-column:auto/span 7}.grid .g-col-lg-8{grid-column:auto/span 8}.grid .g-col-lg-9{grid-column:auto/span 9}.grid .g-col-lg-10{grid-column:auto/span 10}.grid .g-col-lg-11{grid-column:auto/span 11}.grid .g-col-lg-12{grid-column:auto/span 12}.grid .g-start-lg-1{grid-column-start:1}.grid .g-start-lg-2{grid-column-start:2}.grid .g-start-lg-3{grid-column-start:3}.grid .g-start-lg-4{grid-column-start:4}.grid .g-start-lg-5{grid-column-start:5}.grid .g-start-lg-6{grid-column-start:6}.grid .g-start-lg-7{grid-column-start:7}.grid .g-start-lg-8{grid-column-start:8}.grid .g-start-lg-9{grid-column-start:9}.grid .g-start-lg-10{grid-column-start:10}.grid .g-start-lg-11{grid-column-start:11}}@media (min-width: 1200px){.grid .g-col-xl-1{grid-column:auto/span 1}.grid .g-col-xl-2{grid-column:auto/span 2}.grid .g-col-xl-3{grid-column:auto/span 3}.grid .g-col-xl-4{grid-column:auto/span 4}.grid .g-col-xl-5{grid-column:auto/span 5}.grid .g-col-xl-6{grid-column:auto/span 6}.grid .g-col-xl-7{grid-column:auto/span 7}.grid .g-col-xl-8{grid-column:auto/span 8}.grid .g-col-xl-9{grid-column:auto/span 9}.grid .g-col-xl-10{grid-column:auto/span 10}.grid .g-col-xl-11{grid-column:auto/span 11}.grid .g-col-xl-12{grid-column:auto/span 12}.grid .g-start-xl-1{grid-column-start:1}.grid .g-start-xl-2{grid-column-start:2}.grid .g-start-xl-3{grid-column-start:3}.grid .g-start-xl-4{grid-column-start:4}.grid .g-start-xl-5{grid-column-start:5}.grid .g-start-xl-6{grid-column-start:6}.grid .g-start-xl-7{grid-column-start:7}.grid .g-start-xl-8{grid-column-start:8}.grid .g-start-xl-9{grid-column-start:9}.grid .g-start-xl-10{grid-column-start:10}.grid .g-start-xl-11{grid-column-start:11}}@media (min-width: 1400px){.grid .g-col-xxl-1{grid-column:auto/span 1}.grid .g-col-xxl-2{grid-column:auto/span 2}.grid .g-col-xxl-3{grid-column:auto/span 3}.grid .g-col-xxl-4{grid-column:auto/span 4}.grid .g-col-xxl-5{grid-column:auto/span 5}.grid .g-col-xxl-6{grid-column:auto/span 6}.grid .g-col-xxl-7{grid-column:auto/span 7}.grid .g-col-xxl-8{grid-column:auto/span 8}.grid .g-col-xxl-9{grid-column:auto/span 9}.grid .g-col-xxl-10{grid-column:auto/span 10}.grid .g-col-xxl-11{grid-column:auto/span 11}.grid .g-col-xxl-12{grid-column:auto/span 12}.grid .g-start-xxl-1{grid-column-start:1}.grid .g-start-xxl-2{grid-column-start:2}.grid .g-start-xxl-3{grid-column-start:3}.grid .g-start-xxl-4{grid-column-start:4}.grid .g-start-xxl-5{grid-column-start:5}.grid .g-start-xxl-6{grid-column-start:6}.grid .g-start-xxl-7{grid-column-start:7}.grid .g-start-xxl-8{grid-column-start:8}.grid .g-start-xxl-9{grid-column-start:9}.grid .g-start-xxl-10{grid-column-start:10}.grid .g-start-xxl-11{grid-column-start:11}}.col{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-1{margin-left:8.33333%}.offset-2{margin-left:16.66667%}.offset-3{margin-left:25%}.offset-4{margin-left:33.33333%}.offset-5{margin-left:41.66667%}.offset-6{margin-left:50%}.offset-7{margin-left:58.33333%}.offset-8{margin-left:66.66667%}.offset-9{margin-left:75%}.offset-10{margin-left:83.33333%}.offset-11{margin-left:91.66667%}.g-0,.gx-0{--bs-gutter-x: 0}.g-0,.gy-0{--bs-gutter-y: 0}.g-1,.gx-1{--bs-gutter-x: .25rem}.g-1,.gy-1{--bs-gutter-y: .25rem}.g-2,.gx-2{--bs-gutter-x: .5rem}.g-2,.gy-2{--bs-gutter-y: .5rem}.g-3,.gx-3{--bs-gutter-x: 1rem}.g-3,.gy-3{--bs-gutter-y: 1rem}.g-4,.gx-4{--bs-gutter-x: 1.5rem}.g-4,.gy-4{--bs-gutter-y: 1.5rem}.g-5,.gx-5{--bs-gutter-x: 3rem}.g-5,.gy-5{--bs-gutter-y: 3rem}@media (min-width: 576px){.col-sm{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-sm-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-sm-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-sm-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-sm-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-sm-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-sm-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-sm-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-sm-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-sm-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-sm-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-sm-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-sm-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-sm-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-sm-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-sm-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-sm-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-sm-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-sm-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-sm-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-sm-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-sm-0{margin-left:0}.offset-sm-1{margin-left:8.33333%}.offset-sm-2{margin-left:16.66667%}.offset-sm-3{margin-left:25%}.offset-sm-4{margin-left:33.33333%}.offset-sm-5{margin-left:41.66667%}.offset-sm-6{margin-left:50%}.offset-sm-7{margin-left:58.33333%}.offset-sm-8{margin-left:66.66667%}.offset-sm-9{margin-left:75%}.offset-sm-10{margin-left:83.33333%}.offset-sm-11{margin-left:91.66667%}.g-sm-0,.gx-sm-0{--bs-gutter-x: 0}.g-sm-0,.gy-sm-0{--bs-gutter-y: 0}.g-sm-1,.gx-sm-1{--bs-gutter-x: .25rem}.g-sm-1,.gy-sm-1{--bs-gutter-y: .25rem}.g-sm-2,.gx-sm-2{--bs-gutter-x: .5rem}.g-sm-2,.gy-sm-2{--bs-gutter-y: .5rem}.g-sm-3,.gx-sm-3{--bs-gutter-x: 1rem}.g-sm-3,.gy-sm-3{--bs-gutter-y: 1rem}.g-sm-4,.gx-sm-4{--bs-gutter-x: 1.5rem}.g-sm-4,.gy-sm-4{--bs-gutter-y: 1.5rem}.g-sm-5,.gx-sm-5{--bs-gutter-x: 3rem}.g-sm-5,.gy-sm-5{--bs-gutter-y: 3rem}}@media (min-width: 768px){.col-md{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-md-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-md-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-md-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-md-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-md-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-md-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-md-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-md-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-md-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-md-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-md-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-md-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-md-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-md-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-md-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-md-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-md-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-md-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-md-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-md-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-md-0{margin-left:0}.offset-md-1{margin-left:8.33333%}.offset-md-2{margin-left:16.66667%}.offset-md-3{margin-left:25%}.offset-md-4{margin-left:33.33333%}.offset-md-5{margin-left:41.66667%}.offset-md-6{margin-left:50%}.offset-md-7{margin-left:58.33333%}.offset-md-8{margin-left:66.66667%}.offset-md-9{margin-left:75%}.offset-md-10{margin-left:83.33333%}.offset-md-11{margin-left:91.66667%}.g-md-0,.gx-md-0{--bs-gutter-x: 0}.g-md-0,.gy-md-0{--bs-gutter-y: 0}.g-md-1,.gx-md-1{--bs-gutter-x: .25rem}.g-md-1,.gy-md-1{--bs-gutter-y: .25rem}.g-md-2,.gx-md-2{--bs-gutter-x: .5rem}.g-md-2,.gy-md-2{--bs-gutter-y: .5rem}.g-md-3,.gx-md-3{--bs-gutter-x: 1rem}.g-md-3,.gy-md-3{--bs-gutter-y: 1rem}.g-md-4,.gx-md-4{--bs-gutter-x: 1.5rem}.g-md-4,.gy-md-4{--bs-gutter-y: 1.5rem}.g-md-5,.gx-md-5{--bs-gutter-x: 3rem}.g-md-5,.gy-md-5{--bs-gutter-y: 3rem}}@media (min-width: 992px){.col-lg{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-lg-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-lg-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-lg-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-lg-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-lg-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-lg-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-lg-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-lg-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-lg-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-lg-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-lg-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-lg-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-lg-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-lg-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-lg-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-lg-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-lg-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-lg-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-lg-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-lg-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-lg-0{margin-left:0}.offset-lg-1{margin-left:8.33333%}.offset-lg-2{margin-left:16.66667%}.offset-lg-3{margin-left:25%}.offset-lg-4{margin-left:33.33333%}.offset-lg-5{margin-left:41.66667%}.offset-lg-6{margin-left:50%}.offset-lg-7{margin-left:58.33333%}.offset-lg-8{margin-left:66.66667%}.offset-lg-9{margin-left:75%}.offset-lg-10{margin-left:83.33333%}.offset-lg-11{margin-left:91.66667%}.g-lg-0,.gx-lg-0{--bs-gutter-x: 0}.g-lg-0,.gy-lg-0{--bs-gutter-y: 0}.g-lg-1,.gx-lg-1{--bs-gutter-x: .25rem}.g-lg-1,.gy-lg-1{--bs-gutter-y: .25rem}.g-lg-2,.gx-lg-2{--bs-gutter-x: .5rem}.g-lg-2,.gy-lg-2{--bs-gutter-y: .5rem}.g-lg-3,.gx-lg-3{--bs-gutter-x: 1rem}.g-lg-3,.gy-lg-3{--bs-gutter-y: 1rem}.g-lg-4,.gx-lg-4{--bs-gutter-x: 1.5rem}.g-lg-4,.gy-lg-4{--bs-gutter-y: 1.5rem}.g-lg-5,.gx-lg-5{--bs-gutter-x: 3rem}.g-lg-5,.gy-lg-5{--bs-gutter-y: 3rem}}@media (min-width: 1200px){.col-xl{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-xl-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-xl-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-xl-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-xl-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-xl-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-xl-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-xl-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-xl-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-xl-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-xl-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-xl-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-xl-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-xl-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-xl-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-xl-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-xl-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-xl-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-xl-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-xl-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-xl-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-xl-0{margin-left:0}.offset-xl-1{margin-left:8.33333%}.offset-xl-2{margin-left:16.66667%}.offset-xl-3{margin-left:25%}.offset-xl-4{margin-left:33.33333%}.offset-xl-5{margin-left:41.66667%}.offset-xl-6{margin-left:50%}.offset-xl-7{margin-left:58.33333%}.offset-xl-8{margin-left:66.66667%}.offset-xl-9{margin-left:75%}.offset-xl-10{margin-left:83.33333%}.offset-xl-11{margin-left:91.66667%}.g-xl-0,.gx-xl-0{--bs-gutter-x: 0}.g-xl-0,.gy-xl-0{--bs-gutter-y: 0}.g-xl-1,.gx-xl-1{--bs-gutter-x: .25rem}.g-xl-1,.gy-xl-1{--bs-gutter-y: .25rem}.g-xl-2,.gx-xl-2{--bs-gutter-x: .5rem}.g-xl-2,.gy-xl-2{--bs-gutter-y: .5rem}.g-xl-3,.gx-xl-3{--bs-gutter-x: 1rem}.g-xl-3,.gy-xl-3{--bs-gutter-y: 1rem}.g-xl-4,.gx-xl-4{--bs-gutter-x: 1.5rem}.g-xl-4,.gy-xl-4{--bs-gutter-y: 1.5rem}.g-xl-5,.gx-xl-5{--bs-gutter-x: 3rem}.g-xl-5,.gy-xl-5{--bs-gutter-y: 3rem}}@media (min-width: 1400px){.col-xxl{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-xxl-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-xxl-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-xxl-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-xxl-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-xxl-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-xxl-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-xxl-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-xxl-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-xxl-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-xxl-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-xxl-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-xxl-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-xxl-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-xxl-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-xxl-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-xxl-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-xxl-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-xxl-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-xxl-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-xxl-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-xxl-0{margin-left:0}.offset-xxl-1{margin-left:8.33333%}.offset-xxl-2{margin-left:16.66667%}.offset-xxl-3{margin-left:25%}.offset-xxl-4{margin-left:33.33333%}.offset-xxl-5{margin-left:41.66667%}.offset-xxl-6{margin-left:50%}.offset-xxl-7{margin-left:58.33333%}.offset-xxl-8{margin-left:66.66667%}.offset-xxl-9{margin-left:75%}.offset-xxl-10{margin-left:83.33333%}.offset-xxl-11{margin-left:91.66667%}.g-xxl-0,.gx-xxl-0{--bs-gutter-x: 0}.g-xxl-0,.gy-xxl-0{--bs-gutter-y: 0}.g-xxl-1,.gx-xxl-1{--bs-gutter-x: .25rem}.g-xxl-1,.gy-xxl-1{--bs-gutter-y: .25rem}.g-xxl-2,.gx-xxl-2{--bs-gutter-x: .5rem}.g-xxl-2,.gy-xxl-2{--bs-gutter-y: .5rem}.g-xxl-3,.gx-xxl-3{--bs-gutter-x: 1rem}.g-xxl-3,.gy-xxl-3{--bs-gutter-y: 1rem}.g-xxl-4,.gx-xxl-4{--bs-gutter-x: 1.5rem}.g-xxl-4,.gy-xxl-4{--bs-gutter-y: 1.5rem}.g-xxl-5,.gx-xxl-5{--bs-gutter-x: 3rem}.g-xxl-5,.gy-xxl-5{--bs-gutter-y: 3rem}}.table{--bs-table-color-type: initial;--bs-table-bg-type: initial;--bs-table-color-state: initial;--bs-table-bg-state: initial;--bs-table-color: var(--bs-body-color);--bs-table-bg: var(--bs-body-bg);--bs-table-border-color: var(--bs-border-color);--bs-table-accent-bg: rgba(0,0,0,0);--bs-table-striped-color: var(--bs-body-color);--bs-table-striped-bg: rgba(0,0,0,0.05);--bs-table-active-color: var(--bs-body-color);--bs-table-active-bg: rgba(0,0,0,0.1);--bs-table-hover-color: var(--bs-body-color);--bs-table-hover-bg: rgba(0,0,0,0.075);width:100%;margin-bottom:1rem;vertical-align:top;border-color:var(--bs-table-border-color)}.table>:not(caption)>*>*{padding:1rem 1rem;color:var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));background-color:var(--bs-table-bg);border-bottom-width:var(--bs-border-width);box-shadow:inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-accent-bg)))}.table>tbody{vertical-align:inherit}.table>thead{vertical-align:bottom}.table-group-divider{border-top:calc(var(--bs-border-width) * 2) solid currentcolor}.caption-top{caption-side:top}.table-sm>:not(caption)>*>*{padding:.5rem .5rem}.table-bordered>:not(caption)>*{border-width:var(--bs-border-width) 0}.table-bordered>:not(caption)>*>*{border-width:0 var(--bs-border-width)}.table-borderless>:not(caption)>*>*{border-bottom-width:0}.table-borderless>:not(:first-child){border-top-width:0}.table-striped>tbody>tr:nth-of-type(odd)>*{--bs-table-color-type: var(--bs-table-striped-color);--bs-table-bg-type: var(--bs-table-striped-bg)}.table-striped-columns>:not(caption)>tr>:nth-child(even){--bs-table-color-type: var(--bs-table-striped-color);--bs-table-bg-type: var(--bs-table-striped-bg)}.table-active{--bs-table-color-state: var(--bs-table-active-color);--bs-table-bg-state: var(--bs-table-active-bg)}.table-hover>tbody>tr:hover>*{--bs-table-color-state: var(--bs-table-hover-color);--bs-table-bg-state: var(--bs-table-hover-bg)}.table-primary{--bs-table-color: #000;--bs-table-bg: #d6defa;--bs-table-border-color: #c1c8e1;--bs-table-striped-bg: #cbd3ee;--bs-table-striped-color: #000;--bs-table-active-bg: #c1c8e1;--bs-table-active-color: #fff;--bs-table-hover-bg: #c6cde7;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-secondary{--bs-table-color: #000;--bs-table-bg: #fff;--bs-table-border-color: #e6e6e6;--bs-table-striped-bg: #f2f2f2;--bs-table-striped-color: #000;--bs-table-active-bg: #e6e6e6;--bs-table-active-color: #000;--bs-table-hover-bg: #ececec;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-success{--bs-table-color: #000;--bs-table-bg: #d5f0e6;--bs-table-border-color: #c0d8cf;--bs-table-striped-bg: #cae4db;--bs-table-striped-color: #000;--bs-table-active-bg: #c0d8cf;--bs-table-active-color: #000;--bs-table-hover-bg: #c5ded5;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-info{--bs-table-color: #000;--bs-table-bg: #d4e5f0;--bs-table-border-color: #bfced8;--bs-table-striped-bg: #c9dae4;--bs-table-striped-color: #000;--bs-table-active-bg: #bfced8;--bs-table-active-color: #000;--bs-table-hover-bg: #c4d4de;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-warning{--bs-table-color: #000;--bs-table-bg: #fdf2df;--bs-table-border-color: #e4dac9;--bs-table-striped-bg: #f0e6d4;--bs-table-striped-color: #000;--bs-table-active-bg: #e4dac9;--bs-table-active-color: #000;--bs-table-hover-bg: #eae0ce;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-danger{--bs-table-color: #000;--bs-table-bg: #f8d4d5;--bs-table-border-color: #dfbfc0;--bs-table-striped-bg: #ecc9ca;--bs-table-striped-color: #000;--bs-table-active-bg: #dfbfc0;--bs-table-active-color: #fff;--bs-table-hover-bg: #e5c4c5;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-light{--bs-table-color: #000;--bs-table-bg: #f8f9fa;--bs-table-border-color: #dfe0e1;--bs-table-striped-bg: #ecedee;--bs-table-striped-color: #000;--bs-table-active-bg: #dfe0e1;--bs-table-active-color: #000;--bs-table-hover-bg: #e5e6e7;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-dark{--bs-table-color: #fff;--bs-table-bg: #212529;--bs-table-border-color: #373b3e;--bs-table-striped-bg: #2c3034;--bs-table-striped-color: #fff;--bs-table-active-bg: #373b3e;--bs-table-active-color: #fff;--bs-table-hover-bg: #323539;--bs-table-hover-color: #fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-responsive{overflow-x:auto;-webkit-overflow-scrolling:touch}@media (max-width: 575.98px){.table-responsive-sm{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width: 767.98px){.table-responsive-md{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width: 991.98px){.table-responsive-lg{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width: 1199.98px){.table-responsive-xl{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width: 1399.98px){.table-responsive-xxl{overflow-x:auto;-webkit-overflow-scrolling:touch}}.form-label,.shiny-input-container .control-label{margin-bottom:.5rem;font-weight:500}.col-form-label{padding-top:calc(.5rem + var(--bs-border-width));padding-bottom:calc(.5rem + var(--bs-border-width));margin-bottom:0;font-size:inherit;font-weight:500;line-height:1.5}.col-form-label-lg{padding-top:calc(.5rem + var(--bs-border-width));padding-bottom:calc(.5rem + var(--bs-border-width));font-size:1.25rem}.col-form-label-sm{padding-top:calc(.25rem + var(--bs-border-width));padding-bottom:calc(.25rem + var(--bs-border-width));font-size:.875rem}.form-text{margin-top:.25rem;font-size:.875em;color:var(--bs-secondary-color)}.form-control{display:block;width:100%;padding:.5rem 1rem;font-size:.875rem;font-weight:400;line-height:1.5;color:var(--bs-body-color);appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:var(--bs-body-bg);background-clip:padding-box;border:var(--bs-border-width) solid var(--bs-border-color);border-radius:var(--bs-border-radius);box-shadow:0 1px 2px rgba(0,0,0,0.05);transition:border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-control{transition:none}}.form-control[type="file"]{overflow:hidden}.form-control[type="file"]:not(:disabled):not([readonly]){cursor:pointer}.form-control:focus{color:var(--bs-body-color);background-color:var(--bs-body-bg);border-color:#9aacf3;outline:0;box-shadow:0 1px 2px rgba(0,0,0,0.05),0 0 0 .25rem rgba(52,89,230,0.25)}.form-control::-webkit-date-and-time-value{min-width:85px;height:1.5em;margin:0}.form-control::-webkit-datetime-edit{display:block;padding:0}.form-control::placeholder{color:var(--bs-secondary-color);opacity:1}.form-control:disabled{background-color:var(--bs-secondary-bg);opacity:1}.form-control::file-selector-button{padding:.5rem 1rem;margin:-.5rem -1rem;margin-inline-end:1rem;color:var(--bs-body-color);background-color:var(--bs-tertiary-bg);pointer-events:none;border-color:inherit;border-style:solid;border-width:0;border-inline-end-width:var(--bs-border-width);border-radius:0;transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-control::file-selector-button{transition:none}}.form-control:hover:not(:disabled):not([readonly])::file-selector-button{background-color:var(--bs-secondary-bg)}.form-control-plaintext{display:block;width:100%;padding:.5rem 0;margin-bottom:0;line-height:1.5;color:var(--bs-body-color);background-color:transparent;border:solid transparent;border-width:var(--bs-border-width) 0}.form-control-plaintext:focus{outline:0}.form-control-plaintext.form-control-sm,.form-control-plaintext.form-control-lg{padding-right:0;padding-left:0}.form-control-sm{min-height:calc(1.5em + .5rem + calc(var(--bs-border-width) * 2));padding:.25rem .5rem;font-size:.875rem;border-radius:var(--bs-border-radius-sm)}.form-control-sm::file-selector-button{padding:.25rem .5rem;margin:-.25rem -.5rem;margin-inline-end:.5rem}.form-control-lg{min-height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2));padding:.5rem 1rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.form-control-lg::file-selector-button{padding:.5rem 1rem;margin:-.5rem -1rem;margin-inline-end:1rem}textarea.form-control{min-height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2))}textarea.form-control-sm{min-height:calc(1.5em + .5rem + calc(var(--bs-border-width) * 2))}textarea.form-control-lg{min-height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2))}.form-control-color{width:3rem;height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2));padding:.5rem}.form-control-color:not(:disabled):not([readonly]){cursor:pointer}.form-control-color::-moz-color-swatch{border:0 !important;border-radius:var(--bs-border-radius)}.form-control-color::-webkit-color-swatch{border:0 !important;border-radius:var(--bs-border-radius)}.form-control-color.form-control-sm{height:calc(1.5em + .5rem + calc(var(--bs-border-width) * 2))}.form-control-color.form-control-lg{height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2))}.form-select{--bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");display:block;width:100%;padding:.5rem 3rem .5rem 1rem;font-size:.875rem;font-weight:400;line-height:1.5;color:var(--bs-body-color);appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:var(--bs-body-bg);background-image:var(--bs-form-select-bg-img),var(--bs-form-select-bg-icon, none);background-repeat:no-repeat;background-position:right 1rem center;background-size:16px 12px;border:var(--bs-border-width) solid var(--bs-border-color);border-radius:var(--bs-border-radius);box-shadow:inset 0 1px 2px rgba(0,0,0,0.075);transition:border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-select{transition:none}}.form-select:focus{border-color:#9aacf3;outline:0;box-shadow:inset 0 1px 2px rgba(0,0,0,0.075),0 0 0 .25rem rgba(52,89,230,0.25)}.form-select[multiple],.form-select[size]:not([size="1"]){padding-right:1rem;background-image:none}.form-select:disabled{background-color:var(--bs-secondary-bg)}.form-select:-moz-focusring{color:transparent;text-shadow:0 0 0 var(--bs-body-color)}.form-select-sm{padding-top:.25rem;padding-bottom:.25rem;padding-left:.5rem;font-size:.875rem;border-radius:var(--bs-border-radius-sm)}.form-select-lg{padding-top:.5rem;padding-bottom:.5rem;padding-left:1rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}[data-bs-theme="dark"] .form-select{--bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e")}.form-check,.shiny-input-container .checkbox,.shiny-input-container .radio{display:block;min-height:1.5rem;padding-left:0;margin-bottom:.125rem}.form-check .form-check-input,.form-check .shiny-input-container .checkbox input,.form-check .shiny-input-container .radio input,.shiny-input-container .checkbox .form-check-input,.shiny-input-container .checkbox .shiny-input-container .checkbox input,.shiny-input-container .checkbox .shiny-input-container .radio input,.shiny-input-container .radio .form-check-input,.shiny-input-container .radio .shiny-input-container .checkbox input,.shiny-input-container .radio .shiny-input-container .radio input{float:left;margin-left:0}.form-check-reverse{padding-right:0;padding-left:0;text-align:right}.form-check-reverse .form-check-input{float:right;margin-right:0;margin-left:0}.form-check-input,.shiny-input-container .checkbox input,.shiny-input-container .checkbox-inline input,.shiny-input-container .radio input,.shiny-input-container .radio-inline input{--bs-form-check-bg: var(--bs-body-bg);width:1em;height:1em;margin-top:.25em;vertical-align:top;appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:var(--bs-form-check-bg);background-image:var(--bs-form-check-bg-image);background-repeat:no-repeat;background-position:center;background-size:contain;border:var(--bs-border-width) solid var(--bs-border-color);print-color-adjust:exact}.form-check-input[type="checkbox"],.shiny-input-container .checkbox input[type="checkbox"],.shiny-input-container .checkbox-inline input[type="checkbox"],.shiny-input-container .radio input[type="checkbox"],.shiny-input-container .radio-inline input[type="checkbox"]{border-radius:.25em}.form-check-input[type="radio"],.shiny-input-container .checkbox input[type="radio"],.shiny-input-container .checkbox-inline input[type="radio"],.shiny-input-container .radio input[type="radio"],.shiny-input-container .radio-inline input[type="radio"]{border-radius:50%}.form-check-input:active,.shiny-input-container .checkbox input:active,.shiny-input-container .checkbox-inline input:active,.shiny-input-container .radio input:active,.shiny-input-container .radio-inline input:active{filter:brightness(90%)}.form-check-input:focus,.shiny-input-container .checkbox input:focus,.shiny-input-container .checkbox-inline input:focus,.shiny-input-container .radio input:focus,.shiny-input-container .radio-inline input:focus{border-color:#9aacf3;outline:0;box-shadow:0 0 0 .25rem rgba(52,89,230,0.25)}.form-check-input:checked,.shiny-input-container .checkbox input:checked,.shiny-input-container .checkbox-inline input:checked,.shiny-input-container .radio input:checked,.shiny-input-container .radio-inline input:checked{background-color:#3459e6;border-color:#3459e6}.form-check-input:checked[type="checkbox"],.shiny-input-container .checkbox input:checked[type="checkbox"],.shiny-input-container .checkbox-inline input:checked[type="checkbox"],.shiny-input-container .radio input:checked[type="checkbox"],.shiny-input-container .radio-inline input:checked[type="checkbox"]{--bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e")}.form-check-input:checked[type="radio"],.shiny-input-container .checkbox input:checked[type="radio"],.shiny-input-container .checkbox-inline input:checked[type="radio"],.shiny-input-container .radio input:checked[type="radio"],.shiny-input-container .radio-inline input:checked[type="radio"]{--bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e")}.form-check-input[type="checkbox"]:indeterminate,.shiny-input-container .checkbox input[type="checkbox"]:indeterminate,.shiny-input-container .checkbox-inline input[type="checkbox"]:indeterminate,.shiny-input-container .radio input[type="checkbox"]:indeterminate,.shiny-input-container .radio-inline input[type="checkbox"]:indeterminate{background-color:#3459e6;border-color:#3459e6;--bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e")}.form-check-input:disabled,.shiny-input-container .checkbox input:disabled,.shiny-input-container .checkbox-inline input:disabled,.shiny-input-container .radio input:disabled,.shiny-input-container .radio-inline input:disabled{pointer-events:none;filter:none;opacity:.5}.form-check-input[disabled]~.form-check-label,.form-check-input[disabled]~span,.form-check-input:disabled~.form-check-label,.form-check-input:disabled~span,.shiny-input-container .checkbox input[disabled]~.form-check-label,.shiny-input-container .checkbox input[disabled]~span,.shiny-input-container .checkbox input:disabled~.form-check-label,.shiny-input-container .checkbox input:disabled~span,.shiny-input-container .checkbox-inline input[disabled]~.form-check-label,.shiny-input-container .checkbox-inline input[disabled]~span,.shiny-input-container .checkbox-inline input:disabled~.form-check-label,.shiny-input-container .checkbox-inline input:disabled~span,.shiny-input-container .radio input[disabled]~.form-check-label,.shiny-input-container .radio input[disabled]~span,.shiny-input-container .radio input:disabled~.form-check-label,.shiny-input-container .radio input:disabled~span,.shiny-input-container .radio-inline input[disabled]~.form-check-label,.shiny-input-container .radio-inline input[disabled]~span,.shiny-input-container .radio-inline input:disabled~.form-check-label,.shiny-input-container .radio-inline input:disabled~span{cursor:default;opacity:.5}.form-check-label,.shiny-input-container .checkbox label,.shiny-input-container .checkbox-inline label,.shiny-input-container .radio label,.shiny-input-container .radio-inline label{cursor:pointer}.form-switch{padding-left:2.5em}.form-switch .form-check-input{--bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280,0,0,0.25%29'/%3e%3c/svg%3e");width:2em;margin-left:-2.5em;background-image:var(--bs-form-switch-bg);background-position:left center;border-radius:2em;transition:background-position 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-switch .form-check-input{transition:none}}.form-switch .form-check-input:focus{--bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%239aacf3'/%3e%3c/svg%3e")}.form-switch .form-check-input:checked{background-position:right center;--bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e")}.form-switch.form-check-reverse{padding-right:2.5em;padding-left:0}.form-switch.form-check-reverse .form-check-input{margin-right:-2.5em;margin-left:0}.form-check-inline{display:inline-block;margin-right:1rem}.btn-check{position:absolute;clip:rect(0, 0, 0, 0);pointer-events:none}.btn-check[disabled]+.btn,.btn-check:disabled+.btn{pointer-events:none;filter:none;opacity:.65}[data-bs-theme="dark"] .form-switch .form-check-input:not(:checked):not(:focus){--bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255,255,255,0.25%29'/%3e%3c/svg%3e")}.form-range{width:100%;height:1.5rem;padding:0;appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:transparent}.form-range:focus{outline:0}.form-range:focus::-webkit-slider-thumb{box-shadow:0 0 0 1px #fff,0 0 0 .25rem rgba(52,89,230,0.25)}.form-range:focus::-moz-range-thumb{box-shadow:0 0 0 1px #fff,0 0 0 .25rem rgba(52,89,230,0.25)}.form-range::-moz-focus-outer{border:0}.form-range::-webkit-slider-thumb{width:1rem;height:1rem;margin-top:-.25rem;appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:#3459e6;border:0;border-radius:1rem;box-shadow:0 0.1rem 0.25rem rgba(0,0,0,0.1);transition:background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-range::-webkit-slider-thumb{transition:none}}.form-range::-webkit-slider-thumb:active{background-color:#c2cdf8}.form-range::-webkit-slider-runnable-track{width:100%;height:.5rem;color:transparent;cursor:pointer;background-color:var(--bs-tertiary-bg);border-color:transparent;border-radius:1rem;box-shadow:inset 0 1px 2px rgba(0,0,0,0.075)}.form-range::-moz-range-thumb{width:1rem;height:1rem;appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:#3459e6;border:0;border-radius:1rem;box-shadow:0 0.1rem 0.25rem rgba(0,0,0,0.1);transition:background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-range::-moz-range-thumb{transition:none}}.form-range::-moz-range-thumb:active{background-color:#c2cdf8}.form-range::-moz-range-track{width:100%;height:.5rem;color:transparent;cursor:pointer;background-color:var(--bs-tertiary-bg);border-color:transparent;border-radius:1rem;box-shadow:inset 0 1px 2px rgba(0,0,0,0.075)}.form-range:disabled{pointer-events:none}.form-range:disabled::-webkit-slider-thumb{background-color:var(--bs-secondary-color)}.form-range:disabled::-moz-range-thumb{background-color:var(--bs-secondary-color)}.form-floating{position:relative}.form-floating>.form-control,.form-floating>.form-control-plaintext,.form-floating>.form-select{height:calc(3.5rem + calc(var(--bs-border-width) * 2));min-height:calc(3.5rem + calc(var(--bs-border-width) * 2));line-height:1.25}.form-floating>label{position:absolute;top:0;left:0;z-index:2;height:100%;padding:1rem 1rem;overflow:hidden;text-align:start;text-overflow:ellipsis;white-space:nowrap;pointer-events:none;border:var(--bs-border-width) solid transparent;transform-origin:0 0;transition:opacity 0.1s ease-in-out,transform 0.1s ease-in-out}@media (prefers-reduced-motion: reduce){.form-floating>label{transition:none}}.form-floating>.form-control,.form-floating>.form-control-plaintext{padding:1rem 1rem}.form-floating>.form-control::placeholder,.form-floating>.form-control-plaintext::placeholder{color:transparent}.form-floating>.form-control:focus,.form-floating>.form-control:not(:placeholder-shown),.form-floating>.form-control-plaintext:focus,.form-floating>.form-control-plaintext:not(:placeholder-shown){padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-control:-webkit-autofill,.form-floating>.form-control-plaintext:-webkit-autofill{padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-select{padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-control:focus~label,.form-floating>.form-control:not(:placeholder-shown)~label,.form-floating>.form-control-plaintext~label,.form-floating>.form-select~label{color:rgba(var(--bs-body-color-rgb), .65);transform:scale(0.85) translateY(-0.5rem) translateX(0.15rem)}.form-floating>.form-control:focus~label::after,.form-floating>.form-control:not(:placeholder-shown)~label::after,.form-floating>.form-control-plaintext~label::after,.form-floating>.form-select~label::after{position:absolute;inset:1rem .5rem;z-index:-1;height:1.5em;content:"";background-color:var(--bs-body-bg);border-radius:var(--bs-border-radius)}.form-floating>.form-control:-webkit-autofill~label{color:rgba(var(--bs-body-color-rgb), .65);transform:scale(0.85) translateY(-0.5rem) translateX(0.15rem)}.form-floating>.form-control-plaintext~label{border-width:var(--bs-border-width) 0}.form-floating>:disabled~label,.form-floating>.form-control:disabled~label{color:#6c757d}.form-floating>:disabled~label::after,.form-floating>.form-control:disabled~label::after{background-color:var(--bs-secondary-bg)}.input-group{position:relative;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;align-items:stretch;-webkit-align-items:stretch;width:100%}.input-group>.form-control,.input-group>.form-select,.input-group>.form-floating{position:relative;flex:1 1 auto;-webkit-flex:1 1 auto;width:1%;min-width:0}.input-group>.form-control:focus,.input-group>.form-select:focus,.input-group>.form-floating:focus-within{z-index:5}.input-group .btn{position:relative;z-index:2}.input-group .btn:focus{z-index:5}.input-group-text{display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:400;line-height:1.5;color:var(--bs-body-color);text-align:center;white-space:nowrap;background-color:#f8f9fa;border:var(--bs-border-width) solid var(--bs-border-color);border-radius:var(--bs-border-radius)}.input-group-lg>.form-control,.input-group-lg>.form-select,.input-group-lg>.input-group-text,.input-group-lg>.btn{padding:.5rem 1rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.input-group-sm>.form-control,.input-group-sm>.form-select,.input-group-sm>.input-group-text,.input-group-sm>.btn{padding:.25rem .5rem;font-size:.875rem;border-radius:var(--bs-border-radius-sm)}.input-group-lg>.form-select,.input-group-sm>.form-select{padding-right:4rem}.input-group:not(.has-validation)>:not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),.input-group:not(.has-validation)>.dropdown-toggle:nth-last-child(n + 3),.input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-control,.input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-select{border-top-right-radius:0;border-bottom-right-radius:0}.input-group.has-validation>:nth-last-child(n + 3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),.input-group.has-validation>.dropdown-toggle:nth-last-child(n + 4),.input-group.has-validation>.form-floating:nth-last-child(n + 3)>.form-control,.input-group.has-validation>.form-floating:nth-last-child(n + 3)>.form-select{border-top-right-radius:0;border-bottom-right-radius:0}.input-group>:not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback){margin-left:calc(var(--bs-border-width) * -1);border-top-left-radius:0;border-bottom-left-radius:0}.input-group>.form-floating:not(:first-child)>.form-control,.input-group>.form-floating:not(:first-child)>.form-select{border-top-left-radius:0;border-bottom-left-radius:0}.valid-feedback{display:none;width:100%;margin-top:.25rem;font-size:.875em;color:var(--bs-form-valid-color)}.valid-tooltip{position:absolute;top:100%;z-index:5;display:none;max-width:100%;padding:.25rem .5rem;margin-top:.1rem;font-size:.875rem;color:#fff;background-color:var(--bs-success);border-radius:var(--bs-border-radius)}.was-validated :valid~.valid-feedback,.was-validated :valid~.valid-tooltip,.is-valid~.valid-feedback,.is-valid~.valid-tooltip{display:block}.was-validated .form-control:valid,.form-control.is-valid{border-color:var(--bs-form-valid-border-color);padding-right:calc(1.5em + 1rem);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%232fb380' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right calc(.375em + .25rem) center;background-size:calc(.75em + .5rem) calc(.75em + .5rem)}.was-validated .form-control:valid:focus,.form-control.is-valid:focus{border-color:var(--bs-form-valid-border-color);box-shadow:0 0 0 .25rem rgba(var(--bs-success-rgb), 0.25)}.was-validated textarea.form-control:valid,textarea.form-control.is-valid{padding-right:calc(1.5em + 1rem);background-position:top calc(.375em + .25rem) right calc(.375em + .25rem)}.was-validated .form-select:valid,.form-select.is-valid{border-color:var(--bs-form-valid-border-color)}.was-validated .form-select:valid:not([multiple]):not([size]),.was-validated .form-select:valid:not([multiple])[size="1"],.form-select.is-valid:not([multiple]):not([size]),.form-select.is-valid:not([multiple])[size="1"]{--bs-form-select-bg-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%232fb380' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");padding-right:5.5rem;background-position:right 1rem center,center right 3rem;background-size:16px 12px,calc(.75em + .5rem) calc(.75em + .5rem)}.was-validated .form-select:valid:focus,.form-select.is-valid:focus{border-color:var(--bs-form-valid-border-color);box-shadow:0 0 0 .25rem rgba(var(--bs-success-rgb), 0.25)}.was-validated .form-control-color:valid,.form-control-color.is-valid{width:calc(3rem + calc(1.5em + 1rem))}.was-validated .form-check-input:valid,.form-check-input.is-valid{border-color:var(--bs-form-valid-border-color)}.was-validated .form-check-input:valid:checked,.form-check-input.is-valid:checked{background-color:var(--bs-form-valid-color)}.was-validated .form-check-input:valid:focus,.form-check-input.is-valid:focus{box-shadow:0 0 0 .25rem rgba(var(--bs-success-rgb), 0.25)}.was-validated .form-check-input:valid~.form-check-label,.form-check-input.is-valid~.form-check-label{color:var(--bs-form-valid-color)}.form-check-inline .form-check-input~.valid-feedback{margin-left:.5em}.was-validated .input-group>.form-control:not(:focus):valid,.input-group>.form-control:not(:focus).is-valid,.was-validated .input-group>.form-select:not(:focus):valid,.input-group>.form-select:not(:focus).is-valid,.was-validated .input-group>.form-floating:not(:focus-within):valid,.input-group>.form-floating:not(:focus-within).is-valid{z-index:3}.invalid-feedback{display:none;width:100%;margin-top:.25rem;font-size:.875em;color:var(--bs-form-invalid-color)}.invalid-tooltip{position:absolute;top:100%;z-index:5;display:none;max-width:100%;padding:.25rem .5rem;margin-top:.1rem;font-size:.875rem;color:#fff;background-color:var(--bs-danger);border-radius:var(--bs-border-radius)}.was-validated :invalid~.invalid-feedback,.was-validated :invalid~.invalid-tooltip,.is-invalid~.invalid-feedback,.is-invalid~.invalid-tooltip{display:block}.was-validated .form-control:invalid,.form-control.is-invalid{border-color:var(--bs-form-invalid-border-color);padding-right:calc(1.5em + 1rem);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23da292e'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23da292e' stroke='none'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right calc(.375em + .25rem) center;background-size:calc(.75em + .5rem) calc(.75em + .5rem)}.was-validated .form-control:invalid:focus,.form-control.is-invalid:focus{border-color:var(--bs-form-invalid-border-color);box-shadow:0 0 0 .25rem rgba(var(--bs-danger-rgb), 0.25)}.was-validated textarea.form-control:invalid,textarea.form-control.is-invalid{padding-right:calc(1.5em + 1rem);background-position:top calc(.375em + .25rem) right calc(.375em + .25rem)}.was-validated .form-select:invalid,.form-select.is-invalid{border-color:var(--bs-form-invalid-border-color)}.was-validated .form-select:invalid:not([multiple]):not([size]),.was-validated .form-select:invalid:not([multiple])[size="1"],.form-select.is-invalid:not([multiple]):not([size]),.form-select.is-invalid:not([multiple])[size="1"]{--bs-form-select-bg-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23da292e'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23da292e' stroke='none'/%3e%3c/svg%3e");padding-right:5.5rem;background-position:right 1rem center,center right 3rem;background-size:16px 12px,calc(.75em + .5rem) calc(.75em + .5rem)}.was-validated .form-select:invalid:focus,.form-select.is-invalid:focus{border-color:var(--bs-form-invalid-border-color);box-shadow:0 0 0 .25rem rgba(var(--bs-danger-rgb), 0.25)}.was-validated .form-control-color:invalid,.form-control-color.is-invalid{width:calc(3rem + calc(1.5em + 1rem))}.was-validated .form-check-input:invalid,.form-check-input.is-invalid{border-color:var(--bs-form-invalid-border-color)}.was-validated .form-check-input:invalid:checked,.form-check-input.is-invalid:checked{background-color:var(--bs-form-invalid-color)}.was-validated .form-check-input:invalid:focus,.form-check-input.is-invalid:focus{box-shadow:0 0 0 .25rem rgba(var(--bs-danger-rgb), 0.25)}.was-validated .form-check-input:invalid~.form-check-label,.form-check-input.is-invalid~.form-check-label{color:var(--bs-form-invalid-color)}.form-check-inline .form-check-input~.invalid-feedback{margin-left:.5em}.was-validated .input-group>.form-control:not(:focus):invalid,.input-group>.form-control:not(:focus).is-invalid,.was-validated .input-group>.form-select:not(:focus):invalid,.input-group>.form-select:not(:focus).is-invalid,.was-validated .input-group>.form-floating:not(:focus-within):invalid,.input-group>.form-floating:not(:focus-within).is-invalid{z-index:4}.btn{--bs-btn-padding-x: 1rem;--bs-btn-padding-y: .5rem;--bs-btn-font-family: ;--bs-btn-font-size:.875rem;--bs-btn-font-weight: 500;--bs-btn-line-height: 1.5;--bs-btn-color: var(--bs-body-color);--bs-btn-bg: transparent;--bs-btn-border-width: var(--bs-border-width);--bs-btn-border-color: transparent;--bs-btn-border-radius: var(--bs-border-radius);--bs-btn-hover-border-color: transparent;--bs-btn-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-opacity: .65;--bs-btn-focus-box-shadow: 0 0 0 .25rem rgba(var(--bs-btn-focus-shadow-rgb), .5);display:inline-block;padding:var(--bs-btn-padding-y) var(--bs-btn-padding-x);font-family:var(--bs-btn-font-family);font-size:var(--bs-btn-font-size);font-weight:var(--bs-btn-font-weight);line-height:var(--bs-btn-line-height);color:var(--bs-btn-color);text-align:center;text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;vertical-align:middle;cursor:pointer;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;border:var(--bs-btn-border-width) solid var(--bs-btn-border-color);border-radius:var(--bs-btn-border-radius);background-color:var(--bs-btn-bg);box-shadow:var(--bs-btn-box-shadow);transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.btn{transition:none}}.btn:hover{color:var(--bs-btn-hover-color);background-color:var(--bs-btn-hover-bg);border-color:var(--bs-btn-hover-border-color)}.btn-check+.btn:hover{color:var(--bs-btn-color);background-color:var(--bs-btn-bg);border-color:var(--bs-btn-border-color)}.btn:focus-visible{color:var(--bs-btn-hover-color);background-color:var(--bs-btn-hover-bg);border-color:var(--bs-btn-hover-border-color);outline:0;box-shadow:var(--bs-btn-box-shadow),var(--bs-btn-focus-box-shadow)}.btn-check:focus-visible+.btn{border-color:var(--bs-btn-hover-border-color);outline:0;box-shadow:var(--bs-btn-box-shadow),var(--bs-btn-focus-box-shadow)}.btn-check:checked+.btn,:not(.btn-check)+.btn:active,.btn:first-child:active,.btn.active,.btn.show{color:var(--bs-btn-active-color);background-color:var(--bs-btn-active-bg);border-color:var(--bs-btn-active-border-color);box-shadow:var(--bs-btn-active-shadow)}.btn-check:checked+.btn:focus-visible,:not(.btn-check)+.btn:active:focus-visible,.btn:first-child:active:focus-visible,.btn.active:focus-visible,.btn.show:focus-visible{box-shadow:var(--bs-btn-active-shadow),var(--bs-btn-focus-box-shadow)}.btn:disabled,.btn.disabled,fieldset:disabled .btn{color:var(--bs-btn-disabled-color);pointer-events:none;background-color:var(--bs-btn-disabled-bg);border-color:var(--bs-btn-disabled-border-color);opacity:var(--bs-btn-disabled-opacity);box-shadow:none}.btn-default{--bs-btn-color: #000;--bs-btn-bg: #fff;--bs-btn-border-color: #fff;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #fff;--bs-btn-hover-border-color: #fff;--bs-btn-focus-shadow-rgb: 217,217,217;--bs-btn-active-color: #000;--bs-btn-active-bg: #fff;--bs-btn-active-border-color: #fff;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #000;--bs-btn-disabled-bg: #fff;--bs-btn-disabled-border-color: #fff}.btn-primary{--bs-btn-color: #fff;--bs-btn-bg: #3459e6;--bs-btn-border-color: #3459e6;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #2c4cc4;--bs-btn-hover-border-color: #2a47b8;--bs-btn-focus-shadow-rgb: 82,114,234;--bs-btn-active-color: #fff;--bs-btn-active-bg: #2a47b8;--bs-btn-active-border-color: #2743ad;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #3459e6;--bs-btn-disabled-border-color: #3459e6}.btn-secondary,.btn-default:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']){--bs-btn-color: #000;--bs-btn-bg: #fff;--bs-btn-border-color: #fff;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #fff;--bs-btn-hover-border-color: #fff;--bs-btn-focus-shadow-rgb: 217,217,217;--bs-btn-active-color: #000;--bs-btn-active-bg: #fff;--bs-btn-active-border-color: #fff;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #000;--bs-btn-disabled-bg: #fff;--bs-btn-disabled-border-color: #fff}.btn-success{--bs-btn-color: #fff;--bs-btn-bg: #2fb380;--bs-btn-border-color: #2fb380;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #28986d;--bs-btn-hover-border-color: #268f66;--bs-btn-focus-shadow-rgb: 78,190,147;--bs-btn-active-color: #fff;--bs-btn-active-bg: #268f66;--bs-btn-active-border-color: #238660;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #2fb380;--bs-btn-disabled-border-color: #2fb380}.btn-info{--bs-btn-color: #fff;--bs-btn-bg: #287bb5;--bs-btn-border-color: #287bb5;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #22699a;--bs-btn-hover-border-color: #206291;--bs-btn-focus-shadow-rgb: 72,143,192;--bs-btn-active-color: #fff;--bs-btn-active-bg: #206291;--bs-btn-active-border-color: #1e5c88;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #287bb5;--bs-btn-disabled-border-color: #287bb5}.btn-warning{--bs-btn-color: #fff;--bs-btn-bg: #f4bd61;--bs-btn-border-color: #f4bd61;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #cfa152;--bs-btn-hover-border-color: #c3974e;--bs-btn-focus-shadow-rgb: 246,199,121;--bs-btn-active-color: #fff;--bs-btn-active-bg: #c3974e;--bs-btn-active-border-color: #b78e49;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #f4bd61;--bs-btn-disabled-border-color: #f4bd61}.btn-danger{--bs-btn-color: #fff;--bs-btn-bg: #da292e;--bs-btn-border-color: #da292e;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #b92327;--bs-btn-hover-border-color: #ae2125;--bs-btn-focus-shadow-rgb: 224,73,77;--bs-btn-active-color: #fff;--bs-btn-active-bg: #ae2125;--bs-btn-active-border-color: #a41f23;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #da292e;--bs-btn-disabled-border-color: #da292e}.btn-light{--bs-btn-color: #000;--bs-btn-bg: #f8f9fa;--bs-btn-border-color: #f8f9fa;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #d3d4d5;--bs-btn-hover-border-color: #c6c7c8;--bs-btn-focus-shadow-rgb: 211,212,213;--bs-btn-active-color: #fff;--bs-btn-active-bg: #c6c7c8;--bs-btn-active-border-color: #babbbc;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #000;--bs-btn-disabled-bg: #f8f9fa;--bs-btn-disabled-border-color: #f8f9fa}.btn-dark{--bs-btn-color: #fff;--bs-btn-bg: #212529;--bs-btn-border-color: #212529;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #424649;--bs-btn-hover-border-color: #373b3e;--bs-btn-focus-shadow-rgb: 66,70,73;--bs-btn-active-color: #fff;--bs-btn-active-bg: #4d5154;--bs-btn-active-border-color: #373b3e;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #212529;--bs-btn-disabled-border-color: #212529}.btn-outline-default{--bs-btn-color: #fff;--bs-btn-border-color: #fff;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #fff;--bs-btn-hover-border-color: #fff;--bs-btn-focus-shadow-rgb: 255,255,255;--bs-btn-active-color: #000;--bs-btn-active-bg: #fff;--bs-btn-active-border-color: #fff;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #fff;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-primary{--bs-btn-color: #3459e6;--bs-btn-border-color: #3459e6;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #3459e6;--bs-btn-hover-border-color: #3459e6;--bs-btn-focus-shadow-rgb: 52,89,230;--bs-btn-active-color: #fff;--bs-btn-active-bg: #3459e6;--bs-btn-active-border-color: #3459e6;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #3459e6;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #3459e6;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-secondary{--bs-btn-color: #fff;--bs-btn-border-color: #fff;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #fff;--bs-btn-hover-border-color: #fff;--bs-btn-focus-shadow-rgb: 255,255,255;--bs-btn-active-color: #000;--bs-btn-active-bg: #fff;--bs-btn-active-border-color: #fff;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #fff;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-success{--bs-btn-color: #2fb380;--bs-btn-border-color: #2fb380;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #2fb380;--bs-btn-hover-border-color: #2fb380;--bs-btn-focus-shadow-rgb: 47,179,128;--bs-btn-active-color: #fff;--bs-btn-active-bg: #2fb380;--bs-btn-active-border-color: #2fb380;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #2fb380;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #2fb380;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-info{--bs-btn-color: #287bb5;--bs-btn-border-color: #287bb5;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #287bb5;--bs-btn-hover-border-color: #287bb5;--bs-btn-focus-shadow-rgb: 40,123,181;--bs-btn-active-color: #fff;--bs-btn-active-bg: #287bb5;--bs-btn-active-border-color: #287bb5;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #287bb5;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #287bb5;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-warning{--bs-btn-color: #f4bd61;--bs-btn-border-color: #f4bd61;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #f4bd61;--bs-btn-hover-border-color: #f4bd61;--bs-btn-focus-shadow-rgb: 244,189,97;--bs-btn-active-color: #fff;--bs-btn-active-bg: #f4bd61;--bs-btn-active-border-color: #f4bd61;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #f4bd61;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #f4bd61;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-danger{--bs-btn-color: #da292e;--bs-btn-border-color: #da292e;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #da292e;--bs-btn-hover-border-color: #da292e;--bs-btn-focus-shadow-rgb: 218,41,46;--bs-btn-active-color: #fff;--bs-btn-active-bg: #da292e;--bs-btn-active-border-color: #da292e;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #da292e;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #da292e;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-light{--bs-btn-color: #f8f9fa;--bs-btn-border-color: #f8f9fa;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #f8f9fa;--bs-btn-hover-border-color: #f8f9fa;--bs-btn-focus-shadow-rgb: 248,249,250;--bs-btn-active-color: #000;--bs-btn-active-bg: #f8f9fa;--bs-btn-active-border-color: #f8f9fa;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #f8f9fa;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #f8f9fa;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-dark{--bs-btn-color: #212529;--bs-btn-border-color: #212529;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #212529;--bs-btn-hover-border-color: #212529;--bs-btn-focus-shadow-rgb: 33,37,41;--bs-btn-active-color: #fff;--bs-btn-active-bg: #212529;--bs-btn-active-border-color: #212529;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #212529;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #212529;--bs-btn-bg: transparent;--bs-gradient: none}.btn-link{--bs-btn-font-weight: 400;--bs-btn-color: var(--bs-link-color);--bs-btn-bg: transparent;--bs-btn-border-color: transparent;--bs-btn-hover-color: var(--bs-link-hover-color);--bs-btn-hover-border-color: transparent;--bs-btn-active-color: var(--bs-link-hover-color);--bs-btn-active-border-color: transparent;--bs-btn-disabled-color: #6c757d;--bs-btn-disabled-border-color: transparent;--bs-btn-box-shadow: 0 0 0 #000;--bs-btn-focus-shadow-rgb: 82,114,234;text-decoration:underline;-webkit-text-decoration:underline;-moz-text-decoration:underline;-ms-text-decoration:underline;-o-text-decoration:underline}.btn-link:focus-visible{color:var(--bs-btn-color)}.btn-link:hover{color:var(--bs-btn-hover-color)}.btn-lg,.btn-group-lg>.btn{--bs-btn-padding-y: .5rem;--bs-btn-padding-x: 1rem;--bs-btn-font-size:1.25rem;--bs-btn-border-radius: var(--bs-border-radius-lg)}.btn-sm,.btn-group-sm>.btn{--bs-btn-padding-y: .25rem;--bs-btn-padding-x: .5rem;--bs-btn-font-size:.875rem;--bs-btn-border-radius: var(--bs-border-radius-sm)}.fade{transition:opacity 0.15s linear}@media (prefers-reduced-motion: reduce){.fade{transition:none}}.fade:not(.show){opacity:0}.collapse:not(.show){display:none}.collapsing{height:0;overflow:hidden;transition:height 0.35s ease}@media (prefers-reduced-motion: reduce){.collapsing{transition:none}}.collapsing.collapse-horizontal{width:0;height:auto;transition:width 0.35s ease}@media (prefers-reduced-motion: reduce){.collapsing.collapse-horizontal{transition:none}}.dropup,.dropend,.dropdown,.dropstart,.dropup-center,.dropdown-center{position:relative}.dropdown-toggle{white-space:nowrap}.dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:.3em solid;border-right:.3em solid transparent;border-bottom:0;border-left:.3em solid transparent}.dropdown-toggle:empty::after{margin-left:0}.dropdown-menu{--bs-dropdown-zindex: 1000;--bs-dropdown-min-width: 10rem;--bs-dropdown-padding-x: 0;--bs-dropdown-padding-y: .5rem;--bs-dropdown-spacer: .125rem;--bs-dropdown-font-size:.875rem;--bs-dropdown-color: var(--bs-body-color);--bs-dropdown-bg: var(--bs-body-bg);--bs-dropdown-border-color: #dee2e6;--bs-dropdown-border-radius: var(--bs-border-radius);--bs-dropdown-border-width: var(--bs-border-width);--bs-dropdown-inner-border-radius: calc(var(--bs-border-radius) - var(--bs-border-width));--bs-dropdown-divider-bg: #e9ecef;--bs-dropdown-divider-margin-y: .5rem;--bs-dropdown-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-dropdown-link-color: var(--bs-body-color);--bs-dropdown-link-hover-color: #fff;--bs-dropdown-link-hover-bg: #3459e6;--bs-dropdown-link-active-color: #fff;--bs-dropdown-link-active-bg: #3459e6;--bs-dropdown-link-disabled-color: var(--bs-tertiary-color);--bs-dropdown-item-padding-x: 1rem;--bs-dropdown-item-padding-y: .5rem;--bs-dropdown-header-color: #6c757d;--bs-dropdown-header-padding-x: 1rem;--bs-dropdown-header-padding-y: .5rem;position:absolute;z-index:var(--bs-dropdown-zindex);display:none;min-width:var(--bs-dropdown-min-width);padding:var(--bs-dropdown-padding-y) var(--bs-dropdown-padding-x);margin:0;font-size:var(--bs-dropdown-font-size);color:var(--bs-dropdown-color);text-align:left;list-style:none;background-color:var(--bs-dropdown-bg);background-clip:padding-box;border:var(--bs-dropdown-border-width) solid var(--bs-dropdown-border-color);border-radius:var(--bs-dropdown-border-radius);box-shadow:var(--bs-dropdown-box-shadow)}.dropdown-menu[data-bs-popper]{top:100%;left:0;margin-top:var(--bs-dropdown-spacer)}.dropdown-menu-start{--bs-position: start}.dropdown-menu-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-end{--bs-position: end}.dropdown-menu-end[data-bs-popper]{right:0;left:auto}@media (min-width: 576px){.dropdown-menu-sm-start{--bs-position: start}.dropdown-menu-sm-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-sm-end{--bs-position: end}.dropdown-menu-sm-end[data-bs-popper]{right:0;left:auto}}@media (min-width: 768px){.dropdown-menu-md-start{--bs-position: start}.dropdown-menu-md-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-md-end{--bs-position: end}.dropdown-menu-md-end[data-bs-popper]{right:0;left:auto}}@media (min-width: 992px){.dropdown-menu-lg-start{--bs-position: start}.dropdown-menu-lg-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-lg-end{--bs-position: end}.dropdown-menu-lg-end[data-bs-popper]{right:0;left:auto}}@media (min-width: 1200px){.dropdown-menu-xl-start{--bs-position: start}.dropdown-menu-xl-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-xl-end{--bs-position: end}.dropdown-menu-xl-end[data-bs-popper]{right:0;left:auto}}@media (min-width: 1400px){.dropdown-menu-xxl-start{--bs-position: start}.dropdown-menu-xxl-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-xxl-end{--bs-position: end}.dropdown-menu-xxl-end[data-bs-popper]{right:0;left:auto}}.dropup .dropdown-menu[data-bs-popper]{top:auto;bottom:100%;margin-top:0;margin-bottom:var(--bs-dropdown-spacer)}.dropup .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:0;border-right:.3em solid transparent;border-bottom:.3em solid;border-left:.3em solid transparent}.dropup .dropdown-toggle:empty::after{margin-left:0}.dropend .dropdown-menu[data-bs-popper]{top:0;right:auto;left:100%;margin-top:0;margin-left:var(--bs-dropdown-spacer)}.dropend .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:.3em solid transparent;border-right:0;border-bottom:.3em solid transparent;border-left:.3em solid}.dropend .dropdown-toggle:empty::after{margin-left:0}.dropend .dropdown-toggle::after{vertical-align:0}.dropstart .dropdown-menu[data-bs-popper]{top:0;right:100%;left:auto;margin-top:0;margin-right:var(--bs-dropdown-spacer)}.dropstart .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:""}.dropstart .dropdown-toggle::after{display:none}.dropstart .dropdown-toggle::before{display:inline-block;margin-right:.255em;vertical-align:.255em;content:"";border-top:.3em solid transparent;border-right:.3em solid;border-bottom:.3em solid transparent}.dropstart .dropdown-toggle:empty::after{margin-left:0}.dropstart .dropdown-toggle::before{vertical-align:0}.dropdown-divider{height:0;margin:var(--bs-dropdown-divider-margin-y) 0;overflow:hidden;border-top:1px solid var(--bs-dropdown-divider-bg);opacity:1}.dropdown-item{display:block;width:100%;padding:var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);clear:both;font-weight:400;color:var(--bs-dropdown-link-color);text-align:inherit;text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;white-space:nowrap;background-color:transparent;border:0;border-radius:var(--bs-dropdown-item-border-radius, 0)}.dropdown-item:hover,.dropdown-item:focus{color:var(--bs-dropdown-link-hover-color);background-color:var(--bs-dropdown-link-hover-bg)}.dropdown-item.active,.dropdown-item:active{color:var(--bs-dropdown-link-active-color);text-decoration:none;background-color:var(--bs-dropdown-link-active-bg)}.dropdown-item.disabled,.dropdown-item:disabled{color:var(--bs-dropdown-link-disabled-color);pointer-events:none;background-color:transparent}.dropdown-menu.show{display:block}.dropdown-header{display:block;padding:var(--bs-dropdown-header-padding-y) var(--bs-dropdown-header-padding-x);margin-bottom:0;font-size:.875rem;color:var(--bs-dropdown-header-color);white-space:nowrap}.dropdown-item-text{display:block;padding:var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);color:var(--bs-dropdown-link-color)}.dropdown-menu-dark{--bs-dropdown-color: #dee2e6;--bs-dropdown-bg: #343a40;--bs-dropdown-border-color: #dee2e6;--bs-dropdown-box-shadow: ;--bs-dropdown-link-color: #dee2e6;--bs-dropdown-link-hover-color: #fff;--bs-dropdown-divider-bg: #e9ecef;--bs-dropdown-link-hover-bg: rgba(255,255,255,0.15);--bs-dropdown-link-active-color: #fff;--bs-dropdown-link-active-bg: #3459e6;--bs-dropdown-link-disabled-color: #adb5bd;--bs-dropdown-header-color: #adb5bd}.btn-group,.btn-group-vertical{position:relative;display:inline-flex;vertical-align:middle}.btn-group>.btn,.btn-group-vertical>.btn{position:relative;flex:1 1 auto;-webkit-flex:1 1 auto}.btn-group>.btn-check:checked+.btn,.btn-group>.btn-check:focus+.btn,.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active,.btn-group-vertical>.btn-check:checked+.btn,.btn-group-vertical>.btn-check:focus+.btn,.btn-group-vertical>.btn:hover,.btn-group-vertical>.btn:focus,.btn-group-vertical>.btn:active,.btn-group-vertical>.btn.active{z-index:1}.btn-toolbar{display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;justify-content:flex-start;-webkit-justify-content:flex-start}.btn-toolbar .input-group{width:auto}.btn-group{border-radius:var(--bs-border-radius)}.btn-group>:not(.btn-check:first-child)+.btn,.btn-group>.btn-group:not(:first-child){margin-left:calc(var(--bs-border-width) * -1)}.btn-group>.btn:not(:last-child):not(.dropdown-toggle),.btn-group>.btn.dropdown-toggle-split:first-child,.btn-group>.btn-group:not(:last-child)>.btn{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:nth-child(n + 3),.btn-group>:not(.btn-check)+.btn,.btn-group>.btn-group:not(:first-child)>.btn{border-top-left-radius:0;border-bottom-left-radius:0}.dropdown-toggle-split{padding-right:.75rem;padding-left:.75rem}.dropdown-toggle-split::after,.dropup .dropdown-toggle-split::after,.dropend .dropdown-toggle-split::after{margin-left:0}.dropstart .dropdown-toggle-split::before{margin-right:0}.btn-sm+.dropdown-toggle-split,.btn-group-sm>.btn+.dropdown-toggle-split{padding-right:.375rem;padding-left:.375rem}.btn-lg+.dropdown-toggle-split,.btn-group-lg>.btn+.dropdown-toggle-split{padding-right:.75rem;padding-left:.75rem}.btn-group.show .dropdown-toggle{box-shadow:0 1px 2px rgba(0,0,0,0.05)}.btn-group.show .dropdown-toggle.btn-link{box-shadow:none}.btn-group-vertical{flex-direction:column;-webkit-flex-direction:column;align-items:flex-start;-webkit-align-items:flex-start;justify-content:center;-webkit-justify-content:center}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group{width:100%}.btn-group-vertical>.btn:not(:first-child),.btn-group-vertical>.btn-group:not(:first-child){margin-top:calc(var(--bs-border-width) * -1)}.btn-group-vertical>.btn:not(:last-child):not(.dropdown-toggle),.btn-group-vertical>.btn-group:not(:last-child)>.btn{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn~.btn,.btn-group-vertical>.btn-group:not(:first-child)>.btn{border-top-left-radius:0;border-top-right-radius:0}.nav{--bs-nav-link-padding-x: 1rem;--bs-nav-link-padding-y: .5rem;--bs-nav-link-font-weight: ;--bs-nav-link-color: #495057;--bs-nav-link-hover-color: #495057;--bs-nav-link-disabled-color: var(--bs-secondary-color);display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;padding-left:0;margin-bottom:0;list-style:none}.nav-link{display:block;padding:var(--bs-nav-link-padding-y) var(--bs-nav-link-padding-x);font-size:var(--bs-nav-link-font-size);font-weight:var(--bs-nav-link-font-weight);color:var(--bs-nav-link-color);text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;background:none;border:0;transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.nav-link{transition:none}}.nav-link:hover,.nav-link:focus{color:var(--bs-nav-link-hover-color)}.nav-link:focus-visible{outline:0;box-shadow:0 0 0 .25rem rgba(52,89,230,0.25)}.nav-link.disabled,.nav-link:disabled{color:var(--bs-nav-link-disabled-color);pointer-events:none;cursor:default}.nav-tabs{--bs-nav-tabs-border-width: var(--bs-border-width);--bs-nav-tabs-border-color: var(--bs-border-color);--bs-nav-tabs-border-radius: 0;--bs-nav-tabs-link-hover-border-color: var(--bs-secondary-bg) var(--bs-secondary-bg) var(--bs-border-color);--bs-nav-tabs-link-active-color: #3459e6;--bs-nav-tabs-link-active-bg: var(--bs-body-bg);--bs-nav-tabs-link-active-border-color: var(--bs-border-color) var(--bs-border-color) var(--bs-body-bg);border-bottom:var(--bs-nav-tabs-border-width) solid var(--bs-nav-tabs-border-color)}.nav-tabs .nav-link{margin-bottom:calc(-1 * var(--bs-nav-tabs-border-width));border:var(--bs-nav-tabs-border-width) solid transparent;border-top-left-radius:var(--bs-nav-tabs-border-radius);border-top-right-radius:var(--bs-nav-tabs-border-radius)}.nav-tabs .nav-link:hover,.nav-tabs .nav-link:focus{isolation:isolate;border-color:var(--bs-nav-tabs-link-hover-border-color)}.nav-tabs .nav-link.active,.nav-tabs .nav-item.show .nav-link{color:var(--bs-nav-tabs-link-active-color);background-color:var(--bs-nav-tabs-link-active-bg);border-color:var(--bs-nav-tabs-link-active-border-color)}.nav-tabs .dropdown-menu{margin-top:calc(-1 * var(--bs-nav-tabs-border-width));border-top-left-radius:0;border-top-right-radius:0}.nav-pills{--bs-nav-pills-border-radius: var(--bs-border-radius);--bs-nav-pills-link-active-color: #fff;--bs-nav-pills-link-active-bg: #3459e6}.nav-pills .nav-link{border-radius:var(--bs-nav-pills-border-radius)}.nav-pills .nav-link.active,.nav-pills .show>.nav-link{color:var(--bs-nav-pills-link-active-color);background-color:var(--bs-nav-pills-link-active-bg)}.nav-underline{--bs-nav-underline-gap: 1rem;--bs-nav-underline-border-width: .125rem;--bs-nav-underline-link-active-color: var(--bs-emphasis-color);gap:var(--bs-nav-underline-gap)}.nav-underline .nav-link{padding-right:0;padding-left:0;border-bottom:var(--bs-nav-underline-border-width) solid transparent}.nav-underline .nav-link:hover,.nav-underline .nav-link:focus{border-bottom-color:currentcolor}.nav-underline .nav-link.active,.nav-underline .show>.nav-link{font-weight:700;color:var(--bs-nav-underline-link-active-color);border-bottom-color:currentcolor}.nav-fill>.nav-link,.nav-fill .nav-item{flex:1 1 auto;-webkit-flex:1 1 auto;text-align:center}.nav-justified>.nav-link,.nav-justified .nav-item{flex-basis:0;-webkit-flex-basis:0;flex-grow:1;-webkit-flex-grow:1;text-align:center}.nav-fill .nav-item .nav-link,.nav-justified .nav-item .nav-link{width:100%}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.navbar{--bs-navbar-padding-x: 0;--bs-navbar-padding-y: .85rem;--bs-navbar-color: rgba(var(--bs-emphasis-color-rgb), 0.65);--bs-navbar-hover-color: rgba(var(--bs-emphasis-color-rgb), 0.8);--bs-navbar-disabled-color: rgba(var(--bs-emphasis-color-rgb), 0.3);--bs-navbar-active-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-padding-y: .3125rem;--bs-navbar-brand-margin-end: 1rem;--bs-navbar-brand-font-size: 1.25rem;--bs-navbar-brand-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-hover-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-nav-link-padding-x: .75rem;--bs-navbar-toggler-padding-y: .25rem;--bs-navbar-toggler-padding-x: .75rem;--bs-navbar-toggler-font-size: 1.25rem;--bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2873,80,87,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");--bs-navbar-toggler-border-color: rgba(var(--bs-emphasis-color-rgb), 0.15);--bs-navbar-toggler-border-radius: var(--bs-border-radius);--bs-navbar-toggler-focus-width: .25rem;--bs-navbar-toggler-transition: box-shadow 0.15s ease-in-out;position:relative;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;align-items:center;-webkit-align-items:center;justify-content:space-between;-webkit-justify-content:space-between;padding:var(--bs-navbar-padding-y) var(--bs-navbar-padding-x)}.navbar>.container,.navbar>.container-fluid,.navbar>.container-sm,.navbar>.container-md,.navbar>.container-lg,.navbar>.container-xl,.navbar>.container-xxl{display:flex;display:-webkit-flex;flex-wrap:inherit;-webkit-flex-wrap:inherit;align-items:center;-webkit-align-items:center;justify-content:space-between;-webkit-justify-content:space-between}.navbar-brand{padding-top:var(--bs-navbar-brand-padding-y);padding-bottom:var(--bs-navbar-brand-padding-y);margin-right:var(--bs-navbar-brand-margin-end);font-size:var(--bs-navbar-brand-font-size);color:var(--bs-navbar-brand-color);text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;white-space:nowrap}.navbar-brand:hover,.navbar-brand:focus{color:var(--bs-navbar-brand-hover-color)}.navbar-nav{--bs-nav-link-padding-x: 0;--bs-nav-link-padding-y: .5rem;--bs-nav-link-font-weight: ;--bs-nav-link-color: var(--bs-navbar-color);--bs-nav-link-hover-color: var(--bs-navbar-hover-color);--bs-nav-link-disabled-color: var(--bs-navbar-disabled-color);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;padding-left:0;margin-bottom:0;list-style:none}.navbar-nav .nav-link.active,.navbar-nav .nav-link.show{color:var(--bs-navbar-active-color)}.navbar-nav .dropdown-menu{position:static}.navbar-text{padding-top:.5rem;padding-bottom:.5rem;color:var(--bs-navbar-color)}.navbar-text a,.navbar-text a:hover,.navbar-text a:focus{color:var(--bs-navbar-active-color)}.navbar-collapse{flex-basis:100%;-webkit-flex-basis:100%;flex-grow:1;-webkit-flex-grow:1;align-items:center;-webkit-align-items:center}.navbar-toggler{padding:var(--bs-navbar-toggler-padding-y) var(--bs-navbar-toggler-padding-x);font-size:var(--bs-navbar-toggler-font-size);line-height:1;color:var(--bs-navbar-color);background-color:transparent;border:var(--bs-border-width) solid var(--bs-navbar-toggler-border-color);border-radius:var(--bs-navbar-toggler-border-radius);transition:var(--bs-navbar-toggler-transition)}@media (prefers-reduced-motion: reduce){.navbar-toggler{transition:none}}.navbar-toggler:hover{text-decoration:none}.navbar-toggler:focus{text-decoration:none;outline:0;box-shadow:0 0 0 var(--bs-navbar-toggler-focus-width)}.navbar-toggler-icon{display:inline-block;width:1.5em;height:1.5em;vertical-align:middle;background-image:var(--bs-navbar-toggler-icon-bg);background-repeat:no-repeat;background-position:center;background-size:100%}.navbar-nav-scroll{max-height:var(--bs-scroll-height, 75vh);overflow-y:auto}@media (min-width: 576px){.navbar-expand-sm{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-sm .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-sm .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-sm .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-sm .navbar-nav-scroll{overflow:visible}.navbar-expand-sm .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-sm .navbar-toggler{display:none}.navbar-expand-sm .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-sm .offcanvas .offcanvas-header{display:none}.navbar-expand-sm .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}@media (min-width: 768px){.navbar-expand-md{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-md .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-md .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-md .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-md .navbar-nav-scroll{overflow:visible}.navbar-expand-md .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-md .navbar-toggler{display:none}.navbar-expand-md .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-md .offcanvas .offcanvas-header{display:none}.navbar-expand-md .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}@media (min-width: 992px){.navbar-expand-lg{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-lg .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-lg .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-lg .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-lg .navbar-nav-scroll{overflow:visible}.navbar-expand-lg .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-lg .navbar-toggler{display:none}.navbar-expand-lg .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-lg .offcanvas .offcanvas-header{display:none}.navbar-expand-lg .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}@media (min-width: 1200px){.navbar-expand-xl{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-xl .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-xl .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-xl .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-xl .navbar-nav-scroll{overflow:visible}.navbar-expand-xl .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-xl .navbar-toggler{display:none}.navbar-expand-xl .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-xl .offcanvas .offcanvas-header{display:none}.navbar-expand-xl .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}@media (min-width: 1400px){.navbar-expand-xxl{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-xxl .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-xxl .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-xxl .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-xxl .navbar-nav-scroll{overflow:visible}.navbar-expand-xxl .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-xxl .navbar-toggler{display:none}.navbar-expand-xxl .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-xxl .offcanvas .offcanvas-header{display:none}.navbar-expand-xxl .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}.navbar-expand{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand .navbar-nav .dropdown-menu{position:absolute}.navbar-expand .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand .navbar-nav-scroll{overflow:visible}.navbar-expand .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand .navbar-toggler{display:none}.navbar-expand .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand .offcanvas .offcanvas-header{display:none}.navbar-expand .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}.navbar-dark,.navbar[data-bs-theme="dark"]{--bs-navbar-color: rgba(var(--bs-emphasis-color-rgb), 0.55);--bs-navbar-hover-color: rgba(var(--bs-emphasis-color-rgb), 0.75);--bs-navbar-disabled-color: rgba(var(--bs-emphasis-color-rgb), 0.25);--bs-navbar-active-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-hover-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-toggler-border-color: rgba(var(--bs-emphasis-color-rgb), 0.1);--bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")}[data-bs-theme="dark"] .navbar-toggler-icon{--bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")}.card{--bs-card-spacer-y: 1rem;--bs-card-spacer-x: 1.5rem;--bs-card-title-spacer-y: .5rem;--bs-card-title-color: ;--bs-card-subtitle-color: ;--bs-card-border-width: var(--bs-border-width);--bs-card-border-color: var(--bs-border-color-translucent);--bs-card-border-radius: var(--bs-border-radius);--bs-card-box-shadow: ;--bs-card-inner-border-radius: calc(var(--bs-border-radius) - (var(--bs-border-width)));--bs-card-cap-padding-y: 1rem;--bs-card-cap-padding-x: 1.5rem;--bs-card-cap-bg: rgba(var(--bs-body-color-rgb), 0.03);--bs-card-cap-color: ;--bs-card-height: ;--bs-card-color: ;--bs-card-bg: var(--bs-body-bg);--bs-card-img-overlay-padding: 1rem;--bs-card-group-margin: .75rem;position:relative;display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;min-width:0;height:var(--bs-card-height);color:var(--bs-body-color);word-wrap:break-word;background-color:var(--bs-card-bg);background-clip:border-box;border:var(--bs-card-border-width) solid var(--bs-card-border-color);border-radius:var(--bs-card-border-radius);box-shadow:var(--bs-card-box-shadow)}.card>hr{margin-right:0;margin-left:0}.card>.list-group{border-top:inherit;border-bottom:inherit}.card>.list-group:first-child{border-top-width:0;border-top-left-radius:var(--bs-card-inner-border-radius);border-top-right-radius:var(--bs-card-inner-border-radius)}.card>.list-group:last-child{border-bottom-width:0;border-bottom-right-radius:var(--bs-card-inner-border-radius);border-bottom-left-radius:var(--bs-card-inner-border-radius)}.card>.card-header+.list-group,.card>.list-group+.card-footer{border-top:0}.card-body{flex:1 1 auto;-webkit-flex:1 1 auto;padding:var(--bs-card-spacer-y) var(--bs-card-spacer-x);color:var(--bs-card-color)}.card-title{margin-bottom:var(--bs-card-title-spacer-y);color:var(--bs-card-title-color)}.card-subtitle{margin-top:calc(-.5 * var(--bs-card-title-spacer-y));margin-bottom:0;color:var(--bs-card-subtitle-color)}.card-text:last-child{margin-bottom:0}.card-link+.card-link{margin-left:var(--bs-card-spacer-x)}.card-header{padding:var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x);margin-bottom:0;color:var(--bs-card-cap-color);background-color:var(--bs-card-cap-bg);border-bottom:var(--bs-card-border-width) solid var(--bs-card-border-color)}.card-header:first-child{border-radius:var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0}.card-footer{padding:var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x);color:var(--bs-card-cap-color);background-color:var(--bs-card-cap-bg);border-top:var(--bs-card-border-width) solid var(--bs-card-border-color)}.card-footer:last-child{border-radius:0 0 var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius)}.card-header-tabs{margin-right:calc(-.5 * var(--bs-card-cap-padding-x));margin-bottom:calc(-1 * var(--bs-card-cap-padding-y));margin-left:calc(-.5 * var(--bs-card-cap-padding-x));border-bottom:0}.card-header-tabs .nav-link.active{background-color:var(--bs-card-bg);border-bottom-color:var(--bs-card-bg)}.card-header-pills{margin-right:calc(-.5 * var(--bs-card-cap-padding-x));margin-left:calc(-.5 * var(--bs-card-cap-padding-x))}.card-img-overlay{position:absolute;top:0;right:0;bottom:0;left:0;padding:var(--bs-card-img-overlay-padding);border-radius:var(--bs-card-inner-border-radius)}.card-img,.card-img-top,.card-img-bottom{width:100%}.card-img,.card-img-top{border-top-left-radius:var(--bs-card-inner-border-radius);border-top-right-radius:var(--bs-card-inner-border-radius)}.card-img,.card-img-bottom{border-bottom-right-radius:var(--bs-card-inner-border-radius);border-bottom-left-radius:var(--bs-card-inner-border-radius)}.card-group>.card{margin-bottom:var(--bs-card-group-margin)}@media (min-width: 576px){.card-group{display:flex;display:-webkit-flex;flex-flow:row wrap;-webkit-flex-flow:row wrap}.card-group>.card{flex:1 0 0%;-webkit-flex:1 0 0%;margin-bottom:0}.card-group>.card+.card{margin-left:0;border-left:0}.card-group>.card:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}.card-group>.card:not(:last-child) .card-img-top,.card-group>.card:not(:last-child) .card-header{border-top-right-radius:0}.card-group>.card:not(:last-child) .card-img-bottom,.card-group>.card:not(:last-child) .card-footer{border-bottom-right-radius:0}.card-group>.card:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0}.card-group>.card:not(:first-child) .card-img-top,.card-group>.card:not(:first-child) .card-header{border-top-left-radius:0}.card-group>.card:not(:first-child) .card-img-bottom,.card-group>.card:not(:first-child) .card-footer{border-bottom-left-radius:0}}.accordion{--bs-accordion-color: var(--bs-body-color);--bs-accordion-bg: var(--bs-body-bg);--bs-accordion-transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,border-radius 0.15s ease;--bs-accordion-border-color: var(--bs-border-color);--bs-accordion-border-width: var(--bs-border-width);--bs-accordion-border-radius: var(--bs-border-radius);--bs-accordion-inner-border-radius: calc(var(--bs-border-radius) - (var(--bs-border-width)));--bs-accordion-btn-padding-x: 1.25rem;--bs-accordion-btn-padding-y: 1rem;--bs-accordion-btn-color: var(--bs-body-color);--bs-accordion-btn-bg: var(--bs-accordion-bg);--bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23495057'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");--bs-accordion-btn-icon-width: 1.25rem;--bs-accordion-btn-icon-transform: rotate(-180deg);--bs-accordion-btn-icon-transition: transform 0.2s ease-in-out;--bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2315245c'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");--bs-accordion-btn-focus-border-color: #9aacf3;--bs-accordion-btn-focus-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-accordion-body-padding-x: 1.25rem;--bs-accordion-body-padding-y: 1rem;--bs-accordion-active-color: var(--bs-primary-text-emphasis);--bs-accordion-active-bg: var(--bs-primary-bg-subtle)}.accordion-button{position:relative;display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;width:100%;padding:var(--bs-accordion-btn-padding-y) var(--bs-accordion-btn-padding-x);font-size:1rem;color:var(--bs-accordion-btn-color);text-align:left;background-color:var(--bs-accordion-btn-bg);border:0;border-radius:0;overflow-anchor:none;transition:var(--bs-accordion-transition)}@media (prefers-reduced-motion: reduce){.accordion-button{transition:none}}.accordion-button:not(.collapsed){color:var(--bs-accordion-active-color);background-color:var(--bs-accordion-active-bg);box-shadow:inset 0 calc(-1 * var(--bs-accordion-border-width)) 0 var(--bs-accordion-border-color)}.accordion-button:not(.collapsed)::after{background-image:var(--bs-accordion-btn-active-icon);transform:var(--bs-accordion-btn-icon-transform)}.accordion-button::after{flex-shrink:0;-webkit-flex-shrink:0;width:var(--bs-accordion-btn-icon-width);height:var(--bs-accordion-btn-icon-width);margin-left:auto;content:"";background-image:var(--bs-accordion-btn-icon);background-repeat:no-repeat;background-size:var(--bs-accordion-btn-icon-width);transition:var(--bs-accordion-btn-icon-transition)}@media (prefers-reduced-motion: reduce){.accordion-button::after{transition:none}}.accordion-button:hover{z-index:2}.accordion-button:focus{z-index:3;border-color:var(--bs-accordion-btn-focus-border-color);outline:0;box-shadow:var(--bs-accordion-btn-focus-box-shadow)}.accordion-header{margin-bottom:0}.accordion-item{color:var(--bs-accordion-color);background-color:var(--bs-accordion-bg);border:var(--bs-accordion-border-width) solid var(--bs-accordion-border-color)}.accordion-item:first-of-type{border-top-left-radius:var(--bs-accordion-border-radius);border-top-right-radius:var(--bs-accordion-border-radius)}.accordion-item:first-of-type .accordion-button{border-top-left-radius:var(--bs-accordion-inner-border-radius);border-top-right-radius:var(--bs-accordion-inner-border-radius)}.accordion-item:not(:first-of-type){border-top:0}.accordion-item:last-of-type{border-bottom-right-radius:var(--bs-accordion-border-radius);border-bottom-left-radius:var(--bs-accordion-border-radius)}.accordion-item:last-of-type .accordion-button.collapsed{border-bottom-right-radius:var(--bs-accordion-inner-border-radius);border-bottom-left-radius:var(--bs-accordion-inner-border-radius)}.accordion-item:last-of-type .accordion-collapse{border-bottom-right-radius:var(--bs-accordion-border-radius);border-bottom-left-radius:var(--bs-accordion-border-radius)}.accordion-body{padding:var(--bs-accordion-body-padding-y) var(--bs-accordion-body-padding-x)}.accordion-flush .accordion-collapse{border-width:0}.accordion-flush .accordion-item{border-right:0;border-left:0;border-radius:0}.accordion-flush .accordion-item:first-child{border-top:0}.accordion-flush .accordion-item:last-child{border-bottom:0}.accordion-flush .accordion-item .accordion-button,.accordion-flush .accordion-item .accordion-button.collapsed{border-radius:0}[data-bs-theme="dark"] .accordion-button::after{--bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23859bf0'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");--bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23859bf0'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e")}.breadcrumb{--bs-breadcrumb-padding-x: 1rem;--bs-breadcrumb-padding-y: 0;--bs-breadcrumb-margin-bottom: 1rem;--bs-breadcrumb-bg: ;--bs-breadcrumb-border-radius: ;--bs-breadcrumb-divider-color: var(--bs-secondary-color);--bs-breadcrumb-item-padding-x: .5rem;--bs-breadcrumb-item-active-color: var(--bs-secondary-color);display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;padding:var(--bs-breadcrumb-padding-y) var(--bs-breadcrumb-padding-x);margin-bottom:var(--bs-breadcrumb-margin-bottom);font-size:var(--bs-breadcrumb-font-size);list-style:none;background-color:var(--bs-breadcrumb-bg);border-radius:var(--bs-breadcrumb-border-radius)}.breadcrumb-item+.breadcrumb-item{padding-left:var(--bs-breadcrumb-item-padding-x)}.breadcrumb-item+.breadcrumb-item::before{float:left;padding-right:var(--bs-breadcrumb-item-padding-x);color:var(--bs-breadcrumb-divider-color);content:var(--bs-breadcrumb-divider, ">") /* rtl: var(--bs-breadcrumb-divider, ">") */}.breadcrumb-item.active{color:var(--bs-breadcrumb-item-active-color)}.pagination{--bs-pagination-padding-x: 1rem;--bs-pagination-padding-y: .5rem;--bs-pagination-font-size:1rem;--bs-pagination-color: #495057;--bs-pagination-bg: var(--bs-body-bg);--bs-pagination-border-width: var(--bs-border-width);--bs-pagination-border-color: var(--bs-border-color);--bs-pagination-border-radius: var(--bs-border-radius);--bs-pagination-hover-color: #495057;--bs-pagination-hover-bg: #f8f9fa;--bs-pagination-hover-border-color: var(--bs-border-color);--bs-pagination-focus-color: #495057;--bs-pagination-focus-bg: var(--bs-secondary-bg);--bs-pagination-focus-box-shadow: 0 0 0 .25rem rgba(52,89,230,0.25);--bs-pagination-active-color: #fff;--bs-pagination-active-bg: #3459e6;--bs-pagination-active-border-color: #3459e6;--bs-pagination-disabled-color: var(--bs-secondary-color);--bs-pagination-disabled-bg: var(--bs-secondary-bg);--bs-pagination-disabled-border-color: var(--bs-border-color);display:flex;display:-webkit-flex;padding-left:0;list-style:none}.page-link{position:relative;display:block;padding:var(--bs-pagination-padding-y) var(--bs-pagination-padding-x);font-size:var(--bs-pagination-font-size);color:var(--bs-pagination-color);text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;background-color:var(--bs-pagination-bg);border:var(--bs-pagination-border-width) solid var(--bs-pagination-border-color);transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.page-link{transition:none}}.page-link:hover{z-index:2;color:var(--bs-pagination-hover-color);background-color:var(--bs-pagination-hover-bg);border-color:var(--bs-pagination-hover-border-color)}.page-link:focus{z-index:3;color:var(--bs-pagination-focus-color);background-color:var(--bs-pagination-focus-bg);outline:0;box-shadow:var(--bs-pagination-focus-box-shadow)}.page-link.active,.active>.page-link{z-index:3;color:var(--bs-pagination-active-color);background-color:var(--bs-pagination-active-bg);border-color:var(--bs-pagination-active-border-color)}.page-link.disabled,.disabled>.page-link{color:var(--bs-pagination-disabled-color);pointer-events:none;background-color:var(--bs-pagination-disabled-bg);border-color:var(--bs-pagination-disabled-border-color)}.page-item:not(:first-child) .page-link{margin-left:calc(var(--bs-border-width) * -1)}.page-item:first-child .page-link{border-top-left-radius:var(--bs-pagination-border-radius);border-bottom-left-radius:var(--bs-pagination-border-radius)}.page-item:last-child .page-link{border-top-right-radius:var(--bs-pagination-border-radius);border-bottom-right-radius:var(--bs-pagination-border-radius)}.pagination-lg{--bs-pagination-padding-x: 1.5rem;--bs-pagination-padding-y: .75rem;--bs-pagination-font-size:1.25rem;--bs-pagination-border-radius: var(--bs-border-radius-lg)}.pagination-sm{--bs-pagination-padding-x: .5rem;--bs-pagination-padding-y: .25rem;--bs-pagination-font-size:.875rem;--bs-pagination-border-radius: var(--bs-border-radius-sm)}.badge{--bs-badge-padding-x: .65em;--bs-badge-padding-y: .35em;--bs-badge-font-size:.75em;--bs-badge-font-weight: 700;--bs-badge-color: #fff;--bs-badge-border-radius: var(--bs-border-radius);display:inline-block;padding:var(--bs-badge-padding-y) var(--bs-badge-padding-x);font-size:var(--bs-badge-font-size);font-weight:var(--bs-badge-font-weight);line-height:1;color:var(--bs-badge-color);text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:var(--bs-badge-border-radius)}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}.alert{--bs-alert-bg: transparent;--bs-alert-padding-x: 1rem;--bs-alert-padding-y: 1rem;--bs-alert-margin-bottom: 1rem;--bs-alert-color: inherit;--bs-alert-border-color: transparent;--bs-alert-border: var(--bs-border-width) solid var(--bs-alert-border-color);--bs-alert-border-radius: var(--bs-border-radius);--bs-alert-link-color: inherit;position:relative;padding:var(--bs-alert-padding-y) var(--bs-alert-padding-x);margin-bottom:var(--bs-alert-margin-bottom);color:var(--bs-alert-color);background-color:var(--bs-alert-bg);border:var(--bs-alert-border);border-radius:var(--bs-alert-border-radius)}.alert-heading{color:inherit}.alert-link{font-weight:700;color:var(--bs-alert-link-color)}.alert-dismissible{padding-right:3rem}.alert-dismissible .btn-close{position:absolute;top:0;right:0;z-index:2;padding:1.25rem 1rem}.alert-default{--bs-alert-color: var(--bs-default-text-emphasis);--bs-alert-bg: var(--bs-default-bg-subtle);--bs-alert-border-color: var(--bs-default-border-subtle);--bs-alert-link-color: var(--bs-default-text-emphasis)}.alert-primary{--bs-alert-color: var(--bs-primary-text-emphasis);--bs-alert-bg: var(--bs-primary-bg-subtle);--bs-alert-border-color: var(--bs-primary-border-subtle);--bs-alert-link-color: var(--bs-primary-text-emphasis)}.alert-secondary{--bs-alert-color: var(--bs-secondary-text-emphasis);--bs-alert-bg: var(--bs-secondary-bg-subtle);--bs-alert-border-color: var(--bs-secondary-border-subtle);--bs-alert-link-color: var(--bs-secondary-text-emphasis)}.alert-success{--bs-alert-color: var(--bs-success-text-emphasis);--bs-alert-bg: var(--bs-success-bg-subtle);--bs-alert-border-color: var(--bs-success-border-subtle);--bs-alert-link-color: var(--bs-success-text-emphasis)}.alert-info{--bs-alert-color: var(--bs-info-text-emphasis);--bs-alert-bg: var(--bs-info-bg-subtle);--bs-alert-border-color: var(--bs-info-border-subtle);--bs-alert-link-color: var(--bs-info-text-emphasis)}.alert-warning{--bs-alert-color: var(--bs-warning-text-emphasis);--bs-alert-bg: var(--bs-warning-bg-subtle);--bs-alert-border-color: var(--bs-warning-border-subtle);--bs-alert-link-color: var(--bs-warning-text-emphasis)}.alert-danger{--bs-alert-color: var(--bs-danger-text-emphasis);--bs-alert-bg: var(--bs-danger-bg-subtle);--bs-alert-border-color: var(--bs-danger-border-subtle);--bs-alert-link-color: var(--bs-danger-text-emphasis)}.alert-light{--bs-alert-color: var(--bs-light-text-emphasis);--bs-alert-bg: var(--bs-light-bg-subtle);--bs-alert-border-color: var(--bs-light-border-subtle);--bs-alert-link-color: var(--bs-light-text-emphasis)}.alert-dark{--bs-alert-color: var(--bs-dark-text-emphasis);--bs-alert-bg: var(--bs-dark-bg-subtle);--bs-alert-border-color: var(--bs-dark-border-subtle);--bs-alert-link-color: var(--bs-dark-text-emphasis)}@keyframes progress-bar-stripes{0%{background-position-x:1rem}}.progress,.progress-stacked{--bs-progress-height: 1rem;--bs-progress-font-size:.75rem;--bs-progress-bg: var(--bs-secondary-bg);--bs-progress-border-radius: var(--bs-border-radius);--bs-progress-box-shadow: var(--bs-box-shadow-inset);--bs-progress-bar-color: #fff;--bs-progress-bar-bg: #3459e6;--bs-progress-bar-transition: width 0.6s ease;display:flex;display:-webkit-flex;height:var(--bs-progress-height);overflow:hidden;font-size:var(--bs-progress-font-size);background-color:var(--bs-progress-bg);border-radius:var(--bs-progress-border-radius);box-shadow:var(--bs-progress-box-shadow)}.progress-bar{display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;justify-content:center;-webkit-justify-content:center;overflow:hidden;color:var(--bs-progress-bar-color);text-align:center;white-space:nowrap;background-color:var(--bs-progress-bar-bg);transition:var(--bs-progress-bar-transition)}@media (prefers-reduced-motion: reduce){.progress-bar{transition:none}}.progress-bar-striped{background-image:linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-size:var(--bs-progress-height) var(--bs-progress-height)}.progress-stacked>.progress{overflow:visible}.progress-stacked>.progress>.progress-bar{width:100%}.progress-bar-animated{animation:1s linear infinite progress-bar-stripes}@media (prefers-reduced-motion: reduce){.progress-bar-animated{animation:none}}.list-group{--bs-list-group-color: var(--bs-body-color);--bs-list-group-bg: var(--bs-body-bg);--bs-list-group-border-color: var(--bs-border-color);--bs-list-group-border-width: var(--bs-border-width);--bs-list-group-border-radius: var(--bs-border-radius);--bs-list-group-item-padding-x: 1.5rem;--bs-list-group-item-padding-y: 1rem;--bs-list-group-action-color: var(--bs-secondary-color);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-tertiary-bg);--bs-list-group-action-active-color: var(--bs-body-color);--bs-list-group-action-active-bg: var(--bs-secondary-bg);--bs-list-group-disabled-color: var(--bs-secondary-color);--bs-list-group-disabled-bg: var(--bs-body-bg);--bs-list-group-active-color: #fff;--bs-list-group-active-bg: #3459e6;--bs-list-group-active-border-color: #3459e6;display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;padding-left:0;margin-bottom:0;border-radius:var(--bs-list-group-border-radius)}.list-group-numbered{list-style-type:none;counter-reset:section}.list-group-numbered>.list-group-item::before{content:counters(section, ".") ". ";counter-increment:section}.list-group-item-action{width:100%;color:var(--bs-list-group-action-color);text-align:inherit}.list-group-item-action:hover,.list-group-item-action:focus{z-index:1;color:var(--bs-list-group-action-hover-color);text-decoration:none;background-color:var(--bs-list-group-action-hover-bg)}.list-group-item-action:active{color:var(--bs-list-group-action-active-color);background-color:var(--bs-list-group-action-active-bg)}.list-group-item{position:relative;display:block;padding:var(--bs-list-group-item-padding-y) var(--bs-list-group-item-padding-x);color:var(--bs-list-group-color);text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;background-color:var(--bs-list-group-bg);border:var(--bs-list-group-border-width) solid var(--bs-list-group-border-color)}.list-group-item:first-child{border-top-left-radius:inherit;border-top-right-radius:inherit}.list-group-item:last-child{border-bottom-right-radius:inherit;border-bottom-left-radius:inherit}.list-group-item.disabled,.list-group-item:disabled{color:var(--bs-list-group-disabled-color);pointer-events:none;background-color:var(--bs-list-group-disabled-bg)}.list-group-item.active{z-index:2;color:var(--bs-list-group-active-color);background-color:var(--bs-list-group-active-bg);border-color:var(--bs-list-group-active-border-color)}.list-group-item+.list-group-item{border-top-width:0}.list-group-item+.list-group-item.active{margin-top:calc(-1 * var(--bs-list-group-border-width));border-top-width:var(--bs-list-group-border-width)}.list-group-horizontal{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal>.list-group-item.active{margin-top:0}.list-group-horizontal>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}@media (min-width: 576px){.list-group-horizontal-sm{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-sm>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-sm>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-sm>.list-group-item.active{margin-top:0}.list-group-horizontal-sm>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-sm>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width: 768px){.list-group-horizontal-md{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-md>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-md>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-md>.list-group-item.active{margin-top:0}.list-group-horizontal-md>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-md>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width: 992px){.list-group-horizontal-lg{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-lg>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-lg>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-lg>.list-group-item.active{margin-top:0}.list-group-horizontal-lg>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-lg>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width: 1200px){.list-group-horizontal-xl{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-xl>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-xl>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-xl>.list-group-item.active{margin-top:0}.list-group-horizontal-xl>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-xl>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width: 1400px){.list-group-horizontal-xxl{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-xxl>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-xxl>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-xxl>.list-group-item.active{margin-top:0}.list-group-horizontal-xxl>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-xxl>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}.list-group-flush{border-radius:0}.list-group-flush>.list-group-item{border-width:0 0 var(--bs-list-group-border-width)}.list-group-flush>.list-group-item:last-child{border-bottom-width:0}.list-group-item-default{--bs-list-group-color: var(--bs-default-text-emphasis);--bs-list-group-bg: var(--bs-default-bg-subtle);--bs-list-group-border-color: var(--bs-default-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-default-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-default-border-subtle);--bs-list-group-active-color: var(--bs-default-bg-subtle);--bs-list-group-active-bg: var(--bs-default-text-emphasis);--bs-list-group-active-border-color: var(--bs-default-text-emphasis)}.list-group-item-primary{--bs-list-group-color: var(--bs-primary-text-emphasis);--bs-list-group-bg: var(--bs-primary-bg-subtle);--bs-list-group-border-color: var(--bs-primary-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-primary-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-primary-border-subtle);--bs-list-group-active-color: var(--bs-primary-bg-subtle);--bs-list-group-active-bg: var(--bs-primary-text-emphasis);--bs-list-group-active-border-color: var(--bs-primary-text-emphasis)}.list-group-item-secondary{--bs-list-group-color: var(--bs-secondary-text-emphasis);--bs-list-group-bg: var(--bs-secondary-bg-subtle);--bs-list-group-border-color: var(--bs-secondary-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-secondary-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-secondary-border-subtle);--bs-list-group-active-color: var(--bs-secondary-bg-subtle);--bs-list-group-active-bg: var(--bs-secondary-text-emphasis);--bs-list-group-active-border-color: var(--bs-secondary-text-emphasis)}.list-group-item-success{--bs-list-group-color: var(--bs-success-text-emphasis);--bs-list-group-bg: var(--bs-success-bg-subtle);--bs-list-group-border-color: var(--bs-success-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-success-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-success-border-subtle);--bs-list-group-active-color: var(--bs-success-bg-subtle);--bs-list-group-active-bg: var(--bs-success-text-emphasis);--bs-list-group-active-border-color: var(--bs-success-text-emphasis)}.list-group-item-info{--bs-list-group-color: var(--bs-info-text-emphasis);--bs-list-group-bg: var(--bs-info-bg-subtle);--bs-list-group-border-color: var(--bs-info-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-info-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-info-border-subtle);--bs-list-group-active-color: var(--bs-info-bg-subtle);--bs-list-group-active-bg: var(--bs-info-text-emphasis);--bs-list-group-active-border-color: var(--bs-info-text-emphasis)}.list-group-item-warning{--bs-list-group-color: var(--bs-warning-text-emphasis);--bs-list-group-bg: var(--bs-warning-bg-subtle);--bs-list-group-border-color: var(--bs-warning-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-warning-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-warning-border-subtle);--bs-list-group-active-color: var(--bs-warning-bg-subtle);--bs-list-group-active-bg: var(--bs-warning-text-emphasis);--bs-list-group-active-border-color: var(--bs-warning-text-emphasis)}.list-group-item-danger{--bs-list-group-color: var(--bs-danger-text-emphasis);--bs-list-group-bg: var(--bs-danger-bg-subtle);--bs-list-group-border-color: var(--bs-danger-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-danger-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-danger-border-subtle);--bs-list-group-active-color: var(--bs-danger-bg-subtle);--bs-list-group-active-bg: var(--bs-danger-text-emphasis);--bs-list-group-active-border-color: var(--bs-danger-text-emphasis)}.list-group-item-light{--bs-list-group-color: var(--bs-light-text-emphasis);--bs-list-group-bg: var(--bs-light-bg-subtle);--bs-list-group-border-color: var(--bs-light-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-light-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-light-border-subtle);--bs-list-group-active-color: var(--bs-light-bg-subtle);--bs-list-group-active-bg: var(--bs-light-text-emphasis);--bs-list-group-active-border-color: var(--bs-light-text-emphasis)}.list-group-item-dark{--bs-list-group-color: var(--bs-dark-text-emphasis);--bs-list-group-bg: var(--bs-dark-bg-subtle);--bs-list-group-border-color: var(--bs-dark-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-dark-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-dark-border-subtle);--bs-list-group-active-color: var(--bs-dark-bg-subtle);--bs-list-group-active-bg: var(--bs-dark-text-emphasis);--bs-list-group-active-border-color: var(--bs-dark-text-emphasis)}.btn-close{--bs-btn-close-color: #000;--bs-btn-close-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");--bs-btn-close-opacity: .5;--bs-btn-close-hover-opacity: .75;--bs-btn-close-focus-shadow: 0 0 0 .25rem rgba(52,89,230,0.25);--bs-btn-close-focus-opacity: 1;--bs-btn-close-disabled-opacity: .25;--bs-btn-close-white-filter: invert(1) grayscale(100%) brightness(200%);box-sizing:content-box;width:1em;height:1em;padding:.25em .25em;color:var(--bs-btn-close-color);background:transparent var(--bs-btn-close-bg) center/1em auto no-repeat;border:0;border-radius:.375rem;opacity:var(--bs-btn-close-opacity)}.btn-close:hover{color:var(--bs-btn-close-color);text-decoration:none;opacity:var(--bs-btn-close-hover-opacity)}.btn-close:focus{outline:0;box-shadow:var(--bs-btn-close-focus-shadow);opacity:var(--bs-btn-close-focus-opacity)}.btn-close:disabled,.btn-close.disabled{pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;opacity:var(--bs-btn-close-disabled-opacity)}.btn-close-white{filter:var(--bs-btn-close-white-filter)}[data-bs-theme="dark"] .btn-close{filter:var(--bs-btn-close-white-filter)}.toast{--bs-toast-zindex: 1090;--bs-toast-padding-x: .75rem;--bs-toast-padding-y: .5rem;--bs-toast-spacing: 1.5rem;--bs-toast-max-width: 350px;--bs-toast-font-size:.875rem;--bs-toast-color: ;--bs-toast-bg: rgba(var(--bs-body-bg-rgb), 0.85);--bs-toast-border-width: var(--bs-border-width);--bs-toast-border-color: var(--bs-border-color-translucent);--bs-toast-border-radius: var(--bs-border-radius);--bs-toast-box-shadow: var(--bs-box-shadow);--bs-toast-header-color: #212529;--bs-toast-header-bg: rgba(var(--bs-body-bg-rgb), 0.85);--bs-toast-header-border-color: var(--bs-border-color-translucent);width:var(--bs-toast-max-width);max-width:100%;font-size:var(--bs-toast-font-size);color:var(--bs-toast-color);pointer-events:auto;background-color:var(--bs-toast-bg);background-clip:padding-box;border:var(--bs-toast-border-width) solid var(--bs-toast-border-color);box-shadow:var(--bs-toast-box-shadow);border-radius:var(--bs-toast-border-radius)}.toast.showing{opacity:0}.toast:not(.show){display:none}.toast-container{--bs-toast-zindex: 1090;position:absolute;z-index:var(--bs-toast-zindex);width:max-content;width:-webkit-max-content;width:-moz-max-content;width:-ms-max-content;width:-o-max-content;max-width:100%;pointer-events:none}.toast-container>:not(:last-child){margin-bottom:var(--bs-toast-spacing)}.toast-header{display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;padding:var(--bs-toast-padding-y) var(--bs-toast-padding-x);color:var(--bs-toast-header-color);background-color:var(--bs-toast-header-bg);background-clip:padding-box;border-bottom:var(--bs-toast-border-width) solid var(--bs-toast-header-border-color);border-top-left-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width));border-top-right-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width))}.toast-header .btn-close{margin-right:calc(-.5 * var(--bs-toast-padding-x));margin-left:var(--bs-toast-padding-x)}.toast-body{padding:var(--bs-toast-padding-x);word-wrap:break-word}.modal{--bs-modal-zindex: 1055;--bs-modal-width: 500px;--bs-modal-padding: 1rem;--bs-modal-margin: .5rem;--bs-modal-color: ;--bs-modal-bg: var(--bs-body-bg);--bs-modal-border-color: #dee2e6;--bs-modal-border-width: var(--bs-border-width);--bs-modal-border-radius: var(--bs-border-radius-lg);--bs-modal-box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);--bs-modal-inner-border-radius: calc(var(--bs-border-radius-lg) - (var(--bs-border-width)));--bs-modal-header-padding-x: 1rem;--bs-modal-header-padding-y: 1rem;--bs-modal-header-padding: 1rem 1rem;--bs-modal-header-border-color: var(--bs-border-color);--bs-modal-header-border-width: 0;--bs-modal-title-line-height: 1.5;--bs-modal-footer-gap: .5rem;--bs-modal-footer-bg: ;--bs-modal-footer-border-color: var(--bs-border-color);--bs-modal-footer-border-width: 0;position:fixed;top:0;left:0;z-index:var(--bs-modal-zindex);display:none;width:100%;height:100%;overflow-x:hidden;overflow-y:auto;outline:0}.modal-dialog{position:relative;width:auto;margin:var(--bs-modal-margin);pointer-events:none}.modal.fade .modal-dialog{transition:transform 0.3s ease-out;transform:translate(0, -50px)}@media (prefers-reduced-motion: reduce){.modal.fade .modal-dialog{transition:none}}.modal.show .modal-dialog{transform:none}.modal.modal-static .modal-dialog{transform:scale(1.02)}.modal-dialog-scrollable{height:calc(100% - var(--bs-modal-margin) * 2)}.modal-dialog-scrollable .modal-content{max-height:100%;overflow:hidden}.modal-dialog-scrollable .modal-body{overflow-y:auto}.modal-dialog-centered{display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;min-height:calc(100% - var(--bs-modal-margin) * 2)}.modal-content{position:relative;display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;width:100%;color:var(--bs-modal-color);pointer-events:auto;background-color:var(--bs-modal-bg);background-clip:padding-box;border:var(--bs-modal-border-width) solid var(--bs-modal-border-color);border-radius:var(--bs-modal-border-radius);box-shadow:var(--bs-modal-box-shadow);outline:0}.modal-backdrop{--bs-backdrop-zindex: 1050;--bs-backdrop-bg: #000;--bs-backdrop-opacity: .5;position:fixed;top:0;left:0;z-index:var(--bs-backdrop-zindex);width:100vw;height:100vh;background-color:var(--bs-backdrop-bg)}.modal-backdrop.fade{opacity:0}.modal-backdrop.show{opacity:var(--bs-backdrop-opacity)}.modal-header{display:flex;display:-webkit-flex;flex-shrink:0;-webkit-flex-shrink:0;align-items:center;-webkit-align-items:center;justify-content:space-between;-webkit-justify-content:space-between;padding:var(--bs-modal-header-padding);border-bottom:var(--bs-modal-header-border-width) solid var(--bs-modal-header-border-color);border-top-left-radius:var(--bs-modal-inner-border-radius);border-top-right-radius:var(--bs-modal-inner-border-radius)}.modal-header .btn-close{padding:calc(var(--bs-modal-header-padding-y) * .5) calc(var(--bs-modal-header-padding-x) * .5);margin:calc(-.5 * var(--bs-modal-header-padding-y)) calc(-.5 * var(--bs-modal-header-padding-x)) calc(-.5 * var(--bs-modal-header-padding-y)) auto}.modal-title{margin-bottom:0;line-height:var(--bs-modal-title-line-height)}.modal-body{position:relative;flex:1 1 auto;-webkit-flex:1 1 auto;padding:var(--bs-modal-padding)}.modal-footer{display:flex;display:-webkit-flex;flex-shrink:0;-webkit-flex-shrink:0;flex-wrap:wrap;-webkit-flex-wrap:wrap;align-items:center;-webkit-align-items:center;justify-content:flex-end;-webkit-justify-content:flex-end;padding:calc(var(--bs-modal-padding) - var(--bs-modal-footer-gap) * .5);background-color:var(--bs-modal-footer-bg);border-top:var(--bs-modal-footer-border-width) solid var(--bs-modal-footer-border-color);border-bottom-right-radius:var(--bs-modal-inner-border-radius);border-bottom-left-radius:var(--bs-modal-inner-border-radius)}.modal-footer>*{margin:calc(var(--bs-modal-footer-gap) * .5)}@media (min-width: 576px){.modal{--bs-modal-margin: 1.75rem;--bs-modal-box-shadow: 0 1px 2px rgba(0,0,0,0.05)}.modal-dialog{max-width:var(--bs-modal-width);margin-right:auto;margin-left:auto}.modal-sm{--bs-modal-width: 300px}}@media (min-width: 992px){.modal-lg,.modal-xl{--bs-modal-width: 800px}}@media (min-width: 1200px){.modal-xl{--bs-modal-width: 1140px}}.modal-fullscreen{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen .modal-header,.modal-fullscreen .modal-footer{border-radius:0}.modal-fullscreen .modal-body{overflow-y:auto}@media (max-width: 575.98px){.modal-fullscreen-sm-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-sm-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-sm-down .modal-header,.modal-fullscreen-sm-down .modal-footer{border-radius:0}.modal-fullscreen-sm-down .modal-body{overflow-y:auto}}@media (max-width: 767.98px){.modal-fullscreen-md-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-md-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-md-down .modal-header,.modal-fullscreen-md-down .modal-footer{border-radius:0}.modal-fullscreen-md-down .modal-body{overflow-y:auto}}@media (max-width: 991.98px){.modal-fullscreen-lg-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-lg-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-lg-down .modal-header,.modal-fullscreen-lg-down .modal-footer{border-radius:0}.modal-fullscreen-lg-down .modal-body{overflow-y:auto}}@media (max-width: 1199.98px){.modal-fullscreen-xl-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-xl-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-xl-down .modal-header,.modal-fullscreen-xl-down .modal-footer{border-radius:0}.modal-fullscreen-xl-down .modal-body{overflow-y:auto}}@media (max-width: 1399.98px){.modal-fullscreen-xxl-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-xxl-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-xxl-down .modal-header,.modal-fullscreen-xxl-down .modal-footer{border-radius:0}.modal-fullscreen-xxl-down .modal-body{overflow-y:auto}}.tooltip{--bs-tooltip-zindex: 1080;--bs-tooltip-max-width: 200px;--bs-tooltip-padding-x: .5rem;--bs-tooltip-padding-y: .25rem;--bs-tooltip-margin: ;--bs-tooltip-font-size:.875rem;--bs-tooltip-color: var(--bs-body-bg);--bs-tooltip-bg: var(--bs-emphasis-color);--bs-tooltip-border-radius: var(--bs-border-radius);--bs-tooltip-opacity: .9;--bs-tooltip-arrow-width: .8rem;--bs-tooltip-arrow-height: .4rem;z-index:var(--bs-tooltip-zindex);display:block;margin:var(--bs-tooltip-margin);font-family:var(--bs-font-sans-serif);font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;white-space:normal;word-spacing:normal;line-break:auto;font-size:var(--bs-tooltip-font-size);word-wrap:break-word;opacity:0}.tooltip.show{opacity:var(--bs-tooltip-opacity)}.tooltip .tooltip-arrow{display:block;width:var(--bs-tooltip-arrow-width);height:var(--bs-tooltip-arrow-height)}.tooltip .tooltip-arrow::before{position:absolute;content:"";border-color:transparent;border-style:solid}.bs-tooltip-top .tooltip-arrow,.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow{bottom:calc(-1 * var(--bs-tooltip-arrow-height))}.bs-tooltip-top .tooltip-arrow::before,.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::before{top:-1px;border-width:var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-top-color:var(--bs-tooltip-bg)}.bs-tooltip-end .tooltip-arrow,.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow{left:calc(-1 * var(--bs-tooltip-arrow-height));width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}.bs-tooltip-end .tooltip-arrow::before,.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before{right:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-right-color:var(--bs-tooltip-bg)}.bs-tooltip-bottom .tooltip-arrow,.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow{top:calc(-1 * var(--bs-tooltip-arrow-height))}.bs-tooltip-bottom .tooltip-arrow::before,.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::before{bottom:-1px;border-width:0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-bottom-color:var(--bs-tooltip-bg)}.bs-tooltip-start .tooltip-arrow,.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow{right:calc(-1 * var(--bs-tooltip-arrow-height));width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}.bs-tooltip-start .tooltip-arrow::before,.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::before{left:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) 0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-left-color:var(--bs-tooltip-bg)}.tooltip-inner{max-width:var(--bs-tooltip-max-width);padding:var(--bs-tooltip-padding-y) var(--bs-tooltip-padding-x);color:var(--bs-tooltip-color);text-align:center;background-color:var(--bs-tooltip-bg);border-radius:var(--bs-tooltip-border-radius)}.popover{--bs-popover-zindex: 1070;--bs-popover-max-width: 276px;--bs-popover-font-size:.875rem;--bs-popover-bg: var(--bs-body-bg);--bs-popover-border-width: var(--bs-border-width);--bs-popover-border-color: var(--bs-border-color-translucent);--bs-popover-border-radius: var(--bs-border-radius-lg);--bs-popover-inner-border-radius: calc(var(--bs-border-radius-lg) - var(--bs-border-width));--bs-popover-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-popover-header-padding-x: 1rem;--bs-popover-header-padding-y: .5rem;--bs-popover-header-font-size:1rem;--bs-popover-header-color: #212529;--bs-popover-header-bg: var(--bs-secondary-bg);--bs-popover-body-padding-x: 1rem;--bs-popover-body-padding-y: 1rem;--bs-popover-body-color: var(--bs-body-color);--bs-popover-arrow-width: 1rem;--bs-popover-arrow-height: .5rem;--bs-popover-arrow-border: var(--bs-popover-border-color);z-index:var(--bs-popover-zindex);display:block;max-width:var(--bs-popover-max-width);font-family:var(--bs-font-sans-serif);font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;white-space:normal;word-spacing:normal;line-break:auto;font-size:var(--bs-popover-font-size);word-wrap:break-word;background-color:var(--bs-popover-bg);background-clip:padding-box;border:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-radius:var(--bs-popover-border-radius);box-shadow:var(--bs-popover-box-shadow)}.popover .popover-arrow{display:block;width:var(--bs-popover-arrow-width);height:var(--bs-popover-arrow-height)}.popover .popover-arrow::before,.popover .popover-arrow::after{position:absolute;display:block;content:"";border-color:transparent;border-style:solid;border-width:0}.bs-popover-top>.popover-arrow,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow{bottom:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}.bs-popover-top>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow::before,.bs-popover-top>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow::after{border-width:var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}.bs-popover-top>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow::before{bottom:0;border-top-color:var(--bs-popover-arrow-border)}.bs-popover-top>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow::after{bottom:var(--bs-popover-border-width);border-top-color:var(--bs-popover-bg)}.bs-popover-end>.popover-arrow,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow{left:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}.bs-popover-end>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow::before,.bs-popover-end>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow::after{border-width:calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}.bs-popover-end>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow::before{left:0;border-right-color:var(--bs-popover-arrow-border)}.bs-popover-end>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow::after{left:var(--bs-popover-border-width);border-right-color:var(--bs-popover-bg)}.bs-popover-bottom>.popover-arrow,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow{top:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}.bs-popover-bottom>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow::before,.bs-popover-bottom>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow::after{border-width:0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}.bs-popover-bottom>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow::before{top:0;border-bottom-color:var(--bs-popover-arrow-border)}.bs-popover-bottom>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow::after{top:var(--bs-popover-border-width);border-bottom-color:var(--bs-popover-bg)}.bs-popover-bottom .popover-header::before,.bs-popover-auto[data-popper-placement^="bottom"] .popover-header::before{position:absolute;top:0;left:50%;display:block;width:var(--bs-popover-arrow-width);margin-left:calc(-.5 * var(--bs-popover-arrow-width));content:"";border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-header-bg)}.bs-popover-start>.popover-arrow,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow{right:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}.bs-popover-start>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow::before,.bs-popover-start>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow::after{border-width:calc(var(--bs-popover-arrow-width) * .5) 0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}.bs-popover-start>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow::before{right:0;border-left-color:var(--bs-popover-arrow-border)}.bs-popover-start>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow::after{right:var(--bs-popover-border-width);border-left-color:var(--bs-popover-bg)}.popover-header{padding:var(--bs-popover-header-padding-y) var(--bs-popover-header-padding-x);margin-bottom:0;font-size:var(--bs-popover-header-font-size);color:var(--bs-popover-header-color);background-color:var(--bs-popover-header-bg);border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-top-left-radius:var(--bs-popover-inner-border-radius);border-top-right-radius:var(--bs-popover-inner-border-radius)}.popover-header:empty{display:none}.popover-body{padding:var(--bs-popover-body-padding-y) var(--bs-popover-body-padding-x);color:var(--bs-popover-body-color)}.carousel{position:relative}.carousel.pointer-event{touch-action:pan-y;-webkit-touch-action:pan-y;-moz-touch-action:pan-y;-ms-touch-action:pan-y;-o-touch-action:pan-y}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner::after{display:block;clear:both;content:""}.carousel-item{position:relative;display:none;float:left;width:100%;margin-right:-100%;backface-visibility:hidden;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-ms-backface-visibility:hidden;-o-backface-visibility:hidden;transition:transform .6s ease-in-out}@media (prefers-reduced-motion: reduce){.carousel-item{transition:none}}.carousel-item.active,.carousel-item-next,.carousel-item-prev{display:block}.carousel-item-next:not(.carousel-item-start),.active.carousel-item-end{transform:translateX(100%)}.carousel-item-prev:not(.carousel-item-end),.active.carousel-item-start{transform:translateX(-100%)}.carousel-fade .carousel-item{opacity:0;transition-property:opacity;transform:none}.carousel-fade .carousel-item.active,.carousel-fade .carousel-item-next.carousel-item-start,.carousel-fade .carousel-item-prev.carousel-item-end{z-index:1;opacity:1}.carousel-fade .active.carousel-item-start,.carousel-fade .active.carousel-item-end{z-index:0;opacity:0;transition:opacity 0s .6s}@media (prefers-reduced-motion: reduce){.carousel-fade .active.carousel-item-start,.carousel-fade .active.carousel-item-end{transition:none}}.carousel-control-prev,.carousel-control-next{position:absolute;top:0;bottom:0;z-index:1;display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;justify-content:center;-webkit-justify-content:center;width:15%;padding:0;color:#fff;text-align:center;background:none;border:0;opacity:.5;transition:opacity 0.15s ease}@media (prefers-reduced-motion: reduce){.carousel-control-prev,.carousel-control-next{transition:none}}.carousel-control-prev:hover,.carousel-control-prev:focus,.carousel-control-next:hover,.carousel-control-next:focus{color:#fff;text-decoration:none;outline:0;opacity:.9}.carousel-control-prev{left:0}.carousel-control-next{right:0}.carousel-control-prev-icon,.carousel-control-next-icon{display:inline-block;width:2rem;height:2rem;background-repeat:no-repeat;background-position:50%;background-size:100% 100%}.carousel-control-prev-icon{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e")}.carousel-control-next-icon{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e")}.carousel-indicators{position:absolute;right:0;bottom:0;left:0;z-index:2;display:flex;display:-webkit-flex;justify-content:center;-webkit-justify-content:center;padding:0;margin-right:15%;margin-bottom:1rem;margin-left:15%}.carousel-indicators [data-bs-target]{box-sizing:content-box;flex:0 1 auto;-webkit-flex:0 1 auto;width:30px;height:3px;padding:0;margin-right:3px;margin-left:3px;text-indent:-999px;cursor:pointer;background-color:#fff;background-clip:padding-box;border:0;border-top:10px solid transparent;border-bottom:10px solid transparent;opacity:.5;transition:opacity 0.6s ease}@media (prefers-reduced-motion: reduce){.carousel-indicators [data-bs-target]{transition:none}}.carousel-indicators .active{opacity:1}.carousel-caption{position:absolute;right:15%;bottom:1.25rem;left:15%;padding-top:1.25rem;padding-bottom:1.25rem;color:#fff;text-align:center}.carousel-dark .carousel-control-prev-icon,.carousel-dark .carousel-control-next-icon{filter:invert(1) grayscale(100)}.carousel-dark .carousel-indicators [data-bs-target]{background-color:#000}.carousel-dark .carousel-caption{color:#000}[data-bs-theme="dark"] .carousel .carousel-control-prev-icon,[data-bs-theme="dark"] .carousel .carousel-control-next-icon,[data-bs-theme="dark"].carousel .carousel-control-prev-icon,[data-bs-theme="dark"].carousel .carousel-control-next-icon{filter:invert(1) grayscale(100)}[data-bs-theme="dark"] .carousel .carousel-indicators [data-bs-target],[data-bs-theme="dark"].carousel .carousel-indicators [data-bs-target]{background-color:#000}[data-bs-theme="dark"] .carousel .carousel-caption,[data-bs-theme="dark"].carousel .carousel-caption{color:#000}.spinner-grow,.spinner-border{display:inline-block;width:var(--bs-spinner-width);height:var(--bs-spinner-height);vertical-align:var(--bs-spinner-vertical-align);border-radius:50%;animation:var(--bs-spinner-animation-speed) linear infinite var(--bs-spinner-animation-name)}@keyframes spinner-border{to{transform:rotate(360deg) /* rtl:ignore */}}.spinner-border{--bs-spinner-width: 2rem;--bs-spinner-height: 2rem;--bs-spinner-vertical-align: -.125em;--bs-spinner-border-width: .25em;--bs-spinner-animation-speed: .75s;--bs-spinner-animation-name: spinner-border;border:var(--bs-spinner-border-width) solid currentcolor;border-right-color:transparent}.spinner-border-sm{--bs-spinner-width: 1rem;--bs-spinner-height: 1rem;--bs-spinner-border-width: .2em}@keyframes spinner-grow{0%{transform:scale(0)}50%{opacity:1;transform:none}}.spinner-grow{--bs-spinner-width: 2rem;--bs-spinner-height: 2rem;--bs-spinner-vertical-align: -.125em;--bs-spinner-animation-speed: .75s;--bs-spinner-animation-name: spinner-grow;background-color:currentcolor;opacity:0}.spinner-grow-sm{--bs-spinner-width: 1rem;--bs-spinner-height: 1rem}@media (prefers-reduced-motion: reduce){.spinner-border,.spinner-grow{--bs-spinner-animation-speed: 1.5s}}.offcanvas,.offcanvas-xxl,.offcanvas-xl,.offcanvas-lg,.offcanvas-md,.offcanvas-sm{--bs-offcanvas-zindex: 1045;--bs-offcanvas-width: 400px;--bs-offcanvas-height: 30vh;--bs-offcanvas-padding-x: 1rem;--bs-offcanvas-padding-y: 1rem;--bs-offcanvas-color: var(--bs-body-color);--bs-offcanvas-bg: var(--bs-body-bg);--bs-offcanvas-border-width: var(--bs-border-width);--bs-offcanvas-border-color: #dee2e6;--bs-offcanvas-box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);--bs-offcanvas-transition: transform .3s ease-in-out;--bs-offcanvas-title-line-height: 1.5}@media (max-width: 575.98px){.offcanvas-sm{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 575.98px) and (prefers-reduced-motion: reduce){.offcanvas-sm{transition:none}}@media (max-width: 575.98px){.offcanvas-sm.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-sm.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-sm.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-sm.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-sm.showing,.offcanvas-sm.show:not(.hiding){transform:none}.offcanvas-sm.showing,.offcanvas-sm.hiding,.offcanvas-sm.show{visibility:visible}}@media (min-width: 576px){.offcanvas-sm{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-sm .offcanvas-header{display:none}.offcanvas-sm .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}@media (max-width: 767.98px){.offcanvas-md{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 767.98px) and (prefers-reduced-motion: reduce){.offcanvas-md{transition:none}}@media (max-width: 767.98px){.offcanvas-md.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-md.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-md.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-md.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-md.showing,.offcanvas-md.show:not(.hiding){transform:none}.offcanvas-md.showing,.offcanvas-md.hiding,.offcanvas-md.show{visibility:visible}}@media (min-width: 768px){.offcanvas-md{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-md .offcanvas-header{display:none}.offcanvas-md .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}@media (max-width: 991.98px){.offcanvas-lg{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 991.98px) and (prefers-reduced-motion: reduce){.offcanvas-lg{transition:none}}@media (max-width: 991.98px){.offcanvas-lg.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-lg.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-lg.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-lg.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-lg.showing,.offcanvas-lg.show:not(.hiding){transform:none}.offcanvas-lg.showing,.offcanvas-lg.hiding,.offcanvas-lg.show{visibility:visible}}@media (min-width: 992px){.offcanvas-lg{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-lg .offcanvas-header{display:none}.offcanvas-lg .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}@media (max-width: 1199.98px){.offcanvas-xl{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 1199.98px) and (prefers-reduced-motion: reduce){.offcanvas-xl{transition:none}}@media (max-width: 1199.98px){.offcanvas-xl.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-xl.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-xl.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-xl.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-xl.showing,.offcanvas-xl.show:not(.hiding){transform:none}.offcanvas-xl.showing,.offcanvas-xl.hiding,.offcanvas-xl.show{visibility:visible}}@media (min-width: 1200px){.offcanvas-xl{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-xl .offcanvas-header{display:none}.offcanvas-xl .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}@media (max-width: 1399.98px){.offcanvas-xxl{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 1399.98px) and (prefers-reduced-motion: reduce){.offcanvas-xxl{transition:none}}@media (max-width: 1399.98px){.offcanvas-xxl.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-xxl.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-xxl.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-xxl.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-xxl.showing,.offcanvas-xxl.show:not(.hiding){transform:none}.offcanvas-xxl.showing,.offcanvas-xxl.hiding,.offcanvas-xxl.show{visibility:visible}}@media (min-width: 1400px){.offcanvas-xxl{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-xxl .offcanvas-header{display:none}.offcanvas-xxl .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}.offcanvas{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}@media (prefers-reduced-motion: reduce){.offcanvas{transition:none}}.offcanvas.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas.showing,.offcanvas.show:not(.hiding){transform:none}.offcanvas.showing,.offcanvas.hiding,.offcanvas.show{visibility:visible}.offcanvas-backdrop{position:fixed;top:0;left:0;z-index:1040;width:100vw;height:100vh;background-color:#000}.offcanvas-backdrop.fade{opacity:0}.offcanvas-backdrop.show{opacity:.5}.offcanvas-header{display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;justify-content:space-between;-webkit-justify-content:space-between;padding:var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x)}.offcanvas-header .btn-close{padding:calc(var(--bs-offcanvas-padding-y) * .5) calc(var(--bs-offcanvas-padding-x) * .5);margin-top:calc(-.5 * var(--bs-offcanvas-padding-y));margin-right:calc(-.5 * var(--bs-offcanvas-padding-x));margin-bottom:calc(-.5 * var(--bs-offcanvas-padding-y))}.offcanvas-title{margin-bottom:0;line-height:var(--bs-offcanvas-title-line-height)}.offcanvas-body{flex-grow:1;-webkit-flex-grow:1;padding:var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);overflow-y:auto}.placeholder{display:inline-block;min-height:1em;vertical-align:middle;cursor:wait;background-color:currentcolor;opacity:.5}.placeholder.btn::before{display:inline-block;content:""}.placeholder-xs{min-height:.6em}.placeholder-sm{min-height:.8em}.placeholder-lg{min-height:1.2em}.placeholder-glow .placeholder{animation:placeholder-glow 2s ease-in-out infinite}@keyframes placeholder-glow{50%{opacity:.2}}.placeholder-wave{mask-image:linear-gradient(130deg, #000 55%, rgba(0,0,0,0.8) 75%, #000 95%);-webkit-mask-image:linear-gradient(130deg, #000 55%, rgba(0,0,0,0.8) 75%, #000 95%);mask-size:200% 100%;-webkit-mask-size:200% 100%;animation:placeholder-wave 2s linear infinite}@keyframes placeholder-wave{100%{mask-position:-200% 0%;-webkit-mask-position:-200% 0%}}.clearfix::after{display:block;clear:both;content:""}.text-bg-default{color:#000 !important;background-color:RGBA(var(--bs-default-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-primary{color:#fff !important;background-color:RGBA(var(--bs-primary-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-secondary{color:#000 !important;background-color:RGBA(var(--bs-secondary-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-success{color:#fff !important;background-color:RGBA(var(--bs-success-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-info{color:#fff !important;background-color:RGBA(var(--bs-info-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-warning{color:#fff !important;background-color:RGBA(var(--bs-warning-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-danger{color:#fff !important;background-color:RGBA(var(--bs-danger-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-light{color:#000 !important;background-color:RGBA(var(--bs-light-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-dark{color:#fff !important;background-color:RGBA(var(--bs-dark-rgb), var(--bs-bg-opacity, 1)) !important}.link-default{color:RGBA(var(--bs-default-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-default-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-default:hover,.link-default:focus{color:RGBA(255,255,255, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(255,255,255, var(--bs-link-underline-opacity, 1)) !important}.link-primary{color:RGBA(var(--bs-primary-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-primary-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-primary:hover,.link-primary:focus{color:RGBA(42,71,184, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(42,71,184, var(--bs-link-underline-opacity, 1)) !important}.link-secondary{color:RGBA(var(--bs-secondary-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-secondary-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-secondary:hover,.link-secondary:focus{color:RGBA(255,255,255, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(255,255,255, var(--bs-link-underline-opacity, 1)) !important}.link-success{color:RGBA(var(--bs-success-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-success-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-success:hover,.link-success:focus{color:RGBA(38,143,102, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(38,143,102, var(--bs-link-underline-opacity, 1)) !important}.link-info{color:RGBA(var(--bs-info-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-info-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-info:hover,.link-info:focus{color:RGBA(32,98,145, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(32,98,145, var(--bs-link-underline-opacity, 1)) !important}.link-warning{color:RGBA(var(--bs-warning-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-warning-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-warning:hover,.link-warning:focus{color:RGBA(195,151,78, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(195,151,78, var(--bs-link-underline-opacity, 1)) !important}.link-danger{color:RGBA(var(--bs-danger-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-danger-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-danger:hover,.link-danger:focus{color:RGBA(174,33,37, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(174,33,37, var(--bs-link-underline-opacity, 1)) !important}.link-light{color:RGBA(var(--bs-light-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-light-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-light:hover,.link-light:focus{color:RGBA(249,250,251, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(249,250,251, var(--bs-link-underline-opacity, 1)) !important}.link-dark{color:RGBA(var(--bs-dark-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-dark-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-dark:hover,.link-dark:focus{color:RGBA(26,30,33, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(26,30,33, var(--bs-link-underline-opacity, 1)) !important}.link-body-emphasis{color:RGBA(var(--bs-emphasis-color-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-emphasis-color-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-body-emphasis:hover,.link-body-emphasis:focus{color:RGBA(var(--bs-emphasis-color-rgb), var(--bs-link-opacity, 0.75)) !important;text-decoration-color:RGBA(var(--bs-emphasis-color-rgb), var(--bs-link-underline-opacity, 0.75)) !important}.focus-ring:focus{outline:0;box-shadow:var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.icon-link{display:inline-flex;gap:.375rem;align-items:center;-webkit-align-items:center;text-decoration-color:rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 0.5));text-underline-offset:.25em;backface-visibility:hidden;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-ms-backface-visibility:hidden;-o-backface-visibility:hidden}.icon-link>.bi{flex-shrink:0;-webkit-flex-shrink:0;width:1em;height:1em;fill:currentcolor;transition:0.2s ease-in-out transform}@media (prefers-reduced-motion: reduce){.icon-link>.bi{transition:none}}.icon-link-hover:hover>.bi,.icon-link-hover:focus-visible>.bi{transform:var(--bs-icon-link-transform, translate3d(0.25em, 0, 0))}.ratio{position:relative;width:100%}.ratio::before{display:block;padding-top:var(--bs-aspect-ratio);content:""}.ratio>*{position:absolute;top:0;left:0;width:100%;height:100%}.ratio-1x1{--bs-aspect-ratio: 100%}.ratio-4x3{--bs-aspect-ratio: calc(3 / 4 * 100%)}.ratio-16x9{--bs-aspect-ratio: calc(9 / 16 * 100%)}.ratio-21x9{--bs-aspect-ratio: calc(9 / 21 * 100%)}.fixed-top{position:fixed;top:0;right:0;left:0;z-index:1030}.fixed-bottom{position:fixed;right:0;bottom:0;left:0;z-index:1030}.sticky-top{position:sticky;top:0;z-index:1020}.sticky-bottom{position:sticky;bottom:0;z-index:1020}@media (min-width: 576px){.sticky-sm-top{position:sticky;top:0;z-index:1020}.sticky-sm-bottom{position:sticky;bottom:0;z-index:1020}}@media (min-width: 768px){.sticky-md-top{position:sticky;top:0;z-index:1020}.sticky-md-bottom{position:sticky;bottom:0;z-index:1020}}@media (min-width: 992px){.sticky-lg-top{position:sticky;top:0;z-index:1020}.sticky-lg-bottom{position:sticky;bottom:0;z-index:1020}}@media (min-width: 1200px){.sticky-xl-top{position:sticky;top:0;z-index:1020}.sticky-xl-bottom{position:sticky;bottom:0;z-index:1020}}@media (min-width: 1400px){.sticky-xxl-top{position:sticky;top:0;z-index:1020}.sticky-xxl-bottom{position:sticky;bottom:0;z-index:1020}}.hstack{display:flex;display:-webkit-flex;flex-direction:row;-webkit-flex-direction:row;align-items:center;-webkit-align-items:center;align-self:stretch;-webkit-align-self:stretch}.vstack{display:flex;display:-webkit-flex;flex:1 1 auto;-webkit-flex:1 1 auto;flex-direction:column;-webkit-flex-direction:column;align-self:stretch;-webkit-align-self:stretch}.visually-hidden,.visually-hidden-focusable:not(:focus):not(:focus-within){width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.visually-hidden:not(caption),.visually-hidden-focusable:not(:focus):not(:focus-within):not(caption){position:absolute !important}.stretched-link::after{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;content:""}.text-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vr{display:inline-block;align-self:stretch;-webkit-align-self:stretch;width:var(--bs-border-width);min-height:1em;background-color:currentcolor;opacity:.25}.align-baseline{vertical-align:baseline !important}.align-top{vertical-align:top !important}.align-middle{vertical-align:middle !important}.align-bottom{vertical-align:bottom !important}.align-text-bottom{vertical-align:text-bottom !important}.align-text-top{vertical-align:text-top !important}.float-start{float:left !important}.float-end{float:right !important}.float-none{float:none !important}.object-fit-contain{object-fit:contain !important}.object-fit-cover{object-fit:cover !important}.object-fit-fill{object-fit:fill !important}.object-fit-scale{object-fit:scale-down !important}.object-fit-none{object-fit:none !important}.opacity-0{opacity:0 !important}.opacity-25{opacity:.25 !important}.opacity-50{opacity:.5 !important}.opacity-75{opacity:.75 !important}.opacity-100{opacity:1 !important}.overflow-auto{overflow:auto !important}.overflow-hidden{overflow:hidden !important}.overflow-visible{overflow:visible !important}.overflow-scroll{overflow:scroll !important}.overflow-x-auto{overflow-x:auto !important}.overflow-x-hidden{overflow-x:hidden !important}.overflow-x-visible{overflow-x:visible !important}.overflow-x-scroll{overflow-x:scroll !important}.overflow-y-auto{overflow-y:auto !important}.overflow-y-hidden{overflow-y:hidden !important}.overflow-y-visible{overflow-y:visible !important}.overflow-y-scroll{overflow-y:scroll !important}.d-inline{display:inline !important}.d-inline-block{display:inline-block !important}.d-block{display:block !important}.d-grid{display:grid !important}.d-inline-grid{display:inline-grid !important}.d-table{display:table !important}.d-table-row{display:table-row !important}.d-table-cell{display:table-cell !important}.d-flex{display:flex !important}.d-inline-flex{display:inline-flex !important}.d-none{display:none !important}.shadow{box-shadow:0 1px 2px rgba(0,0,0,0.05) !important}.shadow-sm{box-shadow:0 0.125rem 0.25rem rgba(0,0,0,0.075) !important}.shadow-lg{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06) !important}.shadow-none{box-shadow:none !important}.focus-ring-default{--bs-focus-ring-color: rgba(var(--bs-default-rgb), var(--bs-focus-ring-opacity))}.focus-ring-primary{--bs-focus-ring-color: rgba(var(--bs-primary-rgb), var(--bs-focus-ring-opacity))}.focus-ring-secondary{--bs-focus-ring-color: rgba(var(--bs-secondary-rgb), var(--bs-focus-ring-opacity))}.focus-ring-success{--bs-focus-ring-color: rgba(var(--bs-success-rgb), var(--bs-focus-ring-opacity))}.focus-ring-info{--bs-focus-ring-color: rgba(var(--bs-info-rgb), var(--bs-focus-ring-opacity))}.focus-ring-warning{--bs-focus-ring-color: rgba(var(--bs-warning-rgb), var(--bs-focus-ring-opacity))}.focus-ring-danger{--bs-focus-ring-color: rgba(var(--bs-danger-rgb), var(--bs-focus-ring-opacity))}.focus-ring-light{--bs-focus-ring-color: rgba(var(--bs-light-rgb), var(--bs-focus-ring-opacity))}.focus-ring-dark{--bs-focus-ring-color: rgba(var(--bs-dark-rgb), var(--bs-focus-ring-opacity))}.position-static{position:static !important}.position-relative{position:relative !important}.position-absolute{position:absolute !important}.position-fixed{position:fixed !important}.position-sticky{position:sticky !important}.top-0{top:0 !important}.top-50{top:50% !important}.top-100{top:100% !important}.bottom-0{bottom:0 !important}.bottom-50{bottom:50% !important}.bottom-100{bottom:100% !important}.start-0{left:0 !important}.start-50{left:50% !important}.start-100{left:100% !important}.end-0{right:0 !important}.end-50{right:50% !important}.end-100{right:100% !important}.translate-middle{transform:translate(-50%, -50%) !important}.translate-middle-x{transform:translateX(-50%) !important}.translate-middle-y{transform:translateY(-50%) !important}.border{border:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-0{border:0 !important}.border-top{border-top:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-top-0{border-top:0 !important}.border-end{border-right:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-end-0{border-right:0 !important}.border-bottom{border-bottom:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-bottom-0{border-bottom:0 !important}.border-start{border-left:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-start-0{border-left:0 !important}.border-default{--bs-border-opacity: 1;border-color:rgba(var(--bs-default-rgb), var(--bs-border-opacity)) !important}.border-primary{--bs-border-opacity: 1;border-color:rgba(var(--bs-primary-rgb), var(--bs-border-opacity)) !important}.border-secondary{--bs-border-opacity: 1;border-color:rgba(var(--bs-secondary-rgb), var(--bs-border-opacity)) !important}.border-success{--bs-border-opacity: 1;border-color:rgba(var(--bs-success-rgb), var(--bs-border-opacity)) !important}.border-info{--bs-border-opacity: 1;border-color:rgba(var(--bs-info-rgb), var(--bs-border-opacity)) !important}.border-warning{--bs-border-opacity: 1;border-color:rgba(var(--bs-warning-rgb), var(--bs-border-opacity)) !important}.border-danger{--bs-border-opacity: 1;border-color:rgba(var(--bs-danger-rgb), var(--bs-border-opacity)) !important}.border-light{--bs-border-opacity: 1;border-color:rgba(var(--bs-light-rgb), var(--bs-border-opacity)) !important}.border-dark{--bs-border-opacity: 1;border-color:rgba(var(--bs-dark-rgb), var(--bs-border-opacity)) !important}.border-black{--bs-border-opacity: 1;border-color:rgba(var(--bs-black-rgb), var(--bs-border-opacity)) !important}.border-white{--bs-border-opacity: 1;border-color:rgba(var(--bs-white-rgb), var(--bs-border-opacity)) !important}.border-primary-subtle{border-color:var(--bs-primary-border-subtle) !important}.border-secondary-subtle{border-color:var(--bs-secondary-border-subtle) !important}.border-success-subtle{border-color:var(--bs-success-border-subtle) !important}.border-info-subtle{border-color:var(--bs-info-border-subtle) !important}.border-warning-subtle{border-color:var(--bs-warning-border-subtle) !important}.border-danger-subtle{border-color:var(--bs-danger-border-subtle) !important}.border-light-subtle{border-color:var(--bs-light-border-subtle) !important}.border-dark-subtle{border-color:var(--bs-dark-border-subtle) !important}.border-1{border-width:1px !important}.border-2{border-width:2px !important}.border-3{border-width:3px !important}.border-4{border-width:4px !important}.border-5{border-width:5px !important}.border-opacity-10{--bs-border-opacity: .1}.border-opacity-25{--bs-border-opacity: .25}.border-opacity-50{--bs-border-opacity: .5}.border-opacity-75{--bs-border-opacity: .75}.border-opacity-100{--bs-border-opacity: 1}.w-25{width:25% !important}.w-50{width:50% !important}.w-75{width:75% !important}.w-100{width:100% !important}.w-auto{width:auto !important}.mw-100{max-width:100% !important}.vw-100{width:100vw !important}.min-vw-100{min-width:100vw !important}.h-25{height:25% !important}.h-50{height:50% !important}.h-75{height:75% !important}.h-100{height:100% !important}.h-auto{height:auto !important}.mh-100{max-height:100% !important}.vh-100{height:100vh !important}.min-vh-100{min-height:100vh !important}.flex-fill{flex:1 1 auto !important}.flex-row{flex-direction:row !important}.flex-column{flex-direction:column !important}.flex-row-reverse{flex-direction:row-reverse !important}.flex-column-reverse{flex-direction:column-reverse !important}.flex-grow-0{flex-grow:0 !important}.flex-grow-1{flex-grow:1 !important}.flex-shrink-0{flex-shrink:0 !important}.flex-shrink-1{flex-shrink:1 !important}.flex-wrap{flex-wrap:wrap !important}.flex-nowrap{flex-wrap:nowrap !important}.flex-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-start{justify-content:flex-start !important}.justify-content-end{justify-content:flex-end !important}.justify-content-center{justify-content:center !important}.justify-content-between{justify-content:space-between !important}.justify-content-around{justify-content:space-around !important}.justify-content-evenly{justify-content:space-evenly !important}.align-items-start{align-items:flex-start !important}.align-items-end{align-items:flex-end !important}.align-items-center{align-items:center !important}.align-items-baseline{align-items:baseline !important}.align-items-stretch{align-items:stretch !important}.align-content-start{align-content:flex-start !important}.align-content-end{align-content:flex-end !important}.align-content-center{align-content:center !important}.align-content-between{align-content:space-between !important}.align-content-around{align-content:space-around !important}.align-content-stretch{align-content:stretch !important}.align-self-auto{align-self:auto !important}.align-self-start{align-self:flex-start !important}.align-self-end{align-self:flex-end !important}.align-self-center{align-self:center !important}.align-self-baseline{align-self:baseline !important}.align-self-stretch{align-self:stretch !important}.order-first{order:-1 !important}.order-0{order:0 !important}.order-1{order:1 !important}.order-2{order:2 !important}.order-3{order:3 !important}.order-4{order:4 !important}.order-5{order:5 !important}.order-last{order:6 !important}.m-0{margin:0 !important}.m-1{margin:.25rem !important}.m-2{margin:.5rem !important}.m-3{margin:1rem !important}.m-4{margin:1.5rem !important}.m-5{margin:3rem !important}.m-auto{margin:auto !important}.mx-0{margin-right:0 !important;margin-left:0 !important}.mx-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-3{margin-right:1rem !important;margin-left:1rem !important}.mx-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-5{margin-right:3rem !important;margin-left:3rem !important}.mx-auto{margin-right:auto !important;margin-left:auto !important}.my-0{margin-top:0 !important;margin-bottom:0 !important}.my-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-0{margin-top:0 !important}.mt-1{margin-top:.25rem !important}.mt-2{margin-top:.5rem !important}.mt-3{margin-top:1rem !important}.mt-4{margin-top:1.5rem !important}.mt-5{margin-top:3rem !important}.mt-auto{margin-top:auto !important}.me-0{margin-right:0 !important}.me-1{margin-right:.25rem !important}.me-2{margin-right:.5rem !important}.me-3{margin-right:1rem !important}.me-4{margin-right:1.5rem !important}.me-5{margin-right:3rem !important}.me-auto{margin-right:auto !important}.mb-0{margin-bottom:0 !important}.mb-1{margin-bottom:.25rem !important}.mb-2{margin-bottom:.5rem !important}.mb-3{margin-bottom:1rem !important}.mb-4{margin-bottom:1.5rem !important}.mb-5{margin-bottom:3rem !important}.mb-auto{margin-bottom:auto !important}.ms-0{margin-left:0 !important}.ms-1{margin-left:.25rem !important}.ms-2{margin-left:.5rem !important}.ms-3{margin-left:1rem !important}.ms-4{margin-left:1.5rem !important}.ms-5{margin-left:3rem !important}.ms-auto{margin-left:auto !important}.p-0{padding:0 !important}.p-1{padding:.25rem !important}.p-2{padding:.5rem !important}.p-3{padding:1rem !important}.p-4{padding:1.5rem !important}.p-5{padding:3rem !important}.px-0{padding-right:0 !important;padding-left:0 !important}.px-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-3{padding-right:1rem !important;padding-left:1rem !important}.px-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-5{padding-right:3rem !important;padding-left:3rem !important}.py-0{padding-top:0 !important;padding-bottom:0 !important}.py-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-0{padding-top:0 !important}.pt-1{padding-top:.25rem !important}.pt-2{padding-top:.5rem !important}.pt-3{padding-top:1rem !important}.pt-4{padding-top:1.5rem !important}.pt-5{padding-top:3rem !important}.pe-0{padding-right:0 !important}.pe-1{padding-right:.25rem !important}.pe-2{padding-right:.5rem !important}.pe-3{padding-right:1rem !important}.pe-4{padding-right:1.5rem !important}.pe-5{padding-right:3rem !important}.pb-0{padding-bottom:0 !important}.pb-1{padding-bottom:.25rem !important}.pb-2{padding-bottom:.5rem !important}.pb-3{padding-bottom:1rem !important}.pb-4{padding-bottom:1.5rem !important}.pb-5{padding-bottom:3rem !important}.ps-0{padding-left:0 !important}.ps-1{padding-left:.25rem !important}.ps-2{padding-left:.5rem !important}.ps-3{padding-left:1rem !important}.ps-4{padding-left:1.5rem !important}.ps-5{padding-left:3rem !important}.gap-0{gap:0 !important}.gap-1{gap:.25rem !important}.gap-2{gap:.5rem !important}.gap-3{gap:1rem !important}.gap-4{gap:1.5rem !important}.gap-5{gap:3rem !important}.row-gap-0{row-gap:0 !important}.row-gap-1{row-gap:.25rem !important}.row-gap-2{row-gap:.5rem !important}.row-gap-3{row-gap:1rem !important}.row-gap-4{row-gap:1.5rem !important}.row-gap-5{row-gap:3rem !important}.column-gap-0{column-gap:0 !important}.column-gap-1{column-gap:.25rem !important}.column-gap-2{column-gap:.5rem !important}.column-gap-3{column-gap:1rem !important}.column-gap-4{column-gap:1.5rem !important}.column-gap-5{column-gap:3rem !important}.font-monospace{font-family:var(--bs-font-monospace) !important}.fs-1{font-size:calc(1.375rem + 1.5vw) !important}.fs-2{font-size:calc(1.325rem + .9vw) !important}.fs-3{font-size:calc(1.3rem + .6vw) !important}.fs-4{font-size:calc(1.275rem + .3vw) !important}.fs-5{font-size:1.25rem !important}.fs-6{font-size:1rem !important}.fst-italic{font-style:italic !important}.fst-normal{font-style:normal !important}.fw-lighter{font-weight:lighter !important}.fw-light{font-weight:300 !important}.fw-normal{font-weight:400 !important}.fw-medium{font-weight:500 !important}.fw-semibold{font-weight:600 !important}.fw-bold{font-weight:700 !important}.fw-bolder{font-weight:bolder !important}.lh-1{line-height:1 !important}.lh-sm{line-height:1.25 !important}.lh-base{line-height:1.5 !important}.lh-lg{line-height:2 !important}.text-start{text-align:left !important}.text-end{text-align:right !important}.text-center{text-align:center !important}.text-decoration-none{text-decoration:none !important}.text-decoration-underline{text-decoration:underline !important}.text-decoration-line-through{text-decoration:line-through !important}.text-lowercase{text-transform:lowercase !important}.text-uppercase{text-transform:uppercase !important}.text-capitalize{text-transform:capitalize !important}.text-wrap{white-space:normal !important}.text-nowrap{white-space:nowrap !important}.text-break{word-wrap:break-word !important;word-break:break-word !important}.text-default{--bs-text-opacity: 1;color:rgba(var(--bs-default-rgb), var(--bs-text-opacity)) !important}.text-primary{--bs-text-opacity: 1;color:rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important}.text-secondary{--bs-text-opacity: 1;color:rgba(var(--bs-secondary-rgb), var(--bs-text-opacity)) !important}.text-success{--bs-text-opacity: 1;color:rgba(var(--bs-success-rgb), var(--bs-text-opacity)) !important}.text-info{--bs-text-opacity: 1;color:rgba(var(--bs-info-rgb), var(--bs-text-opacity)) !important}.text-warning{--bs-text-opacity: 1;color:rgba(var(--bs-warning-rgb), var(--bs-text-opacity)) !important}.text-danger{--bs-text-opacity: 1;color:rgba(var(--bs-danger-rgb), var(--bs-text-opacity)) !important}.text-light{--bs-text-opacity: 1;color:rgba(var(--bs-light-rgb), var(--bs-text-opacity)) !important}.text-dark{--bs-text-opacity: 1;color:rgba(var(--bs-dark-rgb), var(--bs-text-opacity)) !important}.text-black{--bs-text-opacity: 1;color:rgba(var(--bs-black-rgb), var(--bs-text-opacity)) !important}.text-white{--bs-text-opacity: 1;color:rgba(var(--bs-white-rgb), var(--bs-text-opacity)) !important}.text-body{--bs-text-opacity: 1;color:rgba(var(--bs-body-color-rgb), var(--bs-text-opacity)) !important}.text-muted{--bs-text-opacity: 1;color:var(--bs-secondary-color) !important}.text-black-50{--bs-text-opacity: 1;color:rgba(0,0,0,0.5) !important}.text-white-50{--bs-text-opacity: 1;color:rgba(255,255,255,0.5) !important}.text-body-secondary{--bs-text-opacity: 1;color:var(--bs-secondary-color) !important}.text-body-tertiary{--bs-text-opacity: 1;color:var(--bs-tertiary-color) !important}.text-body-emphasis{--bs-text-opacity: 1;color:var(--bs-emphasis-color) !important}.text-reset{--bs-text-opacity: 1;color:inherit !important}.text-opacity-25{--bs-text-opacity: .25}.text-opacity-50{--bs-text-opacity: .5}.text-opacity-75{--bs-text-opacity: .75}.text-opacity-100{--bs-text-opacity: 1}.text-primary-emphasis{color:var(--bs-primary-text-emphasis) !important}.text-secondary-emphasis{color:var(--bs-secondary-text-emphasis) !important}.text-success-emphasis{color:var(--bs-success-text-emphasis) !important}.text-info-emphasis{color:var(--bs-info-text-emphasis) !important}.text-warning-emphasis{color:var(--bs-warning-text-emphasis) !important}.text-danger-emphasis{color:var(--bs-danger-text-emphasis) !important}.text-light-emphasis{color:var(--bs-light-text-emphasis) !important}.text-dark-emphasis{color:var(--bs-dark-text-emphasis) !important}.link-opacity-10{--bs-link-opacity: .1}.link-opacity-10-hover:hover{--bs-link-opacity: .1}.link-opacity-25{--bs-link-opacity: .25}.link-opacity-25-hover:hover{--bs-link-opacity: .25}.link-opacity-50{--bs-link-opacity: .5}.link-opacity-50-hover:hover{--bs-link-opacity: .5}.link-opacity-75{--bs-link-opacity: .75}.link-opacity-75-hover:hover{--bs-link-opacity: .75}.link-opacity-100{--bs-link-opacity: 1}.link-opacity-100-hover:hover{--bs-link-opacity: 1}.link-offset-1{text-underline-offset:.125em !important}.link-offset-1-hover:hover{text-underline-offset:.125em !important}.link-offset-2{text-underline-offset:.25em !important}.link-offset-2-hover:hover{text-underline-offset:.25em !important}.link-offset-3{text-underline-offset:.375em !important}.link-offset-3-hover:hover{text-underline-offset:.375em !important}.link-underline-default{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-default-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-primary{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-primary-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-secondary{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-secondary-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-success{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-success-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-info{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-info-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-warning{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-warning-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-danger{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-danger-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-light{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-light-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-dark{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-dark-rgb), var(--bs-link-underline-opacity)) !important}.link-underline{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-link-color-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-underline-opacity-0{--bs-link-underline-opacity: 0}.link-underline-opacity-0-hover:hover{--bs-link-underline-opacity: 0}.link-underline-opacity-10{--bs-link-underline-opacity: .1}.link-underline-opacity-10-hover:hover{--bs-link-underline-opacity: .1}.link-underline-opacity-25{--bs-link-underline-opacity: .25}.link-underline-opacity-25-hover:hover{--bs-link-underline-opacity: .25}.link-underline-opacity-50{--bs-link-underline-opacity: .5}.link-underline-opacity-50-hover:hover{--bs-link-underline-opacity: .5}.link-underline-opacity-75{--bs-link-underline-opacity: .75}.link-underline-opacity-75-hover:hover{--bs-link-underline-opacity: .75}.link-underline-opacity-100{--bs-link-underline-opacity: 1}.link-underline-opacity-100-hover:hover{--bs-link-underline-opacity: 1}.bg-default{--bs-bg-opacity: 1;background-color:rgba(var(--bs-default-rgb), var(--bs-bg-opacity)) !important}.bg-primary{--bs-bg-opacity: 1;background-color:rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important}.bg-secondary{--bs-bg-opacity: 1;background-color:rgba(var(--bs-secondary-rgb), var(--bs-bg-opacity)) !important}.bg-success{--bs-bg-opacity: 1;background-color:rgba(var(--bs-success-rgb), var(--bs-bg-opacity)) !important}.bg-info{--bs-bg-opacity: 1;background-color:rgba(var(--bs-info-rgb), var(--bs-bg-opacity)) !important}.bg-warning{--bs-bg-opacity: 1;background-color:rgba(var(--bs-warning-rgb), var(--bs-bg-opacity)) !important}.bg-danger{--bs-bg-opacity: 1;background-color:rgba(var(--bs-danger-rgb), var(--bs-bg-opacity)) !important}.bg-light{--bs-bg-opacity: 1;background-color:rgba(var(--bs-light-rgb), var(--bs-bg-opacity)) !important}.bg-dark{--bs-bg-opacity: 1;background-color:rgba(var(--bs-dark-rgb), var(--bs-bg-opacity)) !important}.bg-black{--bs-bg-opacity: 1;background-color:rgba(var(--bs-black-rgb), var(--bs-bg-opacity)) !important}.bg-white{--bs-bg-opacity: 1;background-color:rgba(var(--bs-white-rgb), var(--bs-bg-opacity)) !important}.bg-body{--bs-bg-opacity: 1;background-color:rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important}.bg-transparent{--bs-bg-opacity: 1;background-color:rgba(0,0,0,0) !important}.bg-body-secondary{--bs-bg-opacity: 1;background-color:rgba(var(--bs-secondary-bg-rgb), var(--bs-bg-opacity)) !important}.bg-body-tertiary{--bs-bg-opacity: 1;background-color:rgba(var(--bs-tertiary-bg-rgb), var(--bs-bg-opacity)) !important}.bg-opacity-10{--bs-bg-opacity: .1}.bg-opacity-25{--bs-bg-opacity: .25}.bg-opacity-50{--bs-bg-opacity: .5}.bg-opacity-75{--bs-bg-opacity: .75}.bg-opacity-100{--bs-bg-opacity: 1}.bg-primary-subtle{background-color:var(--bs-primary-bg-subtle) !important}.bg-secondary-subtle{background-color:var(--bs-secondary-bg-subtle) !important}.bg-success-subtle{background-color:var(--bs-success-bg-subtle) !important}.bg-info-subtle{background-color:var(--bs-info-bg-subtle) !important}.bg-warning-subtle{background-color:var(--bs-warning-bg-subtle) !important}.bg-danger-subtle{background-color:var(--bs-danger-bg-subtle) !important}.bg-light-subtle{background-color:var(--bs-light-bg-subtle) !important}.bg-dark-subtle{background-color:var(--bs-dark-bg-subtle) !important}.bg-gradient{background-image:var(--bs-gradient) !important}.user-select-all{user-select:all !important}.user-select-auto{user-select:auto !important}.user-select-none{user-select:none !important}.pe-none{pointer-events:none !important}.pe-auto{pointer-events:auto !important}.rounded{border-radius:var(--bs-border-radius) !important}.rounded-0{border-radius:0 !important}.rounded-1{border-radius:var(--bs-border-radius-sm) !important}.rounded-2{border-radius:var(--bs-border-radius) !important}.rounded-3{border-radius:var(--bs-border-radius-lg) !important}.rounded-4{border-radius:var(--bs-border-radius-xl) !important}.rounded-5{border-radius:var(--bs-border-radius-xxl) !important}.rounded-circle{border-radius:50% !important}.rounded-pill{border-radius:var(--bs-border-radius-pill) !important}.rounded-top{border-top-left-radius:var(--bs-border-radius) !important;border-top-right-radius:var(--bs-border-radius) !important}.rounded-top-0{border-top-left-radius:0 !important;border-top-right-radius:0 !important}.rounded-top-1{border-top-left-radius:var(--bs-border-radius-sm) !important;border-top-right-radius:var(--bs-border-radius-sm) !important}.rounded-top-2{border-top-left-radius:var(--bs-border-radius) !important;border-top-right-radius:var(--bs-border-radius) !important}.rounded-top-3{border-top-left-radius:var(--bs-border-radius-lg) !important;border-top-right-radius:var(--bs-border-radius-lg) !important}.rounded-top-4{border-top-left-radius:var(--bs-border-radius-xl) !important;border-top-right-radius:var(--bs-border-radius-xl) !important}.rounded-top-5{border-top-left-radius:var(--bs-border-radius-xxl) !important;border-top-right-radius:var(--bs-border-radius-xxl) !important}.rounded-top-circle{border-top-left-radius:50% !important;border-top-right-radius:50% !important}.rounded-top-pill{border-top-left-radius:var(--bs-border-radius-pill) !important;border-top-right-radius:var(--bs-border-radius-pill) !important}.rounded-end{border-top-right-radius:var(--bs-border-radius) !important;border-bottom-right-radius:var(--bs-border-radius) !important}.rounded-end-0{border-top-right-radius:0 !important;border-bottom-right-radius:0 !important}.rounded-end-1{border-top-right-radius:var(--bs-border-radius-sm) !important;border-bottom-right-radius:var(--bs-border-radius-sm) !important}.rounded-end-2{border-top-right-radius:var(--bs-border-radius) !important;border-bottom-right-radius:var(--bs-border-radius) !important}.rounded-end-3{border-top-right-radius:var(--bs-border-radius-lg) !important;border-bottom-right-radius:var(--bs-border-radius-lg) !important}.rounded-end-4{border-top-right-radius:var(--bs-border-radius-xl) !important;border-bottom-right-radius:var(--bs-border-radius-xl) !important}.rounded-end-5{border-top-right-radius:var(--bs-border-radius-xxl) !important;border-bottom-right-radius:var(--bs-border-radius-xxl) !important}.rounded-end-circle{border-top-right-radius:50% !important;border-bottom-right-radius:50% !important}.rounded-end-pill{border-top-right-radius:var(--bs-border-radius-pill) !important;border-bottom-right-radius:var(--bs-border-radius-pill) !important}.rounded-bottom{border-bottom-right-radius:var(--bs-border-radius) !important;border-bottom-left-radius:var(--bs-border-radius) !important}.rounded-bottom-0{border-bottom-right-radius:0 !important;border-bottom-left-radius:0 !important}.rounded-bottom-1{border-bottom-right-radius:var(--bs-border-radius-sm) !important;border-bottom-left-radius:var(--bs-border-radius-sm) !important}.rounded-bottom-2{border-bottom-right-radius:var(--bs-border-radius) !important;border-bottom-left-radius:var(--bs-border-radius) !important}.rounded-bottom-3{border-bottom-right-radius:var(--bs-border-radius-lg) !important;border-bottom-left-radius:var(--bs-border-radius-lg) !important}.rounded-bottom-4{border-bottom-right-radius:var(--bs-border-radius-xl) !important;border-bottom-left-radius:var(--bs-border-radius-xl) !important}.rounded-bottom-5{border-bottom-right-radius:var(--bs-border-radius-xxl) !important;border-bottom-left-radius:var(--bs-border-radius-xxl) !important}.rounded-bottom-circle{border-bottom-right-radius:50% !important;border-bottom-left-radius:50% !important}.rounded-bottom-pill{border-bottom-right-radius:var(--bs-border-radius-pill) !important;border-bottom-left-radius:var(--bs-border-radius-pill) !important}.rounded-start{border-bottom-left-radius:var(--bs-border-radius) !important;border-top-left-radius:var(--bs-border-radius) !important}.rounded-start-0{border-bottom-left-radius:0 !important;border-top-left-radius:0 !important}.rounded-start-1{border-bottom-left-radius:var(--bs-border-radius-sm) !important;border-top-left-radius:var(--bs-border-radius-sm) !important}.rounded-start-2{border-bottom-left-radius:var(--bs-border-radius) !important;border-top-left-radius:var(--bs-border-radius) !important}.rounded-start-3{border-bottom-left-radius:var(--bs-border-radius-lg) !important;border-top-left-radius:var(--bs-border-radius-lg) !important}.rounded-start-4{border-bottom-left-radius:var(--bs-border-radius-xl) !important;border-top-left-radius:var(--bs-border-radius-xl) !important}.rounded-start-5{border-bottom-left-radius:var(--bs-border-radius-xxl) !important;border-top-left-radius:var(--bs-border-radius-xxl) !important}.rounded-start-circle{border-bottom-left-radius:50% !important;border-top-left-radius:50% !important}.rounded-start-pill{border-bottom-left-radius:var(--bs-border-radius-pill) !important;border-top-left-radius:var(--bs-border-radius-pill) !important}.visible{visibility:visible !important}.invisible{visibility:hidden !important}.z-n1{z-index:-1 !important}.z-0{z-index:0 !important}.z-1{z-index:1 !important}.z-2{z-index:2 !important}.z-3{z-index:3 !important}@media (min-width: 576px){.float-sm-start{float:left !important}.float-sm-end{float:right !important}.float-sm-none{float:none !important}.object-fit-sm-contain{object-fit:contain !important}.object-fit-sm-cover{object-fit:cover !important}.object-fit-sm-fill{object-fit:fill !important}.object-fit-sm-scale{object-fit:scale-down !important}.object-fit-sm-none{object-fit:none !important}.d-sm-inline{display:inline !important}.d-sm-inline-block{display:inline-block !important}.d-sm-block{display:block !important}.d-sm-grid{display:grid !important}.d-sm-inline-grid{display:inline-grid !important}.d-sm-table{display:table !important}.d-sm-table-row{display:table-row !important}.d-sm-table-cell{display:table-cell !important}.d-sm-flex{display:flex !important}.d-sm-inline-flex{display:inline-flex !important}.d-sm-none{display:none !important}.flex-sm-fill{flex:1 1 auto !important}.flex-sm-row{flex-direction:row !important}.flex-sm-column{flex-direction:column !important}.flex-sm-row-reverse{flex-direction:row-reverse !important}.flex-sm-column-reverse{flex-direction:column-reverse !important}.flex-sm-grow-0{flex-grow:0 !important}.flex-sm-grow-1{flex-grow:1 !important}.flex-sm-shrink-0{flex-shrink:0 !important}.flex-sm-shrink-1{flex-shrink:1 !important}.flex-sm-wrap{flex-wrap:wrap !important}.flex-sm-nowrap{flex-wrap:nowrap !important}.flex-sm-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-sm-start{justify-content:flex-start !important}.justify-content-sm-end{justify-content:flex-end !important}.justify-content-sm-center{justify-content:center !important}.justify-content-sm-between{justify-content:space-between !important}.justify-content-sm-around{justify-content:space-around !important}.justify-content-sm-evenly{justify-content:space-evenly !important}.align-items-sm-start{align-items:flex-start !important}.align-items-sm-end{align-items:flex-end !important}.align-items-sm-center{align-items:center !important}.align-items-sm-baseline{align-items:baseline !important}.align-items-sm-stretch{align-items:stretch !important}.align-content-sm-start{align-content:flex-start !important}.align-content-sm-end{align-content:flex-end !important}.align-content-sm-center{align-content:center !important}.align-content-sm-between{align-content:space-between !important}.align-content-sm-around{align-content:space-around !important}.align-content-sm-stretch{align-content:stretch !important}.align-self-sm-auto{align-self:auto !important}.align-self-sm-start{align-self:flex-start !important}.align-self-sm-end{align-self:flex-end !important}.align-self-sm-center{align-self:center !important}.align-self-sm-baseline{align-self:baseline !important}.align-self-sm-stretch{align-self:stretch !important}.order-sm-first{order:-1 !important}.order-sm-0{order:0 !important}.order-sm-1{order:1 !important}.order-sm-2{order:2 !important}.order-sm-3{order:3 !important}.order-sm-4{order:4 !important}.order-sm-5{order:5 !important}.order-sm-last{order:6 !important}.m-sm-0{margin:0 !important}.m-sm-1{margin:.25rem !important}.m-sm-2{margin:.5rem !important}.m-sm-3{margin:1rem !important}.m-sm-4{margin:1.5rem !important}.m-sm-5{margin:3rem !important}.m-sm-auto{margin:auto !important}.mx-sm-0{margin-right:0 !important;margin-left:0 !important}.mx-sm-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-sm-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-sm-3{margin-right:1rem !important;margin-left:1rem !important}.mx-sm-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-sm-5{margin-right:3rem !important;margin-left:3rem !important}.mx-sm-auto{margin-right:auto !important;margin-left:auto !important}.my-sm-0{margin-top:0 !important;margin-bottom:0 !important}.my-sm-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-sm-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-sm-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-sm-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-sm-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-sm-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-sm-0{margin-top:0 !important}.mt-sm-1{margin-top:.25rem !important}.mt-sm-2{margin-top:.5rem !important}.mt-sm-3{margin-top:1rem !important}.mt-sm-4{margin-top:1.5rem !important}.mt-sm-5{margin-top:3rem !important}.mt-sm-auto{margin-top:auto !important}.me-sm-0{margin-right:0 !important}.me-sm-1{margin-right:.25rem !important}.me-sm-2{margin-right:.5rem !important}.me-sm-3{margin-right:1rem !important}.me-sm-4{margin-right:1.5rem !important}.me-sm-5{margin-right:3rem !important}.me-sm-auto{margin-right:auto !important}.mb-sm-0{margin-bottom:0 !important}.mb-sm-1{margin-bottom:.25rem !important}.mb-sm-2{margin-bottom:.5rem !important}.mb-sm-3{margin-bottom:1rem !important}.mb-sm-4{margin-bottom:1.5rem !important}.mb-sm-5{margin-bottom:3rem !important}.mb-sm-auto{margin-bottom:auto !important}.ms-sm-0{margin-left:0 !important}.ms-sm-1{margin-left:.25rem !important}.ms-sm-2{margin-left:.5rem !important}.ms-sm-3{margin-left:1rem !important}.ms-sm-4{margin-left:1.5rem !important}.ms-sm-5{margin-left:3rem !important}.ms-sm-auto{margin-left:auto !important}.p-sm-0{padding:0 !important}.p-sm-1{padding:.25rem !important}.p-sm-2{padding:.5rem !important}.p-sm-3{padding:1rem !important}.p-sm-4{padding:1.5rem !important}.p-sm-5{padding:3rem !important}.px-sm-0{padding-right:0 !important;padding-left:0 !important}.px-sm-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-sm-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-sm-3{padding-right:1rem !important;padding-left:1rem !important}.px-sm-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-sm-5{padding-right:3rem !important;padding-left:3rem !important}.py-sm-0{padding-top:0 !important;padding-bottom:0 !important}.py-sm-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-sm-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-sm-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-sm-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-sm-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-sm-0{padding-top:0 !important}.pt-sm-1{padding-top:.25rem !important}.pt-sm-2{padding-top:.5rem !important}.pt-sm-3{padding-top:1rem !important}.pt-sm-4{padding-top:1.5rem !important}.pt-sm-5{padding-top:3rem !important}.pe-sm-0{padding-right:0 !important}.pe-sm-1{padding-right:.25rem !important}.pe-sm-2{padding-right:.5rem !important}.pe-sm-3{padding-right:1rem !important}.pe-sm-4{padding-right:1.5rem !important}.pe-sm-5{padding-right:3rem !important}.pb-sm-0{padding-bottom:0 !important}.pb-sm-1{padding-bottom:.25rem !important}.pb-sm-2{padding-bottom:.5rem !important}.pb-sm-3{padding-bottom:1rem !important}.pb-sm-4{padding-bottom:1.5rem !important}.pb-sm-5{padding-bottom:3rem !important}.ps-sm-0{padding-left:0 !important}.ps-sm-1{padding-left:.25rem !important}.ps-sm-2{padding-left:.5rem !important}.ps-sm-3{padding-left:1rem !important}.ps-sm-4{padding-left:1.5rem !important}.ps-sm-5{padding-left:3rem !important}.gap-sm-0{gap:0 !important}.gap-sm-1{gap:.25rem !important}.gap-sm-2{gap:.5rem !important}.gap-sm-3{gap:1rem !important}.gap-sm-4{gap:1.5rem !important}.gap-sm-5{gap:3rem !important}.row-gap-sm-0{row-gap:0 !important}.row-gap-sm-1{row-gap:.25rem !important}.row-gap-sm-2{row-gap:.5rem !important}.row-gap-sm-3{row-gap:1rem !important}.row-gap-sm-4{row-gap:1.5rem !important}.row-gap-sm-5{row-gap:3rem !important}.column-gap-sm-0{column-gap:0 !important}.column-gap-sm-1{column-gap:.25rem !important}.column-gap-sm-2{column-gap:.5rem !important}.column-gap-sm-3{column-gap:1rem !important}.column-gap-sm-4{column-gap:1.5rem !important}.column-gap-sm-5{column-gap:3rem !important}.text-sm-start{text-align:left !important}.text-sm-end{text-align:right !important}.text-sm-center{text-align:center !important}}@media (min-width: 768px){.float-md-start{float:left !important}.float-md-end{float:right !important}.float-md-none{float:none !important}.object-fit-md-contain{object-fit:contain !important}.object-fit-md-cover{object-fit:cover !important}.object-fit-md-fill{object-fit:fill !important}.object-fit-md-scale{object-fit:scale-down !important}.object-fit-md-none{object-fit:none !important}.d-md-inline{display:inline !important}.d-md-inline-block{display:inline-block !important}.d-md-block{display:block !important}.d-md-grid{display:grid !important}.d-md-inline-grid{display:inline-grid !important}.d-md-table{display:table !important}.d-md-table-row{display:table-row !important}.d-md-table-cell{display:table-cell !important}.d-md-flex{display:flex !important}.d-md-inline-flex{display:inline-flex !important}.d-md-none{display:none !important}.flex-md-fill{flex:1 1 auto !important}.flex-md-row{flex-direction:row !important}.flex-md-column{flex-direction:column !important}.flex-md-row-reverse{flex-direction:row-reverse !important}.flex-md-column-reverse{flex-direction:column-reverse !important}.flex-md-grow-0{flex-grow:0 !important}.flex-md-grow-1{flex-grow:1 !important}.flex-md-shrink-0{flex-shrink:0 !important}.flex-md-shrink-1{flex-shrink:1 !important}.flex-md-wrap{flex-wrap:wrap !important}.flex-md-nowrap{flex-wrap:nowrap !important}.flex-md-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-md-start{justify-content:flex-start !important}.justify-content-md-end{justify-content:flex-end !important}.justify-content-md-center{justify-content:center !important}.justify-content-md-between{justify-content:space-between !important}.justify-content-md-around{justify-content:space-around !important}.justify-content-md-evenly{justify-content:space-evenly !important}.align-items-md-start{align-items:flex-start !important}.align-items-md-end{align-items:flex-end !important}.align-items-md-center{align-items:center !important}.align-items-md-baseline{align-items:baseline !important}.align-items-md-stretch{align-items:stretch !important}.align-content-md-start{align-content:flex-start !important}.align-content-md-end{align-content:flex-end !important}.align-content-md-center{align-content:center !important}.align-content-md-between{align-content:space-between !important}.align-content-md-around{align-content:space-around !important}.align-content-md-stretch{align-content:stretch !important}.align-self-md-auto{align-self:auto !important}.align-self-md-start{align-self:flex-start !important}.align-self-md-end{align-self:flex-end !important}.align-self-md-center{align-self:center !important}.align-self-md-baseline{align-self:baseline !important}.align-self-md-stretch{align-self:stretch !important}.order-md-first{order:-1 !important}.order-md-0{order:0 !important}.order-md-1{order:1 !important}.order-md-2{order:2 !important}.order-md-3{order:3 !important}.order-md-4{order:4 !important}.order-md-5{order:5 !important}.order-md-last{order:6 !important}.m-md-0{margin:0 !important}.m-md-1{margin:.25rem !important}.m-md-2{margin:.5rem !important}.m-md-3{margin:1rem !important}.m-md-4{margin:1.5rem !important}.m-md-5{margin:3rem !important}.m-md-auto{margin:auto !important}.mx-md-0{margin-right:0 !important;margin-left:0 !important}.mx-md-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-md-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-md-3{margin-right:1rem !important;margin-left:1rem !important}.mx-md-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-md-5{margin-right:3rem !important;margin-left:3rem !important}.mx-md-auto{margin-right:auto !important;margin-left:auto !important}.my-md-0{margin-top:0 !important;margin-bottom:0 !important}.my-md-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-md-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-md-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-md-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-md-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-md-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-md-0{margin-top:0 !important}.mt-md-1{margin-top:.25rem !important}.mt-md-2{margin-top:.5rem !important}.mt-md-3{margin-top:1rem !important}.mt-md-4{margin-top:1.5rem !important}.mt-md-5{margin-top:3rem !important}.mt-md-auto{margin-top:auto !important}.me-md-0{margin-right:0 !important}.me-md-1{margin-right:.25rem !important}.me-md-2{margin-right:.5rem !important}.me-md-3{margin-right:1rem !important}.me-md-4{margin-right:1.5rem !important}.me-md-5{margin-right:3rem !important}.me-md-auto{margin-right:auto !important}.mb-md-0{margin-bottom:0 !important}.mb-md-1{margin-bottom:.25rem !important}.mb-md-2{margin-bottom:.5rem !important}.mb-md-3{margin-bottom:1rem !important}.mb-md-4{margin-bottom:1.5rem !important}.mb-md-5{margin-bottom:3rem !important}.mb-md-auto{margin-bottom:auto !important}.ms-md-0{margin-left:0 !important}.ms-md-1{margin-left:.25rem !important}.ms-md-2{margin-left:.5rem !important}.ms-md-3{margin-left:1rem !important}.ms-md-4{margin-left:1.5rem !important}.ms-md-5{margin-left:3rem !important}.ms-md-auto{margin-left:auto !important}.p-md-0{padding:0 !important}.p-md-1{padding:.25rem !important}.p-md-2{padding:.5rem !important}.p-md-3{padding:1rem !important}.p-md-4{padding:1.5rem !important}.p-md-5{padding:3rem !important}.px-md-0{padding-right:0 !important;padding-left:0 !important}.px-md-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-md-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-md-3{padding-right:1rem !important;padding-left:1rem !important}.px-md-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-md-5{padding-right:3rem !important;padding-left:3rem !important}.py-md-0{padding-top:0 !important;padding-bottom:0 !important}.py-md-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-md-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-md-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-md-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-md-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-md-0{padding-top:0 !important}.pt-md-1{padding-top:.25rem !important}.pt-md-2{padding-top:.5rem !important}.pt-md-3{padding-top:1rem !important}.pt-md-4{padding-top:1.5rem !important}.pt-md-5{padding-top:3rem !important}.pe-md-0{padding-right:0 !important}.pe-md-1{padding-right:.25rem !important}.pe-md-2{padding-right:.5rem !important}.pe-md-3{padding-right:1rem !important}.pe-md-4{padding-right:1.5rem !important}.pe-md-5{padding-right:3rem !important}.pb-md-0{padding-bottom:0 !important}.pb-md-1{padding-bottom:.25rem !important}.pb-md-2{padding-bottom:.5rem !important}.pb-md-3{padding-bottom:1rem !important}.pb-md-4{padding-bottom:1.5rem !important}.pb-md-5{padding-bottom:3rem !important}.ps-md-0{padding-left:0 !important}.ps-md-1{padding-left:.25rem !important}.ps-md-2{padding-left:.5rem !important}.ps-md-3{padding-left:1rem !important}.ps-md-4{padding-left:1.5rem !important}.ps-md-5{padding-left:3rem !important}.gap-md-0{gap:0 !important}.gap-md-1{gap:.25rem !important}.gap-md-2{gap:.5rem !important}.gap-md-3{gap:1rem !important}.gap-md-4{gap:1.5rem !important}.gap-md-5{gap:3rem !important}.row-gap-md-0{row-gap:0 !important}.row-gap-md-1{row-gap:.25rem !important}.row-gap-md-2{row-gap:.5rem !important}.row-gap-md-3{row-gap:1rem !important}.row-gap-md-4{row-gap:1.5rem !important}.row-gap-md-5{row-gap:3rem !important}.column-gap-md-0{column-gap:0 !important}.column-gap-md-1{column-gap:.25rem !important}.column-gap-md-2{column-gap:.5rem !important}.column-gap-md-3{column-gap:1rem !important}.column-gap-md-4{column-gap:1.5rem !important}.column-gap-md-5{column-gap:3rem !important}.text-md-start{text-align:left !important}.text-md-end{text-align:right !important}.text-md-center{text-align:center !important}}@media (min-width: 992px){.float-lg-start{float:left !important}.float-lg-end{float:right !important}.float-lg-none{float:none !important}.object-fit-lg-contain{object-fit:contain !important}.object-fit-lg-cover{object-fit:cover !important}.object-fit-lg-fill{object-fit:fill !important}.object-fit-lg-scale{object-fit:scale-down !important}.object-fit-lg-none{object-fit:none !important}.d-lg-inline{display:inline !important}.d-lg-inline-block{display:inline-block !important}.d-lg-block{display:block !important}.d-lg-grid{display:grid !important}.d-lg-inline-grid{display:inline-grid !important}.d-lg-table{display:table !important}.d-lg-table-row{display:table-row !important}.d-lg-table-cell{display:table-cell !important}.d-lg-flex{display:flex !important}.d-lg-inline-flex{display:inline-flex !important}.d-lg-none{display:none !important}.flex-lg-fill{flex:1 1 auto !important}.flex-lg-row{flex-direction:row !important}.flex-lg-column{flex-direction:column !important}.flex-lg-row-reverse{flex-direction:row-reverse !important}.flex-lg-column-reverse{flex-direction:column-reverse !important}.flex-lg-grow-0{flex-grow:0 !important}.flex-lg-grow-1{flex-grow:1 !important}.flex-lg-shrink-0{flex-shrink:0 !important}.flex-lg-shrink-1{flex-shrink:1 !important}.flex-lg-wrap{flex-wrap:wrap !important}.flex-lg-nowrap{flex-wrap:nowrap !important}.flex-lg-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-lg-start{justify-content:flex-start !important}.justify-content-lg-end{justify-content:flex-end !important}.justify-content-lg-center{justify-content:center !important}.justify-content-lg-between{justify-content:space-between !important}.justify-content-lg-around{justify-content:space-around !important}.justify-content-lg-evenly{justify-content:space-evenly !important}.align-items-lg-start{align-items:flex-start !important}.align-items-lg-end{align-items:flex-end !important}.align-items-lg-center{align-items:center !important}.align-items-lg-baseline{align-items:baseline !important}.align-items-lg-stretch{align-items:stretch !important}.align-content-lg-start{align-content:flex-start !important}.align-content-lg-end{align-content:flex-end !important}.align-content-lg-center{align-content:center !important}.align-content-lg-between{align-content:space-between !important}.align-content-lg-around{align-content:space-around !important}.align-content-lg-stretch{align-content:stretch !important}.align-self-lg-auto{align-self:auto !important}.align-self-lg-start{align-self:flex-start !important}.align-self-lg-end{align-self:flex-end !important}.align-self-lg-center{align-self:center !important}.align-self-lg-baseline{align-self:baseline !important}.align-self-lg-stretch{align-self:stretch !important}.order-lg-first{order:-1 !important}.order-lg-0{order:0 !important}.order-lg-1{order:1 !important}.order-lg-2{order:2 !important}.order-lg-3{order:3 !important}.order-lg-4{order:4 !important}.order-lg-5{order:5 !important}.order-lg-last{order:6 !important}.m-lg-0{margin:0 !important}.m-lg-1{margin:.25rem !important}.m-lg-2{margin:.5rem !important}.m-lg-3{margin:1rem !important}.m-lg-4{margin:1.5rem !important}.m-lg-5{margin:3rem !important}.m-lg-auto{margin:auto !important}.mx-lg-0{margin-right:0 !important;margin-left:0 !important}.mx-lg-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-lg-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-lg-3{margin-right:1rem !important;margin-left:1rem !important}.mx-lg-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-lg-5{margin-right:3rem !important;margin-left:3rem !important}.mx-lg-auto{margin-right:auto !important;margin-left:auto !important}.my-lg-0{margin-top:0 !important;margin-bottom:0 !important}.my-lg-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-lg-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-lg-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-lg-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-lg-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-lg-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-lg-0{margin-top:0 !important}.mt-lg-1{margin-top:.25rem !important}.mt-lg-2{margin-top:.5rem !important}.mt-lg-3{margin-top:1rem !important}.mt-lg-4{margin-top:1.5rem !important}.mt-lg-5{margin-top:3rem !important}.mt-lg-auto{margin-top:auto !important}.me-lg-0{margin-right:0 !important}.me-lg-1{margin-right:.25rem !important}.me-lg-2{margin-right:.5rem !important}.me-lg-3{margin-right:1rem !important}.me-lg-4{margin-right:1.5rem !important}.me-lg-5{margin-right:3rem !important}.me-lg-auto{margin-right:auto !important}.mb-lg-0{margin-bottom:0 !important}.mb-lg-1{margin-bottom:.25rem !important}.mb-lg-2{margin-bottom:.5rem !important}.mb-lg-3{margin-bottom:1rem !important}.mb-lg-4{margin-bottom:1.5rem !important}.mb-lg-5{margin-bottom:3rem !important}.mb-lg-auto{margin-bottom:auto !important}.ms-lg-0{margin-left:0 !important}.ms-lg-1{margin-left:.25rem !important}.ms-lg-2{margin-left:.5rem !important}.ms-lg-3{margin-left:1rem !important}.ms-lg-4{margin-left:1.5rem !important}.ms-lg-5{margin-left:3rem !important}.ms-lg-auto{margin-left:auto !important}.p-lg-0{padding:0 !important}.p-lg-1{padding:.25rem !important}.p-lg-2{padding:.5rem !important}.p-lg-3{padding:1rem !important}.p-lg-4{padding:1.5rem !important}.p-lg-5{padding:3rem !important}.px-lg-0{padding-right:0 !important;padding-left:0 !important}.px-lg-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-lg-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-lg-3{padding-right:1rem !important;padding-left:1rem !important}.px-lg-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-lg-5{padding-right:3rem !important;padding-left:3rem !important}.py-lg-0{padding-top:0 !important;padding-bottom:0 !important}.py-lg-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-lg-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-lg-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-lg-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-lg-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-lg-0{padding-top:0 !important}.pt-lg-1{padding-top:.25rem !important}.pt-lg-2{padding-top:.5rem !important}.pt-lg-3{padding-top:1rem !important}.pt-lg-4{padding-top:1.5rem !important}.pt-lg-5{padding-top:3rem !important}.pe-lg-0{padding-right:0 !important}.pe-lg-1{padding-right:.25rem !important}.pe-lg-2{padding-right:.5rem !important}.pe-lg-3{padding-right:1rem !important}.pe-lg-4{padding-right:1.5rem !important}.pe-lg-5{padding-right:3rem !important}.pb-lg-0{padding-bottom:0 !important}.pb-lg-1{padding-bottom:.25rem !important}.pb-lg-2{padding-bottom:.5rem !important}.pb-lg-3{padding-bottom:1rem !important}.pb-lg-4{padding-bottom:1.5rem !important}.pb-lg-5{padding-bottom:3rem !important}.ps-lg-0{padding-left:0 !important}.ps-lg-1{padding-left:.25rem !important}.ps-lg-2{padding-left:.5rem !important}.ps-lg-3{padding-left:1rem !important}.ps-lg-4{padding-left:1.5rem !important}.ps-lg-5{padding-left:3rem !important}.gap-lg-0{gap:0 !important}.gap-lg-1{gap:.25rem !important}.gap-lg-2{gap:.5rem !important}.gap-lg-3{gap:1rem !important}.gap-lg-4{gap:1.5rem !important}.gap-lg-5{gap:3rem !important}.row-gap-lg-0{row-gap:0 !important}.row-gap-lg-1{row-gap:.25rem !important}.row-gap-lg-2{row-gap:.5rem !important}.row-gap-lg-3{row-gap:1rem !important}.row-gap-lg-4{row-gap:1.5rem !important}.row-gap-lg-5{row-gap:3rem !important}.column-gap-lg-0{column-gap:0 !important}.column-gap-lg-1{column-gap:.25rem !important}.column-gap-lg-2{column-gap:.5rem !important}.column-gap-lg-3{column-gap:1rem !important}.column-gap-lg-4{column-gap:1.5rem !important}.column-gap-lg-5{column-gap:3rem !important}.text-lg-start{text-align:left !important}.text-lg-end{text-align:right !important}.text-lg-center{text-align:center !important}}@media (min-width: 1200px){.float-xl-start{float:left !important}.float-xl-end{float:right !important}.float-xl-none{float:none !important}.object-fit-xl-contain{object-fit:contain !important}.object-fit-xl-cover{object-fit:cover !important}.object-fit-xl-fill{object-fit:fill !important}.object-fit-xl-scale{object-fit:scale-down !important}.object-fit-xl-none{object-fit:none !important}.d-xl-inline{display:inline !important}.d-xl-inline-block{display:inline-block !important}.d-xl-block{display:block !important}.d-xl-grid{display:grid !important}.d-xl-inline-grid{display:inline-grid !important}.d-xl-table{display:table !important}.d-xl-table-row{display:table-row !important}.d-xl-table-cell{display:table-cell !important}.d-xl-flex{display:flex !important}.d-xl-inline-flex{display:inline-flex !important}.d-xl-none{display:none !important}.flex-xl-fill{flex:1 1 auto !important}.flex-xl-row{flex-direction:row !important}.flex-xl-column{flex-direction:column !important}.flex-xl-row-reverse{flex-direction:row-reverse !important}.flex-xl-column-reverse{flex-direction:column-reverse !important}.flex-xl-grow-0{flex-grow:0 !important}.flex-xl-grow-1{flex-grow:1 !important}.flex-xl-shrink-0{flex-shrink:0 !important}.flex-xl-shrink-1{flex-shrink:1 !important}.flex-xl-wrap{flex-wrap:wrap !important}.flex-xl-nowrap{flex-wrap:nowrap !important}.flex-xl-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-xl-start{justify-content:flex-start !important}.justify-content-xl-end{justify-content:flex-end !important}.justify-content-xl-center{justify-content:center !important}.justify-content-xl-between{justify-content:space-between !important}.justify-content-xl-around{justify-content:space-around !important}.justify-content-xl-evenly{justify-content:space-evenly !important}.align-items-xl-start{align-items:flex-start !important}.align-items-xl-end{align-items:flex-end !important}.align-items-xl-center{align-items:center !important}.align-items-xl-baseline{align-items:baseline !important}.align-items-xl-stretch{align-items:stretch !important}.align-content-xl-start{align-content:flex-start !important}.align-content-xl-end{align-content:flex-end !important}.align-content-xl-center{align-content:center !important}.align-content-xl-between{align-content:space-between !important}.align-content-xl-around{align-content:space-around !important}.align-content-xl-stretch{align-content:stretch !important}.align-self-xl-auto{align-self:auto !important}.align-self-xl-start{align-self:flex-start !important}.align-self-xl-end{align-self:flex-end !important}.align-self-xl-center{align-self:center !important}.align-self-xl-baseline{align-self:baseline !important}.align-self-xl-stretch{align-self:stretch !important}.order-xl-first{order:-1 !important}.order-xl-0{order:0 !important}.order-xl-1{order:1 !important}.order-xl-2{order:2 !important}.order-xl-3{order:3 !important}.order-xl-4{order:4 !important}.order-xl-5{order:5 !important}.order-xl-last{order:6 !important}.m-xl-0{margin:0 !important}.m-xl-1{margin:.25rem !important}.m-xl-2{margin:.5rem !important}.m-xl-3{margin:1rem !important}.m-xl-4{margin:1.5rem !important}.m-xl-5{margin:3rem !important}.m-xl-auto{margin:auto !important}.mx-xl-0{margin-right:0 !important;margin-left:0 !important}.mx-xl-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-xl-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-xl-3{margin-right:1rem !important;margin-left:1rem !important}.mx-xl-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-xl-5{margin-right:3rem !important;margin-left:3rem !important}.mx-xl-auto{margin-right:auto !important;margin-left:auto !important}.my-xl-0{margin-top:0 !important;margin-bottom:0 !important}.my-xl-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-xl-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-xl-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-xl-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-xl-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-xl-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-xl-0{margin-top:0 !important}.mt-xl-1{margin-top:.25rem !important}.mt-xl-2{margin-top:.5rem !important}.mt-xl-3{margin-top:1rem !important}.mt-xl-4{margin-top:1.5rem !important}.mt-xl-5{margin-top:3rem !important}.mt-xl-auto{margin-top:auto !important}.me-xl-0{margin-right:0 !important}.me-xl-1{margin-right:.25rem !important}.me-xl-2{margin-right:.5rem !important}.me-xl-3{margin-right:1rem !important}.me-xl-4{margin-right:1.5rem !important}.me-xl-5{margin-right:3rem !important}.me-xl-auto{margin-right:auto !important}.mb-xl-0{margin-bottom:0 !important}.mb-xl-1{margin-bottom:.25rem !important}.mb-xl-2{margin-bottom:.5rem !important}.mb-xl-3{margin-bottom:1rem !important}.mb-xl-4{margin-bottom:1.5rem !important}.mb-xl-5{margin-bottom:3rem !important}.mb-xl-auto{margin-bottom:auto !important}.ms-xl-0{margin-left:0 !important}.ms-xl-1{margin-left:.25rem !important}.ms-xl-2{margin-left:.5rem !important}.ms-xl-3{margin-left:1rem !important}.ms-xl-4{margin-left:1.5rem !important}.ms-xl-5{margin-left:3rem !important}.ms-xl-auto{margin-left:auto !important}.p-xl-0{padding:0 !important}.p-xl-1{padding:.25rem !important}.p-xl-2{padding:.5rem !important}.p-xl-3{padding:1rem !important}.p-xl-4{padding:1.5rem !important}.p-xl-5{padding:3rem !important}.px-xl-0{padding-right:0 !important;padding-left:0 !important}.px-xl-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-xl-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-xl-3{padding-right:1rem !important;padding-left:1rem !important}.px-xl-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-xl-5{padding-right:3rem !important;padding-left:3rem !important}.py-xl-0{padding-top:0 !important;padding-bottom:0 !important}.py-xl-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-xl-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-xl-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-xl-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-xl-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-xl-0{padding-top:0 !important}.pt-xl-1{padding-top:.25rem !important}.pt-xl-2{padding-top:.5rem !important}.pt-xl-3{padding-top:1rem !important}.pt-xl-4{padding-top:1.5rem !important}.pt-xl-5{padding-top:3rem !important}.pe-xl-0{padding-right:0 !important}.pe-xl-1{padding-right:.25rem !important}.pe-xl-2{padding-right:.5rem !important}.pe-xl-3{padding-right:1rem !important}.pe-xl-4{padding-right:1.5rem !important}.pe-xl-5{padding-right:3rem !important}.pb-xl-0{padding-bottom:0 !important}.pb-xl-1{padding-bottom:.25rem !important}.pb-xl-2{padding-bottom:.5rem !important}.pb-xl-3{padding-bottom:1rem !important}.pb-xl-4{padding-bottom:1.5rem !important}.pb-xl-5{padding-bottom:3rem !important}.ps-xl-0{padding-left:0 !important}.ps-xl-1{padding-left:.25rem !important}.ps-xl-2{padding-left:.5rem !important}.ps-xl-3{padding-left:1rem !important}.ps-xl-4{padding-left:1.5rem !important}.ps-xl-5{padding-left:3rem !important}.gap-xl-0{gap:0 !important}.gap-xl-1{gap:.25rem !important}.gap-xl-2{gap:.5rem !important}.gap-xl-3{gap:1rem !important}.gap-xl-4{gap:1.5rem !important}.gap-xl-5{gap:3rem !important}.row-gap-xl-0{row-gap:0 !important}.row-gap-xl-1{row-gap:.25rem !important}.row-gap-xl-2{row-gap:.5rem !important}.row-gap-xl-3{row-gap:1rem !important}.row-gap-xl-4{row-gap:1.5rem !important}.row-gap-xl-5{row-gap:3rem !important}.column-gap-xl-0{column-gap:0 !important}.column-gap-xl-1{column-gap:.25rem !important}.column-gap-xl-2{column-gap:.5rem !important}.column-gap-xl-3{column-gap:1rem !important}.column-gap-xl-4{column-gap:1.5rem !important}.column-gap-xl-5{column-gap:3rem !important}.text-xl-start{text-align:left !important}.text-xl-end{text-align:right !important}.text-xl-center{text-align:center !important}}@media (min-width: 1400px){.float-xxl-start{float:left !important}.float-xxl-end{float:right !important}.float-xxl-none{float:none !important}.object-fit-xxl-contain{object-fit:contain !important}.object-fit-xxl-cover{object-fit:cover !important}.object-fit-xxl-fill{object-fit:fill !important}.object-fit-xxl-scale{object-fit:scale-down !important}.object-fit-xxl-none{object-fit:none !important}.d-xxl-inline{display:inline !important}.d-xxl-inline-block{display:inline-block !important}.d-xxl-block{display:block !important}.d-xxl-grid{display:grid !important}.d-xxl-inline-grid{display:inline-grid !important}.d-xxl-table{display:table !important}.d-xxl-table-row{display:table-row !important}.d-xxl-table-cell{display:table-cell !important}.d-xxl-flex{display:flex !important}.d-xxl-inline-flex{display:inline-flex !important}.d-xxl-none{display:none !important}.flex-xxl-fill{flex:1 1 auto !important}.flex-xxl-row{flex-direction:row !important}.flex-xxl-column{flex-direction:column !important}.flex-xxl-row-reverse{flex-direction:row-reverse !important}.flex-xxl-column-reverse{flex-direction:column-reverse !important}.flex-xxl-grow-0{flex-grow:0 !important}.flex-xxl-grow-1{flex-grow:1 !important}.flex-xxl-shrink-0{flex-shrink:0 !important}.flex-xxl-shrink-1{flex-shrink:1 !important}.flex-xxl-wrap{flex-wrap:wrap !important}.flex-xxl-nowrap{flex-wrap:nowrap !important}.flex-xxl-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-xxl-start{justify-content:flex-start !important}.justify-content-xxl-end{justify-content:flex-end !important}.justify-content-xxl-center{justify-content:center !important}.justify-content-xxl-between{justify-content:space-between !important}.justify-content-xxl-around{justify-content:space-around !important}.justify-content-xxl-evenly{justify-content:space-evenly !important}.align-items-xxl-start{align-items:flex-start !important}.align-items-xxl-end{align-items:flex-end !important}.align-items-xxl-center{align-items:center !important}.align-items-xxl-baseline{align-items:baseline !important}.align-items-xxl-stretch{align-items:stretch !important}.align-content-xxl-start{align-content:flex-start !important}.align-content-xxl-end{align-content:flex-end !important}.align-content-xxl-center{align-content:center !important}.align-content-xxl-between{align-content:space-between !important}.align-content-xxl-around{align-content:space-around !important}.align-content-xxl-stretch{align-content:stretch !important}.align-self-xxl-auto{align-self:auto !important}.align-self-xxl-start{align-self:flex-start !important}.align-self-xxl-end{align-self:flex-end !important}.align-self-xxl-center{align-self:center !important}.align-self-xxl-baseline{align-self:baseline !important}.align-self-xxl-stretch{align-self:stretch !important}.order-xxl-first{order:-1 !important}.order-xxl-0{order:0 !important}.order-xxl-1{order:1 !important}.order-xxl-2{order:2 !important}.order-xxl-3{order:3 !important}.order-xxl-4{order:4 !important}.order-xxl-5{order:5 !important}.order-xxl-last{order:6 !important}.m-xxl-0{margin:0 !important}.m-xxl-1{margin:.25rem !important}.m-xxl-2{margin:.5rem !important}.m-xxl-3{margin:1rem !important}.m-xxl-4{margin:1.5rem !important}.m-xxl-5{margin:3rem !important}.m-xxl-auto{margin:auto !important}.mx-xxl-0{margin-right:0 !important;margin-left:0 !important}.mx-xxl-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-xxl-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-xxl-3{margin-right:1rem !important;margin-left:1rem !important}.mx-xxl-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-xxl-5{margin-right:3rem !important;margin-left:3rem !important}.mx-xxl-auto{margin-right:auto !important;margin-left:auto !important}.my-xxl-0{margin-top:0 !important;margin-bottom:0 !important}.my-xxl-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-xxl-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-xxl-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-xxl-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-xxl-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-xxl-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-xxl-0{margin-top:0 !important}.mt-xxl-1{margin-top:.25rem !important}.mt-xxl-2{margin-top:.5rem !important}.mt-xxl-3{margin-top:1rem !important}.mt-xxl-4{margin-top:1.5rem !important}.mt-xxl-5{margin-top:3rem !important}.mt-xxl-auto{margin-top:auto !important}.me-xxl-0{margin-right:0 !important}.me-xxl-1{margin-right:.25rem !important}.me-xxl-2{margin-right:.5rem !important}.me-xxl-3{margin-right:1rem !important}.me-xxl-4{margin-right:1.5rem !important}.me-xxl-5{margin-right:3rem !important}.me-xxl-auto{margin-right:auto !important}.mb-xxl-0{margin-bottom:0 !important}.mb-xxl-1{margin-bottom:.25rem !important}.mb-xxl-2{margin-bottom:.5rem !important}.mb-xxl-3{margin-bottom:1rem !important}.mb-xxl-4{margin-bottom:1.5rem !important}.mb-xxl-5{margin-bottom:3rem !important}.mb-xxl-auto{margin-bottom:auto !important}.ms-xxl-0{margin-left:0 !important}.ms-xxl-1{margin-left:.25rem !important}.ms-xxl-2{margin-left:.5rem !important}.ms-xxl-3{margin-left:1rem !important}.ms-xxl-4{margin-left:1.5rem !important}.ms-xxl-5{margin-left:3rem !important}.ms-xxl-auto{margin-left:auto !important}.p-xxl-0{padding:0 !important}.p-xxl-1{padding:.25rem !important}.p-xxl-2{padding:.5rem !important}.p-xxl-3{padding:1rem !important}.p-xxl-4{padding:1.5rem !important}.p-xxl-5{padding:3rem !important}.px-xxl-0{padding-right:0 !important;padding-left:0 !important}.px-xxl-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-xxl-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-xxl-3{padding-right:1rem !important;padding-left:1rem !important}.px-xxl-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-xxl-5{padding-right:3rem !important;padding-left:3rem !important}.py-xxl-0{padding-top:0 !important;padding-bottom:0 !important}.py-xxl-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-xxl-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-xxl-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-xxl-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-xxl-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-xxl-0{padding-top:0 !important}.pt-xxl-1{padding-top:.25rem !important}.pt-xxl-2{padding-top:.5rem !important}.pt-xxl-3{padding-top:1rem !important}.pt-xxl-4{padding-top:1.5rem !important}.pt-xxl-5{padding-top:3rem !important}.pe-xxl-0{padding-right:0 !important}.pe-xxl-1{padding-right:.25rem !important}.pe-xxl-2{padding-right:.5rem !important}.pe-xxl-3{padding-right:1rem !important}.pe-xxl-4{padding-right:1.5rem !important}.pe-xxl-5{padding-right:3rem !important}.pb-xxl-0{padding-bottom:0 !important}.pb-xxl-1{padding-bottom:.25rem !important}.pb-xxl-2{padding-bottom:.5rem !important}.pb-xxl-3{padding-bottom:1rem !important}.pb-xxl-4{padding-bottom:1.5rem !important}.pb-xxl-5{padding-bottom:3rem !important}.ps-xxl-0{padding-left:0 !important}.ps-xxl-1{padding-left:.25rem !important}.ps-xxl-2{padding-left:.5rem !important}.ps-xxl-3{padding-left:1rem !important}.ps-xxl-4{padding-left:1.5rem !important}.ps-xxl-5{padding-left:3rem !important}.gap-xxl-0{gap:0 !important}.gap-xxl-1{gap:.25rem !important}.gap-xxl-2{gap:.5rem !important}.gap-xxl-3{gap:1rem !important}.gap-xxl-4{gap:1.5rem !important}.gap-xxl-5{gap:3rem !important}.row-gap-xxl-0{row-gap:0 !important}.row-gap-xxl-1{row-gap:.25rem !important}.row-gap-xxl-2{row-gap:.5rem !important}.row-gap-xxl-3{row-gap:1rem !important}.row-gap-xxl-4{row-gap:1.5rem !important}.row-gap-xxl-5{row-gap:3rem !important}.column-gap-xxl-0{column-gap:0 !important}.column-gap-xxl-1{column-gap:.25rem !important}.column-gap-xxl-2{column-gap:.5rem !important}.column-gap-xxl-3{column-gap:1rem !important}.column-gap-xxl-4{column-gap:1.5rem !important}.column-gap-xxl-5{column-gap:3rem !important}.text-xxl-start{text-align:left !important}.text-xxl-end{text-align:right !important}.text-xxl-center{text-align:center !important}}.bg-default{color:#000}.bg-primary{color:#fff}.bg-secondary{color:#000}.bg-success{color:#fff}.bg-info{color:#fff}.bg-warning{color:#fff}.bg-danger{color:#fff}.bg-light{color:#000}.bg-dark{color:#fff}@media (min-width: 1200px){.fs-1{font-size:2.5rem !important}.fs-2{font-size:2rem !important}.fs-3{font-size:1.75rem !important}.fs-4{font-size:1.5rem !important}}@media print{.d-print-inline{display:inline !important}.d-print-inline-block{display:inline-block !important}.d-print-block{display:block !important}.d-print-grid{display:grid !important}.d-print-inline-grid{display:inline-grid !important}.d-print-table{display:table !important}.d-print-table-row{display:table-row !important}.d-print-table-cell{display:table-cell !important}.d-print-flex{display:flex !important}.d-print-inline-flex{display:inline-flex !important}.d-print-none{display:none !important}}.table th[align=left]{text-align:left}.table th[align=right]{text-align:right}.table th[align=center]{text-align:center}:root{--bslib-spacer: 1rem;--bslib-mb-spacer: var(--bslib-spacer, 1rem)}.bslib-mb-spacing{margin-bottom:var(--bslib-mb-spacer)}.bslib-gap-spacing{gap:var(--bslib-mb-spacer)}.bslib-gap-spacing>.bslib-mb-spacing,.bslib-gap-spacing>.form-group,.bslib-gap-spacing>p,.bslib-gap-spacing>pre,.bslib-gap-spacing>.shiny-html-output>.bslib-mb-spacing,.bslib-gap-spacing>.shiny-html-output>.form-group,.bslib-gap-spacing>.shiny-html-output>p,.bslib-gap-spacing>.shiny-html-output>pre,.bslib-gap-spacing>.shiny-panel-conditional>.bslib-mb-spacing,.bslib-gap-spacing>.shiny-panel-conditional>.form-group,.bslib-gap-spacing>.shiny-panel-conditional>p,.bslib-gap-spacing>.shiny-panel-conditional>pre{margin-bottom:0}.html-fill-container>.html-fill-item.bslib-mb-spacing{margin-bottom:0}.tab-content>.tab-pane.html-fill-container{display:none}.tab-content>.active.html-fill-container{display:flex}.tab-content.html-fill-container{padding:0}.bg-blue{--bslib-color-bg: #3459e6;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-blue{--bslib-color-fg: #3459e6;color:var(--bslib-color-fg)}.bg-indigo{--bslib-color-bg: #6610f2;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-indigo{--bslib-color-fg: #6610f2;color:var(--bslib-color-fg)}.bg-purple{--bslib-color-bg: #6f42c1;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-purple{--bslib-color-fg: #6f42c1;color:var(--bslib-color-fg)}.bg-pink{--bslib-color-bg: #d63384;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-pink{--bslib-color-fg: #d63384;color:var(--bslib-color-fg)}.bg-red{--bslib-color-bg: #da292e;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-red{--bslib-color-fg: #da292e;color:var(--bslib-color-fg)}.bg-orange{--bslib-color-bg: #f8765f;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-orange{--bslib-color-fg: #f8765f;color:var(--bslib-color-fg)}.bg-yellow{--bslib-color-bg: #f4bd61;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-yellow{--bslib-color-fg: #f4bd61;color:var(--bslib-color-fg)}.bg-green{--bslib-color-bg: #2fb380;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-green{--bslib-color-fg: #2fb380;color:var(--bslib-color-fg)}.bg-teal{--bslib-color-bg: #20c997;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-teal{--bslib-color-fg: #20c997;color:var(--bslib-color-fg)}.bg-cyan{--bslib-color-bg: #287bb5;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-cyan{--bslib-color-fg: #287bb5;color:var(--bslib-color-fg)}.text-default{--bslib-color-fg: #fff}.bg-default{--bslib-color-bg: #fff;--bslib-color-fg: #000}.text-primary{--bslib-color-fg: #3459e6}.bg-primary{--bslib-color-bg: #3459e6;--bslib-color-fg: #fff}.text-secondary{--bslib-color-fg: #fff}.bg-secondary{--bslib-color-bg: #fff;--bslib-color-fg: #000}.text-success{--bslib-color-fg: #2fb380}.bg-success{--bslib-color-bg: #2fb380;--bslib-color-fg: #fff}.text-info{--bslib-color-fg: #287bb5}.bg-info{--bslib-color-bg: #287bb5;--bslib-color-fg: #fff}.text-warning{--bslib-color-fg: #f4bd61}.bg-warning{--bslib-color-bg: #f4bd61;--bslib-color-fg: #fff}.text-danger{--bslib-color-fg: #da292e}.bg-danger{--bslib-color-bg: #da292e;--bslib-color-fg: #fff}.text-light{--bslib-color-fg: #f8f9fa}.bg-light{--bslib-color-bg: #f8f9fa;--bslib-color-fg: #000}.text-dark{--bslib-color-fg: #212529}.bg-dark{--bslib-color-bg: #212529;--bslib-color-fg: #fff}.bg-gradient-blue-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #483ceb;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #483ceb;color:#fff}.bg-gradient-blue-purple{--bslib-color-fg: #fff;--bslib-color-bg: #4c50d7;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #4c50d7;color:#fff}.bg-gradient-blue-pink{--bslib-color-fg: #fff;--bslib-color-bg: #754abf;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #754abf;color:#fff}.bg-gradient-blue-red{--bslib-color-fg: #fff;--bslib-color-bg: #76469c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #76469c;color:#fff}.bg-gradient-blue-orange{--bslib-color-fg: #fff;--bslib-color-bg: #8265b0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #8265b0;color:#fff}.bg-gradient-blue-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #8181b1;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #8181b1;color:#fff}.bg-gradient-blue-green{--bslib-color-fg: #fff;--bslib-color-bg: #327dbd;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #327dbd;color:#fff}.bg-gradient-blue-teal{--bslib-color-fg: #fff;--bslib-color-bg: #2c86c6;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #2c86c6;color:#fff}.bg-gradient-blue-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #2f67d2;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #2f67d2;color:#fff}.bg-gradient-indigo-blue{--bslib-color-fg: #fff;--bslib-color-bg: #522ded;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #522ded;color:#fff}.bg-gradient-indigo-purple{--bslib-color-fg: #fff;--bslib-color-bg: #6a24de;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #6a24de;color:#fff}.bg-gradient-indigo-pink{--bslib-color-fg: #fff;--bslib-color-bg: #931ec6;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #931ec6;color:#fff}.bg-gradient-indigo-red{--bslib-color-fg: #fff;--bslib-color-bg: #941aa4;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #941aa4;color:#fff}.bg-gradient-indigo-orange{--bslib-color-fg: #fff;--bslib-color-bg: #a039b7;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #a039b7;color:#fff}.bg-gradient-indigo-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #9f55b8;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #9f55b8;color:#fff}.bg-gradient-indigo-green{--bslib-color-fg: #fff;--bslib-color-bg: #5051c4;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #5051c4;color:#fff}.bg-gradient-indigo-teal{--bslib-color-fg: #fff;--bslib-color-bg: #4a5ace;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #4a5ace;color:#fff}.bg-gradient-indigo-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #4d3bda;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #4d3bda;color:#fff}.bg-gradient-purple-blue{--bslib-color-fg: #fff;--bslib-color-bg: #574bd0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #574bd0;color:#fff}.bg-gradient-purple-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #6b2ed5;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #6b2ed5;color:#fff}.bg-gradient-purple-pink{--bslib-color-fg: #fff;--bslib-color-bg: #983ca9;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #983ca9;color:#fff}.bg-gradient-purple-red{--bslib-color-fg: #fff;--bslib-color-bg: #9a3886;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #9a3886;color:#fff}.bg-gradient-purple-orange{--bslib-color-fg: #fff;--bslib-color-bg: #a6579a;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #a6579a;color:#fff}.bg-gradient-purple-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #a4739b;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #a4739b;color:#fff}.bg-gradient-purple-green{--bslib-color-fg: #fff;--bslib-color-bg: #556fa7;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #556fa7;color:#fff}.bg-gradient-purple-teal{--bslib-color-fg: #fff;--bslib-color-bg: #4f78b0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #4f78b0;color:#fff}.bg-gradient-purple-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #5359bc;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #5359bc;color:#fff}.bg-gradient-pink-blue{--bslib-color-fg: #fff;--bslib-color-bg: #9542ab;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #9542ab;color:#fff}.bg-gradient-pink-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #a925b0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #a925b0;color:#fff}.bg-gradient-pink-purple{--bslib-color-fg: #fff;--bslib-color-bg: #ad399c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #ad399c;color:#fff}.bg-gradient-pink-red{--bslib-color-fg: #fff;--bslib-color-bg: #d82f62;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #d82f62;color:#fff}.bg-gradient-pink-orange{--bslib-color-fg: #fff;--bslib-color-bg: #e44e75;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #e44e75;color:#fff}.bg-gradient-pink-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #e26a76;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #e26a76;color:#fff}.bg-gradient-pink-green{--bslib-color-fg: #fff;--bslib-color-bg: #936682;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #936682;color:#fff}.bg-gradient-pink-teal{--bslib-color-fg: #fff;--bslib-color-bg: #8d6f8c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #8d6f8c;color:#fff}.bg-gradient-pink-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #905098;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #905098;color:#fff}.bg-gradient-red-blue{--bslib-color-fg: #fff;--bslib-color-bg: #983c78;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #983c78;color:#fff}.bg-gradient-red-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #ac1f7c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #ac1f7c;color:#fff}.bg-gradient-red-purple{--bslib-color-fg: #fff;--bslib-color-bg: #af3369;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #af3369;color:#fff}.bg-gradient-red-pink{--bslib-color-fg: #fff;--bslib-color-bg: #d82d50;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #d82d50;color:#fff}.bg-gradient-red-orange{--bslib-color-fg: #fff;--bslib-color-bg: #e64842;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #e64842;color:#fff}.bg-gradient-red-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #e46442;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #e46442;color:#fff}.bg-gradient-red-green{--bslib-color-fg: #fff;--bslib-color-bg: #96604f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #96604f;color:#fff}.bg-gradient-red-teal{--bslib-color-fg: #fff;--bslib-color-bg: #906958;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #906958;color:#fff}.bg-gradient-red-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #934a64;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #934a64;color:#fff}.bg-gradient-orange-blue{--bslib-color-fg: #fff;--bslib-color-bg: #aa6a95;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #aa6a95;color:#fff}.bg-gradient-orange-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #be4d9a;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #be4d9a;color:#fff}.bg-gradient-orange-purple{--bslib-color-fg: #fff;--bslib-color-bg: #c16186;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #c16186;color:#fff}.bg-gradient-orange-pink{--bslib-color-fg: #fff;--bslib-color-bg: #ea5b6e;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #ea5b6e;color:#fff}.bg-gradient-orange-red{--bslib-color-fg: #fff;--bslib-color-bg: #ec574b;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #ec574b;color:#fff}.bg-gradient-orange-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #f69260;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #f69260;color:#fff}.bg-gradient-orange-green{--bslib-color-fg: #fff;--bslib-color-bg: #a88e6c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #a88e6c;color:#fff}.bg-gradient-orange-teal{--bslib-color-fg: #fff;--bslib-color-bg: #a29775;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #a29775;color:#fff}.bg-gradient-orange-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #a57881;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #a57881;color:#fff}.bg-gradient-yellow-blue{--bslib-color-fg: #fff;--bslib-color-bg: #a79596;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #a79596;color:#fff}.bg-gradient-yellow-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #bb789b;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #bb789b;color:#fff}.bg-gradient-yellow-purple{--bslib-color-fg: #fff;--bslib-color-bg: #bf8c87;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #bf8c87;color:#fff}.bg-gradient-yellow-pink{--bslib-color-fg: #fff;--bslib-color-bg: #e8866f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #e8866f;color:#fff}.bg-gradient-yellow-red{--bslib-color-fg: #fff;--bslib-color-bg: #ea824d;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #ea824d;color:#fff}.bg-gradient-yellow-orange{--bslib-color-fg: #fff;--bslib-color-bg: #f6a160;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #f6a160;color:#fff}.bg-gradient-yellow-green{--bslib-color-fg: #fff;--bslib-color-bg: #a5b96d;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #a5b96d;color:#fff}.bg-gradient-yellow-teal{--bslib-color-fg: #fff;--bslib-color-bg: #9fc277;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #9fc277;color:#fff}.bg-gradient-yellow-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #a2a383;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #a2a383;color:#fff}.bg-gradient-green-blue{--bslib-color-fg: #fff;--bslib-color-bg: #318fa9;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #318fa9;color:#fff}.bg-gradient-green-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #4572ae;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #4572ae;color:#fff}.bg-gradient-green-purple{--bslib-color-fg: #fff;--bslib-color-bg: #49869a;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #49869a;color:#fff}.bg-gradient-green-pink{--bslib-color-fg: #fff;--bslib-color-bg: #728082;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #728082;color:#fff}.bg-gradient-green-red{--bslib-color-fg: #fff;--bslib-color-bg: #737c5f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #737c5f;color:#fff}.bg-gradient-green-orange{--bslib-color-fg: #fff;--bslib-color-bg: #7f9b73;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #7f9b73;color:#fff}.bg-gradient-green-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #7eb774;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #7eb774;color:#fff}.bg-gradient-green-teal{--bslib-color-fg: #fff;--bslib-color-bg: #29bc89;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #29bc89;color:#fff}.bg-gradient-green-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #2c9d95;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #2c9d95;color:#fff}.bg-gradient-teal-blue{--bslib-color-fg: #fff;--bslib-color-bg: #289cb7;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #289cb7;color:#fff}.bg-gradient-teal-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #3c7fbb;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #3c7fbb;color:#fff}.bg-gradient-teal-purple{--bslib-color-fg: #fff;--bslib-color-bg: #4093a8;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #4093a8;color:#fff}.bg-gradient-teal-pink{--bslib-color-fg: #fff;--bslib-color-bg: #698d8f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #698d8f;color:#fff}.bg-gradient-teal-red{--bslib-color-fg: #fff;--bslib-color-bg: #6a896d;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #6a896d;color:#fff}.bg-gradient-teal-orange{--bslib-color-fg: #fff;--bslib-color-bg: #76a881;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #76a881;color:#fff}.bg-gradient-teal-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #75c481;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #75c481;color:#fff}.bg-gradient-teal-green{--bslib-color-fg: #fff;--bslib-color-bg: #26c08e;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #26c08e;color:#fff}.bg-gradient-teal-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #23aaa3;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #23aaa3;color:#fff}.bg-gradient-cyan-blue{--bslib-color-fg: #fff;--bslib-color-bg: #2d6dc9;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #2d6dc9;color:#fff}.bg-gradient-cyan-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #4150cd;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #4150cd;color:#fff}.bg-gradient-cyan-purple{--bslib-color-fg: #fff;--bslib-color-bg: #4464ba;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #4464ba;color:#fff}.bg-gradient-cyan-pink{--bslib-color-fg: #fff;--bslib-color-bg: #6e5ea1;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #6e5ea1;color:#fff}.bg-gradient-cyan-red{--bslib-color-fg: #fff;--bslib-color-bg: #6f5a7f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #6f5a7f;color:#fff}.bg-gradient-cyan-orange{--bslib-color-fg: #fff;--bslib-color-bg: #7b7993;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #7b7993;color:#fff}.bg-gradient-cyan-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #7a9593;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #7a9593;color:#fff}.bg-gradient-cyan-green{--bslib-color-fg: #fff;--bslib-color-bg: #2b91a0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #2b91a0;color:#fff}.bg-gradient-cyan-teal{--bslib-color-fg: #fff;--bslib-color-bg: #259aa9;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #259aa9;color:#fff}.navbar{font-size:.875rem;font-weight:500}.navbar .nav-item{margin-right:.5rem;margin-left:.5rem}.navbar .navbar-nav .nav-link{border-radius:.375rem}.navbar-dark .navbar-nav .nav-link:hover{background-color:rgba(255,255,255,0.1)}.navbar-dark .navbar-nav .nav-link.active{background-color:rgba(0,0,0,0.5)}.navbar-light .navbar-nav .nav-link:hover{background-color:rgba(0,0,0,0.03)}.navbar-light .navbar-nav .nav-link.active{background-color:rgba(0,0,0,0.05)}.navbar-nav{--bs-nav-link-padding-x: .5rem}.btn-secondary,.btn-default:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-light,.btn-outline-secondary,.btn-outline-light{color:#212529}.btn-secondary:disabled,.btn-default:disabled:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-secondary.disabled,.disabled.btn-default:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-light:disabled,.btn-light.disabled,.btn-outline-secondary:disabled,.btn-outline-secondary.disabled,.btn-outline-light:disabled,.btn-outline-light.disabled{border:1px solid #e6e6e6}.btn-secondary,.btn-default:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-outline-secondary{border-color:#e6e6e6}.btn-secondary:hover,.btn-default:hover:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-secondary:active,.btn-default:active:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-outline-secondary:hover,.btn-outline-secondary:active{background-color:#e6e6e6;border-color:#e6e6e6}.btn-light,.btn-outline-light{border-color:#dfe0e1}.btn-light:hover,.btn-light:active,.btn-outline-light:hover,.btn-outline-light:active{background-color:#dfe0e1;border-color:#dfe0e1}.table{font-size:.875rem;box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06)}thead th{font-size:.875rem;text-transform:uppercase}.input-group-text{box-shadow:0 1px 2px rgba(0,0,0,0.05)}.nav-tabs{font-weight:500}.nav-tabs .nav-link{padding-top:1rem;padding-bottom:1rem;border-width:0 0 1px}.nav-tabs .nav-link.active,.nav-tabs .nav-item.show .nav-link{box-shadow:inset 0 -2px 0 #3459e6}.nav-pills{font-weight:500}.pagination{font-size:.875rem;font-weight:500}.pagination .page-link{box-shadow:0 1px 2px rgba(0,0,0,0.05)}.breadcrumb{font-size:.875rem;font-weight:500;border:1px solid #dee2e6;border-radius:.375rem;box-shadow:0 1px 2px rgba(0,0,0,0.05)}.breadcrumb-item{padding:1rem .5rem 1rem 0}.breadcrumb-item+.breadcrumb-item::before{padding-right:1rem}.alert .btn-close{color:inherit}.badge.bg-secondary,.badge.bg-light{color:#212529}.list-group-item h1,.list-group-item h2,.list-group-item h3,.list-group-item h4,.list-group-item h5,.list-group-item h6,.list-group-item .h1,.list-group-item .h2,.list-group-item .h3,.list-group-item .h4,.list-group-item .h5,.list-group-item .h6,.card h1,.card h2,.card h3,.card h4,.card h5,.card h6,.card .h1,.card .h2,.card .h3,.card .h4,.card .h5,.card .h6{color:inherit}.list-group{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06)}.card{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06)}.modal-footer{background-color:#f8f9fa}.modal-content{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06)}.row>main{max-width:50rem;overflow-wrap:break-word;hyphens:auto}@media (min-width: 1200px) and (max-width: 1399.98px){.container .row{justify-content:space-evenly}}@media (min-width: 1400px){body{font-size:18px}.col-md-3{margin-left:5rem}}.navbar{background:RGBA(var(--bs-body-color-rgb), 0.1);background:color-mix(in oklab, color-mix(in oklab, var(--bs-body-bg) 95%, var(--bs-primary)) 95%, var(--bs-body-color));line-height:initial}.nav-item .nav-link{border-radius:.375rem}.nav-item.active .nav-link{background:RGBA(var(--bs-body-color-rgb), 0.1)}.nav-item .nav-link:hover{background:RGBA(var(--bs-primary-rgb), 0.1)}.navbar>.container{align-items:baseline;-webkit-align-items:baseline}input[type="search"]{width:12rem}[aria-labelledby=dropdown-lightswitch] span.fa{opacity:0.5}@media (max-width: 991.98px){.algolia-autocomplete,input[type="search"],#navbar .dropdown-menu{width:100%}#navbar .dropdown-item{white-space:normal}input[type="search"]{margin:0.25rem 0}}.headroom{will-change:transform;transition:transform 400ms ease}.headroom--pinned{transform:translateY(0%)}.headroom--unpinned{transform:translateY(-100%)}.row>main,.row>aside{margin-top:56px}html,body{scroll-padding:56px}@media (min-width: 576px){#toc{position:sticky;top:56px;max-height:calc(100vh - 56px - 1rem);overflow-y:auto}}aside h2,aside .h2{margin-top:1.5rem;font-size:1.25rem}aside .roles{color:RGBA(var(--bs-body-color-rgb), 0.8)}aside .list-unstyled li{margin-bottom:0.5rem}aside .dev-status .list-unstyled li{margin-bottom:0.1rem}@media (max-width: 767.98px){.row>aside{margin:0.5rem;width:calc(100vw - 1rem);background-color:RGBA(var(--bs-body-color-rgb), 0.1);border-color:var(--bs-border-color);border-radius:.375rem}.row>aside h2:first-child,.row>aside .h2:first-child{margin-top:1rem}}body{position:relative}#toc>.nav{margin-bottom:1rem}#toc>.nav a.nav-link{color:inherit;padding:0.25rem 0.5rem;margin-bottom:2px;border-radius:.375rem}#toc>.nav a.nav-link:hover,#toc>.nav a.nav-link:focus{background-color:RGBA(var(--bs-primary-rgb), 0.1)}#toc>.nav a.nav-link.active{background-color:RGBA(var(--bs-body-color-rgb), 0.1)}#toc>.nav .nav a.nav-link{margin-left:0.5rem}#toc>.nav .nav{display:none !important}#toc>.nav a.active+.nav{display:flex !important}footer{margin:1rem 0 1rem 0;padding-top:1rem;font-size:.875em;border-top:1px solid #dee2e6;background:rgba(0,0,0,0);color:RGBA(var(--bs-body-color-rgb), 0.8);display:flex;column-gap:1rem}@media (max-width: 575.98px){footer{flex-direction:column}}@media (min-width: 576px){footer .pkgdown-footer-right{text-align:right}}footer div{flex:1 1 auto}html,body{height:100%}body>.container{min-height:100%;display:flex;flex-direction:column}body>.container .row{flex:1 0 auto}main img{max-width:100%;height:auto}main table{display:block;overflow:auto}body{font-display:fallback}.page-header{border-bottom:1px solid var(--bs-border-color);padding-bottom:0.5rem;margin-bottom:0.5rem;margin-top:1.5rem}dl{margin-bottom:0}dd{padding-left:1.5rem;margin-bottom:0.25rem}h2,.h2{font-size:1.75rem;margin-top:1.5rem}h3,.h3{font-size:1.25rem;margin-top:1rem;font-weight:bold}h4,.h4{font-size:1.1rem;font-weight:bold}h5,.h5{font-size:1rem;font-weight:bold}summary{margin-bottom:0.5rem}details{margin-bottom:1rem}.html-widget{margin-bottom:1rem}a.anchor{display:none;margin-left:2px;vertical-align:top;width:Min(0.9em, 20px);height:Min(0.9em, 20px);background-image:url(../../link.svg);background-repeat:no-repeat;background-size:Min(0.9em, 20px) Min(0.9em, 20px);background-position:center center}h2:hover .anchor,.h2:hover .anchor,h2:target .anchor,.h2:target .anchor,h3:hover .anchor,.h3:hover .anchor,h3:target .anchor,.h3:target .anchor,h4:hover .anchor,.h4:hover .anchor,h4:target .anchor,.h4:target .anchor,h5:hover .anchor,.h5:hover .anchor,h5:target .anchor,.h5:target .anchor,h6:hover .anchor,.h6:hover .anchor,h6:target .anchor,.h6:target .anchor,dt:hover .anchor,dt:target .anchor{display:inline-block}dt:target,dt:target+dd{border-left:0.25rem solid var(--bs-primary);margin-left:-0.75rem}dt:target{padding-left:0.5rem}dt:target+dd{padding-left:2rem}.orcid{color:#A6CE39;margin-right:4px}.fab{font-family:"Font Awesome 5 Brands" !important}img.logo{float:right;width:100px;margin-left:30px}.template-home img.logo{width:120px}@media (max-width: 575.98px){img.logo{width:80px}}@media (min-width: 576px){.page-header{min-height:88px}.template-home .page-header{min-height:104px}}.line-block{margin-bottom:1rem}.template-reference-index dt{font-weight:normal}.template-reference-index code{word-wrap:normal}.icon{float:right}.icon img{width:40px}a[href='#main']{position:absolute;margin:4px;padding:0.75rem;background-color:var(--bs-body-bg);text-decoration:none;z-index:2000}.lifecycle{color:var(--bs-secondary-color);background-color:var(--bs-secondary-bg);border-radius:5px}.lifecycle-stable{background-color:#108001;color:var(--bs-white)}.lifecycle-superseded{background-color:#074080;color:var(--bs-white)}.lifecycle-experimental,.lifecycle-deprecated{background-color:#fd8008;color:var(--bs-black)}a.footnote-ref{cursor:pointer}.popover{width:Min(100vw, 32rem);font-size:0.9rem;box-shadow:4px 4px 8px RGBA(var(--bs-body-color-rgb), 0.3)}.popover-body{padding:0.75rem}.popover-body p:last-child{margin-bottom:0}.tab-content{padding:1rem}.tabset-pills .tab-content{border:solid 1px #e5e5e5}.tab-content{display:flex}.tab-content>.tab-pane{display:block;visibility:hidden;margin-right:-100%;width:100%}.tab-content>.active{visibility:visible}div.csl-entry{clear:both}.hanging-indent div.csl-entry{margin-left:2em;text-indent:-2em}div.csl-left-margin{min-width:2em;float:left}div.csl-right-inline{margin-left:2em;padding-left:1em}div.csl-indent{margin-left:2em}pre,pre code{word-wrap:normal}[data-bs-theme="dark"] pre,[data-bs-theme="dark"] code{background-color:RGBA(var(--bs-body-color-rgb), 0.1)}[data-bs-theme="dark"] pre code{background:transparent}code{overflow-wrap:break-word}.hasCopyButton{position:relative}.btn-copy-ex{position:absolute;right:5px;top:5px;visibility:hidden}.hasCopyButton:hover button.btn-copy-ex{visibility:visible}pre{padding:0.75rem}pre div.gt-table{white-space:normal;margin-top:1rem}@media (max-width: 575.98px){div>div>pre{margin-left:calc(var(--bs-gutter-x) * -.5);margin-right:calc(var(--bs-gutter-x) * -.5);border-radius:0;padding-left:1rem;padding-right:1rem}.btn-copy-ex{right:calc(var(--bs-gutter-x) * -.5 + 5px)}}code a:any-link{color:inherit;text-decoration-color:RGBA(var(--bs-body-color-rgb), 0.6)}pre code{padding:0;background:transparent}pre code .error,pre code .warning{font-weight:bolder}pre .img img,pre .r-plt img{margin:5px 0;background-color:#fff}[data-bs-theme="dark"] pre img{opacity:0.66;transition:opacity 250ms ease-in-out}[data-bs-theme="dark"] pre img:hover,[data-bs-theme="dark"] pre img:focus,[data-bs-theme="dark"] pre img:active{opacity:1}@media print{code a:link:after,code a:visited:after{content:""}}a.sourceLine:hover{text-decoration:none}mark,.mark{background:linear-gradient(-100deg, RGBA(var(--bs-info-rgb), 0.2), RGBA(var(--bs-info-rgb), 0.7) 95%, RGBA(var(--bs-info-rgb), 0.1))}.algolia-autocomplete .aa-dropdown-menu{margin-top:0.5rem;padding:0.5rem 0.25rem;width:MAX(100%, 20rem);max-height:50vh;overflow-y:auto;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color);border-radius:.375rem}.algolia-autocomplete .aa-dropdown-menu .aa-suggestion{cursor:pointer;font-size:1rem;padding:0.5rem 0.25rem;line-height:1.3}.algolia-autocomplete .aa-dropdown-menu .aa-suggestion:hover{background-color:var(--bs-tertiary-bg);color:var(--bs-body-color)}.algolia-autocomplete .aa-dropdown-menu .aa-suggestion .search-details{text-decoration:underline;display:inline}span.smallcaps{font-variant:small-caps}ul.task-list{list-style:none}ul.task-list li input[type="checkbox"]{width:0.8em;margin:0 0.8em 0.2em -1em;vertical-align:middle}figure.figure{display:block}.quarto-layout-panel{margin-bottom:1em}.quarto-layout-panel>figure{width:100%}.quarto-layout-panel>figure>figcaption,.quarto-layout-panel>.panel-caption{margin-top:10pt}.quarto-layout-panel>.table-caption{margin-top:0px}.table-caption p{margin-bottom:0.5em}.quarto-layout-row{display:flex;flex-direction:row;align-items:flex-start}.quarto-layout-valign-top{align-items:flex-start}.quarto-layout-valign-bottom{align-items:flex-end}.quarto-layout-valign-center{align-items:center}.quarto-layout-cell{position:relative;margin-right:20px}.quarto-layout-cell:last-child{margin-right:0}.quarto-layout-cell figure,.quarto-layout-cell>p{margin:0.2em}.quarto-layout-cell img{max-width:100%}.quarto-layout-cell .html-widget{width:100% !important}.quarto-layout-cell div figure p{margin:0}.quarto-layout-cell figure{display:block;margin-inline-start:0;margin-inline-end:0}.quarto-layout-cell table{display:inline-table}.quarto-layout-cell-subref figcaption,figure .quarto-layout-row figure figcaption{text-align:center;font-style:italic}.quarto-figure{position:relative;margin-bottom:1em}.quarto-figure>figure{width:100%;margin-bottom:0}.quarto-figure-left>figure>p,.quarto-figure-left>figure>div{text-align:left}.quarto-figure-center>figure>p,.quarto-figure-center>figure>div{text-align:center}.quarto-figure-right>figure>p,.quarto-figure-right>figure>div{text-align:right}.quarto-figure>figure>div.cell-annotation,.quarto-figure>figure>div code{text-align:left}figure>p:empty{display:none}figure>p:first-child{margin-top:0;margin-bottom:0}figure>figcaption.quarto-float-caption-bottom{margin-bottom:0.5em}figure>figcaption.quarto-float-caption-top{margin-top:0.5em}:root{--mermaid-bg-color: transparent;--mermaid-edge-color: var(--bs-secondary);--mermaid-fg-color: var(--bs-body-color);--mermaid-fg-color--lighter: RGBA(var(--bs-body-color-rgb), 0.9);--mermaid-fg-color--lightest: RGBA(var(--bs-body-color-rgb), 0.8);--mermaid-font-family: var(--bs-body-font-family);--mermaid-label-bg-color: var(--bs-primary);--mermaid-label-fg-color: var(--bs-body-color);--mermaid-node-bg-color: RGBA(var(--bs-primary-rgb), 0.1);--mermaid-node-fg-color: var(--bs-primary)}pre{background-color:#f1f3f5}pre code{color:#003B4F}pre code span.al{color:#AD0000}pre code span.an{color:#5E5E5E}pre code span.at{color:#657422}pre code span.bn{color:#AD0000}pre code span.cf{color:#003B4F}pre code span.ch{color:#20794D}pre code span.cn{color:#8f5902}pre code span.co{color:#5E5E5E}pre code span.cv{color:#5E5E5E;font-style:italic}pre code span.do{color:#5E5E5E;font-style:italic}pre code span.dt{color:#AD0000}pre code span.dv{color:#AD0000}pre code span.er{color:#AD0000}pre code span.fl{color:#AD0000}pre code span.fu{color:#4758AB}pre code span.im{color:#00769E}pre code span.in{color:#5E5E5E}pre code span.kw{color:#003B4F}pre code span.op{color:#5E5E5E}pre code span.ot{color:#003B4F}pre code span.pp{color:#AD0000}pre code span.sc{color:#5E5E5E}pre code span.ss{color:#20794D}pre code span.st{color:#20794D}pre code span.va{color:#111111}pre code span.vs{color:#20794D}pre code span.wa{color:#5E5E5E;font-style:italic} + */:root,[data-bs-theme="light"]{--bs-blue: #3459e6;--bs-indigo: #6610f2;--bs-purple: #6f42c1;--bs-pink: #d63384;--bs-red: #da292e;--bs-orange: #f8765f;--bs-yellow: #f4bd61;--bs-green: #2fb380;--bs-teal: #20c997;--bs-cyan: #287bb5;--bs-black: #000;--bs-white: #fff;--bs-gray: #6c757d;--bs-gray-dark: #343a40;--bs-gray-100: #f8f9fa;--bs-gray-200: #e9ecef;--bs-gray-300: #dee2e6;--bs-gray-400: #ced4da;--bs-gray-500: #adb5bd;--bs-gray-600: #6c757d;--bs-gray-700: #495057;--bs-gray-800: #343a40;--bs-gray-900: #212529;--bs-default: #fff;--bs-primary: #3459e6;--bs-secondary: #fff;--bs-success: #2fb380;--bs-info: #287bb5;--bs-warning: #f4bd61;--bs-danger: #da292e;--bs-light: #f8f9fa;--bs-dark: #212529;--bs-default-rgb: 255,255,255;--bs-primary-rgb: 52,89,230;--bs-secondary-rgb: 255,255,255;--bs-success-rgb: 47,179,128;--bs-info-rgb: 40,123,181;--bs-warning-rgb: 244,189,97;--bs-danger-rgb: 218,41,46;--bs-light-rgb: 248,249,250;--bs-dark-rgb: 33,37,41;--bs-primary-text-emphasis: #15245c;--bs-secondary-text-emphasis: #666;--bs-success-text-emphasis: #134833;--bs-info-text-emphasis: #103148;--bs-warning-text-emphasis: #624c27;--bs-danger-text-emphasis: #571012;--bs-light-text-emphasis: #495057;--bs-dark-text-emphasis: #495057;--bs-primary-bg-subtle: #d6defa;--bs-secondary-bg-subtle: #fff;--bs-success-bg-subtle: #d5f0e6;--bs-info-bg-subtle: #d4e5f0;--bs-warning-bg-subtle: #fdf2df;--bs-danger-bg-subtle: #f8d4d5;--bs-light-bg-subtle: #fcfcfd;--bs-dark-bg-subtle: #ced4da;--bs-primary-border-subtle: #aebdf5;--bs-secondary-border-subtle: #fff;--bs-success-border-subtle: #ace1cc;--bs-info-border-subtle: #a9cae1;--bs-warning-border-subtle: #fbe5c0;--bs-danger-border-subtle: #f0a9ab;--bs-light-border-subtle: #e9ecef;--bs-dark-border-subtle: #adb5bd;--bs-white-rgb: 255,255,255;--bs-black-rgb: 0,0,0;--bs-font-sans-serif: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--bs-gradient: linear-gradient(180deg, rgba(255,255,255,0.15), rgba(255,255,255,0));--bs-body-font-family: var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight: 400;--bs-body-line-height: 1.5;--bs-body-color: #495057;--bs-body-color-rgb: 73,80,87;--bs-body-bg: #fff;--bs-body-bg-rgb: 255,255,255;--bs-emphasis-color: #000;--bs-emphasis-color-rgb: 0,0,0;--bs-secondary-color: rgba(73,80,87,0.75);--bs-secondary-color-rgb: 73,80,87;--bs-secondary-bg: #e9ecef;--bs-secondary-bg-rgb: 233,236,239;--bs-tertiary-color: rgba(73,80,87,0.5);--bs-tertiary-color-rgb: 73,80,87;--bs-tertiary-bg: #f8f9fa;--bs-tertiary-bg-rgb: 248,249,250;--bs-heading-color: #212529;--bs-link-color: #3459e6;--bs-link-color-rgb: 52,89,230;--bs-link-decoration: underline;--bs-link-hover-color: #2a47b8;--bs-link-hover-color-rgb: 42,71,184;--bs-code-color: RGB(var(--bs-emphasis-color-rgb, 0, 0, 0));--bs-highlight-bg: #fdf2df;--bs-border-width: 1px;--bs-border-style: solid;--bs-border-color: #dee2e6;--bs-border-color-translucent: rgba(0,0,0,0.175);--bs-border-radius: .375rem;--bs-border-radius-sm: .25rem;--bs-border-radius-lg: .5rem;--bs-border-radius-xl: 1rem;--bs-border-radius-xxl: 2rem;--bs-border-radius-2xl: var(--bs-border-radius-xxl);--bs-border-radius-pill: 50rem;--bs-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-box-shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,0.075);--bs-box-shadow-lg: 0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06);--bs-box-shadow-inset: inset 0 1px 2px rgba(0,0,0,0.075);--bs-focus-ring-width: .25rem;--bs-focus-ring-opacity: .25;--bs-focus-ring-color: rgba(52,89,230,0.25);--bs-form-valid-color: #2fb380;--bs-form-valid-border-color: #2fb380;--bs-form-invalid-color: #da292e;--bs-form-invalid-border-color: #da292e}[data-bs-theme="dark"]{color-scheme:dark;--bs-body-color: #dee2e6;--bs-body-color-rgb: 222,226,230;--bs-body-bg: #212529;--bs-body-bg-rgb: 33,37,41;--bs-emphasis-color: #fff;--bs-emphasis-color-rgb: 255,255,255;--bs-secondary-color: rgba(222,226,230,0.75);--bs-secondary-color-rgb: 222,226,230;--bs-secondary-bg: #343a40;--bs-secondary-bg-rgb: 52,58,64;--bs-tertiary-color: rgba(222,226,230,0.5);--bs-tertiary-color-rgb: 222,226,230;--bs-tertiary-bg: #2b3035;--bs-tertiary-bg-rgb: 43,48,53;--bs-primary-text-emphasis: #859bf0;--bs-secondary-text-emphasis: #fff;--bs-success-text-emphasis: #82d1b3;--bs-info-text-emphasis: #7eb0d3;--bs-warning-text-emphasis: #f8d7a0;--bs-danger-text-emphasis: #e97f82;--bs-light-text-emphasis: #f8f9fa;--bs-dark-text-emphasis: #dee2e6;--bs-primary-bg-subtle: #0a122e;--bs-secondary-bg-subtle: #333;--bs-success-bg-subtle: #09241a;--bs-info-bg-subtle: #081924;--bs-warning-bg-subtle: #312613;--bs-danger-bg-subtle: #2c0809;--bs-light-bg-subtle: #343a40;--bs-dark-bg-subtle: #1a1d20;--bs-primary-border-subtle: #1f358a;--bs-secondary-border-subtle: #999;--bs-success-border-subtle: #1c6b4d;--bs-info-border-subtle: #184a6d;--bs-warning-border-subtle: #92713a;--bs-danger-border-subtle: #83191c;--bs-light-border-subtle: #495057;--bs-dark-border-subtle: #343a40;--bs-heading-color: inherit;--bs-link-color: #859bf0;--bs-link-hover-color: #9daff3;--bs-link-color-rgb: 133,155,240;--bs-link-hover-color-rgb: 157,175,243;--bs-code-color: RGB(var(--bs-emphasis-color-rgb, 0, 0, 0));--bs-border-color: #495057;--bs-border-color-translucent: rgba(255,255,255,0.15);--bs-form-valid-color: #82d1b3;--bs-form-valid-border-color: #82d1b3;--bs-form-invalid-color: #e97f82;--bs-form-invalid-border-color: #e97f82}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion: no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0)}hr{margin:1rem 0;color:inherit;border:0;border-top:var(--bs-border-width) solid;opacity:.25}h6,.h6,h5,.h5,h4,.h4,h3,.h3,h2,.h2,h1,.h1{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2;color:var(--bs-heading-color)}h1,.h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width: 1200px){h1,.h1{font-size:2.5rem}}h2,.h2{font-size:calc(1.325rem + .9vw)}@media (min-width: 1200px){h2,.h2{font-size:2rem}}h3,.h3{font-size:calc(1.3rem + .6vw)}@media (min-width: 1200px){h3,.h3{font-size:1.75rem}}h4,.h4{font-size:calc(1.275rem + .3vw)}@media (min-width: 1200px){h4,.h4{font-size:1.5rem}}h5,.h5{font-size:1.25rem}h6,.h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[title]{text-decoration:underline dotted;-webkit-text-decoration:underline dotted;-moz-text-decoration:underline dotted;-ms-text-decoration:underline dotted;-o-text-decoration:underline dotted;cursor:help;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}ol,ul,dl{margin-top:0;margin-bottom:1rem}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem;padding:.625rem 1.25rem;border-left:.25rem solid #e9ecef}blockquote p:last-child,blockquote ul:last-child,blockquote ol:last-child{margin-bottom:0}b,strong{font-weight:bolder}small,.small{font-size:.875em}mark,.mark{padding:.1875em;background-color:var(--bs-highlight-bg)}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 1));text-decoration:underline;-webkit-text-decoration:underline;-moz-text-decoration:underline;-ms-text-decoration:underline;-o-text-decoration:underline}a:hover{--bs-link-color-rgb: var(--bs-link-hover-color-rgb)}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}pre,code,kbd,samp{font-family:var(--bs-font-monospace);font-size:1em}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em;color:RGB(var(--bs-emphasis-color-rgb, 0, 0, 0));background-color:RGBA(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.04);padding:.5rem;border:1px solid var(--bs-border-color, #dee2e6);border-radius:.375rem}pre code{background-color:transparent;font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:var(--bs-code-color);background-color:RGBA(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.04);border-radius:.375rem;padding:.125rem .25rem;word-wrap:break-word}a>code{color:inherit}kbd{padding:.1875rem .375rem;font-size:.875em;color:var(--bs-body-bg);background-color:var(--bs-body-color);border-radius:.25rem}kbd kbd{padding:0;font-size:1em}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:1rem;padding-bottom:1rem;color:var(--bs-secondary-color);text-align:left}th{font-weight:500;text-align:inherit;text-align:-webkit-match-parent}thead,tbody,tfoot,tr,td,th{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}input,button,select,optgroup,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role="button"]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]:not([type="date"]):not([type="datetime-local"]):not([type="month"]):not([type="week"]):not([type="time"])::-webkit-calendar-picker-indicator{display:none !important}button,[type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button:not(:disabled),[type="button"]:not(:disabled),[type="reset"]:not(:disabled),[type="submit"]:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width: 1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-text,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none !important}.lead{font-size:1.25rem;font-weight:300}.display-1{font-size:calc(1.625rem + 4.5vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-1{font-size:5rem}}.display-2{font-size:calc(1.575rem + 3.9vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-2{font-size:4.5rem}}.display-3{font-size:calc(1.525rem + 3.3vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-3{font-size:4rem}}.display-4{font-size:calc(1.475rem + 2.7vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-4{font-size:3.5rem}}.display-5{font-size:calc(1.425rem + 2.1vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-5{font-size:3rem}}.display-6{font-size:calc(1.375rem + 1.5vw);font-weight:300;line-height:1.2}@media (min-width: 1200px){.display-6{font-size:2.5rem}}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none}.list-inline-item{display:inline-block}.list-inline-item:not(:last-child){margin-right:.5rem}.initialism{font-size:.875em;text-transform:uppercase}.blockquote{margin-bottom:1rem;font-size:1.25rem}.blockquote>:last-child{margin-bottom:0}.blockquote-footer{margin-top:-1rem;margin-bottom:1rem;font-size:.875em;color:#6c757d}.blockquote-footer::before{content:"\2014\00A0"}.img-fluid{max-width:100%;height:auto}.img-thumbnail{padding:.25rem;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color);border-radius:var(--bs-border-radius);box-shadow:var(--bs-box-shadow-sm);max-width:100%;height:auto}.figure{display:inline-block}.figure-img{margin-bottom:.5rem;line-height:1}.figure-caption{font-size:.875em;color:var(--bs-secondary-color)}.container,.container-fluid,.container-xxl,.container-xl,.container-lg,.container-md,.container-sm{--bs-gutter-x: 1.5rem;--bs-gutter-y: 0;width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5);margin-right:auto;margin-left:auto}@media (min-width: 576px){.container-sm,.container{max-width:540px}}@media (min-width: 768px){.container-md,.container-sm,.container{max-width:720px}}@media (min-width: 992px){.container-lg,.container-md,.container-sm,.container{max-width:960px}}@media (min-width: 1200px){.container-xl,.container-lg,.container-md,.container-sm,.container{max-width:1140px}}@media (min-width: 1400px){.container-xxl,.container-xl,.container-lg,.container-md,.container-sm,.container{max-width:1320px}}:root{--bs-breakpoint-xs: 0;--bs-breakpoint-sm: 576px;--bs-breakpoint-md: 768px;--bs-breakpoint-lg: 992px;--bs-breakpoint-xl: 1200px;--bs-breakpoint-xxl: 1400px}.row{--bs-gutter-x: 1.5rem;--bs-gutter-y: 0;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;margin-top:calc(-1 * var(--bs-gutter-y));margin-right:calc(-.5 * var(--bs-gutter-x));margin-left:calc(-.5 * var(--bs-gutter-x))}.row>*{flex-shrink:0;-webkit-flex-shrink:0;width:100%;max-width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5);margin-top:var(--bs-gutter-y)}.grid{display:grid;grid-template-rows:repeat(var(--bs-rows, 1), 1fr);grid-template-columns:repeat(var(--bs-columns, 12), 1fr);gap:var(--bs-gap, 1.5rem)}.grid .g-col-1{grid-column:auto/span 1}.grid .g-col-2{grid-column:auto/span 2}.grid .g-col-3{grid-column:auto/span 3}.grid .g-col-4{grid-column:auto/span 4}.grid .g-col-5{grid-column:auto/span 5}.grid .g-col-6{grid-column:auto/span 6}.grid .g-col-7{grid-column:auto/span 7}.grid .g-col-8{grid-column:auto/span 8}.grid .g-col-9{grid-column:auto/span 9}.grid .g-col-10{grid-column:auto/span 10}.grid .g-col-11{grid-column:auto/span 11}.grid .g-col-12{grid-column:auto/span 12}.grid .g-start-1{grid-column-start:1}.grid .g-start-2{grid-column-start:2}.grid .g-start-3{grid-column-start:3}.grid .g-start-4{grid-column-start:4}.grid .g-start-5{grid-column-start:5}.grid .g-start-6{grid-column-start:6}.grid .g-start-7{grid-column-start:7}.grid .g-start-8{grid-column-start:8}.grid .g-start-9{grid-column-start:9}.grid .g-start-10{grid-column-start:10}.grid .g-start-11{grid-column-start:11}@media (min-width: 576px){.grid .g-col-sm-1{grid-column:auto/span 1}.grid .g-col-sm-2{grid-column:auto/span 2}.grid .g-col-sm-3{grid-column:auto/span 3}.grid .g-col-sm-4{grid-column:auto/span 4}.grid .g-col-sm-5{grid-column:auto/span 5}.grid .g-col-sm-6{grid-column:auto/span 6}.grid .g-col-sm-7{grid-column:auto/span 7}.grid .g-col-sm-8{grid-column:auto/span 8}.grid .g-col-sm-9{grid-column:auto/span 9}.grid .g-col-sm-10{grid-column:auto/span 10}.grid .g-col-sm-11{grid-column:auto/span 11}.grid .g-col-sm-12{grid-column:auto/span 12}.grid .g-start-sm-1{grid-column-start:1}.grid .g-start-sm-2{grid-column-start:2}.grid .g-start-sm-3{grid-column-start:3}.grid .g-start-sm-4{grid-column-start:4}.grid .g-start-sm-5{grid-column-start:5}.grid .g-start-sm-6{grid-column-start:6}.grid .g-start-sm-7{grid-column-start:7}.grid .g-start-sm-8{grid-column-start:8}.grid .g-start-sm-9{grid-column-start:9}.grid .g-start-sm-10{grid-column-start:10}.grid .g-start-sm-11{grid-column-start:11}}@media (min-width: 768px){.grid .g-col-md-1{grid-column:auto/span 1}.grid .g-col-md-2{grid-column:auto/span 2}.grid .g-col-md-3{grid-column:auto/span 3}.grid .g-col-md-4{grid-column:auto/span 4}.grid .g-col-md-5{grid-column:auto/span 5}.grid .g-col-md-6{grid-column:auto/span 6}.grid .g-col-md-7{grid-column:auto/span 7}.grid .g-col-md-8{grid-column:auto/span 8}.grid .g-col-md-9{grid-column:auto/span 9}.grid .g-col-md-10{grid-column:auto/span 10}.grid .g-col-md-11{grid-column:auto/span 11}.grid .g-col-md-12{grid-column:auto/span 12}.grid .g-start-md-1{grid-column-start:1}.grid .g-start-md-2{grid-column-start:2}.grid .g-start-md-3{grid-column-start:3}.grid .g-start-md-4{grid-column-start:4}.grid .g-start-md-5{grid-column-start:5}.grid .g-start-md-6{grid-column-start:6}.grid .g-start-md-7{grid-column-start:7}.grid .g-start-md-8{grid-column-start:8}.grid .g-start-md-9{grid-column-start:9}.grid .g-start-md-10{grid-column-start:10}.grid .g-start-md-11{grid-column-start:11}}@media (min-width: 992px){.grid .g-col-lg-1{grid-column:auto/span 1}.grid .g-col-lg-2{grid-column:auto/span 2}.grid .g-col-lg-3{grid-column:auto/span 3}.grid .g-col-lg-4{grid-column:auto/span 4}.grid .g-col-lg-5{grid-column:auto/span 5}.grid .g-col-lg-6{grid-column:auto/span 6}.grid .g-col-lg-7{grid-column:auto/span 7}.grid .g-col-lg-8{grid-column:auto/span 8}.grid .g-col-lg-9{grid-column:auto/span 9}.grid .g-col-lg-10{grid-column:auto/span 10}.grid .g-col-lg-11{grid-column:auto/span 11}.grid .g-col-lg-12{grid-column:auto/span 12}.grid .g-start-lg-1{grid-column-start:1}.grid .g-start-lg-2{grid-column-start:2}.grid .g-start-lg-3{grid-column-start:3}.grid .g-start-lg-4{grid-column-start:4}.grid .g-start-lg-5{grid-column-start:5}.grid .g-start-lg-6{grid-column-start:6}.grid .g-start-lg-7{grid-column-start:7}.grid .g-start-lg-8{grid-column-start:8}.grid .g-start-lg-9{grid-column-start:9}.grid .g-start-lg-10{grid-column-start:10}.grid .g-start-lg-11{grid-column-start:11}}@media (min-width: 1200px){.grid .g-col-xl-1{grid-column:auto/span 1}.grid .g-col-xl-2{grid-column:auto/span 2}.grid .g-col-xl-3{grid-column:auto/span 3}.grid .g-col-xl-4{grid-column:auto/span 4}.grid .g-col-xl-5{grid-column:auto/span 5}.grid .g-col-xl-6{grid-column:auto/span 6}.grid .g-col-xl-7{grid-column:auto/span 7}.grid .g-col-xl-8{grid-column:auto/span 8}.grid .g-col-xl-9{grid-column:auto/span 9}.grid .g-col-xl-10{grid-column:auto/span 10}.grid .g-col-xl-11{grid-column:auto/span 11}.grid .g-col-xl-12{grid-column:auto/span 12}.grid .g-start-xl-1{grid-column-start:1}.grid .g-start-xl-2{grid-column-start:2}.grid .g-start-xl-3{grid-column-start:3}.grid .g-start-xl-4{grid-column-start:4}.grid .g-start-xl-5{grid-column-start:5}.grid .g-start-xl-6{grid-column-start:6}.grid .g-start-xl-7{grid-column-start:7}.grid .g-start-xl-8{grid-column-start:8}.grid .g-start-xl-9{grid-column-start:9}.grid .g-start-xl-10{grid-column-start:10}.grid .g-start-xl-11{grid-column-start:11}}@media (min-width: 1400px){.grid .g-col-xxl-1{grid-column:auto/span 1}.grid .g-col-xxl-2{grid-column:auto/span 2}.grid .g-col-xxl-3{grid-column:auto/span 3}.grid .g-col-xxl-4{grid-column:auto/span 4}.grid .g-col-xxl-5{grid-column:auto/span 5}.grid .g-col-xxl-6{grid-column:auto/span 6}.grid .g-col-xxl-7{grid-column:auto/span 7}.grid .g-col-xxl-8{grid-column:auto/span 8}.grid .g-col-xxl-9{grid-column:auto/span 9}.grid .g-col-xxl-10{grid-column:auto/span 10}.grid .g-col-xxl-11{grid-column:auto/span 11}.grid .g-col-xxl-12{grid-column:auto/span 12}.grid .g-start-xxl-1{grid-column-start:1}.grid .g-start-xxl-2{grid-column-start:2}.grid .g-start-xxl-3{grid-column-start:3}.grid .g-start-xxl-4{grid-column-start:4}.grid .g-start-xxl-5{grid-column-start:5}.grid .g-start-xxl-6{grid-column-start:6}.grid .g-start-xxl-7{grid-column-start:7}.grid .g-start-xxl-8{grid-column-start:8}.grid .g-start-xxl-9{grid-column-start:9}.grid .g-start-xxl-10{grid-column-start:10}.grid .g-start-xxl-11{grid-column-start:11}}.col{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-1{margin-left:8.33333%}.offset-2{margin-left:16.66667%}.offset-3{margin-left:25%}.offset-4{margin-left:33.33333%}.offset-5{margin-left:41.66667%}.offset-6{margin-left:50%}.offset-7{margin-left:58.33333%}.offset-8{margin-left:66.66667%}.offset-9{margin-left:75%}.offset-10{margin-left:83.33333%}.offset-11{margin-left:91.66667%}.g-0,.gx-0{--bs-gutter-x: 0}.g-0,.gy-0{--bs-gutter-y: 0}.g-1,.gx-1{--bs-gutter-x: .25rem}.g-1,.gy-1{--bs-gutter-y: .25rem}.g-2,.gx-2{--bs-gutter-x: .5rem}.g-2,.gy-2{--bs-gutter-y: .5rem}.g-3,.gx-3{--bs-gutter-x: 1rem}.g-3,.gy-3{--bs-gutter-y: 1rem}.g-4,.gx-4{--bs-gutter-x: 1.5rem}.g-4,.gy-4{--bs-gutter-y: 1.5rem}.g-5,.gx-5{--bs-gutter-x: 3rem}.g-5,.gy-5{--bs-gutter-y: 3rem}@media (min-width: 576px){.col-sm{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-sm-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-sm-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-sm-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-sm-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-sm-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-sm-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-sm-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-sm-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-sm-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-sm-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-sm-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-sm-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-sm-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-sm-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-sm-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-sm-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-sm-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-sm-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-sm-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-sm-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-sm-0{margin-left:0}.offset-sm-1{margin-left:8.33333%}.offset-sm-2{margin-left:16.66667%}.offset-sm-3{margin-left:25%}.offset-sm-4{margin-left:33.33333%}.offset-sm-5{margin-left:41.66667%}.offset-sm-6{margin-left:50%}.offset-sm-7{margin-left:58.33333%}.offset-sm-8{margin-left:66.66667%}.offset-sm-9{margin-left:75%}.offset-sm-10{margin-left:83.33333%}.offset-sm-11{margin-left:91.66667%}.g-sm-0,.gx-sm-0{--bs-gutter-x: 0}.g-sm-0,.gy-sm-0{--bs-gutter-y: 0}.g-sm-1,.gx-sm-1{--bs-gutter-x: .25rem}.g-sm-1,.gy-sm-1{--bs-gutter-y: .25rem}.g-sm-2,.gx-sm-2{--bs-gutter-x: .5rem}.g-sm-2,.gy-sm-2{--bs-gutter-y: .5rem}.g-sm-3,.gx-sm-3{--bs-gutter-x: 1rem}.g-sm-3,.gy-sm-3{--bs-gutter-y: 1rem}.g-sm-4,.gx-sm-4{--bs-gutter-x: 1.5rem}.g-sm-4,.gy-sm-4{--bs-gutter-y: 1.5rem}.g-sm-5,.gx-sm-5{--bs-gutter-x: 3rem}.g-sm-5,.gy-sm-5{--bs-gutter-y: 3rem}}@media (min-width: 768px){.col-md{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-md-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-md-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-md-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-md-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-md-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-md-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-md-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-md-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-md-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-md-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-md-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-md-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-md-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-md-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-md-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-md-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-md-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-md-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-md-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-md-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-md-0{margin-left:0}.offset-md-1{margin-left:8.33333%}.offset-md-2{margin-left:16.66667%}.offset-md-3{margin-left:25%}.offset-md-4{margin-left:33.33333%}.offset-md-5{margin-left:41.66667%}.offset-md-6{margin-left:50%}.offset-md-7{margin-left:58.33333%}.offset-md-8{margin-left:66.66667%}.offset-md-9{margin-left:75%}.offset-md-10{margin-left:83.33333%}.offset-md-11{margin-left:91.66667%}.g-md-0,.gx-md-0{--bs-gutter-x: 0}.g-md-0,.gy-md-0{--bs-gutter-y: 0}.g-md-1,.gx-md-1{--bs-gutter-x: .25rem}.g-md-1,.gy-md-1{--bs-gutter-y: .25rem}.g-md-2,.gx-md-2{--bs-gutter-x: .5rem}.g-md-2,.gy-md-2{--bs-gutter-y: .5rem}.g-md-3,.gx-md-3{--bs-gutter-x: 1rem}.g-md-3,.gy-md-3{--bs-gutter-y: 1rem}.g-md-4,.gx-md-4{--bs-gutter-x: 1.5rem}.g-md-4,.gy-md-4{--bs-gutter-y: 1.5rem}.g-md-5,.gx-md-5{--bs-gutter-x: 3rem}.g-md-5,.gy-md-5{--bs-gutter-y: 3rem}}@media (min-width: 992px){.col-lg{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-lg-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-lg-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-lg-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-lg-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-lg-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-lg-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-lg-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-lg-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-lg-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-lg-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-lg-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-lg-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-lg-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-lg-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-lg-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-lg-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-lg-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-lg-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-lg-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-lg-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-lg-0{margin-left:0}.offset-lg-1{margin-left:8.33333%}.offset-lg-2{margin-left:16.66667%}.offset-lg-3{margin-left:25%}.offset-lg-4{margin-left:33.33333%}.offset-lg-5{margin-left:41.66667%}.offset-lg-6{margin-left:50%}.offset-lg-7{margin-left:58.33333%}.offset-lg-8{margin-left:66.66667%}.offset-lg-9{margin-left:75%}.offset-lg-10{margin-left:83.33333%}.offset-lg-11{margin-left:91.66667%}.g-lg-0,.gx-lg-0{--bs-gutter-x: 0}.g-lg-0,.gy-lg-0{--bs-gutter-y: 0}.g-lg-1,.gx-lg-1{--bs-gutter-x: .25rem}.g-lg-1,.gy-lg-1{--bs-gutter-y: .25rem}.g-lg-2,.gx-lg-2{--bs-gutter-x: .5rem}.g-lg-2,.gy-lg-2{--bs-gutter-y: .5rem}.g-lg-3,.gx-lg-3{--bs-gutter-x: 1rem}.g-lg-3,.gy-lg-3{--bs-gutter-y: 1rem}.g-lg-4,.gx-lg-4{--bs-gutter-x: 1.5rem}.g-lg-4,.gy-lg-4{--bs-gutter-y: 1.5rem}.g-lg-5,.gx-lg-5{--bs-gutter-x: 3rem}.g-lg-5,.gy-lg-5{--bs-gutter-y: 3rem}}@media (min-width: 1200px){.col-xl{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-xl-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-xl-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-xl-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-xl-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-xl-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-xl-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-xl-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-xl-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-xl-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-xl-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-xl-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-xl-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-xl-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-xl-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-xl-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-xl-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-xl-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-xl-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-xl-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-xl-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-xl-0{margin-left:0}.offset-xl-1{margin-left:8.33333%}.offset-xl-2{margin-left:16.66667%}.offset-xl-3{margin-left:25%}.offset-xl-4{margin-left:33.33333%}.offset-xl-5{margin-left:41.66667%}.offset-xl-6{margin-left:50%}.offset-xl-7{margin-left:58.33333%}.offset-xl-8{margin-left:66.66667%}.offset-xl-9{margin-left:75%}.offset-xl-10{margin-left:83.33333%}.offset-xl-11{margin-left:91.66667%}.g-xl-0,.gx-xl-0{--bs-gutter-x: 0}.g-xl-0,.gy-xl-0{--bs-gutter-y: 0}.g-xl-1,.gx-xl-1{--bs-gutter-x: .25rem}.g-xl-1,.gy-xl-1{--bs-gutter-y: .25rem}.g-xl-2,.gx-xl-2{--bs-gutter-x: .5rem}.g-xl-2,.gy-xl-2{--bs-gutter-y: .5rem}.g-xl-3,.gx-xl-3{--bs-gutter-x: 1rem}.g-xl-3,.gy-xl-3{--bs-gutter-y: 1rem}.g-xl-4,.gx-xl-4{--bs-gutter-x: 1.5rem}.g-xl-4,.gy-xl-4{--bs-gutter-y: 1.5rem}.g-xl-5,.gx-xl-5{--bs-gutter-x: 3rem}.g-xl-5,.gy-xl-5{--bs-gutter-y: 3rem}}@media (min-width: 1400px){.col-xxl{flex:1 0 0%;-webkit-flex:1 0 0%}.row-cols-xxl-auto>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.row-cols-xxl-1>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.row-cols-xxl-2>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.row-cols-xxl-3>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.row-cols-xxl-4>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.row-cols-xxl-5>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:20%}.row-cols-xxl-6>*{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-xxl-auto{flex:0 0 auto;-webkit-flex:0 0 auto;width:auto}.col-xxl-1{flex:0 0 auto;-webkit-flex:0 0 auto;width:8.33333%}.col-xxl-2{flex:0 0 auto;-webkit-flex:0 0 auto;width:16.66667%}.col-xxl-3{flex:0 0 auto;-webkit-flex:0 0 auto;width:25%}.col-xxl-4{flex:0 0 auto;-webkit-flex:0 0 auto;width:33.33333%}.col-xxl-5{flex:0 0 auto;-webkit-flex:0 0 auto;width:41.66667%}.col-xxl-6{flex:0 0 auto;-webkit-flex:0 0 auto;width:50%}.col-xxl-7{flex:0 0 auto;-webkit-flex:0 0 auto;width:58.33333%}.col-xxl-8{flex:0 0 auto;-webkit-flex:0 0 auto;width:66.66667%}.col-xxl-9{flex:0 0 auto;-webkit-flex:0 0 auto;width:75%}.col-xxl-10{flex:0 0 auto;-webkit-flex:0 0 auto;width:83.33333%}.col-xxl-11{flex:0 0 auto;-webkit-flex:0 0 auto;width:91.66667%}.col-xxl-12{flex:0 0 auto;-webkit-flex:0 0 auto;width:100%}.offset-xxl-0{margin-left:0}.offset-xxl-1{margin-left:8.33333%}.offset-xxl-2{margin-left:16.66667%}.offset-xxl-3{margin-left:25%}.offset-xxl-4{margin-left:33.33333%}.offset-xxl-5{margin-left:41.66667%}.offset-xxl-6{margin-left:50%}.offset-xxl-7{margin-left:58.33333%}.offset-xxl-8{margin-left:66.66667%}.offset-xxl-9{margin-left:75%}.offset-xxl-10{margin-left:83.33333%}.offset-xxl-11{margin-left:91.66667%}.g-xxl-0,.gx-xxl-0{--bs-gutter-x: 0}.g-xxl-0,.gy-xxl-0{--bs-gutter-y: 0}.g-xxl-1,.gx-xxl-1{--bs-gutter-x: .25rem}.g-xxl-1,.gy-xxl-1{--bs-gutter-y: .25rem}.g-xxl-2,.gx-xxl-2{--bs-gutter-x: .5rem}.g-xxl-2,.gy-xxl-2{--bs-gutter-y: .5rem}.g-xxl-3,.gx-xxl-3{--bs-gutter-x: 1rem}.g-xxl-3,.gy-xxl-3{--bs-gutter-y: 1rem}.g-xxl-4,.gx-xxl-4{--bs-gutter-x: 1.5rem}.g-xxl-4,.gy-xxl-4{--bs-gutter-y: 1.5rem}.g-xxl-5,.gx-xxl-5{--bs-gutter-x: 3rem}.g-xxl-5,.gy-xxl-5{--bs-gutter-y: 3rem}}.table{--bs-table-color-type: initial;--bs-table-bg-type: initial;--bs-table-color-state: initial;--bs-table-bg-state: initial;--bs-table-color: var(--bs-body-color);--bs-table-bg: var(--bs-body-bg);--bs-table-border-color: var(--bs-border-color);--bs-table-accent-bg: rgba(0,0,0,0);--bs-table-striped-color: var(--bs-body-color);--bs-table-striped-bg: rgba(0,0,0,0.05);--bs-table-active-color: var(--bs-body-color);--bs-table-active-bg: rgba(0,0,0,0.1);--bs-table-hover-color: var(--bs-body-color);--bs-table-hover-bg: rgba(0,0,0,0.075);width:100%;margin-bottom:1rem;vertical-align:top;border-color:var(--bs-table-border-color)}.table>:not(caption)>*>*{padding:1rem 1rem;color:var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));background-color:var(--bs-table-bg);border-bottom-width:var(--bs-border-width);box-shadow:inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-accent-bg)))}.table>tbody{vertical-align:inherit}.table>thead{vertical-align:bottom}.table-group-divider{border-top:calc(var(--bs-border-width) * 2) solid currentcolor}.caption-top{caption-side:top}.table-sm>:not(caption)>*>*{padding:.5rem .5rem}.table-bordered>:not(caption)>*{border-width:var(--bs-border-width) 0}.table-bordered>:not(caption)>*>*{border-width:0 var(--bs-border-width)}.table-borderless>:not(caption)>*>*{border-bottom-width:0}.table-borderless>:not(:first-child){border-top-width:0}.table-striped>tbody>tr:nth-of-type(odd)>*{--bs-table-color-type: var(--bs-table-striped-color);--bs-table-bg-type: var(--bs-table-striped-bg)}.table-striped-columns>:not(caption)>tr>:nth-child(even){--bs-table-color-type: var(--bs-table-striped-color);--bs-table-bg-type: var(--bs-table-striped-bg)}.table-active{--bs-table-color-state: var(--bs-table-active-color);--bs-table-bg-state: var(--bs-table-active-bg)}.table-hover>tbody>tr:hover>*{--bs-table-color-state: var(--bs-table-hover-color);--bs-table-bg-state: var(--bs-table-hover-bg)}.table-primary{--bs-table-color: #000;--bs-table-bg: #d6defa;--bs-table-border-color: #c1c8e1;--bs-table-striped-bg: #cbd3ee;--bs-table-striped-color: #000;--bs-table-active-bg: #c1c8e1;--bs-table-active-color: #fff;--bs-table-hover-bg: #c6cde7;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-secondary{--bs-table-color: #000;--bs-table-bg: #fff;--bs-table-border-color: #e6e6e6;--bs-table-striped-bg: #f2f2f2;--bs-table-striped-color: #000;--bs-table-active-bg: #e6e6e6;--bs-table-active-color: #000;--bs-table-hover-bg: #ececec;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-success{--bs-table-color: #000;--bs-table-bg: #d5f0e6;--bs-table-border-color: #c0d8cf;--bs-table-striped-bg: #cae4db;--bs-table-striped-color: #000;--bs-table-active-bg: #c0d8cf;--bs-table-active-color: #000;--bs-table-hover-bg: #c5ded5;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-info{--bs-table-color: #000;--bs-table-bg: #d4e5f0;--bs-table-border-color: #bfced8;--bs-table-striped-bg: #c9dae4;--bs-table-striped-color: #000;--bs-table-active-bg: #bfced8;--bs-table-active-color: #000;--bs-table-hover-bg: #c4d4de;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-warning{--bs-table-color: #000;--bs-table-bg: #fdf2df;--bs-table-border-color: #e4dac9;--bs-table-striped-bg: #f0e6d4;--bs-table-striped-color: #000;--bs-table-active-bg: #e4dac9;--bs-table-active-color: #000;--bs-table-hover-bg: #eae0ce;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-danger{--bs-table-color: #000;--bs-table-bg: #f8d4d5;--bs-table-border-color: #dfbfc0;--bs-table-striped-bg: #ecc9ca;--bs-table-striped-color: #000;--bs-table-active-bg: #dfbfc0;--bs-table-active-color: #fff;--bs-table-hover-bg: #e5c4c5;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-light{--bs-table-color: #000;--bs-table-bg: #f8f9fa;--bs-table-border-color: #dfe0e1;--bs-table-striped-bg: #ecedee;--bs-table-striped-color: #000;--bs-table-active-bg: #dfe0e1;--bs-table-active-color: #000;--bs-table-hover-bg: #e5e6e7;--bs-table-hover-color: #000;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-dark{--bs-table-color: #fff;--bs-table-bg: #212529;--bs-table-border-color: #373b3e;--bs-table-striped-bg: #2c3034;--bs-table-striped-color: #fff;--bs-table-active-bg: #373b3e;--bs-table-active-color: #fff;--bs-table-hover-bg: #323539;--bs-table-hover-color: #fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-responsive{overflow-x:auto;-webkit-overflow-scrolling:touch}@media (max-width: 575.98px){.table-responsive-sm{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width: 767.98px){.table-responsive-md{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width: 991.98px){.table-responsive-lg{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width: 1199.98px){.table-responsive-xl{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width: 1399.98px){.table-responsive-xxl{overflow-x:auto;-webkit-overflow-scrolling:touch}}.form-label,.shiny-input-container .control-label{margin-bottom:.5rem;font-weight:500}.col-form-label{padding-top:calc(.5rem + var(--bs-border-width));padding-bottom:calc(.5rem + var(--bs-border-width));margin-bottom:0;font-size:inherit;font-weight:500;line-height:1.5}.col-form-label-lg{padding-top:calc(.5rem + var(--bs-border-width));padding-bottom:calc(.5rem + var(--bs-border-width));font-size:1.25rem}.col-form-label-sm{padding-top:calc(.25rem + var(--bs-border-width));padding-bottom:calc(.25rem + var(--bs-border-width));font-size:.875rem}.form-text{margin-top:.25rem;font-size:.875em;color:var(--bs-secondary-color)}.form-control{display:block;width:100%;padding:.5rem 1rem;font-size:.875rem;font-weight:400;line-height:1.5;color:var(--bs-body-color);appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:var(--bs-body-bg);background-clip:padding-box;border:var(--bs-border-width) solid var(--bs-border-color);border-radius:var(--bs-border-radius);box-shadow:0 1px 2px rgba(0,0,0,0.05);transition:border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-control{transition:none}}.form-control[type="file"]{overflow:hidden}.form-control[type="file"]:not(:disabled):not([readonly]){cursor:pointer}.form-control:focus{color:var(--bs-body-color);background-color:var(--bs-body-bg);border-color:#9aacf3;outline:0;box-shadow:0 1px 2px rgba(0,0,0,0.05),0 0 0 .25rem rgba(52,89,230,0.25)}.form-control::-webkit-date-and-time-value{min-width:85px;height:1.5em;margin:0}.form-control::-webkit-datetime-edit{display:block;padding:0}.form-control::placeholder{color:var(--bs-secondary-color);opacity:1}.form-control:disabled{background-color:var(--bs-secondary-bg);opacity:1}.form-control::file-selector-button{padding:.5rem 1rem;margin:-.5rem -1rem;margin-inline-end:1rem;color:var(--bs-body-color);background-color:var(--bs-tertiary-bg);pointer-events:none;border-color:inherit;border-style:solid;border-width:0;border-inline-end-width:var(--bs-border-width);border-radius:0;transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-control::file-selector-button{transition:none}}.form-control:hover:not(:disabled):not([readonly])::file-selector-button{background-color:var(--bs-secondary-bg)}.form-control-plaintext{display:block;width:100%;padding:.5rem 0;margin-bottom:0;line-height:1.5;color:var(--bs-body-color);background-color:transparent;border:solid transparent;border-width:var(--bs-border-width) 0}.form-control-plaintext:focus{outline:0}.form-control-plaintext.form-control-sm,.form-control-plaintext.form-control-lg{padding-right:0;padding-left:0}.form-control-sm{min-height:calc(1.5em + .5rem + calc(var(--bs-border-width) * 2));padding:.25rem .5rem;font-size:.875rem;border-radius:var(--bs-border-radius-sm)}.form-control-sm::file-selector-button{padding:.25rem .5rem;margin:-.25rem -.5rem;margin-inline-end:.5rem}.form-control-lg{min-height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2));padding:.5rem 1rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.form-control-lg::file-selector-button{padding:.5rem 1rem;margin:-.5rem -1rem;margin-inline-end:1rem}textarea.form-control{min-height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2))}textarea.form-control-sm{min-height:calc(1.5em + .5rem + calc(var(--bs-border-width) * 2))}textarea.form-control-lg{min-height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2))}.form-control-color{width:3rem;height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2));padding:.5rem}.form-control-color:not(:disabled):not([readonly]){cursor:pointer}.form-control-color::-moz-color-swatch{border:0 !important;border-radius:var(--bs-border-radius)}.form-control-color::-webkit-color-swatch{border:0 !important;border-radius:var(--bs-border-radius)}.form-control-color.form-control-sm{height:calc(1.5em + .5rem + calc(var(--bs-border-width) * 2))}.form-control-color.form-control-lg{height:calc(1.5em + 1rem + calc(var(--bs-border-width) * 2))}.form-select{--bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");display:block;width:100%;padding:.5rem 3rem .5rem 1rem;font-size:.875rem;font-weight:400;line-height:1.5;color:var(--bs-body-color);appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:var(--bs-body-bg);background-image:var(--bs-form-select-bg-img),var(--bs-form-select-bg-icon, none);background-repeat:no-repeat;background-position:right 1rem center;background-size:16px 12px;border:var(--bs-border-width) solid var(--bs-border-color);border-radius:var(--bs-border-radius);box-shadow:inset 0 1px 2px rgba(0,0,0,0.075);transition:border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-select{transition:none}}.form-select:focus{border-color:#9aacf3;outline:0;box-shadow:inset 0 1px 2px rgba(0,0,0,0.075),0 0 0 .25rem rgba(52,89,230,0.25)}.form-select[multiple],.form-select[size]:not([size="1"]){padding-right:1rem;background-image:none}.form-select:disabled{background-color:var(--bs-secondary-bg)}.form-select:-moz-focusring{color:transparent;text-shadow:0 0 0 var(--bs-body-color)}.form-select-sm{padding-top:.25rem;padding-bottom:.25rem;padding-left:.5rem;font-size:.875rem;border-radius:var(--bs-border-radius-sm)}.form-select-lg{padding-top:.5rem;padding-bottom:.5rem;padding-left:1rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}[data-bs-theme="dark"] .form-select{--bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e")}.form-check,.shiny-input-container .checkbox,.shiny-input-container .radio{display:block;min-height:1.5rem;padding-left:0;margin-bottom:.125rem}.form-check .form-check-input,.form-check .shiny-input-container .checkbox input,.form-check .shiny-input-container .radio input,.shiny-input-container .checkbox .form-check-input,.shiny-input-container .checkbox .shiny-input-container .checkbox input,.shiny-input-container .checkbox .shiny-input-container .radio input,.shiny-input-container .radio .form-check-input,.shiny-input-container .radio .shiny-input-container .checkbox input,.shiny-input-container .radio .shiny-input-container .radio input{float:left;margin-left:0}.form-check-reverse{padding-right:0;padding-left:0;text-align:right}.form-check-reverse .form-check-input{float:right;margin-right:0;margin-left:0}.form-check-input,.shiny-input-container .checkbox input,.shiny-input-container .checkbox-inline input,.shiny-input-container .radio input,.shiny-input-container .radio-inline input{--bs-form-check-bg: var(--bs-body-bg);width:1em;height:1em;margin-top:.25em;vertical-align:top;appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:var(--bs-form-check-bg);background-image:var(--bs-form-check-bg-image);background-repeat:no-repeat;background-position:center;background-size:contain;border:var(--bs-border-width) solid var(--bs-border-color);print-color-adjust:exact}.form-check-input[type="checkbox"],.shiny-input-container .checkbox input[type="checkbox"],.shiny-input-container .checkbox-inline input[type="checkbox"],.shiny-input-container .radio input[type="checkbox"],.shiny-input-container .radio-inline input[type="checkbox"]{border-radius:.25em}.form-check-input[type="radio"],.shiny-input-container .checkbox input[type="radio"],.shiny-input-container .checkbox-inline input[type="radio"],.shiny-input-container .radio input[type="radio"],.shiny-input-container .radio-inline input[type="radio"]{border-radius:50%}.form-check-input:active,.shiny-input-container .checkbox input:active,.shiny-input-container .checkbox-inline input:active,.shiny-input-container .radio input:active,.shiny-input-container .radio-inline input:active{filter:brightness(90%)}.form-check-input:focus,.shiny-input-container .checkbox input:focus,.shiny-input-container .checkbox-inline input:focus,.shiny-input-container .radio input:focus,.shiny-input-container .radio-inline input:focus{border-color:#9aacf3;outline:0;box-shadow:0 0 0 .25rem rgba(52,89,230,0.25)}.form-check-input:checked,.shiny-input-container .checkbox input:checked,.shiny-input-container .checkbox-inline input:checked,.shiny-input-container .radio input:checked,.shiny-input-container .radio-inline input:checked{background-color:#3459e6;border-color:#3459e6}.form-check-input:checked[type="checkbox"],.shiny-input-container .checkbox input:checked[type="checkbox"],.shiny-input-container .checkbox-inline input:checked[type="checkbox"],.shiny-input-container .radio input:checked[type="checkbox"],.shiny-input-container .radio-inline input:checked[type="checkbox"]{--bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e")}.form-check-input:checked[type="radio"],.shiny-input-container .checkbox input:checked[type="radio"],.shiny-input-container .checkbox-inline input:checked[type="radio"],.shiny-input-container .radio input:checked[type="radio"],.shiny-input-container .radio-inline input:checked[type="radio"]{--bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e")}.form-check-input[type="checkbox"]:indeterminate,.shiny-input-container .checkbox input[type="checkbox"]:indeterminate,.shiny-input-container .checkbox-inline input[type="checkbox"]:indeterminate,.shiny-input-container .radio input[type="checkbox"]:indeterminate,.shiny-input-container .radio-inline input[type="checkbox"]:indeterminate{background-color:#3459e6;border-color:#3459e6;--bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e")}.form-check-input:disabled,.shiny-input-container .checkbox input:disabled,.shiny-input-container .checkbox-inline input:disabled,.shiny-input-container .radio input:disabled,.shiny-input-container .radio-inline input:disabled{pointer-events:none;filter:none;opacity:.5}.form-check-input[disabled]~.form-check-label,.form-check-input[disabled]~span,.form-check-input:disabled~.form-check-label,.form-check-input:disabled~span,.shiny-input-container .checkbox input[disabled]~.form-check-label,.shiny-input-container .checkbox input[disabled]~span,.shiny-input-container .checkbox input:disabled~.form-check-label,.shiny-input-container .checkbox input:disabled~span,.shiny-input-container .checkbox-inline input[disabled]~.form-check-label,.shiny-input-container .checkbox-inline input[disabled]~span,.shiny-input-container .checkbox-inline input:disabled~.form-check-label,.shiny-input-container .checkbox-inline input:disabled~span,.shiny-input-container .radio input[disabled]~.form-check-label,.shiny-input-container .radio input[disabled]~span,.shiny-input-container .radio input:disabled~.form-check-label,.shiny-input-container .radio input:disabled~span,.shiny-input-container .radio-inline input[disabled]~.form-check-label,.shiny-input-container .radio-inline input[disabled]~span,.shiny-input-container .radio-inline input:disabled~.form-check-label,.shiny-input-container .radio-inline input:disabled~span{cursor:default;opacity:.5}.form-check-label,.shiny-input-container .checkbox label,.shiny-input-container .checkbox-inline label,.shiny-input-container .radio label,.shiny-input-container .radio-inline label{cursor:pointer}.form-switch{padding-left:2.5em}.form-switch .form-check-input{--bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280,0,0,0.25%29'/%3e%3c/svg%3e");width:2em;margin-left:-2.5em;background-image:var(--bs-form-switch-bg);background-position:left center;border-radius:2em;transition:background-position 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-switch .form-check-input{transition:none}}.form-switch .form-check-input:focus{--bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%239aacf3'/%3e%3c/svg%3e")}.form-switch .form-check-input:checked{background-position:right center;--bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e")}.form-switch.form-check-reverse{padding-right:2.5em;padding-left:0}.form-switch.form-check-reverse .form-check-input{margin-right:-2.5em;margin-left:0}.form-check-inline{display:inline-block;margin-right:1rem}.btn-check{position:absolute;clip:rect(0, 0, 0, 0);pointer-events:none}.btn-check[disabled]+.btn,.btn-check:disabled+.btn{pointer-events:none;filter:none;opacity:.65}[data-bs-theme="dark"] .form-switch .form-check-input:not(:checked):not(:focus){--bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255,255,255,0.25%29'/%3e%3c/svg%3e")}.form-range{width:100%;height:1.5rem;padding:0;appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:transparent}.form-range:focus{outline:0}.form-range:focus::-webkit-slider-thumb{box-shadow:0 0 0 1px #fff,0 0 0 .25rem rgba(52,89,230,0.25)}.form-range:focus::-moz-range-thumb{box-shadow:0 0 0 1px #fff,0 0 0 .25rem rgba(52,89,230,0.25)}.form-range::-moz-focus-outer{border:0}.form-range::-webkit-slider-thumb{width:1rem;height:1rem;margin-top:-.25rem;appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:#3459e6;border:0;border-radius:1rem;box-shadow:0 0.1rem 0.25rem rgba(0,0,0,0.1);transition:background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-range::-webkit-slider-thumb{transition:none}}.form-range::-webkit-slider-thumb:active{background-color:#c2cdf8}.form-range::-webkit-slider-runnable-track{width:100%;height:.5rem;color:transparent;cursor:pointer;background-color:var(--bs-tertiary-bg);border-color:transparent;border-radius:1rem;box-shadow:inset 0 1px 2px rgba(0,0,0,0.075)}.form-range::-moz-range-thumb{width:1rem;height:1rem;appearance:none;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;background-color:#3459e6;border:0;border-radius:1rem;box-shadow:0 0.1rem 0.25rem rgba(0,0,0,0.1);transition:background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.form-range::-moz-range-thumb{transition:none}}.form-range::-moz-range-thumb:active{background-color:#c2cdf8}.form-range::-moz-range-track{width:100%;height:.5rem;color:transparent;cursor:pointer;background-color:var(--bs-tertiary-bg);border-color:transparent;border-radius:1rem;box-shadow:inset 0 1px 2px rgba(0,0,0,0.075)}.form-range:disabled{pointer-events:none}.form-range:disabled::-webkit-slider-thumb{background-color:var(--bs-secondary-color)}.form-range:disabled::-moz-range-thumb{background-color:var(--bs-secondary-color)}.form-floating{position:relative}.form-floating>.form-control,.form-floating>.form-control-plaintext,.form-floating>.form-select{height:calc(3.5rem + calc(var(--bs-border-width) * 2));min-height:calc(3.5rem + calc(var(--bs-border-width) * 2));line-height:1.25}.form-floating>label{position:absolute;top:0;left:0;z-index:2;height:100%;padding:1rem 1rem;overflow:hidden;text-align:start;text-overflow:ellipsis;white-space:nowrap;pointer-events:none;border:var(--bs-border-width) solid transparent;transform-origin:0 0;transition:opacity 0.1s ease-in-out,transform 0.1s ease-in-out}@media (prefers-reduced-motion: reduce){.form-floating>label{transition:none}}.form-floating>.form-control,.form-floating>.form-control-plaintext{padding:1rem 1rem}.form-floating>.form-control::placeholder,.form-floating>.form-control-plaintext::placeholder{color:transparent}.form-floating>.form-control:focus,.form-floating>.form-control:not(:placeholder-shown),.form-floating>.form-control-plaintext:focus,.form-floating>.form-control-plaintext:not(:placeholder-shown){padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-control:-webkit-autofill,.form-floating>.form-control-plaintext:-webkit-autofill{padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-select{padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-control:focus~label,.form-floating>.form-control:not(:placeholder-shown)~label,.form-floating>.form-control-plaintext~label,.form-floating>.form-select~label{color:rgba(var(--bs-body-color-rgb), .65);transform:scale(0.85) translateY(-0.5rem) translateX(0.15rem)}.form-floating>.form-control:focus~label::after,.form-floating>.form-control:not(:placeholder-shown)~label::after,.form-floating>.form-control-plaintext~label::after,.form-floating>.form-select~label::after{position:absolute;inset:1rem .5rem;z-index:-1;height:1.5em;content:"";background-color:var(--bs-body-bg);border-radius:var(--bs-border-radius)}.form-floating>.form-control:-webkit-autofill~label{color:rgba(var(--bs-body-color-rgb), .65);transform:scale(0.85) translateY(-0.5rem) translateX(0.15rem)}.form-floating>.form-control-plaintext~label{border-width:var(--bs-border-width) 0}.form-floating>:disabled~label,.form-floating>.form-control:disabled~label{color:#6c757d}.form-floating>:disabled~label::after,.form-floating>.form-control:disabled~label::after{background-color:var(--bs-secondary-bg)}.input-group{position:relative;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;align-items:stretch;-webkit-align-items:stretch;width:100%}.input-group>.form-control,.input-group>.form-select,.input-group>.form-floating{position:relative;flex:1 1 auto;-webkit-flex:1 1 auto;width:1%;min-width:0}.input-group>.form-control:focus,.input-group>.form-select:focus,.input-group>.form-floating:focus-within{z-index:5}.input-group .btn{position:relative;z-index:2}.input-group .btn:focus{z-index:5}.input-group-text{display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:400;line-height:1.5;color:var(--bs-body-color);text-align:center;white-space:nowrap;background-color:#f8f9fa;border:var(--bs-border-width) solid var(--bs-border-color);border-radius:var(--bs-border-radius)}.input-group-lg>.form-control,.input-group-lg>.form-select,.input-group-lg>.input-group-text,.input-group-lg>.btn{padding:.5rem 1rem;font-size:1.25rem;border-radius:var(--bs-border-radius-lg)}.input-group-sm>.form-control,.input-group-sm>.form-select,.input-group-sm>.input-group-text,.input-group-sm>.btn{padding:.25rem .5rem;font-size:.875rem;border-radius:var(--bs-border-radius-sm)}.input-group-lg>.form-select,.input-group-sm>.form-select{padding-right:4rem}.input-group:not(.has-validation)>:not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),.input-group:not(.has-validation)>.dropdown-toggle:nth-last-child(n + 3),.input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-control,.input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-select{border-top-right-radius:0;border-bottom-right-radius:0}.input-group.has-validation>:nth-last-child(n + 3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),.input-group.has-validation>.dropdown-toggle:nth-last-child(n + 4),.input-group.has-validation>.form-floating:nth-last-child(n + 3)>.form-control,.input-group.has-validation>.form-floating:nth-last-child(n + 3)>.form-select{border-top-right-radius:0;border-bottom-right-radius:0}.input-group>:not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback){margin-left:calc(var(--bs-border-width) * -1);border-top-left-radius:0;border-bottom-left-radius:0}.input-group>.form-floating:not(:first-child)>.form-control,.input-group>.form-floating:not(:first-child)>.form-select{border-top-left-radius:0;border-bottom-left-radius:0}.valid-feedback{display:none;width:100%;margin-top:.25rem;font-size:.875em;color:var(--bs-form-valid-color)}.valid-tooltip{position:absolute;top:100%;z-index:5;display:none;max-width:100%;padding:.25rem .5rem;margin-top:.1rem;font-size:.875rem;color:#fff;background-color:var(--bs-success);border-radius:var(--bs-border-radius)}.was-validated :valid~.valid-feedback,.was-validated :valid~.valid-tooltip,.is-valid~.valid-feedback,.is-valid~.valid-tooltip{display:block}.was-validated .form-control:valid,.form-control.is-valid{border-color:var(--bs-form-valid-border-color);padding-right:calc(1.5em + 1rem);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%232fb380' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right calc(.375em + .25rem) center;background-size:calc(.75em + .5rem) calc(.75em + .5rem)}.was-validated .form-control:valid:focus,.form-control.is-valid:focus{border-color:var(--bs-form-valid-border-color);box-shadow:0 0 0 .25rem rgba(var(--bs-success-rgb), 0.25)}.was-validated textarea.form-control:valid,textarea.form-control.is-valid{padding-right:calc(1.5em + 1rem);background-position:top calc(.375em + .25rem) right calc(.375em + .25rem)}.was-validated .form-select:valid,.form-select.is-valid{border-color:var(--bs-form-valid-border-color)}.was-validated .form-select:valid:not([multiple]):not([size]),.was-validated .form-select:valid:not([multiple])[size="1"],.form-select.is-valid:not([multiple]):not([size]),.form-select.is-valid:not([multiple])[size="1"]{--bs-form-select-bg-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%232fb380' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");padding-right:5.5rem;background-position:right 1rem center,center right 3rem;background-size:16px 12px,calc(.75em + .5rem) calc(.75em + .5rem)}.was-validated .form-select:valid:focus,.form-select.is-valid:focus{border-color:var(--bs-form-valid-border-color);box-shadow:0 0 0 .25rem rgba(var(--bs-success-rgb), 0.25)}.was-validated .form-control-color:valid,.form-control-color.is-valid{width:calc(3rem + calc(1.5em + 1rem))}.was-validated .form-check-input:valid,.form-check-input.is-valid{border-color:var(--bs-form-valid-border-color)}.was-validated .form-check-input:valid:checked,.form-check-input.is-valid:checked{background-color:var(--bs-form-valid-color)}.was-validated .form-check-input:valid:focus,.form-check-input.is-valid:focus{box-shadow:0 0 0 .25rem rgba(var(--bs-success-rgb), 0.25)}.was-validated .form-check-input:valid~.form-check-label,.form-check-input.is-valid~.form-check-label{color:var(--bs-form-valid-color)}.form-check-inline .form-check-input~.valid-feedback{margin-left:.5em}.was-validated .input-group>.form-control:not(:focus):valid,.input-group>.form-control:not(:focus).is-valid,.was-validated .input-group>.form-select:not(:focus):valid,.input-group>.form-select:not(:focus).is-valid,.was-validated .input-group>.form-floating:not(:focus-within):valid,.input-group>.form-floating:not(:focus-within).is-valid{z-index:3}.invalid-feedback{display:none;width:100%;margin-top:.25rem;font-size:.875em;color:var(--bs-form-invalid-color)}.invalid-tooltip{position:absolute;top:100%;z-index:5;display:none;max-width:100%;padding:.25rem .5rem;margin-top:.1rem;font-size:.875rem;color:#fff;background-color:var(--bs-danger);border-radius:var(--bs-border-radius)}.was-validated :invalid~.invalid-feedback,.was-validated :invalid~.invalid-tooltip,.is-invalid~.invalid-feedback,.is-invalid~.invalid-tooltip{display:block}.was-validated .form-control:invalid,.form-control.is-invalid{border-color:var(--bs-form-invalid-border-color);padding-right:calc(1.5em + 1rem);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23da292e'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23da292e' stroke='none'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right calc(.375em + .25rem) center;background-size:calc(.75em + .5rem) calc(.75em + .5rem)}.was-validated .form-control:invalid:focus,.form-control.is-invalid:focus{border-color:var(--bs-form-invalid-border-color);box-shadow:0 0 0 .25rem rgba(var(--bs-danger-rgb), 0.25)}.was-validated textarea.form-control:invalid,textarea.form-control.is-invalid{padding-right:calc(1.5em + 1rem);background-position:top calc(.375em + .25rem) right calc(.375em + .25rem)}.was-validated .form-select:invalid,.form-select.is-invalid{border-color:var(--bs-form-invalid-border-color)}.was-validated .form-select:invalid:not([multiple]):not([size]),.was-validated .form-select:invalid:not([multiple])[size="1"],.form-select.is-invalid:not([multiple]):not([size]),.form-select.is-invalid:not([multiple])[size="1"]{--bs-form-select-bg-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23da292e'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23da292e' stroke='none'/%3e%3c/svg%3e");padding-right:5.5rem;background-position:right 1rem center,center right 3rem;background-size:16px 12px,calc(.75em + .5rem) calc(.75em + .5rem)}.was-validated .form-select:invalid:focus,.form-select.is-invalid:focus{border-color:var(--bs-form-invalid-border-color);box-shadow:0 0 0 .25rem rgba(var(--bs-danger-rgb), 0.25)}.was-validated .form-control-color:invalid,.form-control-color.is-invalid{width:calc(3rem + calc(1.5em + 1rem))}.was-validated .form-check-input:invalid,.form-check-input.is-invalid{border-color:var(--bs-form-invalid-border-color)}.was-validated .form-check-input:invalid:checked,.form-check-input.is-invalid:checked{background-color:var(--bs-form-invalid-color)}.was-validated .form-check-input:invalid:focus,.form-check-input.is-invalid:focus{box-shadow:0 0 0 .25rem rgba(var(--bs-danger-rgb), 0.25)}.was-validated .form-check-input:invalid~.form-check-label,.form-check-input.is-invalid~.form-check-label{color:var(--bs-form-invalid-color)}.form-check-inline .form-check-input~.invalid-feedback{margin-left:.5em}.was-validated .input-group>.form-control:not(:focus):invalid,.input-group>.form-control:not(:focus).is-invalid,.was-validated .input-group>.form-select:not(:focus):invalid,.input-group>.form-select:not(:focus).is-invalid,.was-validated .input-group>.form-floating:not(:focus-within):invalid,.input-group>.form-floating:not(:focus-within).is-invalid{z-index:4}.btn{--bs-btn-padding-x: 1rem;--bs-btn-padding-y: .5rem;--bs-btn-font-family: ;--bs-btn-font-size:.875rem;--bs-btn-font-weight: 500;--bs-btn-line-height: 1.5;--bs-btn-color: var(--bs-body-color);--bs-btn-bg: transparent;--bs-btn-border-width: var(--bs-border-width);--bs-btn-border-color: transparent;--bs-btn-border-radius: var(--bs-border-radius);--bs-btn-hover-border-color: transparent;--bs-btn-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-opacity: .65;--bs-btn-focus-box-shadow: 0 0 0 .25rem rgba(var(--bs-btn-focus-shadow-rgb), .5);display:inline-block;padding:var(--bs-btn-padding-y) var(--bs-btn-padding-x);font-family:var(--bs-btn-font-family);font-size:var(--bs-btn-font-size);font-weight:var(--bs-btn-font-weight);line-height:var(--bs-btn-line-height);color:var(--bs-btn-color);text-align:center;text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;vertical-align:middle;cursor:pointer;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;border:var(--bs-btn-border-width) solid var(--bs-btn-border-color);border-radius:var(--bs-btn-border-radius);background-color:var(--bs-btn-bg);box-shadow:var(--bs-btn-box-shadow);transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.btn{transition:none}}.btn:hover{color:var(--bs-btn-hover-color);background-color:var(--bs-btn-hover-bg);border-color:var(--bs-btn-hover-border-color)}.btn-check+.btn:hover{color:var(--bs-btn-color);background-color:var(--bs-btn-bg);border-color:var(--bs-btn-border-color)}.btn:focus-visible{color:var(--bs-btn-hover-color);background-color:var(--bs-btn-hover-bg);border-color:var(--bs-btn-hover-border-color);outline:0;box-shadow:var(--bs-btn-box-shadow),var(--bs-btn-focus-box-shadow)}.btn-check:focus-visible+.btn{border-color:var(--bs-btn-hover-border-color);outline:0;box-shadow:var(--bs-btn-box-shadow),var(--bs-btn-focus-box-shadow)}.btn-check:checked+.btn,:not(.btn-check)+.btn:active,.btn:first-child:active,.btn.active,.btn.show{color:var(--bs-btn-active-color);background-color:var(--bs-btn-active-bg);border-color:var(--bs-btn-active-border-color);box-shadow:var(--bs-btn-active-shadow)}.btn-check:checked+.btn:focus-visible,:not(.btn-check)+.btn:active:focus-visible,.btn:first-child:active:focus-visible,.btn.active:focus-visible,.btn.show:focus-visible{box-shadow:var(--bs-btn-active-shadow),var(--bs-btn-focus-box-shadow)}.btn:disabled,.btn.disabled,fieldset:disabled .btn{color:var(--bs-btn-disabled-color);pointer-events:none;background-color:var(--bs-btn-disabled-bg);border-color:var(--bs-btn-disabled-border-color);opacity:var(--bs-btn-disabled-opacity);box-shadow:none}.btn-default{--bs-btn-color: #000;--bs-btn-bg: #fff;--bs-btn-border-color: #fff;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #fff;--bs-btn-hover-border-color: #fff;--bs-btn-focus-shadow-rgb: 217,217,217;--bs-btn-active-color: #000;--bs-btn-active-bg: #fff;--bs-btn-active-border-color: #fff;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #000;--bs-btn-disabled-bg: #fff;--bs-btn-disabled-border-color: #fff}.btn-primary{--bs-btn-color: #fff;--bs-btn-bg: #3459e6;--bs-btn-border-color: #3459e6;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #2c4cc4;--bs-btn-hover-border-color: #2a47b8;--bs-btn-focus-shadow-rgb: 82,114,234;--bs-btn-active-color: #fff;--bs-btn-active-bg: #2a47b8;--bs-btn-active-border-color: #2743ad;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #3459e6;--bs-btn-disabled-border-color: #3459e6}.btn-secondary,.btn-default:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']){--bs-btn-color: #000;--bs-btn-bg: #fff;--bs-btn-border-color: #fff;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #fff;--bs-btn-hover-border-color: #fff;--bs-btn-focus-shadow-rgb: 217,217,217;--bs-btn-active-color: #000;--bs-btn-active-bg: #fff;--bs-btn-active-border-color: #fff;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #000;--bs-btn-disabled-bg: #fff;--bs-btn-disabled-border-color: #fff}.btn-success{--bs-btn-color: #fff;--bs-btn-bg: #2fb380;--bs-btn-border-color: #2fb380;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #28986d;--bs-btn-hover-border-color: #268f66;--bs-btn-focus-shadow-rgb: 78,190,147;--bs-btn-active-color: #fff;--bs-btn-active-bg: #268f66;--bs-btn-active-border-color: #238660;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #2fb380;--bs-btn-disabled-border-color: #2fb380}.btn-info{--bs-btn-color: #fff;--bs-btn-bg: #287bb5;--bs-btn-border-color: #287bb5;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #22699a;--bs-btn-hover-border-color: #206291;--bs-btn-focus-shadow-rgb: 72,143,192;--bs-btn-active-color: #fff;--bs-btn-active-bg: #206291;--bs-btn-active-border-color: #1e5c88;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #287bb5;--bs-btn-disabled-border-color: #287bb5}.btn-warning{--bs-btn-color: #fff;--bs-btn-bg: #f4bd61;--bs-btn-border-color: #f4bd61;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #cfa152;--bs-btn-hover-border-color: #c3974e;--bs-btn-focus-shadow-rgb: 246,199,121;--bs-btn-active-color: #fff;--bs-btn-active-bg: #c3974e;--bs-btn-active-border-color: #b78e49;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #f4bd61;--bs-btn-disabled-border-color: #f4bd61}.btn-danger{--bs-btn-color: #fff;--bs-btn-bg: #da292e;--bs-btn-border-color: #da292e;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #b92327;--bs-btn-hover-border-color: #ae2125;--bs-btn-focus-shadow-rgb: 224,73,77;--bs-btn-active-color: #fff;--bs-btn-active-bg: #ae2125;--bs-btn-active-border-color: #a41f23;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #da292e;--bs-btn-disabled-border-color: #da292e}.btn-light{--bs-btn-color: #000;--bs-btn-bg: #f8f9fa;--bs-btn-border-color: #f8f9fa;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #d3d4d5;--bs-btn-hover-border-color: #c6c7c8;--bs-btn-focus-shadow-rgb: 211,212,213;--bs-btn-active-color: #fff;--bs-btn-active-bg: #c6c7c8;--bs-btn-active-border-color: #babbbc;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #000;--bs-btn-disabled-bg: #f8f9fa;--bs-btn-disabled-border-color: #f8f9fa}.btn-dark{--bs-btn-color: #fff;--bs-btn-bg: #212529;--bs-btn-border-color: #212529;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #424649;--bs-btn-hover-border-color: #373b3e;--bs-btn-focus-shadow-rgb: 66,70,73;--bs-btn-active-color: #fff;--bs-btn-active-bg: #4d5154;--bs-btn-active-border-color: #373b3e;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: #212529;--bs-btn-disabled-border-color: #212529}.btn-outline-default{--bs-btn-color: #fff;--bs-btn-border-color: #fff;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #fff;--bs-btn-hover-border-color: #fff;--bs-btn-focus-shadow-rgb: 255,255,255;--bs-btn-active-color: #000;--bs-btn-active-bg: #fff;--bs-btn-active-border-color: #fff;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #fff;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-primary{--bs-btn-color: #3459e6;--bs-btn-border-color: #3459e6;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #3459e6;--bs-btn-hover-border-color: #3459e6;--bs-btn-focus-shadow-rgb: 52,89,230;--bs-btn-active-color: #fff;--bs-btn-active-bg: #3459e6;--bs-btn-active-border-color: #3459e6;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #3459e6;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #3459e6;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-secondary{--bs-btn-color: #fff;--bs-btn-border-color: #fff;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #fff;--bs-btn-hover-border-color: #fff;--bs-btn-focus-shadow-rgb: 255,255,255;--bs-btn-active-color: #000;--bs-btn-active-bg: #fff;--bs-btn-active-border-color: #fff;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #fff;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #fff;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-success{--bs-btn-color: #2fb380;--bs-btn-border-color: #2fb380;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #2fb380;--bs-btn-hover-border-color: #2fb380;--bs-btn-focus-shadow-rgb: 47,179,128;--bs-btn-active-color: #fff;--bs-btn-active-bg: #2fb380;--bs-btn-active-border-color: #2fb380;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #2fb380;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #2fb380;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-info{--bs-btn-color: #287bb5;--bs-btn-border-color: #287bb5;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #287bb5;--bs-btn-hover-border-color: #287bb5;--bs-btn-focus-shadow-rgb: 40,123,181;--bs-btn-active-color: #fff;--bs-btn-active-bg: #287bb5;--bs-btn-active-border-color: #287bb5;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #287bb5;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #287bb5;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-warning{--bs-btn-color: #f4bd61;--bs-btn-border-color: #f4bd61;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #f4bd61;--bs-btn-hover-border-color: #f4bd61;--bs-btn-focus-shadow-rgb: 244,189,97;--bs-btn-active-color: #fff;--bs-btn-active-bg: #f4bd61;--bs-btn-active-border-color: #f4bd61;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #f4bd61;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #f4bd61;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-danger{--bs-btn-color: #da292e;--bs-btn-border-color: #da292e;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #da292e;--bs-btn-hover-border-color: #da292e;--bs-btn-focus-shadow-rgb: 218,41,46;--bs-btn-active-color: #fff;--bs-btn-active-bg: #da292e;--bs-btn-active-border-color: #da292e;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #da292e;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #da292e;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-light{--bs-btn-color: #f8f9fa;--bs-btn-border-color: #f8f9fa;--bs-btn-hover-color: #000;--bs-btn-hover-bg: #f8f9fa;--bs-btn-hover-border-color: #f8f9fa;--bs-btn-focus-shadow-rgb: 248,249,250;--bs-btn-active-color: #000;--bs-btn-active-bg: #f8f9fa;--bs-btn-active-border-color: #f8f9fa;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #f8f9fa;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #f8f9fa;--bs-btn-bg: transparent;--bs-gradient: none}.btn-outline-dark{--bs-btn-color: #212529;--bs-btn-border-color: #212529;--bs-btn-hover-color: #fff;--bs-btn-hover-bg: #212529;--bs-btn-hover-border-color: #212529;--bs-btn-focus-shadow-rgb: 33,37,41;--bs-btn-active-color: #fff;--bs-btn-active-bg: #212529;--bs-btn-active-border-color: #212529;--bs-btn-active-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-btn-disabled-color: #212529;--bs-btn-disabled-bg: transparent;--bs-btn-disabled-border-color: #212529;--bs-btn-bg: transparent;--bs-gradient: none}.btn-link{--bs-btn-font-weight: 400;--bs-btn-color: var(--bs-link-color);--bs-btn-bg: transparent;--bs-btn-border-color: transparent;--bs-btn-hover-color: var(--bs-link-hover-color);--bs-btn-hover-border-color: transparent;--bs-btn-active-color: var(--bs-link-hover-color);--bs-btn-active-border-color: transparent;--bs-btn-disabled-color: #6c757d;--bs-btn-disabled-border-color: transparent;--bs-btn-box-shadow: 0 0 0 #000;--bs-btn-focus-shadow-rgb: 82,114,234;text-decoration:underline;-webkit-text-decoration:underline;-moz-text-decoration:underline;-ms-text-decoration:underline;-o-text-decoration:underline}.btn-link:focus-visible{color:var(--bs-btn-color)}.btn-link:hover{color:var(--bs-btn-hover-color)}.btn-lg,.btn-group-lg>.btn{--bs-btn-padding-y: .5rem;--bs-btn-padding-x: 1rem;--bs-btn-font-size:1.25rem;--bs-btn-border-radius: var(--bs-border-radius-lg)}.btn-sm,.btn-group-sm>.btn{--bs-btn-padding-y: .25rem;--bs-btn-padding-x: .5rem;--bs-btn-font-size:.875rem;--bs-btn-border-radius: var(--bs-border-radius-sm)}.fade{transition:opacity 0.15s linear}@media (prefers-reduced-motion: reduce){.fade{transition:none}}.fade:not(.show){opacity:0}.collapse:not(.show){display:none}.collapsing{height:0;overflow:hidden;transition:height 0.35s ease}@media (prefers-reduced-motion: reduce){.collapsing{transition:none}}.collapsing.collapse-horizontal{width:0;height:auto;transition:width 0.35s ease}@media (prefers-reduced-motion: reduce){.collapsing.collapse-horizontal{transition:none}}.dropup,.dropend,.dropdown,.dropstart,.dropup-center,.dropdown-center{position:relative}.dropdown-toggle{white-space:nowrap}.dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:.3em solid;border-right:.3em solid transparent;border-bottom:0;border-left:.3em solid transparent}.dropdown-toggle:empty::after{margin-left:0}.dropdown-menu{--bs-dropdown-zindex: 1000;--bs-dropdown-min-width: 10rem;--bs-dropdown-padding-x: 0;--bs-dropdown-padding-y: .5rem;--bs-dropdown-spacer: .125rem;--bs-dropdown-font-size:.875rem;--bs-dropdown-color: var(--bs-body-color);--bs-dropdown-bg: var(--bs-body-bg);--bs-dropdown-border-color: #dee2e6;--bs-dropdown-border-radius: var(--bs-border-radius);--bs-dropdown-border-width: var(--bs-border-width);--bs-dropdown-inner-border-radius: calc(var(--bs-border-radius) - var(--bs-border-width));--bs-dropdown-divider-bg: #e9ecef;--bs-dropdown-divider-margin-y: .5rem;--bs-dropdown-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-dropdown-link-color: var(--bs-body-color);--bs-dropdown-link-hover-color: #fff;--bs-dropdown-link-hover-bg: #3459e6;--bs-dropdown-link-active-color: #fff;--bs-dropdown-link-active-bg: #3459e6;--bs-dropdown-link-disabled-color: var(--bs-tertiary-color);--bs-dropdown-item-padding-x: 1rem;--bs-dropdown-item-padding-y: .5rem;--bs-dropdown-header-color: #6c757d;--bs-dropdown-header-padding-x: 1rem;--bs-dropdown-header-padding-y: .5rem;position:absolute;z-index:var(--bs-dropdown-zindex);display:none;min-width:var(--bs-dropdown-min-width);padding:var(--bs-dropdown-padding-y) var(--bs-dropdown-padding-x);margin:0;font-size:var(--bs-dropdown-font-size);color:var(--bs-dropdown-color);text-align:left;list-style:none;background-color:var(--bs-dropdown-bg);background-clip:padding-box;border:var(--bs-dropdown-border-width) solid var(--bs-dropdown-border-color);border-radius:var(--bs-dropdown-border-radius);box-shadow:var(--bs-dropdown-box-shadow)}.dropdown-menu[data-bs-popper]{top:100%;left:0;margin-top:var(--bs-dropdown-spacer)}.dropdown-menu-start{--bs-position: start}.dropdown-menu-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-end{--bs-position: end}.dropdown-menu-end[data-bs-popper]{right:0;left:auto}@media (min-width: 576px){.dropdown-menu-sm-start{--bs-position: start}.dropdown-menu-sm-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-sm-end{--bs-position: end}.dropdown-menu-sm-end[data-bs-popper]{right:0;left:auto}}@media (min-width: 768px){.dropdown-menu-md-start{--bs-position: start}.dropdown-menu-md-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-md-end{--bs-position: end}.dropdown-menu-md-end[data-bs-popper]{right:0;left:auto}}@media (min-width: 992px){.dropdown-menu-lg-start{--bs-position: start}.dropdown-menu-lg-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-lg-end{--bs-position: end}.dropdown-menu-lg-end[data-bs-popper]{right:0;left:auto}}@media (min-width: 1200px){.dropdown-menu-xl-start{--bs-position: start}.dropdown-menu-xl-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-xl-end{--bs-position: end}.dropdown-menu-xl-end[data-bs-popper]{right:0;left:auto}}@media (min-width: 1400px){.dropdown-menu-xxl-start{--bs-position: start}.dropdown-menu-xxl-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-xxl-end{--bs-position: end}.dropdown-menu-xxl-end[data-bs-popper]{right:0;left:auto}}.dropup .dropdown-menu[data-bs-popper]{top:auto;bottom:100%;margin-top:0;margin-bottom:var(--bs-dropdown-spacer)}.dropup .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:0;border-right:.3em solid transparent;border-bottom:.3em solid;border-left:.3em solid transparent}.dropup .dropdown-toggle:empty::after{margin-left:0}.dropend .dropdown-menu[data-bs-popper]{top:0;right:auto;left:100%;margin-top:0;margin-left:var(--bs-dropdown-spacer)}.dropend .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:.3em solid transparent;border-right:0;border-bottom:.3em solid transparent;border-left:.3em solid}.dropend .dropdown-toggle:empty::after{margin-left:0}.dropend .dropdown-toggle::after{vertical-align:0}.dropstart .dropdown-menu[data-bs-popper]{top:0;right:100%;left:auto;margin-top:0;margin-right:var(--bs-dropdown-spacer)}.dropstart .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:""}.dropstart .dropdown-toggle::after{display:none}.dropstart .dropdown-toggle::before{display:inline-block;margin-right:.255em;vertical-align:.255em;content:"";border-top:.3em solid transparent;border-right:.3em solid;border-bottom:.3em solid transparent}.dropstart .dropdown-toggle:empty::after{margin-left:0}.dropstart .dropdown-toggle::before{vertical-align:0}.dropdown-divider{height:0;margin:var(--bs-dropdown-divider-margin-y) 0;overflow:hidden;border-top:1px solid var(--bs-dropdown-divider-bg);opacity:1}.dropdown-item{display:block;width:100%;padding:var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);clear:both;font-weight:400;color:var(--bs-dropdown-link-color);text-align:inherit;text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;white-space:nowrap;background-color:transparent;border:0;border-radius:var(--bs-dropdown-item-border-radius, 0)}.dropdown-item:hover,.dropdown-item:focus{color:var(--bs-dropdown-link-hover-color);background-color:var(--bs-dropdown-link-hover-bg)}.dropdown-item.active,.dropdown-item:active{color:var(--bs-dropdown-link-active-color);text-decoration:none;background-color:var(--bs-dropdown-link-active-bg)}.dropdown-item.disabled,.dropdown-item:disabled{color:var(--bs-dropdown-link-disabled-color);pointer-events:none;background-color:transparent}.dropdown-menu.show{display:block}.dropdown-header{display:block;padding:var(--bs-dropdown-header-padding-y) var(--bs-dropdown-header-padding-x);margin-bottom:0;font-size:.875rem;color:var(--bs-dropdown-header-color);white-space:nowrap}.dropdown-item-text{display:block;padding:var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);color:var(--bs-dropdown-link-color)}.dropdown-menu-dark{--bs-dropdown-color: #dee2e6;--bs-dropdown-bg: #343a40;--bs-dropdown-border-color: #dee2e6;--bs-dropdown-box-shadow: ;--bs-dropdown-link-color: #dee2e6;--bs-dropdown-link-hover-color: #fff;--bs-dropdown-divider-bg: #e9ecef;--bs-dropdown-link-hover-bg: rgba(255,255,255,0.15);--bs-dropdown-link-active-color: #fff;--bs-dropdown-link-active-bg: #3459e6;--bs-dropdown-link-disabled-color: #adb5bd;--bs-dropdown-header-color: #adb5bd}.btn-group,.btn-group-vertical{position:relative;display:inline-flex;vertical-align:middle}.btn-group>.btn,.btn-group-vertical>.btn{position:relative;flex:1 1 auto;-webkit-flex:1 1 auto}.btn-group>.btn-check:checked+.btn,.btn-group>.btn-check:focus+.btn,.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active,.btn-group-vertical>.btn-check:checked+.btn,.btn-group-vertical>.btn-check:focus+.btn,.btn-group-vertical>.btn:hover,.btn-group-vertical>.btn:focus,.btn-group-vertical>.btn:active,.btn-group-vertical>.btn.active{z-index:1}.btn-toolbar{display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;justify-content:flex-start;-webkit-justify-content:flex-start}.btn-toolbar .input-group{width:auto}.btn-group{border-radius:var(--bs-border-radius)}.btn-group>:not(.btn-check:first-child)+.btn,.btn-group>.btn-group:not(:first-child){margin-left:calc(var(--bs-border-width) * -1)}.btn-group>.btn:not(:last-child):not(.dropdown-toggle),.btn-group>.btn.dropdown-toggle-split:first-child,.btn-group>.btn-group:not(:last-child)>.btn{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:nth-child(n + 3),.btn-group>:not(.btn-check)+.btn,.btn-group>.btn-group:not(:first-child)>.btn{border-top-left-radius:0;border-bottom-left-radius:0}.dropdown-toggle-split{padding-right:.75rem;padding-left:.75rem}.dropdown-toggle-split::after,.dropup .dropdown-toggle-split::after,.dropend .dropdown-toggle-split::after{margin-left:0}.dropstart .dropdown-toggle-split::before{margin-right:0}.btn-sm+.dropdown-toggle-split,.btn-group-sm>.btn+.dropdown-toggle-split{padding-right:.375rem;padding-left:.375rem}.btn-lg+.dropdown-toggle-split,.btn-group-lg>.btn+.dropdown-toggle-split{padding-right:.75rem;padding-left:.75rem}.btn-group.show .dropdown-toggle{box-shadow:0 1px 2px rgba(0,0,0,0.05)}.btn-group.show .dropdown-toggle.btn-link{box-shadow:none}.btn-group-vertical{flex-direction:column;-webkit-flex-direction:column;align-items:flex-start;-webkit-align-items:flex-start;justify-content:center;-webkit-justify-content:center}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group{width:100%}.btn-group-vertical>.btn:not(:first-child),.btn-group-vertical>.btn-group:not(:first-child){margin-top:calc(var(--bs-border-width) * -1)}.btn-group-vertical>.btn:not(:last-child):not(.dropdown-toggle),.btn-group-vertical>.btn-group:not(:last-child)>.btn{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn~.btn,.btn-group-vertical>.btn-group:not(:first-child)>.btn{border-top-left-radius:0;border-top-right-radius:0}.nav{--bs-nav-link-padding-x: 1rem;--bs-nav-link-padding-y: .5rem;--bs-nav-link-font-weight: ;--bs-nav-link-color: #495057;--bs-nav-link-hover-color: #495057;--bs-nav-link-disabled-color: var(--bs-secondary-color);display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;padding-left:0;margin-bottom:0;list-style:none}.nav-link{display:block;padding:var(--bs-nav-link-padding-y) var(--bs-nav-link-padding-x);font-size:var(--bs-nav-link-font-size);font-weight:var(--bs-nav-link-font-weight);color:var(--bs-nav-link-color);text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;background:none;border:0;transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.nav-link{transition:none}}.nav-link:hover,.nav-link:focus{color:var(--bs-nav-link-hover-color)}.nav-link:focus-visible{outline:0;box-shadow:0 0 0 .25rem rgba(52,89,230,0.25)}.nav-link.disabled,.nav-link:disabled{color:var(--bs-nav-link-disabled-color);pointer-events:none;cursor:default}.nav-tabs{--bs-nav-tabs-border-width: var(--bs-border-width);--bs-nav-tabs-border-color: var(--bs-border-color);--bs-nav-tabs-border-radius: 0;--bs-nav-tabs-link-hover-border-color: var(--bs-secondary-bg) var(--bs-secondary-bg) var(--bs-border-color);--bs-nav-tabs-link-active-color: #3459e6;--bs-nav-tabs-link-active-bg: var(--bs-body-bg);--bs-nav-tabs-link-active-border-color: var(--bs-border-color) var(--bs-border-color) var(--bs-body-bg);border-bottom:var(--bs-nav-tabs-border-width) solid var(--bs-nav-tabs-border-color)}.nav-tabs .nav-link{margin-bottom:calc(-1 * var(--bs-nav-tabs-border-width));border:var(--bs-nav-tabs-border-width) solid transparent;border-top-left-radius:var(--bs-nav-tabs-border-radius);border-top-right-radius:var(--bs-nav-tabs-border-radius)}.nav-tabs .nav-link:hover,.nav-tabs .nav-link:focus{isolation:isolate;border-color:var(--bs-nav-tabs-link-hover-border-color)}.nav-tabs .nav-link.active,.nav-tabs .nav-item.show .nav-link{color:var(--bs-nav-tabs-link-active-color);background-color:var(--bs-nav-tabs-link-active-bg);border-color:var(--bs-nav-tabs-link-active-border-color)}.nav-tabs .dropdown-menu{margin-top:calc(-1 * var(--bs-nav-tabs-border-width));border-top-left-radius:0;border-top-right-radius:0}.nav-pills{--bs-nav-pills-border-radius: var(--bs-border-radius);--bs-nav-pills-link-active-color: #fff;--bs-nav-pills-link-active-bg: #3459e6}.nav-pills .nav-link{border-radius:var(--bs-nav-pills-border-radius)}.nav-pills .nav-link.active,.nav-pills .show>.nav-link{color:var(--bs-nav-pills-link-active-color);background-color:var(--bs-nav-pills-link-active-bg)}.nav-underline{--bs-nav-underline-gap: 1rem;--bs-nav-underline-border-width: .125rem;--bs-nav-underline-link-active-color: var(--bs-emphasis-color);gap:var(--bs-nav-underline-gap)}.nav-underline .nav-link{padding-right:0;padding-left:0;border-bottom:var(--bs-nav-underline-border-width) solid transparent}.nav-underline .nav-link:hover,.nav-underline .nav-link:focus{border-bottom-color:currentcolor}.nav-underline .nav-link.active,.nav-underline .show>.nav-link{font-weight:700;color:var(--bs-nav-underline-link-active-color);border-bottom-color:currentcolor}.nav-fill>.nav-link,.nav-fill .nav-item{flex:1 1 auto;-webkit-flex:1 1 auto;text-align:center}.nav-justified>.nav-link,.nav-justified .nav-item{flex-basis:0;-webkit-flex-basis:0;flex-grow:1;-webkit-flex-grow:1;text-align:center}.nav-fill .nav-item .nav-link,.nav-justified .nav-item .nav-link{width:100%}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.navbar,:where([data-bs-theme="light"]) .navbar{--bs-navbar-padding-x: 0;--bs-navbar-padding-y: .85rem;--bs-navbar-color: rgba(var(--bs-emphasis-color-rgb), 0.65);--bs-navbar-hover-color: rgba(var(--bs-emphasis-color-rgb), 0.8);--bs-navbar-disabled-color: rgba(var(--bs-emphasis-color-rgb), 0.3);--bs-navbar-active-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-padding-y: .3125rem;--bs-navbar-brand-margin-end: 1rem;--bs-navbar-brand-font-size: 1.25rem;--bs-navbar-brand-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-hover-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-nav-link-padding-x: .75rem;--bs-navbar-toggler-padding-y: .25rem;--bs-navbar-toggler-padding-x: .75rem;--bs-navbar-toggler-font-size: 1.25rem;--bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2873,80,87,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");--bs-navbar-toggler-border-color: rgba(var(--bs-emphasis-color-rgb), 0.15);--bs-navbar-toggler-border-radius: var(--bs-border-radius);--bs-navbar-toggler-focus-width: .25rem;--bs-navbar-toggler-transition: box-shadow 0.15s ease-in-out}.navbar{position:relative;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;align-items:center;-webkit-align-items:center;justify-content:space-between;-webkit-justify-content:space-between;padding:var(--bs-navbar-padding-y) var(--bs-navbar-padding-x)}.navbar>.container,.navbar>.container-fluid,.navbar>.container-sm,.navbar>.container-md,.navbar>.container-lg,.navbar>.container-xl,.navbar>.container-xxl{display:flex;display:-webkit-flex;flex-wrap:inherit;-webkit-flex-wrap:inherit;align-items:center;-webkit-align-items:center;justify-content:space-between;-webkit-justify-content:space-between}.navbar-brand{padding-top:var(--bs-navbar-brand-padding-y);padding-bottom:var(--bs-navbar-brand-padding-y);margin-right:var(--bs-navbar-brand-margin-end);font-size:var(--bs-navbar-brand-font-size);color:var(--bs-navbar-brand-color);text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;white-space:nowrap}.navbar-brand:hover,.navbar-brand:focus{color:var(--bs-navbar-brand-hover-color)}.navbar-nav{--bs-nav-link-padding-x: 0;--bs-nav-link-padding-y: .5rem;--bs-nav-link-font-weight: ;--bs-nav-link-color: var(--bs-navbar-color);--bs-nav-link-hover-color: var(--bs-navbar-hover-color);--bs-nav-link-disabled-color: var(--bs-navbar-disabled-color);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;padding-left:0;margin-bottom:0;list-style:none}.navbar-nav .nav-link.active,.navbar-nav .nav-link.show{color:var(--bs-navbar-active-color)}.navbar-nav .dropdown-menu{position:static}.navbar-text{padding-top:.5rem;padding-bottom:.5rem;color:var(--bs-navbar-color)}.navbar-text a,.navbar-text a:hover,.navbar-text a:focus{color:var(--bs-navbar-active-color)}.navbar-collapse{flex-basis:100%;-webkit-flex-basis:100%;flex-grow:1;-webkit-flex-grow:1;align-items:center;-webkit-align-items:center}.navbar-toggler{padding:var(--bs-navbar-toggler-padding-y) var(--bs-navbar-toggler-padding-x);font-size:var(--bs-navbar-toggler-font-size);line-height:1;color:var(--bs-navbar-color);background-color:transparent;border:var(--bs-border-width) solid var(--bs-navbar-toggler-border-color);border-radius:var(--bs-navbar-toggler-border-radius);transition:var(--bs-navbar-toggler-transition)}@media (prefers-reduced-motion: reduce){.navbar-toggler{transition:none}}.navbar-toggler:hover{text-decoration:none}.navbar-toggler:focus{text-decoration:none;outline:0;box-shadow:0 0 0 var(--bs-navbar-toggler-focus-width)}.navbar-toggler-icon{display:inline-block;width:1.5em;height:1.5em;vertical-align:middle;background-image:var(--bs-navbar-toggler-icon-bg);background-repeat:no-repeat;background-position:center;background-size:100%}.navbar-nav-scroll{max-height:var(--bs-scroll-height, 75vh);overflow-y:auto}@media (min-width: 576px){.navbar-expand-sm{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-sm .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-sm .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-sm .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-sm .navbar-nav-scroll{overflow:visible}.navbar-expand-sm .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-sm .navbar-toggler{display:none}.navbar-expand-sm .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-sm .offcanvas .offcanvas-header{display:none}.navbar-expand-sm .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}@media (min-width: 768px){.navbar-expand-md{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-md .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-md .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-md .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-md .navbar-nav-scroll{overflow:visible}.navbar-expand-md .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-md .navbar-toggler{display:none}.navbar-expand-md .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-md .offcanvas .offcanvas-header{display:none}.navbar-expand-md .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}@media (min-width: 992px){.navbar-expand-lg{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-lg .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-lg .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-lg .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-lg .navbar-nav-scroll{overflow:visible}.navbar-expand-lg .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-lg .navbar-toggler{display:none}.navbar-expand-lg .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-lg .offcanvas .offcanvas-header{display:none}.navbar-expand-lg .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}@media (min-width: 1200px){.navbar-expand-xl{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-xl .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-xl .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-xl .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-xl .navbar-nav-scroll{overflow:visible}.navbar-expand-xl .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-xl .navbar-toggler{display:none}.navbar-expand-xl .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-xl .offcanvas .offcanvas-header{display:none}.navbar-expand-xl .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}@media (min-width: 1400px){.navbar-expand-xxl{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand-xxl .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand-xxl .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-xxl .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-xxl .navbar-nav-scroll{overflow:visible}.navbar-expand-xxl .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand-xxl .navbar-toggler{display:none}.navbar-expand-xxl .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand-xxl .offcanvas .offcanvas-header{display:none}.navbar-expand-xxl .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}}.navbar-expand{flex-wrap:nowrap;-webkit-flex-wrap:nowrap;justify-content:flex-start;-webkit-justify-content:flex-start}.navbar-expand .navbar-nav{flex-direction:row;-webkit-flex-direction:row}.navbar-expand .navbar-nav .dropdown-menu{position:absolute}.navbar-expand .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand .navbar-nav-scroll{overflow:visible}.navbar-expand .navbar-collapse{display:flex !important;display:-webkit-flex !important;flex-basis:auto;-webkit-flex-basis:auto}.navbar-expand .navbar-toggler{display:none}.navbar-expand .offcanvas{position:static;z-index:auto;flex-grow:1;-webkit-flex-grow:1;width:auto !important;height:auto !important;visibility:visible !important;background-color:transparent !important;border:0 !important;transform:none !important;box-shadow:none;transition:none}.navbar-expand .offcanvas .offcanvas-header{display:none}.navbar-expand .offcanvas .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible}.navbar-dark,:where([data-bs-theme="dark"]) .navbar,.navbar[data-bs-theme="dark"]{--bs-navbar-color: rgba(var(--bs-emphasis-color-rgb), 0.55);--bs-navbar-hover-color: rgba(var(--bs-emphasis-color-rgb), 0.75);--bs-navbar-disabled-color: rgba(var(--bs-emphasis-color-rgb), 0.25);--bs-navbar-active-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-hover-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-toggler-border-color: rgba(var(--bs-emphasis-color-rgb), 0.1);--bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")}:where(.navbar[data-bs-theme="dark"] .navbar-toggler-icon){--bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")}[data-bs-theme="dark"] :where(.navbar:not([data-bs-theme="light"]) .navbar-toggler-icon){--bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")}.navbar[data-bs-theme="light"]{--bs-navbar-color: rgba(var(--bs-emphasis-color-rgb), 0.65);--bs-navbar-hover-color: rgba(var(--bs-emphasis-color-rgb), 0.8);--bs-navbar-disabled-color: rgba(var(--bs-emphasis-color-rgb), 0.3);--bs-navbar-active-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-brand-hover-color: rgba(var(--bs-emphasis-color-rgb), 1);--bs-navbar-toggler-border-color: rgba(var(--bs-emphasis-color-rgb), 0.15)}.navbar[data-bs-theme="light"] .navbar-toggler-icon{--bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2873,80,87,0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")}.card{--bs-card-spacer-y: 1rem;--bs-card-spacer-x: 1.5rem;--bs-card-title-spacer-y: .5rem;--bs-card-title-color: ;--bs-card-subtitle-color: ;--bs-card-border-width: var(--bs-border-width);--bs-card-border-color: var(--bs-border-color-translucent);--bs-card-border-radius: var(--bs-border-radius);--bs-card-box-shadow: ;--bs-card-inner-border-radius: calc(var(--bs-border-radius) - (var(--bs-border-width)));--bs-card-cap-padding-y: 1rem;--bs-card-cap-padding-x: 1.5rem;--bs-card-cap-bg: rgba(var(--bs-body-color-rgb), 0.03);--bs-card-cap-color: ;--bs-card-height: ;--bs-card-color: ;--bs-card-bg: var(--bs-body-bg);--bs-card-img-overlay-padding: 1rem;--bs-card-group-margin: .75rem;position:relative;display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;min-width:0;height:var(--bs-card-height);color:var(--bs-body-color);word-wrap:break-word;background-color:var(--bs-card-bg);background-clip:border-box;border:var(--bs-card-border-width) solid var(--bs-card-border-color);border-radius:var(--bs-card-border-radius);box-shadow:var(--bs-card-box-shadow)}.card>hr{margin-right:0;margin-left:0}.card>.list-group{border-top:inherit;border-bottom:inherit}.card>.list-group:first-child{border-top-width:0;border-top-left-radius:var(--bs-card-inner-border-radius);border-top-right-radius:var(--bs-card-inner-border-radius)}.card>.list-group:last-child{border-bottom-width:0;border-bottom-right-radius:var(--bs-card-inner-border-radius);border-bottom-left-radius:var(--bs-card-inner-border-radius)}.card>.card-header+.list-group,.card>.list-group+.card-footer{border-top:0}.card-body{flex:1 1 auto;-webkit-flex:1 1 auto;padding:var(--bs-card-spacer-y) var(--bs-card-spacer-x);color:var(--bs-card-color)}.card-title{margin-bottom:var(--bs-card-title-spacer-y);color:var(--bs-card-title-color)}.card-subtitle{margin-top:calc(-.5 * var(--bs-card-title-spacer-y));margin-bottom:0;color:var(--bs-card-subtitle-color)}.card-text:last-child{margin-bottom:0}.card-link+.card-link{margin-left:var(--bs-card-spacer-x)}.card-header{padding:var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x);margin-bottom:0;color:var(--bs-card-cap-color);background-color:var(--bs-card-cap-bg);border-bottom:var(--bs-card-border-width) solid var(--bs-card-border-color)}.card-header:first-child{border-radius:var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0}.card-footer{padding:var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x);color:var(--bs-card-cap-color);background-color:var(--bs-card-cap-bg);border-top:var(--bs-card-border-width) solid var(--bs-card-border-color)}.card-footer:last-child{border-radius:0 0 var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius)}.card-header-tabs{margin-right:calc(-.5 * var(--bs-card-cap-padding-x));margin-bottom:calc(-1 * var(--bs-card-cap-padding-y));margin-left:calc(-.5 * var(--bs-card-cap-padding-x));border-bottom:0}.card-header-tabs .nav-link.active{background-color:var(--bs-card-bg);border-bottom-color:var(--bs-card-bg)}.card-header-pills{margin-right:calc(-.5 * var(--bs-card-cap-padding-x));margin-left:calc(-.5 * var(--bs-card-cap-padding-x))}.card-img-overlay{position:absolute;top:0;right:0;bottom:0;left:0;padding:var(--bs-card-img-overlay-padding);border-radius:var(--bs-card-inner-border-radius)}.card-img,.card-img-top,.card-img-bottom{width:100%}.card-img,.card-img-top{border-top-left-radius:var(--bs-card-inner-border-radius);border-top-right-radius:var(--bs-card-inner-border-radius)}.card-img,.card-img-bottom{border-bottom-right-radius:var(--bs-card-inner-border-radius);border-bottom-left-radius:var(--bs-card-inner-border-radius)}.card-group>.card{margin-bottom:var(--bs-card-group-margin)}@media (min-width: 576px){.card-group{display:flex;display:-webkit-flex;flex-flow:row wrap;-webkit-flex-flow:row wrap}.card-group>.card{flex:1 0 0%;-webkit-flex:1 0 0%;margin-bottom:0}.card-group>.card+.card{margin-left:0;border-left:0}.card-group>.card:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}.card-group>.card:not(:last-child) .card-img-top,.card-group>.card:not(:last-child) .card-header{border-top-right-radius:0}.card-group>.card:not(:last-child) .card-img-bottom,.card-group>.card:not(:last-child) .card-footer{border-bottom-right-radius:0}.card-group>.card:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0}.card-group>.card:not(:first-child) .card-img-top,.card-group>.card:not(:first-child) .card-header{border-top-left-radius:0}.card-group>.card:not(:first-child) .card-img-bottom,.card-group>.card:not(:first-child) .card-footer{border-bottom-left-radius:0}}.accordion{--bs-accordion-color: var(--bs-body-color);--bs-accordion-bg: var(--bs-body-bg);--bs-accordion-transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,border-radius 0.15s ease;--bs-accordion-border-color: var(--bs-border-color);--bs-accordion-border-width: var(--bs-border-width);--bs-accordion-border-radius: var(--bs-border-radius);--bs-accordion-inner-border-radius: calc(var(--bs-border-radius) - (var(--bs-border-width)));--bs-accordion-btn-padding-x: 1.25rem;--bs-accordion-btn-padding-y: 1rem;--bs-accordion-btn-color: var(--bs-body-color);--bs-accordion-btn-bg: var(--bs-accordion-bg);--bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23495057'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");--bs-accordion-btn-icon-width: 1.25rem;--bs-accordion-btn-icon-transform: rotate(-180deg);--bs-accordion-btn-icon-transition: transform 0.2s ease-in-out;--bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2315245c'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");--bs-accordion-btn-focus-border-color: #9aacf3;--bs-accordion-btn-focus-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-accordion-body-padding-x: 1.25rem;--bs-accordion-body-padding-y: 1rem;--bs-accordion-active-color: var(--bs-primary-text-emphasis);--bs-accordion-active-bg: var(--bs-primary-bg-subtle)}.accordion-button{position:relative;display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;width:100%;padding:var(--bs-accordion-btn-padding-y) var(--bs-accordion-btn-padding-x);font-size:1rem;color:var(--bs-accordion-btn-color);text-align:left;background-color:var(--bs-accordion-btn-bg);border:0;border-radius:0;overflow-anchor:none;transition:var(--bs-accordion-transition)}@media (prefers-reduced-motion: reduce){.accordion-button{transition:none}}.accordion-button:not(.collapsed){color:var(--bs-accordion-active-color);background-color:var(--bs-accordion-active-bg);box-shadow:inset 0 calc(-1 * var(--bs-accordion-border-width)) 0 var(--bs-accordion-border-color)}.accordion-button:not(.collapsed)::after{background-image:var(--bs-accordion-btn-active-icon);transform:var(--bs-accordion-btn-icon-transform)}.accordion-button::after{flex-shrink:0;-webkit-flex-shrink:0;width:var(--bs-accordion-btn-icon-width);height:var(--bs-accordion-btn-icon-width);margin-left:auto;content:"";background-image:var(--bs-accordion-btn-icon);background-repeat:no-repeat;background-size:var(--bs-accordion-btn-icon-width);transition:var(--bs-accordion-btn-icon-transition)}@media (prefers-reduced-motion: reduce){.accordion-button::after{transition:none}}.accordion-button:hover{z-index:2}.accordion-button:focus{z-index:3;border-color:var(--bs-accordion-btn-focus-border-color);outline:0;box-shadow:var(--bs-accordion-btn-focus-box-shadow)}.accordion-header{margin-bottom:0}.accordion-item{color:var(--bs-accordion-color);background-color:var(--bs-accordion-bg);border:var(--bs-accordion-border-width) solid var(--bs-accordion-border-color)}.accordion-item:first-of-type{border-top-left-radius:var(--bs-accordion-border-radius);border-top-right-radius:var(--bs-accordion-border-radius)}.accordion-item:first-of-type .accordion-button{border-top-left-radius:var(--bs-accordion-inner-border-radius);border-top-right-radius:var(--bs-accordion-inner-border-radius)}.accordion-item:not(:first-of-type){border-top:0}.accordion-item:last-of-type{border-bottom-right-radius:var(--bs-accordion-border-radius);border-bottom-left-radius:var(--bs-accordion-border-radius)}.accordion-item:last-of-type .accordion-button.collapsed{border-bottom-right-radius:var(--bs-accordion-inner-border-radius);border-bottom-left-radius:var(--bs-accordion-inner-border-radius)}.accordion-item:last-of-type .accordion-collapse{border-bottom-right-radius:var(--bs-accordion-border-radius);border-bottom-left-radius:var(--bs-accordion-border-radius)}.accordion-body{padding:var(--bs-accordion-body-padding-y) var(--bs-accordion-body-padding-x)}.accordion-flush .accordion-collapse{border-width:0}.accordion-flush .accordion-item{border-right:0;border-left:0;border-radius:0}.accordion-flush .accordion-item:first-child{border-top:0}.accordion-flush .accordion-item:last-child{border-bottom:0}.accordion-flush .accordion-item .accordion-button,.accordion-flush .accordion-item .accordion-button.collapsed{border-radius:0}[data-bs-theme="dark"] .accordion-button::after{--bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23859bf0'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");--bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23859bf0'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e")}.breadcrumb{--bs-breadcrumb-padding-x: 1rem;--bs-breadcrumb-padding-y: 0;--bs-breadcrumb-margin-bottom: 1rem;--bs-breadcrumb-bg: ;--bs-breadcrumb-border-radius: ;--bs-breadcrumb-divider-color: var(--bs-secondary-color);--bs-breadcrumb-item-padding-x: .5rem;--bs-breadcrumb-item-active-color: var(--bs-secondary-color);display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap;padding:var(--bs-breadcrumb-padding-y) var(--bs-breadcrumb-padding-x);margin-bottom:var(--bs-breadcrumb-margin-bottom);font-size:var(--bs-breadcrumb-font-size);list-style:none;background-color:var(--bs-breadcrumb-bg);border-radius:var(--bs-breadcrumb-border-radius)}.breadcrumb-item+.breadcrumb-item{padding-left:var(--bs-breadcrumb-item-padding-x)}.breadcrumb-item+.breadcrumb-item::before{float:left;padding-right:var(--bs-breadcrumb-item-padding-x);color:var(--bs-breadcrumb-divider-color);content:var(--bs-breadcrumb-divider, ">") /* rtl: var(--bs-breadcrumb-divider, ">") */}.breadcrumb-item.active{color:var(--bs-breadcrumb-item-active-color)}.pagination{--bs-pagination-padding-x: 1rem;--bs-pagination-padding-y: .5rem;--bs-pagination-font-size:1rem;--bs-pagination-color: #495057;--bs-pagination-bg: var(--bs-body-bg);--bs-pagination-border-width: var(--bs-border-width);--bs-pagination-border-color: var(--bs-border-color);--bs-pagination-border-radius: var(--bs-border-radius);--bs-pagination-hover-color: #495057;--bs-pagination-hover-bg: #f8f9fa;--bs-pagination-hover-border-color: var(--bs-border-color);--bs-pagination-focus-color: #495057;--bs-pagination-focus-bg: var(--bs-secondary-bg);--bs-pagination-focus-box-shadow: 0 0 0 .25rem rgba(52,89,230,0.25);--bs-pagination-active-color: #fff;--bs-pagination-active-bg: #3459e6;--bs-pagination-active-border-color: #3459e6;--bs-pagination-disabled-color: var(--bs-secondary-color);--bs-pagination-disabled-bg: var(--bs-secondary-bg);--bs-pagination-disabled-border-color: var(--bs-border-color);display:flex;display:-webkit-flex;padding-left:0;list-style:none}.page-link{position:relative;display:block;padding:var(--bs-pagination-padding-y) var(--bs-pagination-padding-x);font-size:var(--bs-pagination-font-size);color:var(--bs-pagination-color);text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;background-color:var(--bs-pagination-bg);border:var(--bs-pagination-border-width) solid var(--bs-pagination-border-color);transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out}@media (prefers-reduced-motion: reduce){.page-link{transition:none}}.page-link:hover{z-index:2;color:var(--bs-pagination-hover-color);background-color:var(--bs-pagination-hover-bg);border-color:var(--bs-pagination-hover-border-color)}.page-link:focus{z-index:3;color:var(--bs-pagination-focus-color);background-color:var(--bs-pagination-focus-bg);outline:0;box-shadow:var(--bs-pagination-focus-box-shadow)}.page-link.active,.active>.page-link{z-index:3;color:var(--bs-pagination-active-color);background-color:var(--bs-pagination-active-bg);border-color:var(--bs-pagination-active-border-color)}.page-link.disabled,.disabled>.page-link{color:var(--bs-pagination-disabled-color);pointer-events:none;background-color:var(--bs-pagination-disabled-bg);border-color:var(--bs-pagination-disabled-border-color)}.page-item:not(:first-child) .page-link{margin-left:calc(var(--bs-border-width) * -1)}.page-item:first-child .page-link{border-top-left-radius:var(--bs-pagination-border-radius);border-bottom-left-radius:var(--bs-pagination-border-radius)}.page-item:last-child .page-link{border-top-right-radius:var(--bs-pagination-border-radius);border-bottom-right-radius:var(--bs-pagination-border-radius)}.pagination-lg{--bs-pagination-padding-x: 1.5rem;--bs-pagination-padding-y: .75rem;--bs-pagination-font-size:1.25rem;--bs-pagination-border-radius: var(--bs-border-radius-lg)}.pagination-sm{--bs-pagination-padding-x: .5rem;--bs-pagination-padding-y: .25rem;--bs-pagination-font-size:.875rem;--bs-pagination-border-radius: var(--bs-border-radius-sm)}.badge{--bs-badge-padding-x: .65em;--bs-badge-padding-y: .35em;--bs-badge-font-size:.75em;--bs-badge-font-weight: 700;--bs-badge-color: #fff;--bs-badge-border-radius: var(--bs-border-radius);display:inline-block;padding:var(--bs-badge-padding-y) var(--bs-badge-padding-x);font-size:var(--bs-badge-font-size);font-weight:var(--bs-badge-font-weight);line-height:1;color:var(--bs-badge-color);text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:var(--bs-badge-border-radius)}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}.alert{--bs-alert-bg: transparent;--bs-alert-padding-x: 1rem;--bs-alert-padding-y: 1rem;--bs-alert-margin-bottom: 1rem;--bs-alert-color: inherit;--bs-alert-border-color: transparent;--bs-alert-border: var(--bs-border-width) solid var(--bs-alert-border-color);--bs-alert-border-radius: var(--bs-border-radius);--bs-alert-link-color: inherit;position:relative;padding:var(--bs-alert-padding-y) var(--bs-alert-padding-x);margin-bottom:var(--bs-alert-margin-bottom);color:var(--bs-alert-color);background-color:var(--bs-alert-bg);border:var(--bs-alert-border);border-radius:var(--bs-alert-border-radius)}.alert-heading{color:inherit}.alert-link{font-weight:700;color:var(--bs-alert-link-color)}.alert-dismissible{padding-right:3rem}.alert-dismissible .btn-close{position:absolute;top:0;right:0;z-index:2;padding:1.25rem 1rem}.alert-default{--bs-alert-color: var(--bs-default-text-emphasis);--bs-alert-bg: var(--bs-default-bg-subtle);--bs-alert-border-color: var(--bs-default-border-subtle);--bs-alert-link-color: var(--bs-default-text-emphasis)}.alert-primary{--bs-alert-color: var(--bs-primary-text-emphasis);--bs-alert-bg: var(--bs-primary-bg-subtle);--bs-alert-border-color: var(--bs-primary-border-subtle);--bs-alert-link-color: var(--bs-primary-text-emphasis)}.alert-secondary{--bs-alert-color: var(--bs-secondary-text-emphasis);--bs-alert-bg: var(--bs-secondary-bg-subtle);--bs-alert-border-color: var(--bs-secondary-border-subtle);--bs-alert-link-color: var(--bs-secondary-text-emphasis)}.alert-success{--bs-alert-color: var(--bs-success-text-emphasis);--bs-alert-bg: var(--bs-success-bg-subtle);--bs-alert-border-color: var(--bs-success-border-subtle);--bs-alert-link-color: var(--bs-success-text-emphasis)}.alert-info{--bs-alert-color: var(--bs-info-text-emphasis);--bs-alert-bg: var(--bs-info-bg-subtle);--bs-alert-border-color: var(--bs-info-border-subtle);--bs-alert-link-color: var(--bs-info-text-emphasis)}.alert-warning{--bs-alert-color: var(--bs-warning-text-emphasis);--bs-alert-bg: var(--bs-warning-bg-subtle);--bs-alert-border-color: var(--bs-warning-border-subtle);--bs-alert-link-color: var(--bs-warning-text-emphasis)}.alert-danger{--bs-alert-color: var(--bs-danger-text-emphasis);--bs-alert-bg: var(--bs-danger-bg-subtle);--bs-alert-border-color: var(--bs-danger-border-subtle);--bs-alert-link-color: var(--bs-danger-text-emphasis)}.alert-light{--bs-alert-color: var(--bs-light-text-emphasis);--bs-alert-bg: var(--bs-light-bg-subtle);--bs-alert-border-color: var(--bs-light-border-subtle);--bs-alert-link-color: var(--bs-light-text-emphasis)}.alert-dark{--bs-alert-color: var(--bs-dark-text-emphasis);--bs-alert-bg: var(--bs-dark-bg-subtle);--bs-alert-border-color: var(--bs-dark-border-subtle);--bs-alert-link-color: var(--bs-dark-text-emphasis)}@keyframes progress-bar-stripes{0%{background-position-x:1rem}}.progress,.progress-stacked{--bs-progress-height: 1rem;--bs-progress-font-size:.75rem;--bs-progress-bg: var(--bs-secondary-bg);--bs-progress-border-radius: var(--bs-border-radius);--bs-progress-box-shadow: var(--bs-box-shadow-inset);--bs-progress-bar-color: #fff;--bs-progress-bar-bg: #3459e6;--bs-progress-bar-transition: width 0.6s ease;display:flex;display:-webkit-flex;height:var(--bs-progress-height);overflow:hidden;font-size:var(--bs-progress-font-size);background-color:var(--bs-progress-bg);border-radius:var(--bs-progress-border-radius);box-shadow:var(--bs-progress-box-shadow)}.progress-bar{display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;justify-content:center;-webkit-justify-content:center;overflow:hidden;color:var(--bs-progress-bar-color);text-align:center;white-space:nowrap;background-color:var(--bs-progress-bar-bg);transition:var(--bs-progress-bar-transition)}@media (prefers-reduced-motion: reduce){.progress-bar{transition:none}}.progress-bar-striped{background-image:linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);background-size:var(--bs-progress-height) var(--bs-progress-height)}.progress-stacked>.progress{overflow:visible}.progress-stacked>.progress>.progress-bar{width:100%}.progress-bar-animated{animation:1s linear infinite progress-bar-stripes}@media (prefers-reduced-motion: reduce){.progress-bar-animated{animation:none}}.list-group{--bs-list-group-color: var(--bs-body-color);--bs-list-group-bg: var(--bs-body-bg);--bs-list-group-border-color: var(--bs-border-color);--bs-list-group-border-width: var(--bs-border-width);--bs-list-group-border-radius: var(--bs-border-radius);--bs-list-group-item-padding-x: 1.5rem;--bs-list-group-item-padding-y: 1rem;--bs-list-group-action-color: var(--bs-secondary-color);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-tertiary-bg);--bs-list-group-action-active-color: var(--bs-body-color);--bs-list-group-action-active-bg: var(--bs-secondary-bg);--bs-list-group-disabled-color: var(--bs-secondary-color);--bs-list-group-disabled-bg: var(--bs-body-bg);--bs-list-group-active-color: #fff;--bs-list-group-active-bg: #3459e6;--bs-list-group-active-border-color: #3459e6;display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;padding-left:0;margin-bottom:0;border-radius:var(--bs-list-group-border-radius)}.list-group-numbered{list-style-type:none;counter-reset:section}.list-group-numbered>.list-group-item::before{content:counters(section, ".") ". ";counter-increment:section}.list-group-item-action{width:100%;color:var(--bs-list-group-action-color);text-align:inherit}.list-group-item-action:hover,.list-group-item-action:focus{z-index:1;color:var(--bs-list-group-action-hover-color);text-decoration:none;background-color:var(--bs-list-group-action-hover-bg)}.list-group-item-action:active{color:var(--bs-list-group-action-active-color);background-color:var(--bs-list-group-action-active-bg)}.list-group-item{position:relative;display:block;padding:var(--bs-list-group-item-padding-y) var(--bs-list-group-item-padding-x);color:var(--bs-list-group-color);text-decoration:none;-webkit-text-decoration:none;-moz-text-decoration:none;-ms-text-decoration:none;-o-text-decoration:none;background-color:var(--bs-list-group-bg);border:var(--bs-list-group-border-width) solid var(--bs-list-group-border-color)}.list-group-item:first-child{border-top-left-radius:inherit;border-top-right-radius:inherit}.list-group-item:last-child{border-bottom-right-radius:inherit;border-bottom-left-radius:inherit}.list-group-item.disabled,.list-group-item:disabled{color:var(--bs-list-group-disabled-color);pointer-events:none;background-color:var(--bs-list-group-disabled-bg)}.list-group-item.active{z-index:2;color:var(--bs-list-group-active-color);background-color:var(--bs-list-group-active-bg);border-color:var(--bs-list-group-active-border-color)}.list-group-item+.list-group-item{border-top-width:0}.list-group-item+.list-group-item.active{margin-top:calc(-1 * var(--bs-list-group-border-width));border-top-width:var(--bs-list-group-border-width)}.list-group-horizontal{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal>.list-group-item.active{margin-top:0}.list-group-horizontal>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}@media (min-width: 576px){.list-group-horizontal-sm{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-sm>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-sm>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-sm>.list-group-item.active{margin-top:0}.list-group-horizontal-sm>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-sm>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width: 768px){.list-group-horizontal-md{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-md>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-md>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-md>.list-group-item.active{margin-top:0}.list-group-horizontal-md>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-md>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width: 992px){.list-group-horizontal-lg{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-lg>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-lg>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-lg>.list-group-item.active{margin-top:0}.list-group-horizontal-lg>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-lg>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width: 1200px){.list-group-horizontal-xl{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-xl>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-xl>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-xl>.list-group-item.active{margin-top:0}.list-group-horizontal-xl>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-xl>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width: 1400px){.list-group-horizontal-xxl{flex-direction:row;-webkit-flex-direction:row}.list-group-horizontal-xxl>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-xxl>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-xxl>.list-group-item.active{margin-top:0}.list-group-horizontal-xxl>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-xxl>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}.list-group-flush{border-radius:0}.list-group-flush>.list-group-item{border-width:0 0 var(--bs-list-group-border-width)}.list-group-flush>.list-group-item:last-child{border-bottom-width:0}.list-group-item-default{--bs-list-group-color: var(--bs-default-text-emphasis);--bs-list-group-bg: var(--bs-default-bg-subtle);--bs-list-group-border-color: var(--bs-default-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-default-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-default-border-subtle);--bs-list-group-active-color: var(--bs-default-bg-subtle);--bs-list-group-active-bg: var(--bs-default-text-emphasis);--bs-list-group-active-border-color: var(--bs-default-text-emphasis)}.list-group-item-primary{--bs-list-group-color: var(--bs-primary-text-emphasis);--bs-list-group-bg: var(--bs-primary-bg-subtle);--bs-list-group-border-color: var(--bs-primary-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-primary-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-primary-border-subtle);--bs-list-group-active-color: var(--bs-primary-bg-subtle);--bs-list-group-active-bg: var(--bs-primary-text-emphasis);--bs-list-group-active-border-color: var(--bs-primary-text-emphasis)}.list-group-item-secondary{--bs-list-group-color: var(--bs-secondary-text-emphasis);--bs-list-group-bg: var(--bs-secondary-bg-subtle);--bs-list-group-border-color: var(--bs-secondary-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-secondary-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-secondary-border-subtle);--bs-list-group-active-color: var(--bs-secondary-bg-subtle);--bs-list-group-active-bg: var(--bs-secondary-text-emphasis);--bs-list-group-active-border-color: var(--bs-secondary-text-emphasis)}.list-group-item-success{--bs-list-group-color: var(--bs-success-text-emphasis);--bs-list-group-bg: var(--bs-success-bg-subtle);--bs-list-group-border-color: var(--bs-success-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-success-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-success-border-subtle);--bs-list-group-active-color: var(--bs-success-bg-subtle);--bs-list-group-active-bg: var(--bs-success-text-emphasis);--bs-list-group-active-border-color: var(--bs-success-text-emphasis)}.list-group-item-info{--bs-list-group-color: var(--bs-info-text-emphasis);--bs-list-group-bg: var(--bs-info-bg-subtle);--bs-list-group-border-color: var(--bs-info-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-info-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-info-border-subtle);--bs-list-group-active-color: var(--bs-info-bg-subtle);--bs-list-group-active-bg: var(--bs-info-text-emphasis);--bs-list-group-active-border-color: var(--bs-info-text-emphasis)}.list-group-item-warning{--bs-list-group-color: var(--bs-warning-text-emphasis);--bs-list-group-bg: var(--bs-warning-bg-subtle);--bs-list-group-border-color: var(--bs-warning-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-warning-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-warning-border-subtle);--bs-list-group-active-color: var(--bs-warning-bg-subtle);--bs-list-group-active-bg: var(--bs-warning-text-emphasis);--bs-list-group-active-border-color: var(--bs-warning-text-emphasis)}.list-group-item-danger{--bs-list-group-color: var(--bs-danger-text-emphasis);--bs-list-group-bg: var(--bs-danger-bg-subtle);--bs-list-group-border-color: var(--bs-danger-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-danger-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-danger-border-subtle);--bs-list-group-active-color: var(--bs-danger-bg-subtle);--bs-list-group-active-bg: var(--bs-danger-text-emphasis);--bs-list-group-active-border-color: var(--bs-danger-text-emphasis)}.list-group-item-light{--bs-list-group-color: var(--bs-light-text-emphasis);--bs-list-group-bg: var(--bs-light-bg-subtle);--bs-list-group-border-color: var(--bs-light-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-light-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-light-border-subtle);--bs-list-group-active-color: var(--bs-light-bg-subtle);--bs-list-group-active-bg: var(--bs-light-text-emphasis);--bs-list-group-active-border-color: var(--bs-light-text-emphasis)}.list-group-item-dark{--bs-list-group-color: var(--bs-dark-text-emphasis);--bs-list-group-bg: var(--bs-dark-bg-subtle);--bs-list-group-border-color: var(--bs-dark-border-subtle);--bs-list-group-action-hover-color: var(--bs-emphasis-color);--bs-list-group-action-hover-bg: var(--bs-dark-border-subtle);--bs-list-group-action-active-color: var(--bs-emphasis-color);--bs-list-group-action-active-bg: var(--bs-dark-border-subtle);--bs-list-group-active-color: var(--bs-dark-bg-subtle);--bs-list-group-active-bg: var(--bs-dark-text-emphasis);--bs-list-group-active-border-color: var(--bs-dark-text-emphasis)}.btn-close{--bs-btn-close-color: #000;--bs-btn-close-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");--bs-btn-close-opacity: .5;--bs-btn-close-hover-opacity: .75;--bs-btn-close-focus-shadow: 0 0 0 .25rem rgba(52,89,230,0.25);--bs-btn-close-focus-opacity: 1;--bs-btn-close-disabled-opacity: .25;--bs-btn-close-white-filter: invert(1) grayscale(100%) brightness(200%);box-sizing:content-box;width:1em;height:1em;padding:.25em .25em;color:var(--bs-btn-close-color);background:transparent var(--bs-btn-close-bg) center/1em auto no-repeat;border:0;border-radius:.375rem;opacity:var(--bs-btn-close-opacity)}.btn-close:hover{color:var(--bs-btn-close-color);text-decoration:none;opacity:var(--bs-btn-close-hover-opacity)}.btn-close:focus{outline:0;box-shadow:var(--bs-btn-close-focus-shadow);opacity:var(--bs-btn-close-focus-opacity)}.btn-close:disabled,.btn-close.disabled{pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;opacity:var(--bs-btn-close-disabled-opacity)}.btn-close-white{filter:var(--bs-btn-close-white-filter)}[data-bs-theme="dark"] .btn-close{filter:var(--bs-btn-close-white-filter)}.toast{--bs-toast-zindex: 1090;--bs-toast-padding-x: .75rem;--bs-toast-padding-y: .5rem;--bs-toast-spacing: 1.5rem;--bs-toast-max-width: 350px;--bs-toast-font-size:.875rem;--bs-toast-color: ;--bs-toast-bg: rgba(var(--bs-body-bg-rgb), 0.85);--bs-toast-border-width: var(--bs-border-width);--bs-toast-border-color: var(--bs-border-color-translucent);--bs-toast-border-radius: var(--bs-border-radius);--bs-toast-box-shadow: var(--bs-box-shadow);--bs-toast-header-color: #212529;--bs-toast-header-bg: rgba(var(--bs-body-bg-rgb), 0.85);--bs-toast-header-border-color: var(--bs-border-color-translucent);width:var(--bs-toast-max-width);max-width:100%;font-size:var(--bs-toast-font-size);color:var(--bs-toast-color);pointer-events:auto;background-color:var(--bs-toast-bg);background-clip:padding-box;border:var(--bs-toast-border-width) solid var(--bs-toast-border-color);box-shadow:var(--bs-toast-box-shadow);border-radius:var(--bs-toast-border-radius)}.toast.showing{opacity:0}.toast:not(.show){display:none}.toast-container{--bs-toast-zindex: 1090;position:absolute;z-index:var(--bs-toast-zindex);width:max-content;width:-webkit-max-content;width:-moz-max-content;width:-ms-max-content;width:-o-max-content;max-width:100%;pointer-events:none}.toast-container>:not(:last-child){margin-bottom:var(--bs-toast-spacing)}.toast-header{display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;padding:var(--bs-toast-padding-y) var(--bs-toast-padding-x);color:var(--bs-toast-header-color);background-color:var(--bs-toast-header-bg);background-clip:padding-box;border-bottom:var(--bs-toast-border-width) solid var(--bs-toast-header-border-color);border-top-left-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width));border-top-right-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width))}.toast-header .btn-close{margin-right:calc(-.5 * var(--bs-toast-padding-x));margin-left:var(--bs-toast-padding-x)}.toast-body{padding:var(--bs-toast-padding-x);word-wrap:break-word}.modal{--bs-modal-zindex: 1055;--bs-modal-width: 500px;--bs-modal-padding: 1rem;--bs-modal-margin: .5rem;--bs-modal-color: ;--bs-modal-bg: var(--bs-body-bg);--bs-modal-border-color: #dee2e6;--bs-modal-border-width: var(--bs-border-width);--bs-modal-border-radius: var(--bs-border-radius-lg);--bs-modal-box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);--bs-modal-inner-border-radius: calc(var(--bs-border-radius-lg) - (var(--bs-border-width)));--bs-modal-header-padding-x: 1rem;--bs-modal-header-padding-y: 1rem;--bs-modal-header-padding: 1rem 1rem;--bs-modal-header-border-color: var(--bs-border-color);--bs-modal-header-border-width: 0;--bs-modal-title-line-height: 1.5;--bs-modal-footer-gap: .5rem;--bs-modal-footer-bg: ;--bs-modal-footer-border-color: var(--bs-border-color);--bs-modal-footer-border-width: 0;position:fixed;top:0;left:0;z-index:var(--bs-modal-zindex);display:none;width:100%;height:100%;overflow-x:hidden;overflow-y:auto;outline:0}.modal-dialog{position:relative;width:auto;margin:var(--bs-modal-margin);pointer-events:none}.modal.fade .modal-dialog{transition:transform 0.3s ease-out;transform:translate(0, -50px)}@media (prefers-reduced-motion: reduce){.modal.fade .modal-dialog{transition:none}}.modal.show .modal-dialog{transform:none}.modal.modal-static .modal-dialog{transform:scale(1.02)}.modal-dialog-scrollable{height:calc(100% - var(--bs-modal-margin) * 2)}.modal-dialog-scrollable .modal-content{max-height:100%;overflow:hidden}.modal-dialog-scrollable .modal-body{overflow-y:auto}.modal-dialog-centered{display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;min-height:calc(100% - var(--bs-modal-margin) * 2)}.modal-content{position:relative;display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;width:100%;color:var(--bs-modal-color);pointer-events:auto;background-color:var(--bs-modal-bg);background-clip:padding-box;border:var(--bs-modal-border-width) solid var(--bs-modal-border-color);border-radius:var(--bs-modal-border-radius);box-shadow:var(--bs-modal-box-shadow);outline:0}.modal-backdrop{--bs-backdrop-zindex: 1050;--bs-backdrop-bg: #000;--bs-backdrop-opacity: .5;position:fixed;top:0;left:0;z-index:var(--bs-backdrop-zindex);width:100vw;height:100vh;background-color:var(--bs-backdrop-bg)}.modal-backdrop.fade{opacity:0}.modal-backdrop.show{opacity:var(--bs-backdrop-opacity)}.modal-header{display:flex;display:-webkit-flex;flex-shrink:0;-webkit-flex-shrink:0;align-items:center;-webkit-align-items:center;justify-content:space-between;-webkit-justify-content:space-between;padding:var(--bs-modal-header-padding);border-bottom:var(--bs-modal-header-border-width) solid var(--bs-modal-header-border-color);border-top-left-radius:var(--bs-modal-inner-border-radius);border-top-right-radius:var(--bs-modal-inner-border-radius)}.modal-header .btn-close{padding:calc(var(--bs-modal-header-padding-y) * .5) calc(var(--bs-modal-header-padding-x) * .5);margin:calc(-.5 * var(--bs-modal-header-padding-y)) calc(-.5 * var(--bs-modal-header-padding-x)) calc(-.5 * var(--bs-modal-header-padding-y)) auto}.modal-title{margin-bottom:0;line-height:var(--bs-modal-title-line-height)}.modal-body{position:relative;flex:1 1 auto;-webkit-flex:1 1 auto;padding:var(--bs-modal-padding)}.modal-footer{display:flex;display:-webkit-flex;flex-shrink:0;-webkit-flex-shrink:0;flex-wrap:wrap;-webkit-flex-wrap:wrap;align-items:center;-webkit-align-items:center;justify-content:flex-end;-webkit-justify-content:flex-end;padding:calc(var(--bs-modal-padding) - var(--bs-modal-footer-gap) * .5);background-color:var(--bs-modal-footer-bg);border-top:var(--bs-modal-footer-border-width) solid var(--bs-modal-footer-border-color);border-bottom-right-radius:var(--bs-modal-inner-border-radius);border-bottom-left-radius:var(--bs-modal-inner-border-radius)}.modal-footer>*{margin:calc(var(--bs-modal-footer-gap) * .5)}@media (min-width: 576px){.modal{--bs-modal-margin: 1.75rem;--bs-modal-box-shadow: 0 1px 2px rgba(0,0,0,0.05)}.modal-dialog{max-width:var(--bs-modal-width);margin-right:auto;margin-left:auto}.modal-sm{--bs-modal-width: 300px}}@media (min-width: 992px){.modal-lg,.modal-xl{--bs-modal-width: 800px}}@media (min-width: 1200px){.modal-xl{--bs-modal-width: 1140px}}.modal-fullscreen{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen .modal-header,.modal-fullscreen .modal-footer{border-radius:0}.modal-fullscreen .modal-body{overflow-y:auto}@media (max-width: 575.98px){.modal-fullscreen-sm-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-sm-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-sm-down .modal-header,.modal-fullscreen-sm-down .modal-footer{border-radius:0}.modal-fullscreen-sm-down .modal-body{overflow-y:auto}}@media (max-width: 767.98px){.modal-fullscreen-md-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-md-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-md-down .modal-header,.modal-fullscreen-md-down .modal-footer{border-radius:0}.modal-fullscreen-md-down .modal-body{overflow-y:auto}}@media (max-width: 991.98px){.modal-fullscreen-lg-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-lg-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-lg-down .modal-header,.modal-fullscreen-lg-down .modal-footer{border-radius:0}.modal-fullscreen-lg-down .modal-body{overflow-y:auto}}@media (max-width: 1199.98px){.modal-fullscreen-xl-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-xl-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-xl-down .modal-header,.modal-fullscreen-xl-down .modal-footer{border-radius:0}.modal-fullscreen-xl-down .modal-body{overflow-y:auto}}@media (max-width: 1399.98px){.modal-fullscreen-xxl-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-xxl-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-xxl-down .modal-header,.modal-fullscreen-xxl-down .modal-footer{border-radius:0}.modal-fullscreen-xxl-down .modal-body{overflow-y:auto}}.tooltip{--bs-tooltip-zindex: 1080;--bs-tooltip-max-width: 200px;--bs-tooltip-padding-x: .5rem;--bs-tooltip-padding-y: .25rem;--bs-tooltip-margin: ;--bs-tooltip-font-size:.875rem;--bs-tooltip-color: var(--bs-body-bg);--bs-tooltip-bg: var(--bs-emphasis-color);--bs-tooltip-border-radius: var(--bs-border-radius);--bs-tooltip-opacity: .9;--bs-tooltip-arrow-width: .8rem;--bs-tooltip-arrow-height: .4rem;z-index:var(--bs-tooltip-zindex);display:block;margin:var(--bs-tooltip-margin);font-family:var(--bs-font-sans-serif);font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;white-space:normal;word-spacing:normal;line-break:auto;font-size:var(--bs-tooltip-font-size);word-wrap:break-word;opacity:0}.tooltip.show{opacity:var(--bs-tooltip-opacity)}.tooltip .tooltip-arrow{display:block;width:var(--bs-tooltip-arrow-width);height:var(--bs-tooltip-arrow-height)}.tooltip .tooltip-arrow::before{position:absolute;content:"";border-color:transparent;border-style:solid}.bs-tooltip-top .tooltip-arrow,.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow{bottom:calc(-1 * var(--bs-tooltip-arrow-height))}.bs-tooltip-top .tooltip-arrow::before,.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::before{top:-1px;border-width:var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-top-color:var(--bs-tooltip-bg)}.bs-tooltip-end .tooltip-arrow,.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow{left:calc(-1 * var(--bs-tooltip-arrow-height));width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}.bs-tooltip-end .tooltip-arrow::before,.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before{right:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-right-color:var(--bs-tooltip-bg)}.bs-tooltip-bottom .tooltip-arrow,.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow{top:calc(-1 * var(--bs-tooltip-arrow-height))}.bs-tooltip-bottom .tooltip-arrow::before,.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::before{bottom:-1px;border-width:0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-bottom-color:var(--bs-tooltip-bg)}.bs-tooltip-start .tooltip-arrow,.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow{right:calc(-1 * var(--bs-tooltip-arrow-height));width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}.bs-tooltip-start .tooltip-arrow::before,.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::before{left:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) 0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-left-color:var(--bs-tooltip-bg)}.tooltip-inner{max-width:var(--bs-tooltip-max-width);padding:var(--bs-tooltip-padding-y) var(--bs-tooltip-padding-x);color:var(--bs-tooltip-color);text-align:center;background-color:var(--bs-tooltip-bg);border-radius:var(--bs-tooltip-border-radius)}.popover{--bs-popover-zindex: 1070;--bs-popover-max-width: 276px;--bs-popover-font-size:.875rem;--bs-popover-bg: var(--bs-body-bg);--bs-popover-border-width: var(--bs-border-width);--bs-popover-border-color: var(--bs-border-color-translucent);--bs-popover-border-radius: var(--bs-border-radius-lg);--bs-popover-inner-border-radius: calc(var(--bs-border-radius-lg) - var(--bs-border-width));--bs-popover-box-shadow: 0 1px 2px rgba(0,0,0,0.05);--bs-popover-header-padding-x: 1rem;--bs-popover-header-padding-y: .5rem;--bs-popover-header-font-size:1rem;--bs-popover-header-color: #212529;--bs-popover-header-bg: var(--bs-secondary-bg);--bs-popover-body-padding-x: 1rem;--bs-popover-body-padding-y: 1rem;--bs-popover-body-color: var(--bs-body-color);--bs-popover-arrow-width: 1rem;--bs-popover-arrow-height: .5rem;--bs-popover-arrow-border: var(--bs-popover-border-color);z-index:var(--bs-popover-zindex);display:block;max-width:var(--bs-popover-max-width);font-family:var(--bs-font-sans-serif);font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;white-space:normal;word-spacing:normal;line-break:auto;font-size:var(--bs-popover-font-size);word-wrap:break-word;background-color:var(--bs-popover-bg);background-clip:padding-box;border:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-radius:var(--bs-popover-border-radius);box-shadow:var(--bs-popover-box-shadow)}.popover .popover-arrow{display:block;width:var(--bs-popover-arrow-width);height:var(--bs-popover-arrow-height)}.popover .popover-arrow::before,.popover .popover-arrow::after{position:absolute;display:block;content:"";border-color:transparent;border-style:solid;border-width:0}.bs-popover-top>.popover-arrow,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow{bottom:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}.bs-popover-top>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow::before,.bs-popover-top>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow::after{border-width:var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}.bs-popover-top>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow::before{bottom:0;border-top-color:var(--bs-popover-arrow-border)}.bs-popover-top>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="top"]>.popover-arrow::after{bottom:var(--bs-popover-border-width);border-top-color:var(--bs-popover-bg)}.bs-popover-end>.popover-arrow,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow{left:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}.bs-popover-end>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow::before,.bs-popover-end>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow::after{border-width:calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}.bs-popover-end>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow::before{left:0;border-right-color:var(--bs-popover-arrow-border)}.bs-popover-end>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="right"]>.popover-arrow::after{left:var(--bs-popover-border-width);border-right-color:var(--bs-popover-bg)}.bs-popover-bottom>.popover-arrow,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow{top:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}.bs-popover-bottom>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow::before,.bs-popover-bottom>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow::after{border-width:0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}.bs-popover-bottom>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow::before{top:0;border-bottom-color:var(--bs-popover-arrow-border)}.bs-popover-bottom>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="bottom"]>.popover-arrow::after{top:var(--bs-popover-border-width);border-bottom-color:var(--bs-popover-bg)}.bs-popover-bottom .popover-header::before,.bs-popover-auto[data-popper-placement^="bottom"] .popover-header::before{position:absolute;top:0;left:50%;display:block;width:var(--bs-popover-arrow-width);margin-left:calc(-.5 * var(--bs-popover-arrow-width));content:"";border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-header-bg)}.bs-popover-start>.popover-arrow,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow{right:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}.bs-popover-start>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow::before,.bs-popover-start>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow::after{border-width:calc(var(--bs-popover-arrow-width) * .5) 0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}.bs-popover-start>.popover-arrow::before,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow::before{right:0;border-left-color:var(--bs-popover-arrow-border)}.bs-popover-start>.popover-arrow::after,.bs-popover-auto[data-popper-placement^="left"]>.popover-arrow::after{right:var(--bs-popover-border-width);border-left-color:var(--bs-popover-bg)}.popover-header{padding:var(--bs-popover-header-padding-y) var(--bs-popover-header-padding-x);margin-bottom:0;font-size:var(--bs-popover-header-font-size);color:var(--bs-popover-header-color);background-color:var(--bs-popover-header-bg);border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-top-left-radius:var(--bs-popover-inner-border-radius);border-top-right-radius:var(--bs-popover-inner-border-radius)}.popover-header:empty{display:none}.popover-body{padding:var(--bs-popover-body-padding-y) var(--bs-popover-body-padding-x);color:var(--bs-popover-body-color)}.carousel{position:relative}.carousel.pointer-event{touch-action:pan-y;-webkit-touch-action:pan-y;-moz-touch-action:pan-y;-ms-touch-action:pan-y;-o-touch-action:pan-y}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner::after{display:block;clear:both;content:""}.carousel-item{position:relative;display:none;float:left;width:100%;margin-right:-100%;backface-visibility:hidden;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-ms-backface-visibility:hidden;-o-backface-visibility:hidden;transition:transform .6s ease-in-out}@media (prefers-reduced-motion: reduce){.carousel-item{transition:none}}.carousel-item.active,.carousel-item-next,.carousel-item-prev{display:block}.carousel-item-next:not(.carousel-item-start),.active.carousel-item-end{transform:translateX(100%)}.carousel-item-prev:not(.carousel-item-end),.active.carousel-item-start{transform:translateX(-100%)}.carousel-fade .carousel-item{opacity:0;transition-property:opacity;transform:none}.carousel-fade .carousel-item.active,.carousel-fade .carousel-item-next.carousel-item-start,.carousel-fade .carousel-item-prev.carousel-item-end{z-index:1;opacity:1}.carousel-fade .active.carousel-item-start,.carousel-fade .active.carousel-item-end{z-index:0;opacity:0;transition:opacity 0s .6s}@media (prefers-reduced-motion: reduce){.carousel-fade .active.carousel-item-start,.carousel-fade .active.carousel-item-end{transition:none}}.carousel-control-prev,.carousel-control-next{position:absolute;top:0;bottom:0;z-index:1;display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;justify-content:center;-webkit-justify-content:center;width:15%;padding:0;color:#fff;text-align:center;background:none;border:0;opacity:.5;transition:opacity 0.15s ease}@media (prefers-reduced-motion: reduce){.carousel-control-prev,.carousel-control-next{transition:none}}.carousel-control-prev:hover,.carousel-control-prev:focus,.carousel-control-next:hover,.carousel-control-next:focus{color:#fff;text-decoration:none;outline:0;opacity:.9}.carousel-control-prev{left:0}.carousel-control-next{right:0}.carousel-control-prev-icon,.carousel-control-next-icon{display:inline-block;width:2rem;height:2rem;background-repeat:no-repeat;background-position:50%;background-size:100% 100%}.carousel-control-prev-icon{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e")}.carousel-control-next-icon{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e")}.carousel-indicators{position:absolute;right:0;bottom:0;left:0;z-index:2;display:flex;display:-webkit-flex;justify-content:center;-webkit-justify-content:center;padding:0;margin-right:15%;margin-bottom:1rem;margin-left:15%}.carousel-indicators [data-bs-target]{box-sizing:content-box;flex:0 1 auto;-webkit-flex:0 1 auto;width:30px;height:3px;padding:0;margin-right:3px;margin-left:3px;text-indent:-999px;cursor:pointer;background-color:#fff;background-clip:padding-box;border:0;border-top:10px solid transparent;border-bottom:10px solid transparent;opacity:.5;transition:opacity 0.6s ease}@media (prefers-reduced-motion: reduce){.carousel-indicators [data-bs-target]{transition:none}}.carousel-indicators .active{opacity:1}.carousel-caption{position:absolute;right:15%;bottom:1.25rem;left:15%;padding-top:1.25rem;padding-bottom:1.25rem;color:#fff;text-align:center}.carousel-dark .carousel-control-prev-icon,.carousel-dark .carousel-control-next-icon{filter:invert(1) grayscale(100)}.carousel-dark .carousel-indicators [data-bs-target]{background-color:#000}.carousel-dark .carousel-caption{color:#000}[data-bs-theme="dark"] .carousel .carousel-control-prev-icon,[data-bs-theme="dark"] .carousel .carousel-control-next-icon,[data-bs-theme="dark"].carousel .carousel-control-prev-icon,[data-bs-theme="dark"].carousel .carousel-control-next-icon{filter:invert(1) grayscale(100)}[data-bs-theme="dark"] .carousel .carousel-indicators [data-bs-target],[data-bs-theme="dark"].carousel .carousel-indicators [data-bs-target]{background-color:#000}[data-bs-theme="dark"] .carousel .carousel-caption,[data-bs-theme="dark"].carousel .carousel-caption{color:#000}.spinner-grow,.spinner-border{display:inline-block;width:var(--bs-spinner-width);height:var(--bs-spinner-height);vertical-align:var(--bs-spinner-vertical-align);border-radius:50%;animation:var(--bs-spinner-animation-speed) linear infinite var(--bs-spinner-animation-name)}@keyframes spinner-border{to{transform:rotate(360deg) /* rtl:ignore */}}.spinner-border{--bs-spinner-width: 2rem;--bs-spinner-height: 2rem;--bs-spinner-vertical-align: -.125em;--bs-spinner-border-width: .25em;--bs-spinner-animation-speed: .75s;--bs-spinner-animation-name: spinner-border;border:var(--bs-spinner-border-width) solid currentcolor;border-right-color:transparent}.spinner-border-sm{--bs-spinner-width: 1rem;--bs-spinner-height: 1rem;--bs-spinner-border-width: .2em}@keyframes spinner-grow{0%{transform:scale(0)}50%{opacity:1;transform:none}}.spinner-grow{--bs-spinner-width: 2rem;--bs-spinner-height: 2rem;--bs-spinner-vertical-align: -.125em;--bs-spinner-animation-speed: .75s;--bs-spinner-animation-name: spinner-grow;background-color:currentcolor;opacity:0}.spinner-grow-sm{--bs-spinner-width: 1rem;--bs-spinner-height: 1rem}@media (prefers-reduced-motion: reduce){.spinner-border,.spinner-grow{--bs-spinner-animation-speed: 1.5s}}.offcanvas,.offcanvas-xxl,.offcanvas-xl,.offcanvas-lg,.offcanvas-md,.offcanvas-sm{--bs-offcanvas-zindex: 1045;--bs-offcanvas-width: 400px;--bs-offcanvas-height: 30vh;--bs-offcanvas-padding-x: 1rem;--bs-offcanvas-padding-y: 1rem;--bs-offcanvas-color: var(--bs-body-color);--bs-offcanvas-bg: var(--bs-body-bg);--bs-offcanvas-border-width: var(--bs-border-width);--bs-offcanvas-border-color: #dee2e6;--bs-offcanvas-box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);--bs-offcanvas-transition: transform .3s ease-in-out;--bs-offcanvas-title-line-height: 1.5}@media (max-width: 575.98px){.offcanvas-sm{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 575.98px) and (prefers-reduced-motion: reduce){.offcanvas-sm{transition:none}}@media (max-width: 575.98px){.offcanvas-sm.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-sm.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-sm.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-sm.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-sm.showing,.offcanvas-sm.show:not(.hiding){transform:none}.offcanvas-sm.showing,.offcanvas-sm.hiding,.offcanvas-sm.show{visibility:visible}}@media (min-width: 576px){.offcanvas-sm{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-sm .offcanvas-header{display:none}.offcanvas-sm .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}@media (max-width: 767.98px){.offcanvas-md{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 767.98px) and (prefers-reduced-motion: reduce){.offcanvas-md{transition:none}}@media (max-width: 767.98px){.offcanvas-md.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-md.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-md.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-md.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-md.showing,.offcanvas-md.show:not(.hiding){transform:none}.offcanvas-md.showing,.offcanvas-md.hiding,.offcanvas-md.show{visibility:visible}}@media (min-width: 768px){.offcanvas-md{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-md .offcanvas-header{display:none}.offcanvas-md .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}@media (max-width: 991.98px){.offcanvas-lg{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 991.98px) and (prefers-reduced-motion: reduce){.offcanvas-lg{transition:none}}@media (max-width: 991.98px){.offcanvas-lg.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-lg.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-lg.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-lg.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-lg.showing,.offcanvas-lg.show:not(.hiding){transform:none}.offcanvas-lg.showing,.offcanvas-lg.hiding,.offcanvas-lg.show{visibility:visible}}@media (min-width: 992px){.offcanvas-lg{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-lg .offcanvas-header{display:none}.offcanvas-lg .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}@media (max-width: 1199.98px){.offcanvas-xl{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 1199.98px) and (prefers-reduced-motion: reduce){.offcanvas-xl{transition:none}}@media (max-width: 1199.98px){.offcanvas-xl.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-xl.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-xl.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-xl.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-xl.showing,.offcanvas-xl.show:not(.hiding){transform:none}.offcanvas-xl.showing,.offcanvas-xl.hiding,.offcanvas-xl.show{visibility:visible}}@media (min-width: 1200px){.offcanvas-xl{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-xl .offcanvas-header{display:none}.offcanvas-xl .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}@media (max-width: 1399.98px){.offcanvas-xxl{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}}@media (max-width: 1399.98px) and (prefers-reduced-motion: reduce){.offcanvas-xxl{transition:none}}@media (max-width: 1399.98px){.offcanvas-xxl.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas-xxl.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas-xxl.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas-xxl.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas-xxl.showing,.offcanvas-xxl.show:not(.hiding){transform:none}.offcanvas-xxl.showing,.offcanvas-xxl.hiding,.offcanvas-xxl.show{visibility:visible}}@media (min-width: 1400px){.offcanvas-xxl{--bs-offcanvas-height: auto;--bs-offcanvas-border-width: 0;background-color:transparent !important}.offcanvas-xxl .offcanvas-header{display:none}.offcanvas-xxl .offcanvas-body{display:flex;display:-webkit-flex;flex-grow:0;-webkit-flex-grow:0;padding:0;overflow-y:visible;background-color:transparent !important}}.offcanvas{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;display:-webkit-flex;flex-direction:column;-webkit-flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;box-shadow:var(--bs-offcanvas-box-shadow);transition:var(--bs-offcanvas-transition)}@media (prefers-reduced-motion: reduce){.offcanvas{transition:none}}.offcanvas.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas.showing,.offcanvas.show:not(.hiding){transform:none}.offcanvas.showing,.offcanvas.hiding,.offcanvas.show{visibility:visible}.offcanvas-backdrop{position:fixed;top:0;left:0;z-index:1040;width:100vw;height:100vh;background-color:#000}.offcanvas-backdrop.fade{opacity:0}.offcanvas-backdrop.show{opacity:.5}.offcanvas-header{display:flex;display:-webkit-flex;align-items:center;-webkit-align-items:center;justify-content:space-between;-webkit-justify-content:space-between;padding:var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x)}.offcanvas-header .btn-close{padding:calc(var(--bs-offcanvas-padding-y) * .5) calc(var(--bs-offcanvas-padding-x) * .5);margin-top:calc(-.5 * var(--bs-offcanvas-padding-y));margin-right:calc(-.5 * var(--bs-offcanvas-padding-x));margin-bottom:calc(-.5 * var(--bs-offcanvas-padding-y))}.offcanvas-title{margin-bottom:0;line-height:var(--bs-offcanvas-title-line-height)}.offcanvas-body{flex-grow:1;-webkit-flex-grow:1;padding:var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);overflow-y:auto}.placeholder{display:inline-block;min-height:1em;vertical-align:middle;cursor:wait;background-color:currentcolor;opacity:.5}.placeholder.btn::before{display:inline-block;content:""}.placeholder-xs{min-height:.6em}.placeholder-sm{min-height:.8em}.placeholder-lg{min-height:1.2em}.placeholder-glow .placeholder{animation:placeholder-glow 2s ease-in-out infinite}@keyframes placeholder-glow{50%{opacity:.2}}.placeholder-wave{mask-image:linear-gradient(130deg, #000 55%, rgba(0,0,0,0.8) 75%, #000 95%);-webkit-mask-image:linear-gradient(130deg, #000 55%, rgba(0,0,0,0.8) 75%, #000 95%);mask-size:200% 100%;-webkit-mask-size:200% 100%;animation:placeholder-wave 2s linear infinite}@keyframes placeholder-wave{100%{mask-position:-200% 0%;-webkit-mask-position:-200% 0%}}.clearfix::after{display:block;clear:both;content:""}.text-bg-default{color:#000 !important;background-color:RGBA(var(--bs-default-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-primary{color:#fff !important;background-color:RGBA(var(--bs-primary-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-secondary{color:#000 !important;background-color:RGBA(var(--bs-secondary-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-success{color:#fff !important;background-color:RGBA(var(--bs-success-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-info{color:#fff !important;background-color:RGBA(var(--bs-info-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-warning{color:#fff !important;background-color:RGBA(var(--bs-warning-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-danger{color:#fff !important;background-color:RGBA(var(--bs-danger-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-light{color:#000 !important;background-color:RGBA(var(--bs-light-rgb), var(--bs-bg-opacity, 1)) !important}.text-bg-dark{color:#fff !important;background-color:RGBA(var(--bs-dark-rgb), var(--bs-bg-opacity, 1)) !important}.link-default{color:RGBA(var(--bs-default-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-default-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-default:hover,.link-default:focus{color:RGBA(255,255,255, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(255,255,255, var(--bs-link-underline-opacity, 1)) !important}.link-primary{color:RGBA(var(--bs-primary-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-primary-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-primary:hover,.link-primary:focus{color:RGBA(42,71,184, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(42,71,184, var(--bs-link-underline-opacity, 1)) !important}.link-secondary{color:RGBA(var(--bs-secondary-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-secondary-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-secondary:hover,.link-secondary:focus{color:RGBA(255,255,255, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(255,255,255, var(--bs-link-underline-opacity, 1)) !important}.link-success{color:RGBA(var(--bs-success-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-success-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-success:hover,.link-success:focus{color:RGBA(38,143,102, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(38,143,102, var(--bs-link-underline-opacity, 1)) !important}.link-info{color:RGBA(var(--bs-info-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-info-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-info:hover,.link-info:focus{color:RGBA(32,98,145, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(32,98,145, var(--bs-link-underline-opacity, 1)) !important}.link-warning{color:RGBA(var(--bs-warning-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-warning-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-warning:hover,.link-warning:focus{color:RGBA(195,151,78, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(195,151,78, var(--bs-link-underline-opacity, 1)) !important}.link-danger{color:RGBA(var(--bs-danger-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-danger-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-danger:hover,.link-danger:focus{color:RGBA(174,33,37, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(174,33,37, var(--bs-link-underline-opacity, 1)) !important}.link-light{color:RGBA(var(--bs-light-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-light-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-light:hover,.link-light:focus{color:RGBA(249,250,251, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(249,250,251, var(--bs-link-underline-opacity, 1)) !important}.link-dark{color:RGBA(var(--bs-dark-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-dark-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-dark:hover,.link-dark:focus{color:RGBA(26,30,33, var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(26,30,33, var(--bs-link-underline-opacity, 1)) !important}.link-body-emphasis{color:RGBA(var(--bs-emphasis-color-rgb), var(--bs-link-opacity, 1)) !important;text-decoration-color:RGBA(var(--bs-emphasis-color-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-body-emphasis:hover,.link-body-emphasis:focus{color:RGBA(var(--bs-emphasis-color-rgb), var(--bs-link-opacity, 0.75)) !important;text-decoration-color:RGBA(var(--bs-emphasis-color-rgb), var(--bs-link-underline-opacity, 0.75)) !important}.focus-ring:focus{outline:0;box-shadow:var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}.icon-link{display:inline-flex;gap:.375rem;align-items:center;-webkit-align-items:center;text-decoration-color:rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 0.5));text-underline-offset:.25em;backface-visibility:hidden;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-ms-backface-visibility:hidden;-o-backface-visibility:hidden}.icon-link>.bi{flex-shrink:0;-webkit-flex-shrink:0;width:1em;height:1em;fill:currentcolor;transition:0.2s ease-in-out transform}@media (prefers-reduced-motion: reduce){.icon-link>.bi{transition:none}}.icon-link-hover:hover>.bi,.icon-link-hover:focus-visible>.bi{transform:var(--bs-icon-link-transform, translate3d(0.25em, 0, 0))}.ratio{position:relative;width:100%}.ratio::before{display:block;padding-top:var(--bs-aspect-ratio);content:""}.ratio>*{position:absolute;top:0;left:0;width:100%;height:100%}.ratio-1x1{--bs-aspect-ratio: 100%}.ratio-4x3{--bs-aspect-ratio: calc(3 / 4 * 100%)}.ratio-16x9{--bs-aspect-ratio: calc(9 / 16 * 100%)}.ratio-21x9{--bs-aspect-ratio: calc(9 / 21 * 100%)}.fixed-top{position:fixed;top:0;right:0;left:0;z-index:1030}.fixed-bottom{position:fixed;right:0;bottom:0;left:0;z-index:1030}.sticky-top{position:sticky;top:0;z-index:1020}.sticky-bottom{position:sticky;bottom:0;z-index:1020}@media (min-width: 576px){.sticky-sm-top{position:sticky;top:0;z-index:1020}.sticky-sm-bottom{position:sticky;bottom:0;z-index:1020}}@media (min-width: 768px){.sticky-md-top{position:sticky;top:0;z-index:1020}.sticky-md-bottom{position:sticky;bottom:0;z-index:1020}}@media (min-width: 992px){.sticky-lg-top{position:sticky;top:0;z-index:1020}.sticky-lg-bottom{position:sticky;bottom:0;z-index:1020}}@media (min-width: 1200px){.sticky-xl-top{position:sticky;top:0;z-index:1020}.sticky-xl-bottom{position:sticky;bottom:0;z-index:1020}}@media (min-width: 1400px){.sticky-xxl-top{position:sticky;top:0;z-index:1020}.sticky-xxl-bottom{position:sticky;bottom:0;z-index:1020}}.hstack{display:flex;display:-webkit-flex;flex-direction:row;-webkit-flex-direction:row;align-items:center;-webkit-align-items:center;align-self:stretch;-webkit-align-self:stretch}.vstack{display:flex;display:-webkit-flex;flex:1 1 auto;-webkit-flex:1 1 auto;flex-direction:column;-webkit-flex-direction:column;align-self:stretch;-webkit-align-self:stretch}.visually-hidden,.visually-hidden-focusable:not(:focus):not(:focus-within){width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.visually-hidden:not(caption),.visually-hidden-focusable:not(:focus):not(:focus-within):not(caption){position:absolute !important}.stretched-link::after{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;content:""}.text-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vr{display:inline-block;align-self:stretch;-webkit-align-self:stretch;width:var(--bs-border-width);min-height:1em;background-color:currentcolor;opacity:.25}.align-baseline{vertical-align:baseline !important}.align-top{vertical-align:top !important}.align-middle{vertical-align:middle !important}.align-bottom{vertical-align:bottom !important}.align-text-bottom{vertical-align:text-bottom !important}.align-text-top{vertical-align:text-top !important}.float-start{float:left !important}.float-end{float:right !important}.float-none{float:none !important}.object-fit-contain{object-fit:contain !important}.object-fit-cover{object-fit:cover !important}.object-fit-fill{object-fit:fill !important}.object-fit-scale{object-fit:scale-down !important}.object-fit-none{object-fit:none !important}.opacity-0{opacity:0 !important}.opacity-25{opacity:.25 !important}.opacity-50{opacity:.5 !important}.opacity-75{opacity:.75 !important}.opacity-100{opacity:1 !important}.overflow-auto{overflow:auto !important}.overflow-hidden{overflow:hidden !important}.overflow-visible{overflow:visible !important}.overflow-scroll{overflow:scroll !important}.overflow-x-auto{overflow-x:auto !important}.overflow-x-hidden{overflow-x:hidden !important}.overflow-x-visible{overflow-x:visible !important}.overflow-x-scroll{overflow-x:scroll !important}.overflow-y-auto{overflow-y:auto !important}.overflow-y-hidden{overflow-y:hidden !important}.overflow-y-visible{overflow-y:visible !important}.overflow-y-scroll{overflow-y:scroll !important}.d-inline{display:inline !important}.d-inline-block{display:inline-block !important}.d-block{display:block !important}.d-grid{display:grid !important}.d-inline-grid{display:inline-grid !important}.d-table{display:table !important}.d-table-row{display:table-row !important}.d-table-cell{display:table-cell !important}.d-flex{display:flex !important}.d-inline-flex{display:inline-flex !important}.d-none{display:none !important}.shadow{box-shadow:0 1px 2px rgba(0,0,0,0.05) !important}.shadow-sm{box-shadow:0 0.125rem 0.25rem rgba(0,0,0,0.075) !important}.shadow-lg{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06) !important}.shadow-none{box-shadow:none !important}.focus-ring-default{--bs-focus-ring-color: rgba(var(--bs-default-rgb), var(--bs-focus-ring-opacity))}.focus-ring-primary{--bs-focus-ring-color: rgba(var(--bs-primary-rgb), var(--bs-focus-ring-opacity))}.focus-ring-secondary{--bs-focus-ring-color: rgba(var(--bs-secondary-rgb), var(--bs-focus-ring-opacity))}.focus-ring-success{--bs-focus-ring-color: rgba(var(--bs-success-rgb), var(--bs-focus-ring-opacity))}.focus-ring-info{--bs-focus-ring-color: rgba(var(--bs-info-rgb), var(--bs-focus-ring-opacity))}.focus-ring-warning{--bs-focus-ring-color: rgba(var(--bs-warning-rgb), var(--bs-focus-ring-opacity))}.focus-ring-danger{--bs-focus-ring-color: rgba(var(--bs-danger-rgb), var(--bs-focus-ring-opacity))}.focus-ring-light{--bs-focus-ring-color: rgba(var(--bs-light-rgb), var(--bs-focus-ring-opacity))}.focus-ring-dark{--bs-focus-ring-color: rgba(var(--bs-dark-rgb), var(--bs-focus-ring-opacity))}.position-static{position:static !important}.position-relative{position:relative !important}.position-absolute{position:absolute !important}.position-fixed{position:fixed !important}.position-sticky{position:sticky !important}.top-0{top:0 !important}.top-50{top:50% !important}.top-100{top:100% !important}.bottom-0{bottom:0 !important}.bottom-50{bottom:50% !important}.bottom-100{bottom:100% !important}.start-0{left:0 !important}.start-50{left:50% !important}.start-100{left:100% !important}.end-0{right:0 !important}.end-50{right:50% !important}.end-100{right:100% !important}.translate-middle{transform:translate(-50%, -50%) !important}.translate-middle-x{transform:translateX(-50%) !important}.translate-middle-y{transform:translateY(-50%) !important}.border{border:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-0{border:0 !important}.border-top{border-top:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-top-0{border-top:0 !important}.border-end{border-right:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-end-0{border-right:0 !important}.border-bottom{border-bottom:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-bottom-0{border-bottom:0 !important}.border-start{border-left:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important}.border-start-0{border-left:0 !important}.border-default{--bs-border-opacity: 1;border-color:rgba(var(--bs-default-rgb), var(--bs-border-opacity)) !important}.border-primary{--bs-border-opacity: 1;border-color:rgba(var(--bs-primary-rgb), var(--bs-border-opacity)) !important}.border-secondary{--bs-border-opacity: 1;border-color:rgba(var(--bs-secondary-rgb), var(--bs-border-opacity)) !important}.border-success{--bs-border-opacity: 1;border-color:rgba(var(--bs-success-rgb), var(--bs-border-opacity)) !important}.border-info{--bs-border-opacity: 1;border-color:rgba(var(--bs-info-rgb), var(--bs-border-opacity)) !important}.border-warning{--bs-border-opacity: 1;border-color:rgba(var(--bs-warning-rgb), var(--bs-border-opacity)) !important}.border-danger{--bs-border-opacity: 1;border-color:rgba(var(--bs-danger-rgb), var(--bs-border-opacity)) !important}.border-light{--bs-border-opacity: 1;border-color:rgba(var(--bs-light-rgb), var(--bs-border-opacity)) !important}.border-dark{--bs-border-opacity: 1;border-color:rgba(var(--bs-dark-rgb), var(--bs-border-opacity)) !important}.border-black{--bs-border-opacity: 1;border-color:rgba(var(--bs-black-rgb), var(--bs-border-opacity)) !important}.border-white{--bs-border-opacity: 1;border-color:rgba(var(--bs-white-rgb), var(--bs-border-opacity)) !important}.border-primary-subtle{border-color:var(--bs-primary-border-subtle) !important}.border-secondary-subtle{border-color:var(--bs-secondary-border-subtle) !important}.border-success-subtle{border-color:var(--bs-success-border-subtle) !important}.border-info-subtle{border-color:var(--bs-info-border-subtle) !important}.border-warning-subtle{border-color:var(--bs-warning-border-subtle) !important}.border-danger-subtle{border-color:var(--bs-danger-border-subtle) !important}.border-light-subtle{border-color:var(--bs-light-border-subtle) !important}.border-dark-subtle{border-color:var(--bs-dark-border-subtle) !important}.border-1{border-width:1px !important}.border-2{border-width:2px !important}.border-3{border-width:3px !important}.border-4{border-width:4px !important}.border-5{border-width:5px !important}.border-opacity-10{--bs-border-opacity: .1}.border-opacity-25{--bs-border-opacity: .25}.border-opacity-50{--bs-border-opacity: .5}.border-opacity-75{--bs-border-opacity: .75}.border-opacity-100{--bs-border-opacity: 1}.w-25{width:25% !important}.w-50{width:50% !important}.w-75{width:75% !important}.w-100{width:100% !important}.w-auto{width:auto !important}.mw-100{max-width:100% !important}.vw-100{width:100vw !important}.min-vw-100{min-width:100vw !important}.h-25{height:25% !important}.h-50{height:50% !important}.h-75{height:75% !important}.h-100{height:100% !important}.h-auto{height:auto !important}.mh-100{max-height:100% !important}.vh-100{height:100vh !important}.min-vh-100{min-height:100vh !important}.flex-fill{flex:1 1 auto !important}.flex-row{flex-direction:row !important}.flex-column{flex-direction:column !important}.flex-row-reverse{flex-direction:row-reverse !important}.flex-column-reverse{flex-direction:column-reverse !important}.flex-grow-0{flex-grow:0 !important}.flex-grow-1{flex-grow:1 !important}.flex-shrink-0{flex-shrink:0 !important}.flex-shrink-1{flex-shrink:1 !important}.flex-wrap{flex-wrap:wrap !important}.flex-nowrap{flex-wrap:nowrap !important}.flex-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-start{justify-content:flex-start !important}.justify-content-end{justify-content:flex-end !important}.justify-content-center{justify-content:center !important}.justify-content-between{justify-content:space-between !important}.justify-content-around{justify-content:space-around !important}.justify-content-evenly{justify-content:space-evenly !important}.align-items-start{align-items:flex-start !important}.align-items-end{align-items:flex-end !important}.align-items-center{align-items:center !important}.align-items-baseline{align-items:baseline !important}.align-items-stretch{align-items:stretch !important}.align-content-start{align-content:flex-start !important}.align-content-end{align-content:flex-end !important}.align-content-center{align-content:center !important}.align-content-between{align-content:space-between !important}.align-content-around{align-content:space-around !important}.align-content-stretch{align-content:stretch !important}.align-self-auto{align-self:auto !important}.align-self-start{align-self:flex-start !important}.align-self-end{align-self:flex-end !important}.align-self-center{align-self:center !important}.align-self-baseline{align-self:baseline !important}.align-self-stretch{align-self:stretch !important}.order-first{order:-1 !important}.order-0{order:0 !important}.order-1{order:1 !important}.order-2{order:2 !important}.order-3{order:3 !important}.order-4{order:4 !important}.order-5{order:5 !important}.order-last{order:6 !important}.m-0{margin:0 !important}.m-1{margin:.25rem !important}.m-2{margin:.5rem !important}.m-3{margin:1rem !important}.m-4{margin:1.5rem !important}.m-5{margin:3rem !important}.m-auto{margin:auto !important}.mx-0{margin-right:0 !important;margin-left:0 !important}.mx-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-3{margin-right:1rem !important;margin-left:1rem !important}.mx-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-5{margin-right:3rem !important;margin-left:3rem !important}.mx-auto{margin-right:auto !important;margin-left:auto !important}.my-0{margin-top:0 !important;margin-bottom:0 !important}.my-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-0{margin-top:0 !important}.mt-1{margin-top:.25rem !important}.mt-2{margin-top:.5rem !important}.mt-3{margin-top:1rem !important}.mt-4{margin-top:1.5rem !important}.mt-5{margin-top:3rem !important}.mt-auto{margin-top:auto !important}.me-0{margin-right:0 !important}.me-1{margin-right:.25rem !important}.me-2{margin-right:.5rem !important}.me-3{margin-right:1rem !important}.me-4{margin-right:1.5rem !important}.me-5{margin-right:3rem !important}.me-auto{margin-right:auto !important}.mb-0{margin-bottom:0 !important}.mb-1{margin-bottom:.25rem !important}.mb-2{margin-bottom:.5rem !important}.mb-3{margin-bottom:1rem !important}.mb-4{margin-bottom:1.5rem !important}.mb-5{margin-bottom:3rem !important}.mb-auto{margin-bottom:auto !important}.ms-0{margin-left:0 !important}.ms-1{margin-left:.25rem !important}.ms-2{margin-left:.5rem !important}.ms-3{margin-left:1rem !important}.ms-4{margin-left:1.5rem !important}.ms-5{margin-left:3rem !important}.ms-auto{margin-left:auto !important}.p-0{padding:0 !important}.p-1{padding:.25rem !important}.p-2{padding:.5rem !important}.p-3{padding:1rem !important}.p-4{padding:1.5rem !important}.p-5{padding:3rem !important}.px-0{padding-right:0 !important;padding-left:0 !important}.px-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-3{padding-right:1rem !important;padding-left:1rem !important}.px-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-5{padding-right:3rem !important;padding-left:3rem !important}.py-0{padding-top:0 !important;padding-bottom:0 !important}.py-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-0{padding-top:0 !important}.pt-1{padding-top:.25rem !important}.pt-2{padding-top:.5rem !important}.pt-3{padding-top:1rem !important}.pt-4{padding-top:1.5rem !important}.pt-5{padding-top:3rem !important}.pe-0{padding-right:0 !important}.pe-1{padding-right:.25rem !important}.pe-2{padding-right:.5rem !important}.pe-3{padding-right:1rem !important}.pe-4{padding-right:1.5rem !important}.pe-5{padding-right:3rem !important}.pb-0{padding-bottom:0 !important}.pb-1{padding-bottom:.25rem !important}.pb-2{padding-bottom:.5rem !important}.pb-3{padding-bottom:1rem !important}.pb-4{padding-bottom:1.5rem !important}.pb-5{padding-bottom:3rem !important}.ps-0{padding-left:0 !important}.ps-1{padding-left:.25rem !important}.ps-2{padding-left:.5rem !important}.ps-3{padding-left:1rem !important}.ps-4{padding-left:1.5rem !important}.ps-5{padding-left:3rem !important}.gap-0{gap:0 !important}.gap-1{gap:.25rem !important}.gap-2{gap:.5rem !important}.gap-3{gap:1rem !important}.gap-4{gap:1.5rem !important}.gap-5{gap:3rem !important}.row-gap-0{row-gap:0 !important}.row-gap-1{row-gap:.25rem !important}.row-gap-2{row-gap:.5rem !important}.row-gap-3{row-gap:1rem !important}.row-gap-4{row-gap:1.5rem !important}.row-gap-5{row-gap:3rem !important}.column-gap-0{column-gap:0 !important}.column-gap-1{column-gap:.25rem !important}.column-gap-2{column-gap:.5rem !important}.column-gap-3{column-gap:1rem !important}.column-gap-4{column-gap:1.5rem !important}.column-gap-5{column-gap:3rem !important}.font-monospace{font-family:var(--bs-font-monospace) !important}.fs-1{font-size:calc(1.375rem + 1.5vw) !important}.fs-2{font-size:calc(1.325rem + .9vw) !important}.fs-3{font-size:calc(1.3rem + .6vw) !important}.fs-4{font-size:calc(1.275rem + .3vw) !important}.fs-5{font-size:1.25rem !important}.fs-6{font-size:1rem !important}.fst-italic{font-style:italic !important}.fst-normal{font-style:normal !important}.fw-lighter{font-weight:lighter !important}.fw-light{font-weight:300 !important}.fw-normal{font-weight:400 !important}.fw-medium{font-weight:500 !important}.fw-semibold{font-weight:600 !important}.fw-bold{font-weight:700 !important}.fw-bolder{font-weight:bolder !important}.lh-1{line-height:1 !important}.lh-sm{line-height:1.25 !important}.lh-base{line-height:1.5 !important}.lh-lg{line-height:2 !important}.text-start{text-align:left !important}.text-end{text-align:right !important}.text-center{text-align:center !important}.text-decoration-none{text-decoration:none !important}.text-decoration-underline{text-decoration:underline !important}.text-decoration-line-through{text-decoration:line-through !important}.text-lowercase{text-transform:lowercase !important}.text-uppercase{text-transform:uppercase !important}.text-capitalize{text-transform:capitalize !important}.text-wrap{white-space:normal !important}.text-nowrap{white-space:nowrap !important}.text-break{word-wrap:break-word !important;word-break:break-word !important}.text-default{--bs-text-opacity: 1;color:rgba(var(--bs-default-rgb), var(--bs-text-opacity)) !important}.text-primary{--bs-text-opacity: 1;color:rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important}.text-secondary{--bs-text-opacity: 1;color:rgba(var(--bs-secondary-rgb), var(--bs-text-opacity)) !important}.text-success{--bs-text-opacity: 1;color:rgba(var(--bs-success-rgb), var(--bs-text-opacity)) !important}.text-info{--bs-text-opacity: 1;color:rgba(var(--bs-info-rgb), var(--bs-text-opacity)) !important}.text-warning{--bs-text-opacity: 1;color:rgba(var(--bs-warning-rgb), var(--bs-text-opacity)) !important}.text-danger{--bs-text-opacity: 1;color:rgba(var(--bs-danger-rgb), var(--bs-text-opacity)) !important}.text-light{--bs-text-opacity: 1;color:rgba(var(--bs-light-rgb), var(--bs-text-opacity)) !important}.text-dark{--bs-text-opacity: 1;color:rgba(var(--bs-dark-rgb), var(--bs-text-opacity)) !important}.text-black{--bs-text-opacity: 1;color:rgba(var(--bs-black-rgb), var(--bs-text-opacity)) !important}.text-white{--bs-text-opacity: 1;color:rgba(var(--bs-white-rgb), var(--bs-text-opacity)) !important}.text-body{--bs-text-opacity: 1;color:rgba(var(--bs-body-color-rgb), var(--bs-text-opacity)) !important}.text-muted{--bs-text-opacity: 1;color:var(--bs-secondary-color) !important}.text-black-50{--bs-text-opacity: 1;color:rgba(0,0,0,0.5) !important}.text-white-50{--bs-text-opacity: 1;color:rgba(255,255,255,0.5) !important}.text-body-secondary{--bs-text-opacity: 1;color:var(--bs-secondary-color) !important}.text-body-tertiary{--bs-text-opacity: 1;color:var(--bs-tertiary-color) !important}.text-body-emphasis{--bs-text-opacity: 1;color:var(--bs-emphasis-color) !important}.text-reset{--bs-text-opacity: 1;color:inherit !important}.text-opacity-25{--bs-text-opacity: .25}.text-opacity-50{--bs-text-opacity: .5}.text-opacity-75{--bs-text-opacity: .75}.text-opacity-100{--bs-text-opacity: 1}.text-primary-emphasis{color:var(--bs-primary-text-emphasis) !important}.text-secondary-emphasis{color:var(--bs-secondary-text-emphasis) !important}.text-success-emphasis{color:var(--bs-success-text-emphasis) !important}.text-info-emphasis{color:var(--bs-info-text-emphasis) !important}.text-warning-emphasis{color:var(--bs-warning-text-emphasis) !important}.text-danger-emphasis{color:var(--bs-danger-text-emphasis) !important}.text-light-emphasis{color:var(--bs-light-text-emphasis) !important}.text-dark-emphasis{color:var(--bs-dark-text-emphasis) !important}.link-opacity-10{--bs-link-opacity: .1}.link-opacity-10-hover:hover{--bs-link-opacity: .1}.link-opacity-25{--bs-link-opacity: .25}.link-opacity-25-hover:hover{--bs-link-opacity: .25}.link-opacity-50{--bs-link-opacity: .5}.link-opacity-50-hover:hover{--bs-link-opacity: .5}.link-opacity-75{--bs-link-opacity: .75}.link-opacity-75-hover:hover{--bs-link-opacity: .75}.link-opacity-100{--bs-link-opacity: 1}.link-opacity-100-hover:hover{--bs-link-opacity: 1}.link-offset-1{text-underline-offset:.125em !important}.link-offset-1-hover:hover{text-underline-offset:.125em !important}.link-offset-2{text-underline-offset:.25em !important}.link-offset-2-hover:hover{text-underline-offset:.25em !important}.link-offset-3{text-underline-offset:.375em !important}.link-offset-3-hover:hover{text-underline-offset:.375em !important}.link-underline-default{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-default-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-primary{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-primary-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-secondary{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-secondary-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-success{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-success-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-info{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-info-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-warning{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-warning-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-danger{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-danger-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-light{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-light-rgb), var(--bs-link-underline-opacity)) !important}.link-underline-dark{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-dark-rgb), var(--bs-link-underline-opacity)) !important}.link-underline{--bs-link-underline-opacity: 1;text-decoration-color:rgba(var(--bs-link-color-rgb), var(--bs-link-underline-opacity, 1)) !important}.link-underline-opacity-0{--bs-link-underline-opacity: 0}.link-underline-opacity-0-hover:hover{--bs-link-underline-opacity: 0}.link-underline-opacity-10{--bs-link-underline-opacity: .1}.link-underline-opacity-10-hover:hover{--bs-link-underline-opacity: .1}.link-underline-opacity-25{--bs-link-underline-opacity: .25}.link-underline-opacity-25-hover:hover{--bs-link-underline-opacity: .25}.link-underline-opacity-50{--bs-link-underline-opacity: .5}.link-underline-opacity-50-hover:hover{--bs-link-underline-opacity: .5}.link-underline-opacity-75{--bs-link-underline-opacity: .75}.link-underline-opacity-75-hover:hover{--bs-link-underline-opacity: .75}.link-underline-opacity-100{--bs-link-underline-opacity: 1}.link-underline-opacity-100-hover:hover{--bs-link-underline-opacity: 1}.bg-default{--bs-bg-opacity: 1;background-color:rgba(var(--bs-default-rgb), var(--bs-bg-opacity)) !important}.bg-primary{--bs-bg-opacity: 1;background-color:rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important}.bg-secondary{--bs-bg-opacity: 1;background-color:rgba(var(--bs-secondary-rgb), var(--bs-bg-opacity)) !important}.bg-success{--bs-bg-opacity: 1;background-color:rgba(var(--bs-success-rgb), var(--bs-bg-opacity)) !important}.bg-info{--bs-bg-opacity: 1;background-color:rgba(var(--bs-info-rgb), var(--bs-bg-opacity)) !important}.bg-warning{--bs-bg-opacity: 1;background-color:rgba(var(--bs-warning-rgb), var(--bs-bg-opacity)) !important}.bg-danger{--bs-bg-opacity: 1;background-color:rgba(var(--bs-danger-rgb), var(--bs-bg-opacity)) !important}.bg-light{--bs-bg-opacity: 1;background-color:rgba(var(--bs-light-rgb), var(--bs-bg-opacity)) !important}.bg-dark{--bs-bg-opacity: 1;background-color:rgba(var(--bs-dark-rgb), var(--bs-bg-opacity)) !important}.bg-black{--bs-bg-opacity: 1;background-color:rgba(var(--bs-black-rgb), var(--bs-bg-opacity)) !important}.bg-white{--bs-bg-opacity: 1;background-color:rgba(var(--bs-white-rgb), var(--bs-bg-opacity)) !important}.bg-body{--bs-bg-opacity: 1;background-color:rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important}.bg-transparent{--bs-bg-opacity: 1;background-color:rgba(0,0,0,0) !important}.bg-body-secondary{--bs-bg-opacity: 1;background-color:rgba(var(--bs-secondary-bg-rgb), var(--bs-bg-opacity)) !important}.bg-body-tertiary{--bs-bg-opacity: 1;background-color:rgba(var(--bs-tertiary-bg-rgb), var(--bs-bg-opacity)) !important}.bg-opacity-10{--bs-bg-opacity: .1}.bg-opacity-25{--bs-bg-opacity: .25}.bg-opacity-50{--bs-bg-opacity: .5}.bg-opacity-75{--bs-bg-opacity: .75}.bg-opacity-100{--bs-bg-opacity: 1}.bg-primary-subtle{background-color:var(--bs-primary-bg-subtle) !important}.bg-secondary-subtle{background-color:var(--bs-secondary-bg-subtle) !important}.bg-success-subtle{background-color:var(--bs-success-bg-subtle) !important}.bg-info-subtle{background-color:var(--bs-info-bg-subtle) !important}.bg-warning-subtle{background-color:var(--bs-warning-bg-subtle) !important}.bg-danger-subtle{background-color:var(--bs-danger-bg-subtle) !important}.bg-light-subtle{background-color:var(--bs-light-bg-subtle) !important}.bg-dark-subtle{background-color:var(--bs-dark-bg-subtle) !important}.bg-gradient{background-image:var(--bs-gradient) !important}.user-select-all{user-select:all !important}.user-select-auto{user-select:auto !important}.user-select-none{user-select:none !important}.pe-none{pointer-events:none !important}.pe-auto{pointer-events:auto !important}.rounded{border-radius:var(--bs-border-radius) !important}.rounded-0{border-radius:0 !important}.rounded-1{border-radius:var(--bs-border-radius-sm) !important}.rounded-2{border-radius:var(--bs-border-radius) !important}.rounded-3{border-radius:var(--bs-border-radius-lg) !important}.rounded-4{border-radius:var(--bs-border-radius-xl) !important}.rounded-5{border-radius:var(--bs-border-radius-xxl) !important}.rounded-circle{border-radius:50% !important}.rounded-pill{border-radius:var(--bs-border-radius-pill) !important}.rounded-top{border-top-left-radius:var(--bs-border-radius) !important;border-top-right-radius:var(--bs-border-radius) !important}.rounded-top-0{border-top-left-radius:0 !important;border-top-right-radius:0 !important}.rounded-top-1{border-top-left-radius:var(--bs-border-radius-sm) !important;border-top-right-radius:var(--bs-border-radius-sm) !important}.rounded-top-2{border-top-left-radius:var(--bs-border-radius) !important;border-top-right-radius:var(--bs-border-radius) !important}.rounded-top-3{border-top-left-radius:var(--bs-border-radius-lg) !important;border-top-right-radius:var(--bs-border-radius-lg) !important}.rounded-top-4{border-top-left-radius:var(--bs-border-radius-xl) !important;border-top-right-radius:var(--bs-border-radius-xl) !important}.rounded-top-5{border-top-left-radius:var(--bs-border-radius-xxl) !important;border-top-right-radius:var(--bs-border-radius-xxl) !important}.rounded-top-circle{border-top-left-radius:50% !important;border-top-right-radius:50% !important}.rounded-top-pill{border-top-left-radius:var(--bs-border-radius-pill) !important;border-top-right-radius:var(--bs-border-radius-pill) !important}.rounded-end{border-top-right-radius:var(--bs-border-radius) !important;border-bottom-right-radius:var(--bs-border-radius) !important}.rounded-end-0{border-top-right-radius:0 !important;border-bottom-right-radius:0 !important}.rounded-end-1{border-top-right-radius:var(--bs-border-radius-sm) !important;border-bottom-right-radius:var(--bs-border-radius-sm) !important}.rounded-end-2{border-top-right-radius:var(--bs-border-radius) !important;border-bottom-right-radius:var(--bs-border-radius) !important}.rounded-end-3{border-top-right-radius:var(--bs-border-radius-lg) !important;border-bottom-right-radius:var(--bs-border-radius-lg) !important}.rounded-end-4{border-top-right-radius:var(--bs-border-radius-xl) !important;border-bottom-right-radius:var(--bs-border-radius-xl) !important}.rounded-end-5{border-top-right-radius:var(--bs-border-radius-xxl) !important;border-bottom-right-radius:var(--bs-border-radius-xxl) !important}.rounded-end-circle{border-top-right-radius:50% !important;border-bottom-right-radius:50% !important}.rounded-end-pill{border-top-right-radius:var(--bs-border-radius-pill) !important;border-bottom-right-radius:var(--bs-border-radius-pill) !important}.rounded-bottom{border-bottom-right-radius:var(--bs-border-radius) !important;border-bottom-left-radius:var(--bs-border-radius) !important}.rounded-bottom-0{border-bottom-right-radius:0 !important;border-bottom-left-radius:0 !important}.rounded-bottom-1{border-bottom-right-radius:var(--bs-border-radius-sm) !important;border-bottom-left-radius:var(--bs-border-radius-sm) !important}.rounded-bottom-2{border-bottom-right-radius:var(--bs-border-radius) !important;border-bottom-left-radius:var(--bs-border-radius) !important}.rounded-bottom-3{border-bottom-right-radius:var(--bs-border-radius-lg) !important;border-bottom-left-radius:var(--bs-border-radius-lg) !important}.rounded-bottom-4{border-bottom-right-radius:var(--bs-border-radius-xl) !important;border-bottom-left-radius:var(--bs-border-radius-xl) !important}.rounded-bottom-5{border-bottom-right-radius:var(--bs-border-radius-xxl) !important;border-bottom-left-radius:var(--bs-border-radius-xxl) !important}.rounded-bottom-circle{border-bottom-right-radius:50% !important;border-bottom-left-radius:50% !important}.rounded-bottom-pill{border-bottom-right-radius:var(--bs-border-radius-pill) !important;border-bottom-left-radius:var(--bs-border-radius-pill) !important}.rounded-start{border-bottom-left-radius:var(--bs-border-radius) !important;border-top-left-radius:var(--bs-border-radius) !important}.rounded-start-0{border-bottom-left-radius:0 !important;border-top-left-radius:0 !important}.rounded-start-1{border-bottom-left-radius:var(--bs-border-radius-sm) !important;border-top-left-radius:var(--bs-border-radius-sm) !important}.rounded-start-2{border-bottom-left-radius:var(--bs-border-radius) !important;border-top-left-radius:var(--bs-border-radius) !important}.rounded-start-3{border-bottom-left-radius:var(--bs-border-radius-lg) !important;border-top-left-radius:var(--bs-border-radius-lg) !important}.rounded-start-4{border-bottom-left-radius:var(--bs-border-radius-xl) !important;border-top-left-radius:var(--bs-border-radius-xl) !important}.rounded-start-5{border-bottom-left-radius:var(--bs-border-radius-xxl) !important;border-top-left-radius:var(--bs-border-radius-xxl) !important}.rounded-start-circle{border-bottom-left-radius:50% !important;border-top-left-radius:50% !important}.rounded-start-pill{border-bottom-left-radius:var(--bs-border-radius-pill) !important;border-top-left-radius:var(--bs-border-radius-pill) !important}.visible{visibility:visible !important}.invisible{visibility:hidden !important}.z-n1{z-index:-1 !important}.z-0{z-index:0 !important}.z-1{z-index:1 !important}.z-2{z-index:2 !important}.z-3{z-index:3 !important}@media (min-width: 576px){.float-sm-start{float:left !important}.float-sm-end{float:right !important}.float-sm-none{float:none !important}.object-fit-sm-contain{object-fit:contain !important}.object-fit-sm-cover{object-fit:cover !important}.object-fit-sm-fill{object-fit:fill !important}.object-fit-sm-scale{object-fit:scale-down !important}.object-fit-sm-none{object-fit:none !important}.d-sm-inline{display:inline !important}.d-sm-inline-block{display:inline-block !important}.d-sm-block{display:block !important}.d-sm-grid{display:grid !important}.d-sm-inline-grid{display:inline-grid !important}.d-sm-table{display:table !important}.d-sm-table-row{display:table-row !important}.d-sm-table-cell{display:table-cell !important}.d-sm-flex{display:flex !important}.d-sm-inline-flex{display:inline-flex !important}.d-sm-none{display:none !important}.flex-sm-fill{flex:1 1 auto !important}.flex-sm-row{flex-direction:row !important}.flex-sm-column{flex-direction:column !important}.flex-sm-row-reverse{flex-direction:row-reverse !important}.flex-sm-column-reverse{flex-direction:column-reverse !important}.flex-sm-grow-0{flex-grow:0 !important}.flex-sm-grow-1{flex-grow:1 !important}.flex-sm-shrink-0{flex-shrink:0 !important}.flex-sm-shrink-1{flex-shrink:1 !important}.flex-sm-wrap{flex-wrap:wrap !important}.flex-sm-nowrap{flex-wrap:nowrap !important}.flex-sm-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-sm-start{justify-content:flex-start !important}.justify-content-sm-end{justify-content:flex-end !important}.justify-content-sm-center{justify-content:center !important}.justify-content-sm-between{justify-content:space-between !important}.justify-content-sm-around{justify-content:space-around !important}.justify-content-sm-evenly{justify-content:space-evenly !important}.align-items-sm-start{align-items:flex-start !important}.align-items-sm-end{align-items:flex-end !important}.align-items-sm-center{align-items:center !important}.align-items-sm-baseline{align-items:baseline !important}.align-items-sm-stretch{align-items:stretch !important}.align-content-sm-start{align-content:flex-start !important}.align-content-sm-end{align-content:flex-end !important}.align-content-sm-center{align-content:center !important}.align-content-sm-between{align-content:space-between !important}.align-content-sm-around{align-content:space-around !important}.align-content-sm-stretch{align-content:stretch !important}.align-self-sm-auto{align-self:auto !important}.align-self-sm-start{align-self:flex-start !important}.align-self-sm-end{align-self:flex-end !important}.align-self-sm-center{align-self:center !important}.align-self-sm-baseline{align-self:baseline !important}.align-self-sm-stretch{align-self:stretch !important}.order-sm-first{order:-1 !important}.order-sm-0{order:0 !important}.order-sm-1{order:1 !important}.order-sm-2{order:2 !important}.order-sm-3{order:3 !important}.order-sm-4{order:4 !important}.order-sm-5{order:5 !important}.order-sm-last{order:6 !important}.m-sm-0{margin:0 !important}.m-sm-1{margin:.25rem !important}.m-sm-2{margin:.5rem !important}.m-sm-3{margin:1rem !important}.m-sm-4{margin:1.5rem !important}.m-sm-5{margin:3rem !important}.m-sm-auto{margin:auto !important}.mx-sm-0{margin-right:0 !important;margin-left:0 !important}.mx-sm-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-sm-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-sm-3{margin-right:1rem !important;margin-left:1rem !important}.mx-sm-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-sm-5{margin-right:3rem !important;margin-left:3rem !important}.mx-sm-auto{margin-right:auto !important;margin-left:auto !important}.my-sm-0{margin-top:0 !important;margin-bottom:0 !important}.my-sm-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-sm-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-sm-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-sm-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-sm-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-sm-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-sm-0{margin-top:0 !important}.mt-sm-1{margin-top:.25rem !important}.mt-sm-2{margin-top:.5rem !important}.mt-sm-3{margin-top:1rem !important}.mt-sm-4{margin-top:1.5rem !important}.mt-sm-5{margin-top:3rem !important}.mt-sm-auto{margin-top:auto !important}.me-sm-0{margin-right:0 !important}.me-sm-1{margin-right:.25rem !important}.me-sm-2{margin-right:.5rem !important}.me-sm-3{margin-right:1rem !important}.me-sm-4{margin-right:1.5rem !important}.me-sm-5{margin-right:3rem !important}.me-sm-auto{margin-right:auto !important}.mb-sm-0{margin-bottom:0 !important}.mb-sm-1{margin-bottom:.25rem !important}.mb-sm-2{margin-bottom:.5rem !important}.mb-sm-3{margin-bottom:1rem !important}.mb-sm-4{margin-bottom:1.5rem !important}.mb-sm-5{margin-bottom:3rem !important}.mb-sm-auto{margin-bottom:auto !important}.ms-sm-0{margin-left:0 !important}.ms-sm-1{margin-left:.25rem !important}.ms-sm-2{margin-left:.5rem !important}.ms-sm-3{margin-left:1rem !important}.ms-sm-4{margin-left:1.5rem !important}.ms-sm-5{margin-left:3rem !important}.ms-sm-auto{margin-left:auto !important}.p-sm-0{padding:0 !important}.p-sm-1{padding:.25rem !important}.p-sm-2{padding:.5rem !important}.p-sm-3{padding:1rem !important}.p-sm-4{padding:1.5rem !important}.p-sm-5{padding:3rem !important}.px-sm-0{padding-right:0 !important;padding-left:0 !important}.px-sm-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-sm-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-sm-3{padding-right:1rem !important;padding-left:1rem !important}.px-sm-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-sm-5{padding-right:3rem !important;padding-left:3rem !important}.py-sm-0{padding-top:0 !important;padding-bottom:0 !important}.py-sm-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-sm-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-sm-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-sm-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-sm-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-sm-0{padding-top:0 !important}.pt-sm-1{padding-top:.25rem !important}.pt-sm-2{padding-top:.5rem !important}.pt-sm-3{padding-top:1rem !important}.pt-sm-4{padding-top:1.5rem !important}.pt-sm-5{padding-top:3rem !important}.pe-sm-0{padding-right:0 !important}.pe-sm-1{padding-right:.25rem !important}.pe-sm-2{padding-right:.5rem !important}.pe-sm-3{padding-right:1rem !important}.pe-sm-4{padding-right:1.5rem !important}.pe-sm-5{padding-right:3rem !important}.pb-sm-0{padding-bottom:0 !important}.pb-sm-1{padding-bottom:.25rem !important}.pb-sm-2{padding-bottom:.5rem !important}.pb-sm-3{padding-bottom:1rem !important}.pb-sm-4{padding-bottom:1.5rem !important}.pb-sm-5{padding-bottom:3rem !important}.ps-sm-0{padding-left:0 !important}.ps-sm-1{padding-left:.25rem !important}.ps-sm-2{padding-left:.5rem !important}.ps-sm-3{padding-left:1rem !important}.ps-sm-4{padding-left:1.5rem !important}.ps-sm-5{padding-left:3rem !important}.gap-sm-0{gap:0 !important}.gap-sm-1{gap:.25rem !important}.gap-sm-2{gap:.5rem !important}.gap-sm-3{gap:1rem !important}.gap-sm-4{gap:1.5rem !important}.gap-sm-5{gap:3rem !important}.row-gap-sm-0{row-gap:0 !important}.row-gap-sm-1{row-gap:.25rem !important}.row-gap-sm-2{row-gap:.5rem !important}.row-gap-sm-3{row-gap:1rem !important}.row-gap-sm-4{row-gap:1.5rem !important}.row-gap-sm-5{row-gap:3rem !important}.column-gap-sm-0{column-gap:0 !important}.column-gap-sm-1{column-gap:.25rem !important}.column-gap-sm-2{column-gap:.5rem !important}.column-gap-sm-3{column-gap:1rem !important}.column-gap-sm-4{column-gap:1.5rem !important}.column-gap-sm-5{column-gap:3rem !important}.text-sm-start{text-align:left !important}.text-sm-end{text-align:right !important}.text-sm-center{text-align:center !important}}@media (min-width: 768px){.float-md-start{float:left !important}.float-md-end{float:right !important}.float-md-none{float:none !important}.object-fit-md-contain{object-fit:contain !important}.object-fit-md-cover{object-fit:cover !important}.object-fit-md-fill{object-fit:fill !important}.object-fit-md-scale{object-fit:scale-down !important}.object-fit-md-none{object-fit:none !important}.d-md-inline{display:inline !important}.d-md-inline-block{display:inline-block !important}.d-md-block{display:block !important}.d-md-grid{display:grid !important}.d-md-inline-grid{display:inline-grid !important}.d-md-table{display:table !important}.d-md-table-row{display:table-row !important}.d-md-table-cell{display:table-cell !important}.d-md-flex{display:flex !important}.d-md-inline-flex{display:inline-flex !important}.d-md-none{display:none !important}.flex-md-fill{flex:1 1 auto !important}.flex-md-row{flex-direction:row !important}.flex-md-column{flex-direction:column !important}.flex-md-row-reverse{flex-direction:row-reverse !important}.flex-md-column-reverse{flex-direction:column-reverse !important}.flex-md-grow-0{flex-grow:0 !important}.flex-md-grow-1{flex-grow:1 !important}.flex-md-shrink-0{flex-shrink:0 !important}.flex-md-shrink-1{flex-shrink:1 !important}.flex-md-wrap{flex-wrap:wrap !important}.flex-md-nowrap{flex-wrap:nowrap !important}.flex-md-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-md-start{justify-content:flex-start !important}.justify-content-md-end{justify-content:flex-end !important}.justify-content-md-center{justify-content:center !important}.justify-content-md-between{justify-content:space-between !important}.justify-content-md-around{justify-content:space-around !important}.justify-content-md-evenly{justify-content:space-evenly !important}.align-items-md-start{align-items:flex-start !important}.align-items-md-end{align-items:flex-end !important}.align-items-md-center{align-items:center !important}.align-items-md-baseline{align-items:baseline !important}.align-items-md-stretch{align-items:stretch !important}.align-content-md-start{align-content:flex-start !important}.align-content-md-end{align-content:flex-end !important}.align-content-md-center{align-content:center !important}.align-content-md-between{align-content:space-between !important}.align-content-md-around{align-content:space-around !important}.align-content-md-stretch{align-content:stretch !important}.align-self-md-auto{align-self:auto !important}.align-self-md-start{align-self:flex-start !important}.align-self-md-end{align-self:flex-end !important}.align-self-md-center{align-self:center !important}.align-self-md-baseline{align-self:baseline !important}.align-self-md-stretch{align-self:stretch !important}.order-md-first{order:-1 !important}.order-md-0{order:0 !important}.order-md-1{order:1 !important}.order-md-2{order:2 !important}.order-md-3{order:3 !important}.order-md-4{order:4 !important}.order-md-5{order:5 !important}.order-md-last{order:6 !important}.m-md-0{margin:0 !important}.m-md-1{margin:.25rem !important}.m-md-2{margin:.5rem !important}.m-md-3{margin:1rem !important}.m-md-4{margin:1.5rem !important}.m-md-5{margin:3rem !important}.m-md-auto{margin:auto !important}.mx-md-0{margin-right:0 !important;margin-left:0 !important}.mx-md-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-md-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-md-3{margin-right:1rem !important;margin-left:1rem !important}.mx-md-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-md-5{margin-right:3rem !important;margin-left:3rem !important}.mx-md-auto{margin-right:auto !important;margin-left:auto !important}.my-md-0{margin-top:0 !important;margin-bottom:0 !important}.my-md-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-md-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-md-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-md-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-md-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-md-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-md-0{margin-top:0 !important}.mt-md-1{margin-top:.25rem !important}.mt-md-2{margin-top:.5rem !important}.mt-md-3{margin-top:1rem !important}.mt-md-4{margin-top:1.5rem !important}.mt-md-5{margin-top:3rem !important}.mt-md-auto{margin-top:auto !important}.me-md-0{margin-right:0 !important}.me-md-1{margin-right:.25rem !important}.me-md-2{margin-right:.5rem !important}.me-md-3{margin-right:1rem !important}.me-md-4{margin-right:1.5rem !important}.me-md-5{margin-right:3rem !important}.me-md-auto{margin-right:auto !important}.mb-md-0{margin-bottom:0 !important}.mb-md-1{margin-bottom:.25rem !important}.mb-md-2{margin-bottom:.5rem !important}.mb-md-3{margin-bottom:1rem !important}.mb-md-4{margin-bottom:1.5rem !important}.mb-md-5{margin-bottom:3rem !important}.mb-md-auto{margin-bottom:auto !important}.ms-md-0{margin-left:0 !important}.ms-md-1{margin-left:.25rem !important}.ms-md-2{margin-left:.5rem !important}.ms-md-3{margin-left:1rem !important}.ms-md-4{margin-left:1.5rem !important}.ms-md-5{margin-left:3rem !important}.ms-md-auto{margin-left:auto !important}.p-md-0{padding:0 !important}.p-md-1{padding:.25rem !important}.p-md-2{padding:.5rem !important}.p-md-3{padding:1rem !important}.p-md-4{padding:1.5rem !important}.p-md-5{padding:3rem !important}.px-md-0{padding-right:0 !important;padding-left:0 !important}.px-md-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-md-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-md-3{padding-right:1rem !important;padding-left:1rem !important}.px-md-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-md-5{padding-right:3rem !important;padding-left:3rem !important}.py-md-0{padding-top:0 !important;padding-bottom:0 !important}.py-md-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-md-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-md-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-md-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-md-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-md-0{padding-top:0 !important}.pt-md-1{padding-top:.25rem !important}.pt-md-2{padding-top:.5rem !important}.pt-md-3{padding-top:1rem !important}.pt-md-4{padding-top:1.5rem !important}.pt-md-5{padding-top:3rem !important}.pe-md-0{padding-right:0 !important}.pe-md-1{padding-right:.25rem !important}.pe-md-2{padding-right:.5rem !important}.pe-md-3{padding-right:1rem !important}.pe-md-4{padding-right:1.5rem !important}.pe-md-5{padding-right:3rem !important}.pb-md-0{padding-bottom:0 !important}.pb-md-1{padding-bottom:.25rem !important}.pb-md-2{padding-bottom:.5rem !important}.pb-md-3{padding-bottom:1rem !important}.pb-md-4{padding-bottom:1.5rem !important}.pb-md-5{padding-bottom:3rem !important}.ps-md-0{padding-left:0 !important}.ps-md-1{padding-left:.25rem !important}.ps-md-2{padding-left:.5rem !important}.ps-md-3{padding-left:1rem !important}.ps-md-4{padding-left:1.5rem !important}.ps-md-5{padding-left:3rem !important}.gap-md-0{gap:0 !important}.gap-md-1{gap:.25rem !important}.gap-md-2{gap:.5rem !important}.gap-md-3{gap:1rem !important}.gap-md-4{gap:1.5rem !important}.gap-md-5{gap:3rem !important}.row-gap-md-0{row-gap:0 !important}.row-gap-md-1{row-gap:.25rem !important}.row-gap-md-2{row-gap:.5rem !important}.row-gap-md-3{row-gap:1rem !important}.row-gap-md-4{row-gap:1.5rem !important}.row-gap-md-5{row-gap:3rem !important}.column-gap-md-0{column-gap:0 !important}.column-gap-md-1{column-gap:.25rem !important}.column-gap-md-2{column-gap:.5rem !important}.column-gap-md-3{column-gap:1rem !important}.column-gap-md-4{column-gap:1.5rem !important}.column-gap-md-5{column-gap:3rem !important}.text-md-start{text-align:left !important}.text-md-end{text-align:right !important}.text-md-center{text-align:center !important}}@media (min-width: 992px){.float-lg-start{float:left !important}.float-lg-end{float:right !important}.float-lg-none{float:none !important}.object-fit-lg-contain{object-fit:contain !important}.object-fit-lg-cover{object-fit:cover !important}.object-fit-lg-fill{object-fit:fill !important}.object-fit-lg-scale{object-fit:scale-down !important}.object-fit-lg-none{object-fit:none !important}.d-lg-inline{display:inline !important}.d-lg-inline-block{display:inline-block !important}.d-lg-block{display:block !important}.d-lg-grid{display:grid !important}.d-lg-inline-grid{display:inline-grid !important}.d-lg-table{display:table !important}.d-lg-table-row{display:table-row !important}.d-lg-table-cell{display:table-cell !important}.d-lg-flex{display:flex !important}.d-lg-inline-flex{display:inline-flex !important}.d-lg-none{display:none !important}.flex-lg-fill{flex:1 1 auto !important}.flex-lg-row{flex-direction:row !important}.flex-lg-column{flex-direction:column !important}.flex-lg-row-reverse{flex-direction:row-reverse !important}.flex-lg-column-reverse{flex-direction:column-reverse !important}.flex-lg-grow-0{flex-grow:0 !important}.flex-lg-grow-1{flex-grow:1 !important}.flex-lg-shrink-0{flex-shrink:0 !important}.flex-lg-shrink-1{flex-shrink:1 !important}.flex-lg-wrap{flex-wrap:wrap !important}.flex-lg-nowrap{flex-wrap:nowrap !important}.flex-lg-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-lg-start{justify-content:flex-start !important}.justify-content-lg-end{justify-content:flex-end !important}.justify-content-lg-center{justify-content:center !important}.justify-content-lg-between{justify-content:space-between !important}.justify-content-lg-around{justify-content:space-around !important}.justify-content-lg-evenly{justify-content:space-evenly !important}.align-items-lg-start{align-items:flex-start !important}.align-items-lg-end{align-items:flex-end !important}.align-items-lg-center{align-items:center !important}.align-items-lg-baseline{align-items:baseline !important}.align-items-lg-stretch{align-items:stretch !important}.align-content-lg-start{align-content:flex-start !important}.align-content-lg-end{align-content:flex-end !important}.align-content-lg-center{align-content:center !important}.align-content-lg-between{align-content:space-between !important}.align-content-lg-around{align-content:space-around !important}.align-content-lg-stretch{align-content:stretch !important}.align-self-lg-auto{align-self:auto !important}.align-self-lg-start{align-self:flex-start !important}.align-self-lg-end{align-self:flex-end !important}.align-self-lg-center{align-self:center !important}.align-self-lg-baseline{align-self:baseline !important}.align-self-lg-stretch{align-self:stretch !important}.order-lg-first{order:-1 !important}.order-lg-0{order:0 !important}.order-lg-1{order:1 !important}.order-lg-2{order:2 !important}.order-lg-3{order:3 !important}.order-lg-4{order:4 !important}.order-lg-5{order:5 !important}.order-lg-last{order:6 !important}.m-lg-0{margin:0 !important}.m-lg-1{margin:.25rem !important}.m-lg-2{margin:.5rem !important}.m-lg-3{margin:1rem !important}.m-lg-4{margin:1.5rem !important}.m-lg-5{margin:3rem !important}.m-lg-auto{margin:auto !important}.mx-lg-0{margin-right:0 !important;margin-left:0 !important}.mx-lg-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-lg-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-lg-3{margin-right:1rem !important;margin-left:1rem !important}.mx-lg-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-lg-5{margin-right:3rem !important;margin-left:3rem !important}.mx-lg-auto{margin-right:auto !important;margin-left:auto !important}.my-lg-0{margin-top:0 !important;margin-bottom:0 !important}.my-lg-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-lg-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-lg-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-lg-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-lg-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-lg-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-lg-0{margin-top:0 !important}.mt-lg-1{margin-top:.25rem !important}.mt-lg-2{margin-top:.5rem !important}.mt-lg-3{margin-top:1rem !important}.mt-lg-4{margin-top:1.5rem !important}.mt-lg-5{margin-top:3rem !important}.mt-lg-auto{margin-top:auto !important}.me-lg-0{margin-right:0 !important}.me-lg-1{margin-right:.25rem !important}.me-lg-2{margin-right:.5rem !important}.me-lg-3{margin-right:1rem !important}.me-lg-4{margin-right:1.5rem !important}.me-lg-5{margin-right:3rem !important}.me-lg-auto{margin-right:auto !important}.mb-lg-0{margin-bottom:0 !important}.mb-lg-1{margin-bottom:.25rem !important}.mb-lg-2{margin-bottom:.5rem !important}.mb-lg-3{margin-bottom:1rem !important}.mb-lg-4{margin-bottom:1.5rem !important}.mb-lg-5{margin-bottom:3rem !important}.mb-lg-auto{margin-bottom:auto !important}.ms-lg-0{margin-left:0 !important}.ms-lg-1{margin-left:.25rem !important}.ms-lg-2{margin-left:.5rem !important}.ms-lg-3{margin-left:1rem !important}.ms-lg-4{margin-left:1.5rem !important}.ms-lg-5{margin-left:3rem !important}.ms-lg-auto{margin-left:auto !important}.p-lg-0{padding:0 !important}.p-lg-1{padding:.25rem !important}.p-lg-2{padding:.5rem !important}.p-lg-3{padding:1rem !important}.p-lg-4{padding:1.5rem !important}.p-lg-5{padding:3rem !important}.px-lg-0{padding-right:0 !important;padding-left:0 !important}.px-lg-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-lg-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-lg-3{padding-right:1rem !important;padding-left:1rem !important}.px-lg-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-lg-5{padding-right:3rem !important;padding-left:3rem !important}.py-lg-0{padding-top:0 !important;padding-bottom:0 !important}.py-lg-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-lg-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-lg-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-lg-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-lg-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-lg-0{padding-top:0 !important}.pt-lg-1{padding-top:.25rem !important}.pt-lg-2{padding-top:.5rem !important}.pt-lg-3{padding-top:1rem !important}.pt-lg-4{padding-top:1.5rem !important}.pt-lg-5{padding-top:3rem !important}.pe-lg-0{padding-right:0 !important}.pe-lg-1{padding-right:.25rem !important}.pe-lg-2{padding-right:.5rem !important}.pe-lg-3{padding-right:1rem !important}.pe-lg-4{padding-right:1.5rem !important}.pe-lg-5{padding-right:3rem !important}.pb-lg-0{padding-bottom:0 !important}.pb-lg-1{padding-bottom:.25rem !important}.pb-lg-2{padding-bottom:.5rem !important}.pb-lg-3{padding-bottom:1rem !important}.pb-lg-4{padding-bottom:1.5rem !important}.pb-lg-5{padding-bottom:3rem !important}.ps-lg-0{padding-left:0 !important}.ps-lg-1{padding-left:.25rem !important}.ps-lg-2{padding-left:.5rem !important}.ps-lg-3{padding-left:1rem !important}.ps-lg-4{padding-left:1.5rem !important}.ps-lg-5{padding-left:3rem !important}.gap-lg-0{gap:0 !important}.gap-lg-1{gap:.25rem !important}.gap-lg-2{gap:.5rem !important}.gap-lg-3{gap:1rem !important}.gap-lg-4{gap:1.5rem !important}.gap-lg-5{gap:3rem !important}.row-gap-lg-0{row-gap:0 !important}.row-gap-lg-1{row-gap:.25rem !important}.row-gap-lg-2{row-gap:.5rem !important}.row-gap-lg-3{row-gap:1rem !important}.row-gap-lg-4{row-gap:1.5rem !important}.row-gap-lg-5{row-gap:3rem !important}.column-gap-lg-0{column-gap:0 !important}.column-gap-lg-1{column-gap:.25rem !important}.column-gap-lg-2{column-gap:.5rem !important}.column-gap-lg-3{column-gap:1rem !important}.column-gap-lg-4{column-gap:1.5rem !important}.column-gap-lg-5{column-gap:3rem !important}.text-lg-start{text-align:left !important}.text-lg-end{text-align:right !important}.text-lg-center{text-align:center !important}}@media (min-width: 1200px){.float-xl-start{float:left !important}.float-xl-end{float:right !important}.float-xl-none{float:none !important}.object-fit-xl-contain{object-fit:contain !important}.object-fit-xl-cover{object-fit:cover !important}.object-fit-xl-fill{object-fit:fill !important}.object-fit-xl-scale{object-fit:scale-down !important}.object-fit-xl-none{object-fit:none !important}.d-xl-inline{display:inline !important}.d-xl-inline-block{display:inline-block !important}.d-xl-block{display:block !important}.d-xl-grid{display:grid !important}.d-xl-inline-grid{display:inline-grid !important}.d-xl-table{display:table !important}.d-xl-table-row{display:table-row !important}.d-xl-table-cell{display:table-cell !important}.d-xl-flex{display:flex !important}.d-xl-inline-flex{display:inline-flex !important}.d-xl-none{display:none !important}.flex-xl-fill{flex:1 1 auto !important}.flex-xl-row{flex-direction:row !important}.flex-xl-column{flex-direction:column !important}.flex-xl-row-reverse{flex-direction:row-reverse !important}.flex-xl-column-reverse{flex-direction:column-reverse !important}.flex-xl-grow-0{flex-grow:0 !important}.flex-xl-grow-1{flex-grow:1 !important}.flex-xl-shrink-0{flex-shrink:0 !important}.flex-xl-shrink-1{flex-shrink:1 !important}.flex-xl-wrap{flex-wrap:wrap !important}.flex-xl-nowrap{flex-wrap:nowrap !important}.flex-xl-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-xl-start{justify-content:flex-start !important}.justify-content-xl-end{justify-content:flex-end !important}.justify-content-xl-center{justify-content:center !important}.justify-content-xl-between{justify-content:space-between !important}.justify-content-xl-around{justify-content:space-around !important}.justify-content-xl-evenly{justify-content:space-evenly !important}.align-items-xl-start{align-items:flex-start !important}.align-items-xl-end{align-items:flex-end !important}.align-items-xl-center{align-items:center !important}.align-items-xl-baseline{align-items:baseline !important}.align-items-xl-stretch{align-items:stretch !important}.align-content-xl-start{align-content:flex-start !important}.align-content-xl-end{align-content:flex-end !important}.align-content-xl-center{align-content:center !important}.align-content-xl-between{align-content:space-between !important}.align-content-xl-around{align-content:space-around !important}.align-content-xl-stretch{align-content:stretch !important}.align-self-xl-auto{align-self:auto !important}.align-self-xl-start{align-self:flex-start !important}.align-self-xl-end{align-self:flex-end !important}.align-self-xl-center{align-self:center !important}.align-self-xl-baseline{align-self:baseline !important}.align-self-xl-stretch{align-self:stretch !important}.order-xl-first{order:-1 !important}.order-xl-0{order:0 !important}.order-xl-1{order:1 !important}.order-xl-2{order:2 !important}.order-xl-3{order:3 !important}.order-xl-4{order:4 !important}.order-xl-5{order:5 !important}.order-xl-last{order:6 !important}.m-xl-0{margin:0 !important}.m-xl-1{margin:.25rem !important}.m-xl-2{margin:.5rem !important}.m-xl-3{margin:1rem !important}.m-xl-4{margin:1.5rem !important}.m-xl-5{margin:3rem !important}.m-xl-auto{margin:auto !important}.mx-xl-0{margin-right:0 !important;margin-left:0 !important}.mx-xl-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-xl-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-xl-3{margin-right:1rem !important;margin-left:1rem !important}.mx-xl-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-xl-5{margin-right:3rem !important;margin-left:3rem !important}.mx-xl-auto{margin-right:auto !important;margin-left:auto !important}.my-xl-0{margin-top:0 !important;margin-bottom:0 !important}.my-xl-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-xl-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-xl-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-xl-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-xl-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-xl-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-xl-0{margin-top:0 !important}.mt-xl-1{margin-top:.25rem !important}.mt-xl-2{margin-top:.5rem !important}.mt-xl-3{margin-top:1rem !important}.mt-xl-4{margin-top:1.5rem !important}.mt-xl-5{margin-top:3rem !important}.mt-xl-auto{margin-top:auto !important}.me-xl-0{margin-right:0 !important}.me-xl-1{margin-right:.25rem !important}.me-xl-2{margin-right:.5rem !important}.me-xl-3{margin-right:1rem !important}.me-xl-4{margin-right:1.5rem !important}.me-xl-5{margin-right:3rem !important}.me-xl-auto{margin-right:auto !important}.mb-xl-0{margin-bottom:0 !important}.mb-xl-1{margin-bottom:.25rem !important}.mb-xl-2{margin-bottom:.5rem !important}.mb-xl-3{margin-bottom:1rem !important}.mb-xl-4{margin-bottom:1.5rem !important}.mb-xl-5{margin-bottom:3rem !important}.mb-xl-auto{margin-bottom:auto !important}.ms-xl-0{margin-left:0 !important}.ms-xl-1{margin-left:.25rem !important}.ms-xl-2{margin-left:.5rem !important}.ms-xl-3{margin-left:1rem !important}.ms-xl-4{margin-left:1.5rem !important}.ms-xl-5{margin-left:3rem !important}.ms-xl-auto{margin-left:auto !important}.p-xl-0{padding:0 !important}.p-xl-1{padding:.25rem !important}.p-xl-2{padding:.5rem !important}.p-xl-3{padding:1rem !important}.p-xl-4{padding:1.5rem !important}.p-xl-5{padding:3rem !important}.px-xl-0{padding-right:0 !important;padding-left:0 !important}.px-xl-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-xl-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-xl-3{padding-right:1rem !important;padding-left:1rem !important}.px-xl-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-xl-5{padding-right:3rem !important;padding-left:3rem !important}.py-xl-0{padding-top:0 !important;padding-bottom:0 !important}.py-xl-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-xl-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-xl-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-xl-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-xl-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-xl-0{padding-top:0 !important}.pt-xl-1{padding-top:.25rem !important}.pt-xl-2{padding-top:.5rem !important}.pt-xl-3{padding-top:1rem !important}.pt-xl-4{padding-top:1.5rem !important}.pt-xl-5{padding-top:3rem !important}.pe-xl-0{padding-right:0 !important}.pe-xl-1{padding-right:.25rem !important}.pe-xl-2{padding-right:.5rem !important}.pe-xl-3{padding-right:1rem !important}.pe-xl-4{padding-right:1.5rem !important}.pe-xl-5{padding-right:3rem !important}.pb-xl-0{padding-bottom:0 !important}.pb-xl-1{padding-bottom:.25rem !important}.pb-xl-2{padding-bottom:.5rem !important}.pb-xl-3{padding-bottom:1rem !important}.pb-xl-4{padding-bottom:1.5rem !important}.pb-xl-5{padding-bottom:3rem !important}.ps-xl-0{padding-left:0 !important}.ps-xl-1{padding-left:.25rem !important}.ps-xl-2{padding-left:.5rem !important}.ps-xl-3{padding-left:1rem !important}.ps-xl-4{padding-left:1.5rem !important}.ps-xl-5{padding-left:3rem !important}.gap-xl-0{gap:0 !important}.gap-xl-1{gap:.25rem !important}.gap-xl-2{gap:.5rem !important}.gap-xl-3{gap:1rem !important}.gap-xl-4{gap:1.5rem !important}.gap-xl-5{gap:3rem !important}.row-gap-xl-0{row-gap:0 !important}.row-gap-xl-1{row-gap:.25rem !important}.row-gap-xl-2{row-gap:.5rem !important}.row-gap-xl-3{row-gap:1rem !important}.row-gap-xl-4{row-gap:1.5rem !important}.row-gap-xl-5{row-gap:3rem !important}.column-gap-xl-0{column-gap:0 !important}.column-gap-xl-1{column-gap:.25rem !important}.column-gap-xl-2{column-gap:.5rem !important}.column-gap-xl-3{column-gap:1rem !important}.column-gap-xl-4{column-gap:1.5rem !important}.column-gap-xl-5{column-gap:3rem !important}.text-xl-start{text-align:left !important}.text-xl-end{text-align:right !important}.text-xl-center{text-align:center !important}}@media (min-width: 1400px){.float-xxl-start{float:left !important}.float-xxl-end{float:right !important}.float-xxl-none{float:none !important}.object-fit-xxl-contain{object-fit:contain !important}.object-fit-xxl-cover{object-fit:cover !important}.object-fit-xxl-fill{object-fit:fill !important}.object-fit-xxl-scale{object-fit:scale-down !important}.object-fit-xxl-none{object-fit:none !important}.d-xxl-inline{display:inline !important}.d-xxl-inline-block{display:inline-block !important}.d-xxl-block{display:block !important}.d-xxl-grid{display:grid !important}.d-xxl-inline-grid{display:inline-grid !important}.d-xxl-table{display:table !important}.d-xxl-table-row{display:table-row !important}.d-xxl-table-cell{display:table-cell !important}.d-xxl-flex{display:flex !important}.d-xxl-inline-flex{display:inline-flex !important}.d-xxl-none{display:none !important}.flex-xxl-fill{flex:1 1 auto !important}.flex-xxl-row{flex-direction:row !important}.flex-xxl-column{flex-direction:column !important}.flex-xxl-row-reverse{flex-direction:row-reverse !important}.flex-xxl-column-reverse{flex-direction:column-reverse !important}.flex-xxl-grow-0{flex-grow:0 !important}.flex-xxl-grow-1{flex-grow:1 !important}.flex-xxl-shrink-0{flex-shrink:0 !important}.flex-xxl-shrink-1{flex-shrink:1 !important}.flex-xxl-wrap{flex-wrap:wrap !important}.flex-xxl-nowrap{flex-wrap:nowrap !important}.flex-xxl-wrap-reverse{flex-wrap:wrap-reverse !important}.justify-content-xxl-start{justify-content:flex-start !important}.justify-content-xxl-end{justify-content:flex-end !important}.justify-content-xxl-center{justify-content:center !important}.justify-content-xxl-between{justify-content:space-between !important}.justify-content-xxl-around{justify-content:space-around !important}.justify-content-xxl-evenly{justify-content:space-evenly !important}.align-items-xxl-start{align-items:flex-start !important}.align-items-xxl-end{align-items:flex-end !important}.align-items-xxl-center{align-items:center !important}.align-items-xxl-baseline{align-items:baseline !important}.align-items-xxl-stretch{align-items:stretch !important}.align-content-xxl-start{align-content:flex-start !important}.align-content-xxl-end{align-content:flex-end !important}.align-content-xxl-center{align-content:center !important}.align-content-xxl-between{align-content:space-between !important}.align-content-xxl-around{align-content:space-around !important}.align-content-xxl-stretch{align-content:stretch !important}.align-self-xxl-auto{align-self:auto !important}.align-self-xxl-start{align-self:flex-start !important}.align-self-xxl-end{align-self:flex-end !important}.align-self-xxl-center{align-self:center !important}.align-self-xxl-baseline{align-self:baseline !important}.align-self-xxl-stretch{align-self:stretch !important}.order-xxl-first{order:-1 !important}.order-xxl-0{order:0 !important}.order-xxl-1{order:1 !important}.order-xxl-2{order:2 !important}.order-xxl-3{order:3 !important}.order-xxl-4{order:4 !important}.order-xxl-5{order:5 !important}.order-xxl-last{order:6 !important}.m-xxl-0{margin:0 !important}.m-xxl-1{margin:.25rem !important}.m-xxl-2{margin:.5rem !important}.m-xxl-3{margin:1rem !important}.m-xxl-4{margin:1.5rem !important}.m-xxl-5{margin:3rem !important}.m-xxl-auto{margin:auto !important}.mx-xxl-0{margin-right:0 !important;margin-left:0 !important}.mx-xxl-1{margin-right:.25rem !important;margin-left:.25rem !important}.mx-xxl-2{margin-right:.5rem !important;margin-left:.5rem !important}.mx-xxl-3{margin-right:1rem !important;margin-left:1rem !important}.mx-xxl-4{margin-right:1.5rem !important;margin-left:1.5rem !important}.mx-xxl-5{margin-right:3rem !important;margin-left:3rem !important}.mx-xxl-auto{margin-right:auto !important;margin-left:auto !important}.my-xxl-0{margin-top:0 !important;margin-bottom:0 !important}.my-xxl-1{margin-top:.25rem !important;margin-bottom:.25rem !important}.my-xxl-2{margin-top:.5rem !important;margin-bottom:.5rem !important}.my-xxl-3{margin-top:1rem !important;margin-bottom:1rem !important}.my-xxl-4{margin-top:1.5rem !important;margin-bottom:1.5rem !important}.my-xxl-5{margin-top:3rem !important;margin-bottom:3rem !important}.my-xxl-auto{margin-top:auto !important;margin-bottom:auto !important}.mt-xxl-0{margin-top:0 !important}.mt-xxl-1{margin-top:.25rem !important}.mt-xxl-2{margin-top:.5rem !important}.mt-xxl-3{margin-top:1rem !important}.mt-xxl-4{margin-top:1.5rem !important}.mt-xxl-5{margin-top:3rem !important}.mt-xxl-auto{margin-top:auto !important}.me-xxl-0{margin-right:0 !important}.me-xxl-1{margin-right:.25rem !important}.me-xxl-2{margin-right:.5rem !important}.me-xxl-3{margin-right:1rem !important}.me-xxl-4{margin-right:1.5rem !important}.me-xxl-5{margin-right:3rem !important}.me-xxl-auto{margin-right:auto !important}.mb-xxl-0{margin-bottom:0 !important}.mb-xxl-1{margin-bottom:.25rem !important}.mb-xxl-2{margin-bottom:.5rem !important}.mb-xxl-3{margin-bottom:1rem !important}.mb-xxl-4{margin-bottom:1.5rem !important}.mb-xxl-5{margin-bottom:3rem !important}.mb-xxl-auto{margin-bottom:auto !important}.ms-xxl-0{margin-left:0 !important}.ms-xxl-1{margin-left:.25rem !important}.ms-xxl-2{margin-left:.5rem !important}.ms-xxl-3{margin-left:1rem !important}.ms-xxl-4{margin-left:1.5rem !important}.ms-xxl-5{margin-left:3rem !important}.ms-xxl-auto{margin-left:auto !important}.p-xxl-0{padding:0 !important}.p-xxl-1{padding:.25rem !important}.p-xxl-2{padding:.5rem !important}.p-xxl-3{padding:1rem !important}.p-xxl-4{padding:1.5rem !important}.p-xxl-5{padding:3rem !important}.px-xxl-0{padding-right:0 !important;padding-left:0 !important}.px-xxl-1{padding-right:.25rem !important;padding-left:.25rem !important}.px-xxl-2{padding-right:.5rem !important;padding-left:.5rem !important}.px-xxl-3{padding-right:1rem !important;padding-left:1rem !important}.px-xxl-4{padding-right:1.5rem !important;padding-left:1.5rem !important}.px-xxl-5{padding-right:3rem !important;padding-left:3rem !important}.py-xxl-0{padding-top:0 !important;padding-bottom:0 !important}.py-xxl-1{padding-top:.25rem !important;padding-bottom:.25rem !important}.py-xxl-2{padding-top:.5rem !important;padding-bottom:.5rem !important}.py-xxl-3{padding-top:1rem !important;padding-bottom:1rem !important}.py-xxl-4{padding-top:1.5rem !important;padding-bottom:1.5rem !important}.py-xxl-5{padding-top:3rem !important;padding-bottom:3rem !important}.pt-xxl-0{padding-top:0 !important}.pt-xxl-1{padding-top:.25rem !important}.pt-xxl-2{padding-top:.5rem !important}.pt-xxl-3{padding-top:1rem !important}.pt-xxl-4{padding-top:1.5rem !important}.pt-xxl-5{padding-top:3rem !important}.pe-xxl-0{padding-right:0 !important}.pe-xxl-1{padding-right:.25rem !important}.pe-xxl-2{padding-right:.5rem !important}.pe-xxl-3{padding-right:1rem !important}.pe-xxl-4{padding-right:1.5rem !important}.pe-xxl-5{padding-right:3rem !important}.pb-xxl-0{padding-bottom:0 !important}.pb-xxl-1{padding-bottom:.25rem !important}.pb-xxl-2{padding-bottom:.5rem !important}.pb-xxl-3{padding-bottom:1rem !important}.pb-xxl-4{padding-bottom:1.5rem !important}.pb-xxl-5{padding-bottom:3rem !important}.ps-xxl-0{padding-left:0 !important}.ps-xxl-1{padding-left:.25rem !important}.ps-xxl-2{padding-left:.5rem !important}.ps-xxl-3{padding-left:1rem !important}.ps-xxl-4{padding-left:1.5rem !important}.ps-xxl-5{padding-left:3rem !important}.gap-xxl-0{gap:0 !important}.gap-xxl-1{gap:.25rem !important}.gap-xxl-2{gap:.5rem !important}.gap-xxl-3{gap:1rem !important}.gap-xxl-4{gap:1.5rem !important}.gap-xxl-5{gap:3rem !important}.row-gap-xxl-0{row-gap:0 !important}.row-gap-xxl-1{row-gap:.25rem !important}.row-gap-xxl-2{row-gap:.5rem !important}.row-gap-xxl-3{row-gap:1rem !important}.row-gap-xxl-4{row-gap:1.5rem !important}.row-gap-xxl-5{row-gap:3rem !important}.column-gap-xxl-0{column-gap:0 !important}.column-gap-xxl-1{column-gap:.25rem !important}.column-gap-xxl-2{column-gap:.5rem !important}.column-gap-xxl-3{column-gap:1rem !important}.column-gap-xxl-4{column-gap:1.5rem !important}.column-gap-xxl-5{column-gap:3rem !important}.text-xxl-start{text-align:left !important}.text-xxl-end{text-align:right !important}.text-xxl-center{text-align:center !important}}.bg-default{color:#000}.bg-primary{color:#fff}.bg-secondary{color:#000}.bg-success{color:#fff}.bg-info{color:#fff}.bg-warning{color:#fff}.bg-danger{color:#fff}.bg-light{color:#000}.bg-dark{color:#fff}@media (min-width: 1200px){.fs-1{font-size:2.5rem !important}.fs-2{font-size:2rem !important}.fs-3{font-size:1.75rem !important}.fs-4{font-size:1.5rem !important}}@media print{.d-print-inline{display:inline !important}.d-print-inline-block{display:inline-block !important}.d-print-block{display:block !important}.d-print-grid{display:grid !important}.d-print-inline-grid{display:inline-grid !important}.d-print-table{display:table !important}.d-print-table-row{display:table-row !important}.d-print-table-cell{display:table-cell !important}.d-print-flex{display:flex !important}.d-print-inline-flex{display:inline-flex !important}.d-print-none{display:none !important}}.table th[align=left]{text-align:left}.table th[align=right]{text-align:right}.table th[align=center]{text-align:center}:root{--bslib-spacer: 1rem;--bslib-mb-spacer: var(--bslib-spacer, 1rem)}.bslib-mb-spacing{margin-bottom:var(--bslib-mb-spacer)}.bslib-gap-spacing{gap:var(--bslib-mb-spacer)}.bslib-gap-spacing>.bslib-mb-spacing,.bslib-gap-spacing>.form-group,.bslib-gap-spacing>p,.bslib-gap-spacing>pre,.bslib-gap-spacing>.shiny-html-output>.bslib-mb-spacing,.bslib-gap-spacing>.shiny-html-output>.form-group,.bslib-gap-spacing>.shiny-html-output>p,.bslib-gap-spacing>.shiny-html-output>pre,.bslib-gap-spacing>.shiny-panel-conditional>.bslib-mb-spacing,.bslib-gap-spacing>.shiny-panel-conditional>.form-group,.bslib-gap-spacing>.shiny-panel-conditional>p,.bslib-gap-spacing>.shiny-panel-conditional>pre{margin-bottom:0}.html-fill-container>.html-fill-item.bslib-mb-spacing{margin-bottom:0}.tab-content>.tab-pane.html-fill-container{display:none}.tab-content>.active.html-fill-container{display:flex}.tab-content.html-fill-container{padding:0}.bg-blue{--bslib-color-bg: #3459e6;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-blue{--bslib-color-fg: #3459e6;color:var(--bslib-color-fg)}.bg-indigo{--bslib-color-bg: #6610f2;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-indigo{--bslib-color-fg: #6610f2;color:var(--bslib-color-fg)}.bg-purple{--bslib-color-bg: #6f42c1;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-purple{--bslib-color-fg: #6f42c1;color:var(--bslib-color-fg)}.bg-pink{--bslib-color-bg: #d63384;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-pink{--bslib-color-fg: #d63384;color:var(--bslib-color-fg)}.bg-red{--bslib-color-bg: #da292e;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-red{--bslib-color-fg: #da292e;color:var(--bslib-color-fg)}.bg-orange{--bslib-color-bg: #f8765f;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-orange{--bslib-color-fg: #f8765f;color:var(--bslib-color-fg)}.bg-yellow{--bslib-color-bg: #f4bd61;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-yellow{--bslib-color-fg: #f4bd61;color:var(--bslib-color-fg)}.bg-green{--bslib-color-bg: #2fb380;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-green{--bslib-color-fg: #2fb380;color:var(--bslib-color-fg)}.bg-teal{--bslib-color-bg: #20c997;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-teal{--bslib-color-fg: #20c997;color:var(--bslib-color-fg)}.bg-cyan{--bslib-color-bg: #287bb5;--bslib-color-fg: #fff;background-color:var(--bslib-color-bg);color:var(--bslib-color-fg)}.text-cyan{--bslib-color-fg: #287bb5;color:var(--bslib-color-fg)}.text-default{--bslib-color-fg: #fff}.bg-default{--bslib-color-bg: #fff;--bslib-color-fg: #000}.text-primary{--bslib-color-fg: #3459e6}.bg-primary{--bslib-color-bg: #3459e6;--bslib-color-fg: #fff}.text-secondary{--bslib-color-fg: #fff}.bg-secondary{--bslib-color-bg: #fff;--bslib-color-fg: #000}.text-success{--bslib-color-fg: #2fb380}.bg-success{--bslib-color-bg: #2fb380;--bslib-color-fg: #fff}.text-info{--bslib-color-fg: #287bb5}.bg-info{--bslib-color-bg: #287bb5;--bslib-color-fg: #fff}.text-warning{--bslib-color-fg: #f4bd61}.bg-warning{--bslib-color-bg: #f4bd61;--bslib-color-fg: #fff}.text-danger{--bslib-color-fg: #da292e}.bg-danger{--bslib-color-bg: #da292e;--bslib-color-fg: #fff}.text-light{--bslib-color-fg: #f8f9fa}.bg-light{--bslib-color-bg: #f8f9fa;--bslib-color-fg: #000}.text-dark{--bslib-color-fg: #212529}.bg-dark{--bslib-color-bg: #212529;--bslib-color-fg: #fff}.bg-gradient-blue-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #483ceb;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #483ceb;color:#fff}.bg-gradient-blue-purple{--bslib-color-fg: #fff;--bslib-color-bg: #4c50d7;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #4c50d7;color:#fff}.bg-gradient-blue-pink{--bslib-color-fg: #fff;--bslib-color-bg: #754abf;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #754abf;color:#fff}.bg-gradient-blue-red{--bslib-color-fg: #fff;--bslib-color-bg: #76469c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #76469c;color:#fff}.bg-gradient-blue-orange{--bslib-color-fg: #fff;--bslib-color-bg: #8265b0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #8265b0;color:#fff}.bg-gradient-blue-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #8181b1;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #8181b1;color:#fff}.bg-gradient-blue-green{--bslib-color-fg: #fff;--bslib-color-bg: #327dbd;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #327dbd;color:#fff}.bg-gradient-blue-teal{--bslib-color-fg: #fff;--bslib-color-bg: #2c86c6;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #2c86c6;color:#fff}.bg-gradient-blue-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #2f67d2;background:linear-gradient(var(--bg-gradient-deg, 140deg), #3459e6 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #2f67d2;color:#fff}.bg-gradient-indigo-blue{--bslib-color-fg: #fff;--bslib-color-bg: #522ded;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #522ded;color:#fff}.bg-gradient-indigo-purple{--bslib-color-fg: #fff;--bslib-color-bg: #6a24de;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #6a24de;color:#fff}.bg-gradient-indigo-pink{--bslib-color-fg: #fff;--bslib-color-bg: #931ec6;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #931ec6;color:#fff}.bg-gradient-indigo-red{--bslib-color-fg: #fff;--bslib-color-bg: #941aa4;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #941aa4;color:#fff}.bg-gradient-indigo-orange{--bslib-color-fg: #fff;--bslib-color-bg: #a039b7;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #a039b7;color:#fff}.bg-gradient-indigo-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #9f55b8;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #9f55b8;color:#fff}.bg-gradient-indigo-green{--bslib-color-fg: #fff;--bslib-color-bg: #5051c4;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #5051c4;color:#fff}.bg-gradient-indigo-teal{--bslib-color-fg: #fff;--bslib-color-bg: #4a5ace;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #4a5ace;color:#fff}.bg-gradient-indigo-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #4d3bda;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6610f2 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #4d3bda;color:#fff}.bg-gradient-purple-blue{--bslib-color-fg: #fff;--bslib-color-bg: #574bd0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #574bd0;color:#fff}.bg-gradient-purple-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #6b2ed5;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #6b2ed5;color:#fff}.bg-gradient-purple-pink{--bslib-color-fg: #fff;--bslib-color-bg: #983ca9;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #983ca9;color:#fff}.bg-gradient-purple-red{--bslib-color-fg: #fff;--bslib-color-bg: #9a3886;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #9a3886;color:#fff}.bg-gradient-purple-orange{--bslib-color-fg: #fff;--bslib-color-bg: #a6579a;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #a6579a;color:#fff}.bg-gradient-purple-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #a4739b;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #a4739b;color:#fff}.bg-gradient-purple-green{--bslib-color-fg: #fff;--bslib-color-bg: #556fa7;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #556fa7;color:#fff}.bg-gradient-purple-teal{--bslib-color-fg: #fff;--bslib-color-bg: #4f78b0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #4f78b0;color:#fff}.bg-gradient-purple-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #5359bc;background:linear-gradient(var(--bg-gradient-deg, 140deg), #6f42c1 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #5359bc;color:#fff}.bg-gradient-pink-blue{--bslib-color-fg: #fff;--bslib-color-bg: #9542ab;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #9542ab;color:#fff}.bg-gradient-pink-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #a925b0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #a925b0;color:#fff}.bg-gradient-pink-purple{--bslib-color-fg: #fff;--bslib-color-bg: #ad399c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #ad399c;color:#fff}.bg-gradient-pink-red{--bslib-color-fg: #fff;--bslib-color-bg: #d82f62;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #d82f62;color:#fff}.bg-gradient-pink-orange{--bslib-color-fg: #fff;--bslib-color-bg: #e44e75;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #e44e75;color:#fff}.bg-gradient-pink-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #e26a76;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #e26a76;color:#fff}.bg-gradient-pink-green{--bslib-color-fg: #fff;--bslib-color-bg: #936682;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #936682;color:#fff}.bg-gradient-pink-teal{--bslib-color-fg: #fff;--bslib-color-bg: #8d6f8c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #8d6f8c;color:#fff}.bg-gradient-pink-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #905098;background:linear-gradient(var(--bg-gradient-deg, 140deg), #d63384 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #905098;color:#fff}.bg-gradient-red-blue{--bslib-color-fg: #fff;--bslib-color-bg: #983c78;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #983c78;color:#fff}.bg-gradient-red-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #ac1f7c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #ac1f7c;color:#fff}.bg-gradient-red-purple{--bslib-color-fg: #fff;--bslib-color-bg: #af3369;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #af3369;color:#fff}.bg-gradient-red-pink{--bslib-color-fg: #fff;--bslib-color-bg: #d82d50;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #d82d50;color:#fff}.bg-gradient-red-orange{--bslib-color-fg: #fff;--bslib-color-bg: #e64842;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #e64842;color:#fff}.bg-gradient-red-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #e46442;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #e46442;color:#fff}.bg-gradient-red-green{--bslib-color-fg: #fff;--bslib-color-bg: #96604f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #96604f;color:#fff}.bg-gradient-red-teal{--bslib-color-fg: #fff;--bslib-color-bg: #906958;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #906958;color:#fff}.bg-gradient-red-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #934a64;background:linear-gradient(var(--bg-gradient-deg, 140deg), #da292e var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #934a64;color:#fff}.bg-gradient-orange-blue{--bslib-color-fg: #fff;--bslib-color-bg: #aa6a95;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #aa6a95;color:#fff}.bg-gradient-orange-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #be4d9a;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #be4d9a;color:#fff}.bg-gradient-orange-purple{--bslib-color-fg: #fff;--bslib-color-bg: #c16186;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #c16186;color:#fff}.bg-gradient-orange-pink{--bslib-color-fg: #fff;--bslib-color-bg: #ea5b6e;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #ea5b6e;color:#fff}.bg-gradient-orange-red{--bslib-color-fg: #fff;--bslib-color-bg: #ec574b;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #ec574b;color:#fff}.bg-gradient-orange-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #f69260;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #f69260;color:#fff}.bg-gradient-orange-green{--bslib-color-fg: #fff;--bslib-color-bg: #a88e6c;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #a88e6c;color:#fff}.bg-gradient-orange-teal{--bslib-color-fg: #fff;--bslib-color-bg: #a29775;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #a29775;color:#fff}.bg-gradient-orange-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #a57881;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f8765f var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #a57881;color:#fff}.bg-gradient-yellow-blue{--bslib-color-fg: #fff;--bslib-color-bg: #a79596;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #a79596;color:#fff}.bg-gradient-yellow-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #bb789b;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #bb789b;color:#fff}.bg-gradient-yellow-purple{--bslib-color-fg: #fff;--bslib-color-bg: #bf8c87;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #bf8c87;color:#fff}.bg-gradient-yellow-pink{--bslib-color-fg: #fff;--bslib-color-bg: #e8866f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #e8866f;color:#fff}.bg-gradient-yellow-red{--bslib-color-fg: #fff;--bslib-color-bg: #ea824d;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #ea824d;color:#fff}.bg-gradient-yellow-orange{--bslib-color-fg: #fff;--bslib-color-bg: #f6a160;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #f6a160;color:#fff}.bg-gradient-yellow-green{--bslib-color-fg: #fff;--bslib-color-bg: #a5b96d;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #a5b96d;color:#fff}.bg-gradient-yellow-teal{--bslib-color-fg: #fff;--bslib-color-bg: #9fc277;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #9fc277;color:#fff}.bg-gradient-yellow-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #a2a383;background:linear-gradient(var(--bg-gradient-deg, 140deg), #f4bd61 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #a2a383;color:#fff}.bg-gradient-green-blue{--bslib-color-fg: #fff;--bslib-color-bg: #318fa9;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #318fa9;color:#fff}.bg-gradient-green-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #4572ae;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #4572ae;color:#fff}.bg-gradient-green-purple{--bslib-color-fg: #fff;--bslib-color-bg: #49869a;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #49869a;color:#fff}.bg-gradient-green-pink{--bslib-color-fg: #fff;--bslib-color-bg: #728082;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #728082;color:#fff}.bg-gradient-green-red{--bslib-color-fg: #fff;--bslib-color-bg: #737c5f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #737c5f;color:#fff}.bg-gradient-green-orange{--bslib-color-fg: #fff;--bslib-color-bg: #7f9b73;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #7f9b73;color:#fff}.bg-gradient-green-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #7eb774;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #7eb774;color:#fff}.bg-gradient-green-teal{--bslib-color-fg: #fff;--bslib-color-bg: #29bc89;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #29bc89;color:#fff}.bg-gradient-green-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #2c9d95;background:linear-gradient(var(--bg-gradient-deg, 140deg), #2fb380 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #2c9d95;color:#fff}.bg-gradient-teal-blue{--bslib-color-fg: #fff;--bslib-color-bg: #289cb7;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #289cb7;color:#fff}.bg-gradient-teal-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #3c7fbb;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #3c7fbb;color:#fff}.bg-gradient-teal-purple{--bslib-color-fg: #fff;--bslib-color-bg: #4093a8;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #4093a8;color:#fff}.bg-gradient-teal-pink{--bslib-color-fg: #fff;--bslib-color-bg: #698d8f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #698d8f;color:#fff}.bg-gradient-teal-red{--bslib-color-fg: #fff;--bslib-color-bg: #6a896d;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #6a896d;color:#fff}.bg-gradient-teal-orange{--bslib-color-fg: #fff;--bslib-color-bg: #76a881;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #76a881;color:#fff}.bg-gradient-teal-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #75c481;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #75c481;color:#fff}.bg-gradient-teal-green{--bslib-color-fg: #fff;--bslib-color-bg: #26c08e;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #26c08e;color:#fff}.bg-gradient-teal-cyan{--bslib-color-fg: #fff;--bslib-color-bg: #23aaa3;background:linear-gradient(var(--bg-gradient-deg, 140deg), #20c997 var(--bg-gradient-start, 36%), #287bb5 var(--bg-gradient-end, 180%)) #23aaa3;color:#fff}.bg-gradient-cyan-blue{--bslib-color-fg: #fff;--bslib-color-bg: #2d6dc9;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #3459e6 var(--bg-gradient-end, 180%)) #2d6dc9;color:#fff}.bg-gradient-cyan-indigo{--bslib-color-fg: #fff;--bslib-color-bg: #4150cd;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #6610f2 var(--bg-gradient-end, 180%)) #4150cd;color:#fff}.bg-gradient-cyan-purple{--bslib-color-fg: #fff;--bslib-color-bg: #4464ba;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #6f42c1 var(--bg-gradient-end, 180%)) #4464ba;color:#fff}.bg-gradient-cyan-pink{--bslib-color-fg: #fff;--bslib-color-bg: #6e5ea1;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #d63384 var(--bg-gradient-end, 180%)) #6e5ea1;color:#fff}.bg-gradient-cyan-red{--bslib-color-fg: #fff;--bslib-color-bg: #6f5a7f;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #da292e var(--bg-gradient-end, 180%)) #6f5a7f;color:#fff}.bg-gradient-cyan-orange{--bslib-color-fg: #fff;--bslib-color-bg: #7b7993;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #f8765f var(--bg-gradient-end, 180%)) #7b7993;color:#fff}.bg-gradient-cyan-yellow{--bslib-color-fg: #fff;--bslib-color-bg: #7a9593;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #f4bd61 var(--bg-gradient-end, 180%)) #7a9593;color:#fff}.bg-gradient-cyan-green{--bslib-color-fg: #fff;--bslib-color-bg: #2b91a0;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #2fb380 var(--bg-gradient-end, 180%)) #2b91a0;color:#fff}.bg-gradient-cyan-teal{--bslib-color-fg: #fff;--bslib-color-bg: #259aa9;background:linear-gradient(var(--bg-gradient-deg, 140deg), #287bb5 var(--bg-gradient-start, 36%), #20c997 var(--bg-gradient-end, 180%)) #259aa9;color:#fff}.navbar{font-size:.875rem;font-weight:500}.navbar .nav-item{margin-right:.5rem;margin-left:.5rem}.navbar .navbar-nav .nav-link{border-radius:.375rem}.navbar-dark .navbar-nav .nav-link:hover{background-color:rgba(255,255,255,0.1)}.navbar-dark .navbar-nav .nav-link.active{background-color:rgba(0,0,0,0.5)}.navbar-light .navbar-nav .nav-link:hover{background-color:rgba(0,0,0,0.03)}.navbar-light .navbar-nav .nav-link.active{background-color:rgba(0,0,0,0.05)}.navbar-nav{--bs-nav-link-padding-x: .5rem}.btn-secondary,.btn-default:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-light,.btn-outline-secondary,.btn-outline-light{color:#212529}.btn-secondary:disabled,.btn-default:disabled:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-secondary.disabled,.disabled.btn-default:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-light:disabled,.btn-light.disabled,.btn-outline-secondary:disabled,.btn-outline-secondary.disabled,.btn-outline-light:disabled,.btn-outline-light.disabled{border:1px solid #e6e6e6}.btn-secondary,.btn-default:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-outline-secondary{border-color:#e6e6e6}.btn-secondary:hover,.btn-default:hover:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-secondary:active,.btn-default:active:not(.btn-primary):not(.btn-info):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-dark):not(.btn-light):not([class*='btn-outline-']),.btn-outline-secondary:hover,.btn-outline-secondary:active{background-color:#e6e6e6;border-color:#e6e6e6}.btn-light,.btn-outline-light{border-color:#dfe0e1}.btn-light:hover,.btn-light:active,.btn-outline-light:hover,.btn-outline-light:active{background-color:#dfe0e1;border-color:#dfe0e1}.table{font-size:.875rem;box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06)}thead th{font-size:.875rem;text-transform:uppercase}.input-group-text{box-shadow:0 1px 2px rgba(0,0,0,0.05)}.nav-tabs{font-weight:500}.nav-tabs .nav-link{padding-top:1rem;padding-bottom:1rem;border-width:0 0 1px}.nav-tabs .nav-link.active,.nav-tabs .nav-item.show .nav-link{box-shadow:inset 0 -2px 0 #3459e6}.nav-pills{font-weight:500}.pagination{font-size:.875rem;font-weight:500}.pagination .page-link{box-shadow:0 1px 2px rgba(0,0,0,0.05)}.breadcrumb{font-size:.875rem;font-weight:500;border:1px solid #dee2e6;border-radius:.375rem;box-shadow:0 1px 2px rgba(0,0,0,0.05)}.breadcrumb-item{padding:1rem .5rem 1rem 0}.breadcrumb-item+.breadcrumb-item::before{padding-right:1rem}.alert .btn-close{color:inherit}.badge.bg-secondary,.badge.bg-light{color:#212529}.list-group-item h1,.list-group-item h2,.list-group-item h3,.list-group-item h4,.list-group-item h5,.list-group-item h6,.list-group-item .h1,.list-group-item .h2,.list-group-item .h3,.list-group-item .h4,.list-group-item .h5,.list-group-item .h6,.card h1,.card h2,.card h3,.card h4,.card h5,.card h6,.card .h1,.card .h2,.card .h3,.card .h4,.card .h5,.card .h6{color:inherit}.list-group{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06)}.card{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06)}.modal-footer{background-color:#f8f9fa}.modal-content{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06)}.row>main{max-width:50rem}@media (max-width: 767.98px){.row>main{overflow-wrap:break-word;hyphens:auto}}@media (min-width: 1200px) and (max-width: 1399.98px){.container .row{justify-content:space-evenly}}@media (min-width: 1400px){body{font-size:18px}.col-md-3{margin-left:5rem}}.navbar{background:RGBA(var(--bs-body-color-rgb), 0.1);background:color-mix(in oklab, color-mix(in oklab, var(--bs-body-bg) 95%, var(--bs-primary)) 95%, var(--bs-body-color));line-height:initial}.nav-item .nav-link{border-radius:.375rem}.nav-item.active .nav-link{background:RGBA(var(--bs-body-color-rgb), 0.1)}.nav-item .nav-link:hover{background:RGBA(var(--bs-primary-rgb), 0.1)}.navbar>.container{align-items:baseline;-webkit-align-items:baseline}input[type="search"]{width:12rem}[aria-labelledby=dropdown-lightswitch] span.fa{opacity:0.5}@media (max-width: 991.98px){.algolia-autocomplete,input[type="search"],#navbar .dropdown-menu{width:100%}#navbar .dropdown-item{white-space:normal}input[type="search"]{margin:0.25rem 0}}.headroom{will-change:transform;transition:transform 400ms ease}.headroom--pinned{transform:translateY(0%)}.headroom--unpinned{transform:translateY(-100%)}.row>main,.row>aside{margin-top:56px}html,body{scroll-padding:56px}@media (min-width: 576px){#toc{position:sticky;top:56px;max-height:calc(100vh - 56px - 1rem);overflow-y:auto}}aside h2,aside .h2{margin-top:1.5rem;font-size:1.25rem}aside .roles{color:RGBA(var(--bs-body-color-rgb), 0.8)}aside .list-unstyled li{margin-bottom:0.5rem}aside .dev-status .list-unstyled li{margin-bottom:0.1rem}@media (max-width: 767.98px){.row>aside{margin:0.5rem;width:calc(100vw - 1rem);background-color:RGBA(var(--bs-body-color-rgb), 0.1);border-color:var(--bs-border-color);border-radius:.375rem}.row>aside h2:first-child,.row>aside .h2:first-child{margin-top:1rem}}body{position:relative}#toc>.nav{margin-bottom:1rem}#toc>.nav a.nav-link{color:inherit;padding:0.25rem 0.5rem;margin-bottom:2px;border-radius:.375rem}#toc>.nav a.nav-link:hover,#toc>.nav a.nav-link:focus{background-color:RGBA(var(--bs-primary-rgb), 0.1)}#toc>.nav a.nav-link.active{background-color:RGBA(var(--bs-body-color-rgb), 0.1)}#toc>.nav .nav a.nav-link{margin-left:0.5rem}#toc>.nav .nav{display:none !important}#toc>.nav a.active+.nav{display:flex !important}footer{margin:1rem 0 1rem 0;padding-top:1rem;font-size:.875em;border-top:1px solid #dee2e6;background:rgba(0,0,0,0);color:RGBA(var(--bs-body-color-rgb), 0.8);display:flex;column-gap:1rem}@media (max-width: 575.98px){footer{flex-direction:column}}@media (min-width: 576px){footer .pkgdown-footer-right{text-align:right}}footer div{flex:1 1 auto}html,body{height:100%}body>.container{min-height:100%;display:flex;flex-direction:column}body>.container .row{flex:1 0 auto}main img{max-width:100%;height:auto}main table{display:block;overflow:auto}body{font-display:fallback}.page-header{border-bottom:1px solid var(--bs-border-color);padding-bottom:0.5rem;margin-bottom:0.5rem;margin-top:1.5rem}dl{margin-bottom:0}dd{padding-left:1.5rem;margin-bottom:0.25rem}h2,.h2{font-size:1.75rem;margin-top:1.5rem}h3,.h3{font-size:1.25rem;margin-top:1rem;font-weight:bold}h4,.h4{font-size:1.1rem;font-weight:bold}h5,.h5{font-size:1rem;font-weight:bold}summary{margin-bottom:0.5rem}details{margin-bottom:1rem}.html-widget{margin-bottom:1rem}a.anchor{display:none;margin-left:2px;vertical-align:top;width:Min(0.9em, 20px);height:Min(0.9em, 20px);background-image:url(../../link.svg);background-repeat:no-repeat;background-size:Min(0.9em, 20px) Min(0.9em, 20px);background-position:center center}h2:hover .anchor,.h2:hover .anchor,h2:target .anchor,.h2:target .anchor,h3:hover .anchor,.h3:hover .anchor,h3:target .anchor,.h3:target .anchor,h4:hover .anchor,.h4:hover .anchor,h4:target .anchor,.h4:target .anchor,h5:hover .anchor,.h5:hover .anchor,h5:target .anchor,.h5:target .anchor,h6:hover .anchor,.h6:hover .anchor,h6:target .anchor,.h6:target .anchor,dt:hover .anchor,dt:target .anchor{display:inline-block}dt:target,dt:target+dd{border-left:0.25rem solid var(--bs-primary);margin-left:-0.75rem}dt:target{padding-left:0.5rem}dt:target+dd{padding-left:2rem}.orcid{color:#A6CE39;margin-right:4px}.ror{height:16px;margin-right:4px}.fab{font-family:"Font Awesome 5 Brands" !important}img.logo{float:right;width:100px;margin-left:30px}.template-home img.logo{width:120px}@media (max-width: 575.98px){img.logo{width:80px}}@media (min-width: 576px){.page-header{min-height:88px}.template-home .page-header{min-height:104px}}.line-block{margin-bottom:1rem}.template-reference-index dt{font-weight:normal}.template-reference-index code{word-wrap:normal}.icon{float:right}.icon img{width:40px}a[href='#main']{position:absolute;margin:4px;padding:0.75rem;background-color:var(--bs-body-bg);text-decoration:none;z-index:2000}.lifecycle{color:var(--bs-secondary-color);background-color:var(--bs-secondary-bg);border-radius:5px}.lifecycle-stable{background-color:#108001;color:var(--bs-white)}.lifecycle-superseded{background-color:#074080;color:var(--bs-white)}.lifecycle-experimental,.lifecycle-deprecated{background-color:#fd8008;color:var(--bs-black)}a.footnote-ref{cursor:pointer}.popover{width:Min(100vw, 32rem);font-size:0.9rem;box-shadow:4px 4px 8px RGBA(var(--bs-body-color-rgb), 0.3)}.popover-body{padding:0.75rem}.popover-body p:last-child{margin-bottom:0}.tab-content{padding:1rem}.tabset-pills .tab-content{border:solid 1px #e5e5e5}.tab-content{display:flex}.tab-content>.tab-pane{display:block;visibility:hidden;margin-right:-100%;width:100%}.tab-content>.active{visibility:visible}div.csl-entry{clear:both}.hanging-indent div.csl-entry{margin-left:2em;text-indent:-2em}div.csl-left-margin{min-width:2em;float:left}div.csl-right-inline{margin-left:2em;padding-left:1em}div.csl-indent{margin-left:2em}pre,pre code{word-wrap:normal}[data-bs-theme="dark"] pre,[data-bs-theme="dark"] code{background-color:RGBA(var(--bs-body-color-rgb), 0.1)}[data-bs-theme="dark"] pre code{background:transparent}code{overflow-wrap:break-word}.hasCopyButton{position:relative}.btn-copy-ex{position:absolute;right:5px;top:5px;visibility:hidden}.hasCopyButton:hover button.btn-copy-ex{visibility:visible}pre{padding:0.75rem}pre div.gt-table{white-space:normal;margin-top:1rem}@media (max-width: 575.98px){div>div>pre{margin-left:calc(var(--bs-gutter-x) * -.5);margin-right:calc(var(--bs-gutter-x) * -.5);border-radius:0;padding-left:1rem;padding-right:1rem}.btn-copy-ex{right:calc(var(--bs-gutter-x) * -.5 + 5px)}}code a:any-link{color:inherit;text-decoration-color:RGBA(var(--bs-body-color-rgb), 0.6)}pre code{padding:0;background:transparent}pre code .error,pre code .warning{font-weight:bolder}pre .img img,pre .r-plt img{margin:5px 0;background-color:#fff}[data-bs-theme="dark"] pre img{opacity:0.66;transition:opacity 250ms ease-in-out}[data-bs-theme="dark"] pre img:hover,[data-bs-theme="dark"] pre img:focus,[data-bs-theme="dark"] pre img:active{opacity:1}@media print{code a:link:after,code a:visited:after{content:""}}a.sourceLine:hover{text-decoration:none}mark,.mark{background:linear-gradient(-100deg, RGBA(var(--bs-info-rgb), 0.2), RGBA(var(--bs-info-rgb), 0.7) 95%, RGBA(var(--bs-info-rgb), 0.1))}.algolia-autocomplete .aa-dropdown-menu{margin-top:0.5rem;padding:0.5rem 0.25rem;width:MAX(100%, 20rem);max-height:50vh;overflow-y:auto;background-color:var(--bs-body-bg);border:var(--bs-border-width) solid var(--bs-border-color);border-radius:.375rem}.algolia-autocomplete .aa-dropdown-menu .aa-suggestion{cursor:pointer;font-size:1rem;padding:0.5rem 0.25rem;line-height:1.3}.algolia-autocomplete .aa-dropdown-menu .aa-suggestion:hover{background-color:var(--bs-tertiary-bg);color:var(--bs-body-color)}.algolia-autocomplete .aa-dropdown-menu .aa-suggestion .search-details{text-decoration:underline;display:inline}span.smallcaps{font-variant:small-caps}ul.task-list{list-style:none}ul.task-list li input[type="checkbox"]{width:0.8em;margin:0 0.8em 0.2em -1em;vertical-align:middle}figure.figure{display:block}.quarto-layout-panel{margin-bottom:1em}.quarto-layout-panel>figure{width:100%}.quarto-layout-panel>figure>figcaption,.quarto-layout-panel>.panel-caption{margin-top:10pt}.quarto-layout-panel>.table-caption{margin-top:0px}.table-caption p{margin-bottom:0.5em}.quarto-layout-row{display:flex;flex-direction:row;align-items:flex-start}.quarto-layout-valign-top{align-items:flex-start}.quarto-layout-valign-bottom{align-items:flex-end}.quarto-layout-valign-center{align-items:center}.quarto-layout-cell{position:relative;margin-right:20px}.quarto-layout-cell:last-child{margin-right:0}.quarto-layout-cell figure,.quarto-layout-cell>p{margin:0.2em}.quarto-layout-cell img{max-width:100%}.quarto-layout-cell .html-widget{width:100% !important}.quarto-layout-cell div figure p{margin:0}.quarto-layout-cell figure{display:block;margin-inline-start:0;margin-inline-end:0}.quarto-layout-cell table{display:inline-table}.quarto-layout-cell-subref figcaption,figure .quarto-layout-row figure figcaption{text-align:center;font-style:italic}.quarto-figure{position:relative;margin-bottom:1em}.quarto-figure>figure{width:100%;margin-bottom:0}.quarto-figure-left>figure>p,.quarto-figure-left>figure>div{text-align:left}.quarto-figure-center>figure>p,.quarto-figure-center>figure>div{text-align:center}.quarto-figure-right>figure>p,.quarto-figure-right>figure>div{text-align:right}.quarto-figure>figure>div.cell-annotation,.quarto-figure>figure>div code{text-align:left}figure>p:empty{display:none}figure>p:first-child{margin-top:0;margin-bottom:0}figure>figcaption.quarto-float-caption-bottom{margin-bottom:0.5em}figure>figcaption.quarto-float-caption-top{margin-top:0.5em}:root{--mermaid-bg-color: transparent;--mermaid-edge-color: var(--bs-secondary);--mermaid-fg-color: var(--bs-body-color);--mermaid-fg-color--lighter: RGBA(var(--bs-body-color-rgb), 0.9);--mermaid-fg-color--lightest: RGBA(var(--bs-body-color-rgb), 0.8);--mermaid-font-family: var(--bs-body-font-family);--mermaid-label-bg-color: var(--bs-primary);--mermaid-label-fg-color: var(--bs-body-color);--mermaid-node-bg-color: RGBA(var(--bs-primary-rgb), 0.1);--mermaid-node-fg-color: var(--bs-primary)}pre{background-color:#f1f3f5}pre code{color:#003B4F}pre code span.al{color:#AD0000}pre code span.an{color:#5E5E5E}pre code span.at{color:#657422}pre code span.bn{color:#AD0000}pre code span.cf{color:#003B4F}pre code span.ch{color:#20794D}pre code span.cn{color:#8f5902}pre code span.co{color:#5E5E5E}pre code span.cv{color:#5E5E5E;font-style:italic}pre code span.do{color:#5E5E5E;font-style:italic}pre code span.dt{color:#AD0000}pre code span.dv{color:#AD0000}pre code span.er{color:#AD0000}pre code span.fl{color:#AD0000}pre code span.fu{color:#4758AB}pre code span.im{color:#00769E}pre code span.in{color:#5E5E5E}pre code span.kw{color:#003B4F}pre code span.op{color:#5E5E5E}pre code span.ot{color:#003B4F}pre code span.pp{color:#AD0000}pre code span.sc{color:#5E5E5E}pre code span.ss{color:#20794D}pre code span.st{color:#20794D}pre code span.va{color:#111111}pre code span.vs{color:#20794D}pre code span.wa{color:#5E5E5E;font-style:italic} diff --git a/docs/deps/bootstrap-5.3.1/font.css b/docs/deps/bootstrap-5.3.1/font.css index 05b14c95..f2684eac 100644 --- a/docs/deps/bootstrap-5.3.1/font.css +++ b/docs/deps/bootstrap-5.3.1/font.css @@ -4,8 +4,8 @@ font-style: normal; font-weight: 400; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2'); - unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2JL7SUc.woff2) format('woff2'); + unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } /* cyrillic */ @font-face { @@ -13,7 +13,7 @@ font-style: normal; font-weight: 400; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa0ZL7SUc.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* greek-ext */ @@ -22,7 +22,7 @@ font-style: normal; font-weight: 400; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2ZL7SUc.woff2) format('woff2'); unicode-range: U+1F00-1FFF; } /* greek */ @@ -31,7 +31,7 @@ font-style: normal; font-weight: 400; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1pL7SUc.woff2) format('woff2'); unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; } /* vietnamese */ @@ -40,7 +40,7 @@ font-style: normal; font-weight: 400; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2pL7SUc.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; } /* latin-ext */ @@ -49,8 +49,8 @@ font-style: normal; font-weight: 400; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2'); - unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa25L7SUc.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { @@ -58,8 +58,8 @@ font-style: normal; font-weight: 400; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2'); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1ZL7.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } /* cyrillic-ext */ @font-face { @@ -67,8 +67,8 @@ font-style: normal; font-weight: 500; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2'); - unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2JL7SUc.woff2) format('woff2'); + unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } /* cyrillic */ @font-face { @@ -76,7 +76,7 @@ font-style: normal; font-weight: 500; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa0ZL7SUc.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* greek-ext */ @@ -85,7 +85,7 @@ font-style: normal; font-weight: 500; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2ZL7SUc.woff2) format('woff2'); unicode-range: U+1F00-1FFF; } /* greek */ @@ -94,7 +94,7 @@ font-style: normal; font-weight: 500; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1pL7SUc.woff2) format('woff2'); unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; } /* vietnamese */ @@ -103,7 +103,7 @@ font-style: normal; font-weight: 500; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2pL7SUc.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; } /* latin-ext */ @@ -112,8 +112,8 @@ font-style: normal; font-weight: 500; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2'); - unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa25L7SUc.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { @@ -121,8 +121,8 @@ font-style: normal; font-weight: 500; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2'); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1ZL7.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } /* cyrillic-ext */ @font-face { @@ -130,8 +130,8 @@ font-style: normal; font-weight: 700; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2) format('woff2'); - unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2JL7SUc.woff2) format('woff2'); + unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } /* cyrillic */ @font-face { @@ -139,7 +139,7 @@ font-style: normal; font-weight: 700; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa0ZL7SUc.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* greek-ext */ @@ -148,7 +148,7 @@ font-style: normal; font-weight: 700; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2ZL7SUc.woff2) format('woff2'); unicode-range: U+1F00-1FFF; } /* greek */ @@ -157,7 +157,7 @@ font-style: normal; font-weight: 700; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1pL7SUc.woff2) format('woff2'); unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; } /* vietnamese */ @@ -166,7 +166,7 @@ font-style: normal; font-weight: 700; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2) format('woff2'); + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2pL7SUc.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; } /* latin-ext */ @@ -175,8 +175,8 @@ font-style: normal; font-weight: 700; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2) format('woff2'); - unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa25L7SUc.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { @@ -184,6 +184,6 @@ font-style: normal; font-weight: 700; font-display: swap; - src: url(fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format('woff2'); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; + src: url(fonts/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1ZL7.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } diff --git a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459W1hyzbi.woff2 b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459W1hyzbi.woff2 index 5379c126..dbdd0584 100644 Binary files a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459W1hyzbi.woff2 and b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459W1hyzbi.woff2 differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459WRhyzbi.woff2 b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459WRhyzbi.woff2 index 4b7bc4a3..66361379 100644 Binary files a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459WRhyzbi.woff2 and b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459WRhyzbi.woff2 differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459WZhyzbi.woff2 b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459WZhyzbi.woff2 index 6ec37309..838e60a6 100644 Binary files a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459WZhyzbi.woff2 and b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459WZhyzbi.woff2 differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459Wdhyzbi.woff2 b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459Wdhyzbi.woff2 index 76691276..cd88473e 100644 Binary files a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459Wdhyzbi.woff2 and b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459Wdhyzbi.woff2 differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2 b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2 index 6122800c..4891e37c 100644 Binary files a/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2 and b/docs/deps/bootstrap-5.3.1/fonts/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2 differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fABc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fABc4EsA.woff2 deleted file mode 100644 index cb5834ff..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fABc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fBBc4.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fBBc4.woff2 deleted file mode 100644 index 29342a8d..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fBBc4.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fBxc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fBxc4EsA.woff2 deleted file mode 100644 index 0933dfe8..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fBxc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCBc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCBc4EsA.woff2 deleted file mode 100644 index 064e94b7..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCBc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCRc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCRc4EsA.woff2 deleted file mode 100644 index 8571683e..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCRc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fChc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fChc4EsA.woff2 deleted file mode 100644 index 68f094cd..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fChc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCxc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCxc4EsA.woff2 deleted file mode 100644 index 6b0b4afe..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmEU9fCxc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fABc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fABc4EsA.woff2 deleted file mode 100644 index 9d7fb7f8..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fABc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fBBc4.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fBBc4.woff2 deleted file mode 100644 index 60681387..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fBBc4.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fBxc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fBxc4EsA.woff2 deleted file mode 100644 index b289f002..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fBxc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCBc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCBc4EsA.woff2 deleted file mode 100644 index 87711c04..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCBc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCRc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCRc4EsA.woff2 deleted file mode 100644 index 0f6e60b8..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCRc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fChc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fChc4EsA.woff2 deleted file mode 100644 index 91231c9c..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fChc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCxc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCxc4EsA.woff2 deleted file mode 100644 index c0099878..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmSU5fCxc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfABc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfABc4EsA.woff2 deleted file mode 100644 index 1bb7737c..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfABc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfBBc4.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfBBc4.woff2 deleted file mode 100644 index 771fbecc..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfBBc4.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfBxc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfBxc4EsA.woff2 deleted file mode 100644 index cb9bfa71..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfBxc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCBc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCBc4EsA.woff2 deleted file mode 100644 index a0d68e2b..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCBc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCRc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCRc4EsA.woff2 deleted file mode 100644 index 63995528..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCRc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfChc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfChc4EsA.woff2 deleted file mode 100644 index 94ab5fb0..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfChc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCxc4EsA.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCxc4EsA.woff2 deleted file mode 100644 index 3c450111..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOlCnqEu92Fr1MmWUlfCxc4EsA.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu4WxKOzY.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu4WxKOzY.woff2 deleted file mode 100644 index fc71d944..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu4WxKOzY.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu4mxK.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu4mxK.woff2 deleted file mode 100644 index 020729ef..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu4mxK.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu5mxKOzY.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu5mxKOzY.woff2 deleted file mode 100644 index 47da3629..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu5mxKOzY.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu72xKOzY.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu72xKOzY.woff2 deleted file mode 100644 index 22ddee9c..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu72xKOzY.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7GxKOzY.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7GxKOzY.woff2 deleted file mode 100644 index 8a8de615..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7GxKOzY.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7WxKOzY.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7WxKOzY.woff2 deleted file mode 100644 index 6284d2e3..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7WxKOzY.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7mxKOzY.woff2 b/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7mxKOzY.woff2 deleted file mode 100644 index 72ce0e98..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/KFOmCnqEu92Fr1Mu7mxKOzY.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2 b/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2 deleted file mode 100644 index b655a438..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa0ZL7SUc.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2 b/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2 deleted file mode 100644 index 40255432..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2 b/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2 deleted file mode 100644 index eb38b38e..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1pL7SUc.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2 b/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2 deleted file mode 100644 index 3df865d7..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa25L7SUc.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2 b/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2 deleted file mode 100644 index a61a0be5..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2JL7SUc.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2 b/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2 deleted file mode 100644 index 9117b5b0..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2ZL7SUc.woff2 and /dev/null differ diff --git a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2 b/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2 deleted file mode 100644 index ce21ca17..00000000 Binary files a/docs/deps/bootstrap-5.3.1/fonts/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa2pL7SUc.woff2 and /dev/null differ diff --git a/docs/deps/data-deps.txt b/docs/deps/data-deps.txt index 8aa49e21..ca4dfd9c 100644 --- a/docs/deps/data-deps.txt +++ b/docs/deps/data-deps.txt @@ -2,8 +2,8 @@ - - + + diff --git a/docs/deps/font-awesome-6.5.2/css/all.css b/docs/deps/font-awesome-6.5.2/css/all.css new file mode 100644 index 00000000..151dd57c --- /dev/null +++ b/docs/deps/font-awesome-6.5.2/css/all.css @@ -0,0 +1,8028 @@ +/*! + * Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + * Copyright 2024 Fonticons, Inc. + */ +.fa { + font-family: var(--fa-style-family, "Font Awesome 6 Free"); + font-weight: var(--fa-style, 900); } + +.fa, +.fa-classic, +.fa-sharp, +.fas, +.fa-solid, +.far, +.fa-regular, +.fab, +.fa-brands { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + display: var(--fa-display, inline-block); + font-style: normal; + font-variant: normal; + line-height: 1; + text-rendering: auto; } + +.fas, +.fa-classic, +.fa-solid, +.far, +.fa-regular { + font-family: 'Font Awesome 6 Free'; } + +.fab, +.fa-brands { + font-family: 'Font Awesome 6 Brands'; } + +.fa-1x { + font-size: 1em; } + +.fa-2x { + font-size: 2em; } + +.fa-3x { + font-size: 3em; } + +.fa-4x { + font-size: 4em; } + +.fa-5x { + font-size: 5em; } + +.fa-6x { + font-size: 6em; } + +.fa-7x { + font-size: 7em; } + +.fa-8x { + font-size: 8em; } + +.fa-9x { + font-size: 9em; } + +.fa-10x { + font-size: 10em; } + +.fa-2xs { + font-size: 0.625em; + line-height: 0.1em; + vertical-align: 0.225em; } + +.fa-xs { + font-size: 0.75em; + line-height: 0.08333em; + vertical-align: 0.125em; } + +.fa-sm { + font-size: 0.875em; + line-height: 0.07143em; + vertical-align: 0.05357em; } + +.fa-lg { + font-size: 1.25em; + line-height: 0.05em; + vertical-align: -0.075em; } + +.fa-xl { + font-size: 1.5em; + line-height: 0.04167em; + vertical-align: -0.125em; } + +.fa-2xl { + font-size: 2em; + line-height: 0.03125em; + vertical-align: -0.1875em; } + +.fa-fw { + text-align: center; + width: 1.25em; } + +.fa-ul { + list-style-type: none; + margin-left: var(--fa-li-margin, 2.5em); + padding-left: 0; } + .fa-ul > li { + position: relative; } + +.fa-li { + left: calc(var(--fa-li-width, 2em) * -1); + position: absolute; + text-align: center; + width: var(--fa-li-width, 2em); + line-height: inherit; } + +.fa-border { + border-color: var(--fa-border-color, #eee); + border-radius: var(--fa-border-radius, 0.1em); + border-style: var(--fa-border-style, solid); + border-width: var(--fa-border-width, 0.08em); + padding: var(--fa-border-padding, 0.2em 0.25em 0.15em); } + +.fa-pull-left { + float: left; + margin-right: var(--fa-pull-margin, 0.3em); } + +.fa-pull-right { + float: right; + margin-left: var(--fa-pull-margin, 0.3em); } + +.fa-beat { + -webkit-animation-name: fa-beat; + animation-name: fa-beat; + -webkit-animation-delay: var(--fa-animation-delay, 0s); + animation-delay: var(--fa-animation-delay, 0s); + -webkit-animation-direction: var(--fa-animation-direction, normal); + animation-direction: var(--fa-animation-direction, normal); + -webkit-animation-duration: var(--fa-animation-duration, 1s); + animation-duration: var(--fa-animation-duration, 1s); + -webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite); + animation-iteration-count: var(--fa-animation-iteration-count, infinite); + -webkit-animation-timing-function: var(--fa-animation-timing, ease-in-out); + animation-timing-function: var(--fa-animation-timing, ease-in-out); } + +.fa-bounce { + -webkit-animation-name: fa-bounce; + animation-name: fa-bounce; + -webkit-animation-delay: var(--fa-animation-delay, 0s); + animation-delay: var(--fa-animation-delay, 0s); + -webkit-animation-direction: var(--fa-animation-direction, normal); + animation-direction: var(--fa-animation-direction, normal); + -webkit-animation-duration: var(--fa-animation-duration, 1s); + animation-duration: var(--fa-animation-duration, 1s); + -webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite); + animation-iteration-count: var(--fa-animation-iteration-count, infinite); + -webkit-animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.28, 0.84, 0.42, 1)); + animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.28, 0.84, 0.42, 1)); } + +.fa-fade { + -webkit-animation-name: fa-fade; + animation-name: fa-fade; + -webkit-animation-delay: var(--fa-animation-delay, 0s); + animation-delay: var(--fa-animation-delay, 0s); + -webkit-animation-direction: var(--fa-animation-direction, normal); + animation-direction: var(--fa-animation-direction, normal); + -webkit-animation-duration: var(--fa-animation-duration, 1s); + animation-duration: var(--fa-animation-duration, 1s); + -webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite); + animation-iteration-count: var(--fa-animation-iteration-count, infinite); + -webkit-animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.4, 0, 0.6, 1)); + animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.4, 0, 0.6, 1)); } + +.fa-beat-fade { + -webkit-animation-name: fa-beat-fade; + animation-name: fa-beat-fade; + -webkit-animation-delay: var(--fa-animation-delay, 0s); + animation-delay: var(--fa-animation-delay, 0s); + -webkit-animation-direction: var(--fa-animation-direction, normal); + animation-direction: var(--fa-animation-direction, normal); + -webkit-animation-duration: var(--fa-animation-duration, 1s); + animation-duration: var(--fa-animation-duration, 1s); + -webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite); + animation-iteration-count: var(--fa-animation-iteration-count, infinite); + -webkit-animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.4, 0, 0.6, 1)); + animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.4, 0, 0.6, 1)); } + +.fa-flip { + -webkit-animation-name: fa-flip; + animation-name: fa-flip; + -webkit-animation-delay: var(--fa-animation-delay, 0s); + animation-delay: var(--fa-animation-delay, 0s); + -webkit-animation-direction: var(--fa-animation-direction, normal); + animation-direction: var(--fa-animation-direction, normal); + -webkit-animation-duration: var(--fa-animation-duration, 1s); + animation-duration: var(--fa-animation-duration, 1s); + -webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite); + animation-iteration-count: var(--fa-animation-iteration-count, infinite); + -webkit-animation-timing-function: var(--fa-animation-timing, ease-in-out); + animation-timing-function: var(--fa-animation-timing, ease-in-out); } + +.fa-shake { + -webkit-animation-name: fa-shake; + animation-name: fa-shake; + -webkit-animation-delay: var(--fa-animation-delay, 0s); + animation-delay: var(--fa-animation-delay, 0s); + -webkit-animation-direction: var(--fa-animation-direction, normal); + animation-direction: var(--fa-animation-direction, normal); + -webkit-animation-duration: var(--fa-animation-duration, 1s); + animation-duration: var(--fa-animation-duration, 1s); + -webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite); + animation-iteration-count: var(--fa-animation-iteration-count, infinite); + -webkit-animation-timing-function: var(--fa-animation-timing, linear); + animation-timing-function: var(--fa-animation-timing, linear); } + +.fa-spin { + -webkit-animation-name: fa-spin; + animation-name: fa-spin; + -webkit-animation-delay: var(--fa-animation-delay, 0s); + animation-delay: var(--fa-animation-delay, 0s); + -webkit-animation-direction: var(--fa-animation-direction, normal); + animation-direction: var(--fa-animation-direction, normal); + -webkit-animation-duration: var(--fa-animation-duration, 2s); + animation-duration: var(--fa-animation-duration, 2s); + -webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite); + animation-iteration-count: var(--fa-animation-iteration-count, infinite); + -webkit-animation-timing-function: var(--fa-animation-timing, linear); + animation-timing-function: var(--fa-animation-timing, linear); } + +.fa-spin-reverse { + --fa-animation-direction: reverse; } + +.fa-pulse, +.fa-spin-pulse { + -webkit-animation-name: fa-spin; + animation-name: fa-spin; + -webkit-animation-direction: var(--fa-animation-direction, normal); + animation-direction: var(--fa-animation-direction, normal); + -webkit-animation-duration: var(--fa-animation-duration, 1s); + animation-duration: var(--fa-animation-duration, 1s); + -webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite); + animation-iteration-count: var(--fa-animation-iteration-count, infinite); + -webkit-animation-timing-function: var(--fa-animation-timing, steps(8)); + animation-timing-function: var(--fa-animation-timing, steps(8)); } + +@media (prefers-reduced-motion: reduce) { + .fa-beat, + .fa-bounce, + .fa-fade, + .fa-beat-fade, + .fa-flip, + .fa-pulse, + .fa-shake, + .fa-spin, + .fa-spin-pulse { + -webkit-animation-delay: -1ms; + animation-delay: -1ms; + -webkit-animation-duration: 1ms; + animation-duration: 1ms; + -webkit-animation-iteration-count: 1; + animation-iteration-count: 1; + -webkit-transition-delay: 0s; + transition-delay: 0s; + -webkit-transition-duration: 0s; + transition-duration: 0s; } } + +@-webkit-keyframes fa-beat { + 0%, 90% { + -webkit-transform: scale(1); + transform: scale(1); } + 45% { + -webkit-transform: scale(var(--fa-beat-scale, 1.25)); + transform: scale(var(--fa-beat-scale, 1.25)); } } + +@keyframes fa-beat { + 0%, 90% { + -webkit-transform: scale(1); + transform: scale(1); } + 45% { + -webkit-transform: scale(var(--fa-beat-scale, 1.25)); + transform: scale(var(--fa-beat-scale, 1.25)); } } + +@-webkit-keyframes fa-bounce { + 0% { + -webkit-transform: scale(1, 1) translateY(0); + transform: scale(1, 1) translateY(0); } + 10% { + -webkit-transform: scale(var(--fa-bounce-start-scale-x, 1.1), var(--fa-bounce-start-scale-y, 0.9)) translateY(0); + transform: scale(var(--fa-bounce-start-scale-x, 1.1), var(--fa-bounce-start-scale-y, 0.9)) translateY(0); } + 30% { + -webkit-transform: scale(var(--fa-bounce-jump-scale-x, 0.9), var(--fa-bounce-jump-scale-y, 1.1)) translateY(var(--fa-bounce-height, -0.5em)); + transform: scale(var(--fa-bounce-jump-scale-x, 0.9), var(--fa-bounce-jump-scale-y, 1.1)) translateY(var(--fa-bounce-height, -0.5em)); } + 50% { + -webkit-transform: scale(var(--fa-bounce-land-scale-x, 1.05), var(--fa-bounce-land-scale-y, 0.95)) translateY(0); + transform: scale(var(--fa-bounce-land-scale-x, 1.05), var(--fa-bounce-land-scale-y, 0.95)) translateY(0); } + 57% { + -webkit-transform: scale(1, 1) translateY(var(--fa-bounce-rebound, -0.125em)); + transform: scale(1, 1) translateY(var(--fa-bounce-rebound, -0.125em)); } + 64% { + -webkit-transform: scale(1, 1) translateY(0); + transform: scale(1, 1) translateY(0); } + 100% { + -webkit-transform: scale(1, 1) translateY(0); + transform: scale(1, 1) translateY(0); } } + +@keyframes fa-bounce { + 0% { + -webkit-transform: scale(1, 1) translateY(0); + transform: scale(1, 1) translateY(0); } + 10% { + -webkit-transform: scale(var(--fa-bounce-start-scale-x, 1.1), var(--fa-bounce-start-scale-y, 0.9)) translateY(0); + transform: scale(var(--fa-bounce-start-scale-x, 1.1), var(--fa-bounce-start-scale-y, 0.9)) translateY(0); } + 30% { + -webkit-transform: scale(var(--fa-bounce-jump-scale-x, 0.9), var(--fa-bounce-jump-scale-y, 1.1)) translateY(var(--fa-bounce-height, -0.5em)); + transform: scale(var(--fa-bounce-jump-scale-x, 0.9), var(--fa-bounce-jump-scale-y, 1.1)) translateY(var(--fa-bounce-height, -0.5em)); } + 50% { + -webkit-transform: scale(var(--fa-bounce-land-scale-x, 1.05), var(--fa-bounce-land-scale-y, 0.95)) translateY(0); + transform: scale(var(--fa-bounce-land-scale-x, 1.05), var(--fa-bounce-land-scale-y, 0.95)) translateY(0); } + 57% { + -webkit-transform: scale(1, 1) translateY(var(--fa-bounce-rebound, -0.125em)); + transform: scale(1, 1) translateY(var(--fa-bounce-rebound, -0.125em)); } + 64% { + -webkit-transform: scale(1, 1) translateY(0); + transform: scale(1, 1) translateY(0); } + 100% { + -webkit-transform: scale(1, 1) translateY(0); + transform: scale(1, 1) translateY(0); } } + +@-webkit-keyframes fa-fade { + 50% { + opacity: var(--fa-fade-opacity, 0.4); } } + +@keyframes fa-fade { + 50% { + opacity: var(--fa-fade-opacity, 0.4); } } + +@-webkit-keyframes fa-beat-fade { + 0%, 100% { + opacity: var(--fa-beat-fade-opacity, 0.4); + -webkit-transform: scale(1); + transform: scale(1); } + 50% { + opacity: 1; + -webkit-transform: scale(var(--fa-beat-fade-scale, 1.125)); + transform: scale(var(--fa-beat-fade-scale, 1.125)); } } + +@keyframes fa-beat-fade { + 0%, 100% { + opacity: var(--fa-beat-fade-opacity, 0.4); + -webkit-transform: scale(1); + transform: scale(1); } + 50% { + opacity: 1; + -webkit-transform: scale(var(--fa-beat-fade-scale, 1.125)); + transform: scale(var(--fa-beat-fade-scale, 1.125)); } } + +@-webkit-keyframes fa-flip { + 50% { + -webkit-transform: rotate3d(var(--fa-flip-x, 0), var(--fa-flip-y, 1), var(--fa-flip-z, 0), var(--fa-flip-angle, -180deg)); + transform: rotate3d(var(--fa-flip-x, 0), var(--fa-flip-y, 1), var(--fa-flip-z, 0), var(--fa-flip-angle, -180deg)); } } + +@keyframes fa-flip { + 50% { + -webkit-transform: rotate3d(var(--fa-flip-x, 0), var(--fa-flip-y, 1), var(--fa-flip-z, 0), var(--fa-flip-angle, -180deg)); + transform: rotate3d(var(--fa-flip-x, 0), var(--fa-flip-y, 1), var(--fa-flip-z, 0), var(--fa-flip-angle, -180deg)); } } + +@-webkit-keyframes fa-shake { + 0% { + -webkit-transform: rotate(-15deg); + transform: rotate(-15deg); } + 4% { + -webkit-transform: rotate(15deg); + transform: rotate(15deg); } + 8%, 24% { + -webkit-transform: rotate(-18deg); + transform: rotate(-18deg); } + 12%, 28% { + -webkit-transform: rotate(18deg); + transform: rotate(18deg); } + 16% { + -webkit-transform: rotate(-22deg); + transform: rotate(-22deg); } + 20% { + -webkit-transform: rotate(22deg); + transform: rotate(22deg); } + 32% { + -webkit-transform: rotate(-12deg); + transform: rotate(-12deg); } + 36% { + -webkit-transform: rotate(12deg); + transform: rotate(12deg); } + 40%, 100% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); } } + +@keyframes fa-shake { + 0% { + -webkit-transform: rotate(-15deg); + transform: rotate(-15deg); } + 4% { + -webkit-transform: rotate(15deg); + transform: rotate(15deg); } + 8%, 24% { + -webkit-transform: rotate(-18deg); + transform: rotate(-18deg); } + 12%, 28% { + -webkit-transform: rotate(18deg); + transform: rotate(18deg); } + 16% { + -webkit-transform: rotate(-22deg); + transform: rotate(-22deg); } + 20% { + -webkit-transform: rotate(22deg); + transform: rotate(22deg); } + 32% { + -webkit-transform: rotate(-12deg); + transform: rotate(-12deg); } + 36% { + -webkit-transform: rotate(12deg); + transform: rotate(12deg); } + 40%, 100% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); } } + +@-webkit-keyframes fa-spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); } } + +@keyframes fa-spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); } } + +.fa-rotate-90 { + -webkit-transform: rotate(90deg); + transform: rotate(90deg); } + +.fa-rotate-180 { + -webkit-transform: rotate(180deg); + transform: rotate(180deg); } + +.fa-rotate-270 { + -webkit-transform: rotate(270deg); + transform: rotate(270deg); } + +.fa-flip-horizontal { + -webkit-transform: scale(-1, 1); + transform: scale(-1, 1); } + +.fa-flip-vertical { + -webkit-transform: scale(1, -1); + transform: scale(1, -1); } + +.fa-flip-both, +.fa-flip-horizontal.fa-flip-vertical { + -webkit-transform: scale(-1, -1); + transform: scale(-1, -1); } + +.fa-rotate-by { + -webkit-transform: rotate(var(--fa-rotate-angle, 0)); + transform: rotate(var(--fa-rotate-angle, 0)); } + +.fa-stack { + display: inline-block; + height: 2em; + line-height: 2em; + position: relative; + vertical-align: middle; + width: 2.5em; } + +.fa-stack-1x, +.fa-stack-2x { + left: 0; + position: absolute; + text-align: center; + width: 100%; + z-index: var(--fa-stack-z-index, auto); } + +.fa-stack-1x { + line-height: inherit; } + +.fa-stack-2x { + font-size: 2em; } + +.fa-inverse { + color: var(--fa-inverse, #fff); } + +/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen +readers do not read off random characters that represent icons */ + +.fa-0::before { + content: "\30"; } + +.fa-1::before { + content: "\31"; } + +.fa-2::before { + content: "\32"; } + +.fa-3::before { + content: "\33"; } + +.fa-4::before { + content: "\34"; } + +.fa-5::before { + content: "\35"; } + +.fa-6::before { + content: "\36"; } + +.fa-7::before { + content: "\37"; } + +.fa-8::before { + content: "\38"; } + +.fa-9::before { + content: "\39"; } + +.fa-fill-drip::before { + content: "\f576"; } + +.fa-arrows-to-circle::before { + content: "\e4bd"; } + +.fa-circle-chevron-right::before { + content: "\f138"; } + +.fa-chevron-circle-right::before { + content: "\f138"; } + +.fa-at::before { + content: "\40"; } + +.fa-trash-can::before { + content: "\f2ed"; } + +.fa-trash-alt::before { + content: "\f2ed"; } + +.fa-text-height::before { + content: "\f034"; } + +.fa-user-xmark::before { + content: "\f235"; } + +.fa-user-times::before { + content: "\f235"; } + +.fa-stethoscope::before { + content: "\f0f1"; } + +.fa-message::before { + content: "\f27a"; } + +.fa-comment-alt::before { + content: "\f27a"; } + +.fa-info::before { + content: "\f129"; } + +.fa-down-left-and-up-right-to-center::before { + content: "\f422"; } + +.fa-compress-alt::before { + content: "\f422"; } + +.fa-explosion::before { + content: "\e4e9"; } + +.fa-file-lines::before { + content: "\f15c"; } + +.fa-file-alt::before { + content: "\f15c"; } + +.fa-file-text::before { + content: "\f15c"; } + +.fa-wave-square::before { + content: "\f83e"; } + +.fa-ring::before { + content: "\f70b"; } + +.fa-building-un::before { + content: "\e4d9"; } + +.fa-dice-three::before { + content: "\f527"; } + +.fa-calendar-days::before { + content: "\f073"; } + +.fa-calendar-alt::before { + content: "\f073"; } + +.fa-anchor-circle-check::before { + content: "\e4aa"; } + +.fa-building-circle-arrow-right::before { + content: "\e4d1"; } + +.fa-volleyball::before { + content: "\f45f"; } + +.fa-volleyball-ball::before { + content: "\f45f"; } + +.fa-arrows-up-to-line::before { + content: "\e4c2"; } + +.fa-sort-down::before { + content: "\f0dd"; } + +.fa-sort-desc::before { + content: "\f0dd"; } + +.fa-circle-minus::before { + content: "\f056"; } + +.fa-minus-circle::before { + content: "\f056"; } + +.fa-door-open::before { + content: "\f52b"; } + +.fa-right-from-bracket::before { + content: "\f2f5"; } + +.fa-sign-out-alt::before { + content: "\f2f5"; } + +.fa-atom::before { + content: "\f5d2"; } + +.fa-soap::before { + content: "\e06e"; } + +.fa-icons::before { + content: "\f86d"; } + +.fa-heart-music-camera-bolt::before { + content: "\f86d"; } + +.fa-microphone-lines-slash::before { + content: "\f539"; } + +.fa-microphone-alt-slash::before { + content: "\f539"; } + +.fa-bridge-circle-check::before { + content: "\e4c9"; } + +.fa-pump-medical::before { + content: "\e06a"; } + +.fa-fingerprint::before { + content: "\f577"; } + +.fa-hand-point-right::before { + content: "\f0a4"; } + +.fa-magnifying-glass-location::before { + content: "\f689"; } + +.fa-search-location::before { + content: "\f689"; } + +.fa-forward-step::before { + content: "\f051"; } + +.fa-step-forward::before { + content: "\f051"; } + +.fa-face-smile-beam::before { + content: "\f5b8"; } + +.fa-smile-beam::before { + content: "\f5b8"; } + +.fa-flag-checkered::before { + content: "\f11e"; } + +.fa-football::before { + content: "\f44e"; } + +.fa-football-ball::before { + content: "\f44e"; } + +.fa-school-circle-exclamation::before { + content: "\e56c"; } + +.fa-crop::before { + content: "\f125"; } + +.fa-angles-down::before { + content: "\f103"; } + +.fa-angle-double-down::before { + content: "\f103"; } + +.fa-users-rectangle::before { + content: "\e594"; } + +.fa-people-roof::before { + content: "\e537"; } + +.fa-people-line::before { + content: "\e534"; } + +.fa-beer-mug-empty::before { + content: "\f0fc"; } + +.fa-beer::before { + content: "\f0fc"; } + +.fa-diagram-predecessor::before { + content: "\e477"; } + +.fa-arrow-up-long::before { + content: "\f176"; } + +.fa-long-arrow-up::before { + content: "\f176"; } + +.fa-fire-flame-simple::before { + content: "\f46a"; } + +.fa-burn::before { + content: "\f46a"; } + +.fa-person::before { + content: "\f183"; } + +.fa-male::before { + content: "\f183"; } + +.fa-laptop::before { + content: "\f109"; } + +.fa-file-csv::before { + content: "\f6dd"; } + +.fa-menorah::before { + content: "\f676"; } + +.fa-truck-plane::before { + content: "\e58f"; } + +.fa-record-vinyl::before { + content: "\f8d9"; } + +.fa-face-grin-stars::before { + content: "\f587"; } + +.fa-grin-stars::before { + content: "\f587"; } + +.fa-bong::before { + content: "\f55c"; } + +.fa-spaghetti-monster-flying::before { + content: "\f67b"; } + +.fa-pastafarianism::before { + content: "\f67b"; } + +.fa-arrow-down-up-across-line::before { + content: "\e4af"; } + +.fa-spoon::before { + content: "\f2e5"; } + +.fa-utensil-spoon::before { + content: "\f2e5"; } + +.fa-jar-wheat::before { + content: "\e517"; } + +.fa-envelopes-bulk::before { + content: "\f674"; } + +.fa-mail-bulk::before { + content: "\f674"; } + +.fa-file-circle-exclamation::before { + content: "\e4eb"; } + +.fa-circle-h::before { + content: "\f47e"; } + +.fa-hospital-symbol::before { + content: "\f47e"; } + +.fa-pager::before { + content: "\f815"; } + +.fa-address-book::before { + content: "\f2b9"; } + +.fa-contact-book::before { + content: "\f2b9"; } + +.fa-strikethrough::before { + content: "\f0cc"; } + +.fa-k::before { + content: "\4b"; } + +.fa-landmark-flag::before { + content: "\e51c"; } + +.fa-pencil::before { + content: "\f303"; } + +.fa-pencil-alt::before { + content: "\f303"; } + +.fa-backward::before { + content: "\f04a"; } + +.fa-caret-right::before { + content: "\f0da"; } + +.fa-comments::before { + content: "\f086"; } + +.fa-paste::before { + content: "\f0ea"; } + +.fa-file-clipboard::before { + content: "\f0ea"; } + +.fa-code-pull-request::before { + content: "\e13c"; } + +.fa-clipboard-list::before { + content: "\f46d"; } + +.fa-truck-ramp-box::before { + content: "\f4de"; } + +.fa-truck-loading::before { + content: "\f4de"; } + +.fa-user-check::before { + content: "\f4fc"; } + +.fa-vial-virus::before { + content: "\e597"; } + +.fa-sheet-plastic::before { + content: "\e571"; } + +.fa-blog::before { + content: "\f781"; } + +.fa-user-ninja::before { + content: "\f504"; } + +.fa-person-arrow-up-from-line::before { + content: "\e539"; } + +.fa-scroll-torah::before { + content: "\f6a0"; } + +.fa-torah::before { + content: "\f6a0"; } + +.fa-broom-ball::before { + content: "\f458"; } + +.fa-quidditch::before { + content: "\f458"; } + +.fa-quidditch-broom-ball::before { + content: "\f458"; } + +.fa-toggle-off::before { + content: "\f204"; } + +.fa-box-archive::before { + content: "\f187"; } + +.fa-archive::before { + content: "\f187"; } + +.fa-person-drowning::before { + content: "\e545"; } + +.fa-arrow-down-9-1::before { + content: "\f886"; } + +.fa-sort-numeric-desc::before { + content: "\f886"; } + +.fa-sort-numeric-down-alt::before { + content: "\f886"; } + +.fa-face-grin-tongue-squint::before { + content: "\f58a"; } + +.fa-grin-tongue-squint::before { + content: "\f58a"; } + +.fa-spray-can::before { + content: "\f5bd"; } + +.fa-truck-monster::before { + content: "\f63b"; } + +.fa-w::before { + content: "\57"; } + +.fa-earth-africa::before { + content: "\f57c"; } + +.fa-globe-africa::before { + content: "\f57c"; } + +.fa-rainbow::before { + content: "\f75b"; } + +.fa-circle-notch::before { + content: "\f1ce"; } + +.fa-tablet-screen-button::before { + content: "\f3fa"; } + +.fa-tablet-alt::before { + content: "\f3fa"; } + +.fa-paw::before { + content: "\f1b0"; } + +.fa-cloud::before { + content: "\f0c2"; } + +.fa-trowel-bricks::before { + content: "\e58a"; } + +.fa-face-flushed::before { + content: "\f579"; } + +.fa-flushed::before { + content: "\f579"; } + +.fa-hospital-user::before { + content: "\f80d"; } + +.fa-tent-arrow-left-right::before { + content: "\e57f"; } + +.fa-gavel::before { + content: "\f0e3"; } + +.fa-legal::before { + content: "\f0e3"; } + +.fa-binoculars::before { + content: "\f1e5"; } + +.fa-microphone-slash::before { + content: "\f131"; } + +.fa-box-tissue::before { + content: "\e05b"; } + +.fa-motorcycle::before { + content: "\f21c"; } + +.fa-bell-concierge::before { + content: "\f562"; } + +.fa-concierge-bell::before { + content: "\f562"; } + +.fa-pen-ruler::before { + content: "\f5ae"; } + +.fa-pencil-ruler::before { + content: "\f5ae"; } + +.fa-people-arrows::before { + content: "\e068"; } + +.fa-people-arrows-left-right::before { + content: "\e068"; } + +.fa-mars-and-venus-burst::before { + content: "\e523"; } + +.fa-square-caret-right::before { + content: "\f152"; } + +.fa-caret-square-right::before { + content: "\f152"; } + +.fa-scissors::before { + content: "\f0c4"; } + +.fa-cut::before { + content: "\f0c4"; } + +.fa-sun-plant-wilt::before { + content: "\e57a"; } + +.fa-toilets-portable::before { + content: "\e584"; } + +.fa-hockey-puck::before { + content: "\f453"; } + +.fa-table::before { + content: "\f0ce"; } + +.fa-magnifying-glass-arrow-right::before { + content: "\e521"; } + +.fa-tachograph-digital::before { + content: "\f566"; } + +.fa-digital-tachograph::before { + content: "\f566"; } + +.fa-users-slash::before { + content: "\e073"; } + +.fa-clover::before { + content: "\e139"; } + +.fa-reply::before { + content: "\f3e5"; } + +.fa-mail-reply::before { + content: "\f3e5"; } + +.fa-star-and-crescent::before { + content: "\f699"; } + +.fa-house-fire::before { + content: "\e50c"; } + +.fa-square-minus::before { + content: "\f146"; } + +.fa-minus-square::before { + content: "\f146"; } + +.fa-helicopter::before { + content: "\f533"; } + +.fa-compass::before { + content: "\f14e"; } + +.fa-square-caret-down::before { + content: "\f150"; } + +.fa-caret-square-down::before { + content: "\f150"; } + +.fa-file-circle-question::before { + content: "\e4ef"; } + +.fa-laptop-code::before { + content: "\f5fc"; } + +.fa-swatchbook::before { + content: "\f5c3"; } + +.fa-prescription-bottle::before { + content: "\f485"; } + +.fa-bars::before { + content: "\f0c9"; } + +.fa-navicon::before { + content: "\f0c9"; } + +.fa-people-group::before { + content: "\e533"; } + +.fa-hourglass-end::before { + content: "\f253"; } + +.fa-hourglass-3::before { + content: "\f253"; } + +.fa-heart-crack::before { + content: "\f7a9"; } + +.fa-heart-broken::before { + content: "\f7a9"; } + +.fa-square-up-right::before { + content: "\f360"; } + +.fa-external-link-square-alt::before { + content: "\f360"; } + +.fa-face-kiss-beam::before { + content: "\f597"; } + +.fa-kiss-beam::before { + content: "\f597"; } + +.fa-film::before { + content: "\f008"; } + +.fa-ruler-horizontal::before { + content: "\f547"; } + +.fa-people-robbery::before { + content: "\e536"; } + +.fa-lightbulb::before { + content: "\f0eb"; } + +.fa-caret-left::before { + content: "\f0d9"; } + +.fa-circle-exclamation::before { + content: "\f06a"; } + +.fa-exclamation-circle::before { + content: "\f06a"; } + +.fa-school-circle-xmark::before { + content: "\e56d"; } + +.fa-arrow-right-from-bracket::before { + content: "\f08b"; } + +.fa-sign-out::before { + content: "\f08b"; } + +.fa-circle-chevron-down::before { + content: "\f13a"; } + +.fa-chevron-circle-down::before { + content: "\f13a"; } + +.fa-unlock-keyhole::before { + content: "\f13e"; } + +.fa-unlock-alt::before { + content: "\f13e"; } + +.fa-cloud-showers-heavy::before { + content: "\f740"; } + +.fa-headphones-simple::before { + content: "\f58f"; } + +.fa-headphones-alt::before { + content: "\f58f"; } + +.fa-sitemap::before { + content: "\f0e8"; } + +.fa-circle-dollar-to-slot::before { + content: "\f4b9"; } + +.fa-donate::before { + content: "\f4b9"; } + +.fa-memory::before { + content: "\f538"; } + +.fa-road-spikes::before { + content: "\e568"; } + +.fa-fire-burner::before { + content: "\e4f1"; } + +.fa-flag::before { + content: "\f024"; } + +.fa-hanukiah::before { + content: "\f6e6"; } + +.fa-feather::before { + content: "\f52d"; } + +.fa-volume-low::before { + content: "\f027"; } + +.fa-volume-down::before { + content: "\f027"; } + +.fa-comment-slash::before { + content: "\f4b3"; } + +.fa-cloud-sun-rain::before { + content: "\f743"; } + +.fa-compress::before { + content: "\f066"; } + +.fa-wheat-awn::before { + content: "\e2cd"; } + +.fa-wheat-alt::before { + content: "\e2cd"; } + +.fa-ankh::before { + content: "\f644"; } + +.fa-hands-holding-child::before { + content: "\e4fa"; } + +.fa-asterisk::before { + content: "\2a"; } + +.fa-square-check::before { + content: "\f14a"; } + +.fa-check-square::before { + content: "\f14a"; } + +.fa-peseta-sign::before { + content: "\e221"; } + +.fa-heading::before { + content: "\f1dc"; } + +.fa-header::before { + content: "\f1dc"; } + +.fa-ghost::before { + content: "\f6e2"; } + +.fa-list::before { + content: "\f03a"; } + +.fa-list-squares::before { + content: "\f03a"; } + +.fa-square-phone-flip::before { + content: "\f87b"; } + +.fa-phone-square-alt::before { + content: "\f87b"; } + +.fa-cart-plus::before { + content: "\f217"; } + +.fa-gamepad::before { + content: "\f11b"; } + +.fa-circle-dot::before { + content: "\f192"; } + +.fa-dot-circle::before { + content: "\f192"; } + +.fa-face-dizzy::before { + content: "\f567"; } + +.fa-dizzy::before { + content: "\f567"; } + +.fa-egg::before { + content: "\f7fb"; } + +.fa-house-medical-circle-xmark::before { + content: "\e513"; } + +.fa-campground::before { + content: "\f6bb"; } + +.fa-folder-plus::before { + content: "\f65e"; } + +.fa-futbol::before { + content: "\f1e3"; } + +.fa-futbol-ball::before { + content: "\f1e3"; } + +.fa-soccer-ball::before { + content: "\f1e3"; } + +.fa-paintbrush::before { + content: "\f1fc"; } + +.fa-paint-brush::before { + content: "\f1fc"; } + +.fa-lock::before { + content: "\f023"; } + +.fa-gas-pump::before { + content: "\f52f"; } + +.fa-hot-tub-person::before { + content: "\f593"; } + +.fa-hot-tub::before { + content: "\f593"; } + +.fa-map-location::before { + content: "\f59f"; } + +.fa-map-marked::before { + content: "\f59f"; } + +.fa-house-flood-water::before { + content: "\e50e"; } + +.fa-tree::before { + content: "\f1bb"; } + +.fa-bridge-lock::before { + content: "\e4cc"; } + +.fa-sack-dollar::before { + content: "\f81d"; } + +.fa-pen-to-square::before { + content: "\f044"; } + +.fa-edit::before { + content: "\f044"; } + +.fa-car-side::before { + content: "\f5e4"; } + +.fa-share-nodes::before { + content: "\f1e0"; } + +.fa-share-alt::before { + content: "\f1e0"; } + +.fa-heart-circle-minus::before { + content: "\e4ff"; } + +.fa-hourglass-half::before { + content: "\f252"; } + +.fa-hourglass-2::before { + content: "\f252"; } + +.fa-microscope::before { + content: "\f610"; } + +.fa-sink::before { + content: "\e06d"; } + +.fa-bag-shopping::before { + content: "\f290"; } + +.fa-shopping-bag::before { + content: "\f290"; } + +.fa-arrow-down-z-a::before { + content: "\f881"; } + +.fa-sort-alpha-desc::before { + content: "\f881"; } + +.fa-sort-alpha-down-alt::before { + content: "\f881"; } + +.fa-mitten::before { + content: "\f7b5"; } + +.fa-person-rays::before { + content: "\e54d"; } + +.fa-users::before { + content: "\f0c0"; } + +.fa-eye-slash::before { + content: "\f070"; } + +.fa-flask-vial::before { + content: "\e4f3"; } + +.fa-hand::before { + content: "\f256"; } + +.fa-hand-paper::before { + content: "\f256"; } + +.fa-om::before { + content: "\f679"; } + +.fa-worm::before { + content: "\e599"; } + +.fa-house-circle-xmark::before { + content: "\e50b"; } + +.fa-plug::before { + content: "\f1e6"; } + +.fa-chevron-up::before { + content: "\f077"; } + +.fa-hand-spock::before { + content: "\f259"; } + +.fa-stopwatch::before { + content: "\f2f2"; } + +.fa-face-kiss::before { + content: "\f596"; } + +.fa-kiss::before { + content: "\f596"; } + +.fa-bridge-circle-xmark::before { + content: "\e4cb"; } + +.fa-face-grin-tongue::before { + content: "\f589"; } + +.fa-grin-tongue::before { + content: "\f589"; } + +.fa-chess-bishop::before { + content: "\f43a"; } + +.fa-face-grin-wink::before { + content: "\f58c"; } + +.fa-grin-wink::before { + content: "\f58c"; } + +.fa-ear-deaf::before { + content: "\f2a4"; } + +.fa-deaf::before { + content: "\f2a4"; } + +.fa-deafness::before { + content: "\f2a4"; } + +.fa-hard-of-hearing::before { + content: "\f2a4"; } + +.fa-road-circle-check::before { + content: "\e564"; } + +.fa-dice-five::before { + content: "\f523"; } + +.fa-square-rss::before { + content: "\f143"; } + +.fa-rss-square::before { + content: "\f143"; } + +.fa-land-mine-on::before { + content: "\e51b"; } + +.fa-i-cursor::before { + content: "\f246"; } + +.fa-stamp::before { + content: "\f5bf"; } + +.fa-stairs::before { + content: "\e289"; } + +.fa-i::before { + content: "\49"; } + +.fa-hryvnia-sign::before { + content: "\f6f2"; } + +.fa-hryvnia::before { + content: "\f6f2"; } + +.fa-pills::before { + content: "\f484"; } + +.fa-face-grin-wide::before { + content: "\f581"; } + +.fa-grin-alt::before { + content: "\f581"; } + +.fa-tooth::before { + content: "\f5c9"; } + +.fa-v::before { + content: "\56"; } + +.fa-bangladeshi-taka-sign::before { + content: "\e2e6"; } + +.fa-bicycle::before { + content: "\f206"; } + +.fa-staff-snake::before { + content: "\e579"; } + +.fa-rod-asclepius::before { + content: "\e579"; } + +.fa-rod-snake::before { + content: "\e579"; } + +.fa-staff-aesculapius::before { + content: "\e579"; } + +.fa-head-side-cough-slash::before { + content: "\e062"; } + +.fa-truck-medical::before { + content: "\f0f9"; } + +.fa-ambulance::before { + content: "\f0f9"; } + +.fa-wheat-awn-circle-exclamation::before { + content: "\e598"; } + +.fa-snowman::before { + content: "\f7d0"; } + +.fa-mortar-pestle::before { + content: "\f5a7"; } + +.fa-road-barrier::before { + content: "\e562"; } + +.fa-school::before { + content: "\f549"; } + +.fa-igloo::before { + content: "\f7ae"; } + +.fa-joint::before { + content: "\f595"; } + +.fa-angle-right::before { + content: "\f105"; } + +.fa-horse::before { + content: "\f6f0"; } + +.fa-q::before { + content: "\51"; } + +.fa-g::before { + content: "\47"; } + +.fa-notes-medical::before { + content: "\f481"; } + +.fa-temperature-half::before { + content: "\f2c9"; } + +.fa-temperature-2::before { + content: "\f2c9"; } + +.fa-thermometer-2::before { + content: "\f2c9"; } + +.fa-thermometer-half::before { + content: "\f2c9"; } + +.fa-dong-sign::before { + content: "\e169"; } + +.fa-capsules::before { + content: "\f46b"; } + +.fa-poo-storm::before { + content: "\f75a"; } + +.fa-poo-bolt::before { + content: "\f75a"; } + +.fa-face-frown-open::before { + content: "\f57a"; } + +.fa-frown-open::before { + content: "\f57a"; } + +.fa-hand-point-up::before { + content: "\f0a6"; } + +.fa-money-bill::before { + content: "\f0d6"; } + +.fa-bookmark::before { + content: "\f02e"; } + +.fa-align-justify::before { + content: "\f039"; } + +.fa-umbrella-beach::before { + content: "\f5ca"; } + +.fa-helmet-un::before { + content: "\e503"; } + +.fa-bullseye::before { + content: "\f140"; } + +.fa-bacon::before { + content: "\f7e5"; } + +.fa-hand-point-down::before { + content: "\f0a7"; } + +.fa-arrow-up-from-bracket::before { + content: "\e09a"; } + +.fa-folder::before { + content: "\f07b"; } + +.fa-folder-blank::before { + content: "\f07b"; } + +.fa-file-waveform::before { + content: "\f478"; } + +.fa-file-medical-alt::before { + content: "\f478"; } + +.fa-radiation::before { + content: "\f7b9"; } + +.fa-chart-simple::before { + content: "\e473"; } + +.fa-mars-stroke::before { + content: "\f229"; } + +.fa-vial::before { + content: "\f492"; } + +.fa-gauge::before { + content: "\f624"; } + +.fa-dashboard::before { + content: "\f624"; } + +.fa-gauge-med::before { + content: "\f624"; } + +.fa-tachometer-alt-average::before { + content: "\f624"; } + +.fa-wand-magic-sparkles::before { + content: "\e2ca"; } + +.fa-magic-wand-sparkles::before { + content: "\e2ca"; } + +.fa-e::before { + content: "\45"; } + +.fa-pen-clip::before { + content: "\f305"; } + +.fa-pen-alt::before { + content: "\f305"; } + +.fa-bridge-circle-exclamation::before { + content: "\e4ca"; } + +.fa-user::before { + content: "\f007"; } + +.fa-school-circle-check::before { + content: "\e56b"; } + +.fa-dumpster::before { + content: "\f793"; } + +.fa-van-shuttle::before { + content: "\f5b6"; } + +.fa-shuttle-van::before { + content: "\f5b6"; } + +.fa-building-user::before { + content: "\e4da"; } + +.fa-square-caret-left::before { + content: "\f191"; } + +.fa-caret-square-left::before { + content: "\f191"; } + +.fa-highlighter::before { + content: "\f591"; } + +.fa-key::before { + content: "\f084"; } + +.fa-bullhorn::before { + content: "\f0a1"; } + +.fa-globe::before { + content: "\f0ac"; } + +.fa-synagogue::before { + content: "\f69b"; } + +.fa-person-half-dress::before { + content: "\e548"; } + +.fa-road-bridge::before { + content: "\e563"; } + +.fa-location-arrow::before { + content: "\f124"; } + +.fa-c::before { + content: "\43"; } + +.fa-tablet-button::before { + content: "\f10a"; } + +.fa-building-lock::before { + content: "\e4d6"; } + +.fa-pizza-slice::before { + content: "\f818"; } + +.fa-money-bill-wave::before { + content: "\f53a"; } + +.fa-chart-area::before { + content: "\f1fe"; } + +.fa-area-chart::before { + content: "\f1fe"; } + +.fa-house-flag::before { + content: "\e50d"; } + +.fa-person-circle-minus::before { + content: "\e540"; } + +.fa-ban::before { + content: "\f05e"; } + +.fa-cancel::before { + content: "\f05e"; } + +.fa-camera-rotate::before { + content: "\e0d8"; } + +.fa-spray-can-sparkles::before { + content: "\f5d0"; } + +.fa-air-freshener::before { + content: "\f5d0"; } + +.fa-star::before { + content: "\f005"; } + +.fa-repeat::before { + content: "\f363"; } + +.fa-cross::before { + content: "\f654"; } + +.fa-box::before { + content: "\f466"; } + +.fa-venus-mars::before { + content: "\f228"; } + +.fa-arrow-pointer::before { + content: "\f245"; } + +.fa-mouse-pointer::before { + content: "\f245"; } + +.fa-maximize::before { + content: "\f31e"; } + +.fa-expand-arrows-alt::before { + content: "\f31e"; } + +.fa-charging-station::before { + content: "\f5e7"; } + +.fa-shapes::before { + content: "\f61f"; } + +.fa-triangle-circle-square::before { + content: "\f61f"; } + +.fa-shuffle::before { + content: "\f074"; } + +.fa-random::before { + content: "\f074"; } + +.fa-person-running::before { + content: "\f70c"; } + +.fa-running::before { + content: "\f70c"; } + +.fa-mobile-retro::before { + content: "\e527"; } + +.fa-grip-lines-vertical::before { + content: "\f7a5"; } + +.fa-spider::before { + content: "\f717"; } + +.fa-hands-bound::before { + content: "\e4f9"; } + +.fa-file-invoice-dollar::before { + content: "\f571"; } + +.fa-plane-circle-exclamation::before { + content: "\e556"; } + +.fa-x-ray::before { + content: "\f497"; } + +.fa-spell-check::before { + content: "\f891"; } + +.fa-slash::before { + content: "\f715"; } + +.fa-computer-mouse::before { + content: "\f8cc"; } + +.fa-mouse::before { + content: "\f8cc"; } + +.fa-arrow-right-to-bracket::before { + content: "\f090"; } + +.fa-sign-in::before { + content: "\f090"; } + +.fa-shop-slash::before { + content: "\e070"; } + +.fa-store-alt-slash::before { + content: "\e070"; } + +.fa-server::before { + content: "\f233"; } + +.fa-virus-covid-slash::before { + content: "\e4a9"; } + +.fa-shop-lock::before { + content: "\e4a5"; } + +.fa-hourglass-start::before { + content: "\f251"; } + +.fa-hourglass-1::before { + content: "\f251"; } + +.fa-blender-phone::before { + content: "\f6b6"; } + +.fa-building-wheat::before { + content: "\e4db"; } + +.fa-person-breastfeeding::before { + content: "\e53a"; } + +.fa-right-to-bracket::before { + content: "\f2f6"; } + +.fa-sign-in-alt::before { + content: "\f2f6"; } + +.fa-venus::before { + content: "\f221"; } + +.fa-passport::before { + content: "\f5ab"; } + +.fa-heart-pulse::before { + content: "\f21e"; } + +.fa-heartbeat::before { + content: "\f21e"; } + +.fa-people-carry-box::before { + content: "\f4ce"; } + +.fa-people-carry::before { + content: "\f4ce"; } + +.fa-temperature-high::before { + content: "\f769"; } + +.fa-microchip::before { + content: "\f2db"; } + +.fa-crown::before { + content: "\f521"; } + +.fa-weight-hanging::before { + content: "\f5cd"; } + +.fa-xmarks-lines::before { + content: "\e59a"; } + +.fa-file-prescription::before { + content: "\f572"; } + +.fa-weight-scale::before { + content: "\f496"; } + +.fa-weight::before { + content: "\f496"; } + +.fa-user-group::before { + content: "\f500"; } + +.fa-user-friends::before { + content: "\f500"; } + +.fa-arrow-up-a-z::before { + content: "\f15e"; } + +.fa-sort-alpha-up::before { + content: "\f15e"; } + +.fa-chess-knight::before { + content: "\f441"; } + +.fa-face-laugh-squint::before { + content: "\f59b"; } + +.fa-laugh-squint::before { + content: "\f59b"; } + +.fa-wheelchair::before { + content: "\f193"; } + +.fa-circle-arrow-up::before { + content: "\f0aa"; } + +.fa-arrow-circle-up::before { + content: "\f0aa"; } + +.fa-toggle-on::before { + content: "\f205"; } + +.fa-person-walking::before { + content: "\f554"; } + +.fa-walking::before { + content: "\f554"; } + +.fa-l::before { + content: "\4c"; } + +.fa-fire::before { + content: "\f06d"; } + +.fa-bed-pulse::before { + content: "\f487"; } + +.fa-procedures::before { + content: "\f487"; } + +.fa-shuttle-space::before { + content: "\f197"; } + +.fa-space-shuttle::before { + content: "\f197"; } + +.fa-face-laugh::before { + content: "\f599"; } + +.fa-laugh::before { + content: "\f599"; } + +.fa-folder-open::before { + content: "\f07c"; } + +.fa-heart-circle-plus::before { + content: "\e500"; } + +.fa-code-fork::before { + content: "\e13b"; } + +.fa-city::before { + content: "\f64f"; } + +.fa-microphone-lines::before { + content: "\f3c9"; } + +.fa-microphone-alt::before { + content: "\f3c9"; } + +.fa-pepper-hot::before { + content: "\f816"; } + +.fa-unlock::before { + content: "\f09c"; } + +.fa-colon-sign::before { + content: "\e140"; } + +.fa-headset::before { + content: "\f590"; } + +.fa-store-slash::before { + content: "\e071"; } + +.fa-road-circle-xmark::before { + content: "\e566"; } + +.fa-user-minus::before { + content: "\f503"; } + +.fa-mars-stroke-up::before { + content: "\f22a"; } + +.fa-mars-stroke-v::before { + content: "\f22a"; } + +.fa-champagne-glasses::before { + content: "\f79f"; } + +.fa-glass-cheers::before { + content: "\f79f"; } + +.fa-clipboard::before { + content: "\f328"; } + +.fa-house-circle-exclamation::before { + content: "\e50a"; } + +.fa-file-arrow-up::before { + content: "\f574"; } + +.fa-file-upload::before { + content: "\f574"; } + +.fa-wifi::before { + content: "\f1eb"; } + +.fa-wifi-3::before { + content: "\f1eb"; } + +.fa-wifi-strong::before { + content: "\f1eb"; } + +.fa-bath::before { + content: "\f2cd"; } + +.fa-bathtub::before { + content: "\f2cd"; } + +.fa-underline::before { + content: "\f0cd"; } + +.fa-user-pen::before { + content: "\f4ff"; } + +.fa-user-edit::before { + content: "\f4ff"; } + +.fa-signature::before { + content: "\f5b7"; } + +.fa-stroopwafel::before { + content: "\f551"; } + +.fa-bold::before { + content: "\f032"; } + +.fa-anchor-lock::before { + content: "\e4ad"; } + +.fa-building-ngo::before { + content: "\e4d7"; } + +.fa-manat-sign::before { + content: "\e1d5"; } + +.fa-not-equal::before { + content: "\f53e"; } + +.fa-border-top-left::before { + content: "\f853"; } + +.fa-border-style::before { + content: "\f853"; } + +.fa-map-location-dot::before { + content: "\f5a0"; } + +.fa-map-marked-alt::before { + content: "\f5a0"; } + +.fa-jedi::before { + content: "\f669"; } + +.fa-square-poll-vertical::before { + content: "\f681"; } + +.fa-poll::before { + content: "\f681"; } + +.fa-mug-hot::before { + content: "\f7b6"; } + +.fa-car-battery::before { + content: "\f5df"; } + +.fa-battery-car::before { + content: "\f5df"; } + +.fa-gift::before { + content: "\f06b"; } + +.fa-dice-two::before { + content: "\f528"; } + +.fa-chess-queen::before { + content: "\f445"; } + +.fa-glasses::before { + content: "\f530"; } + +.fa-chess-board::before { + content: "\f43c"; } + +.fa-building-circle-check::before { + content: "\e4d2"; } + +.fa-person-chalkboard::before { + content: "\e53d"; } + +.fa-mars-stroke-right::before { + content: "\f22b"; } + +.fa-mars-stroke-h::before { + content: "\f22b"; } + +.fa-hand-back-fist::before { + content: "\f255"; } + +.fa-hand-rock::before { + content: "\f255"; } + +.fa-square-caret-up::before { + content: "\f151"; } + +.fa-caret-square-up::before { + content: "\f151"; } + +.fa-cloud-showers-water::before { + content: "\e4e4"; } + +.fa-chart-bar::before { + content: "\f080"; } + +.fa-bar-chart::before { + content: "\f080"; } + +.fa-hands-bubbles::before { + content: "\e05e"; } + +.fa-hands-wash::before { + content: "\e05e"; } + +.fa-less-than-equal::before { + content: "\f537"; } + +.fa-train::before { + content: "\f238"; } + +.fa-eye-low-vision::before { + content: "\f2a8"; } + +.fa-low-vision::before { + content: "\f2a8"; } + +.fa-crow::before { + content: "\f520"; } + +.fa-sailboat::before { + content: "\e445"; } + +.fa-window-restore::before { + content: "\f2d2"; } + +.fa-square-plus::before { + content: "\f0fe"; } + +.fa-plus-square::before { + content: "\f0fe"; } + +.fa-torii-gate::before { + content: "\f6a1"; } + +.fa-frog::before { + content: "\f52e"; } + +.fa-bucket::before { + content: "\e4cf"; } + +.fa-image::before { + content: "\f03e"; } + +.fa-microphone::before { + content: "\f130"; } + +.fa-cow::before { + content: "\f6c8"; } + +.fa-caret-up::before { + content: "\f0d8"; } + +.fa-screwdriver::before { + content: "\f54a"; } + +.fa-folder-closed::before { + content: "\e185"; } + +.fa-house-tsunami::before { + content: "\e515"; } + +.fa-square-nfi::before { + content: "\e576"; } + +.fa-arrow-up-from-ground-water::before { + content: "\e4b5"; } + +.fa-martini-glass::before { + content: "\f57b"; } + +.fa-glass-martini-alt::before { + content: "\f57b"; } + +.fa-rotate-left::before { + content: "\f2ea"; } + +.fa-rotate-back::before { + content: "\f2ea"; } + +.fa-rotate-backward::before { + content: "\f2ea"; } + +.fa-undo-alt::before { + content: "\f2ea"; } + +.fa-table-columns::before { + content: "\f0db"; } + +.fa-columns::before { + content: "\f0db"; } + +.fa-lemon::before { + content: "\f094"; } + +.fa-head-side-mask::before { + content: "\e063"; } + +.fa-handshake::before { + content: "\f2b5"; } + +.fa-gem::before { + content: "\f3a5"; } + +.fa-dolly::before { + content: "\f472"; } + +.fa-dolly-box::before { + content: "\f472"; } + +.fa-smoking::before { + content: "\f48d"; } + +.fa-minimize::before { + content: "\f78c"; } + +.fa-compress-arrows-alt::before { + content: "\f78c"; } + +.fa-monument::before { + content: "\f5a6"; } + +.fa-snowplow::before { + content: "\f7d2"; } + +.fa-angles-right::before { + content: "\f101"; } + +.fa-angle-double-right::before { + content: "\f101"; } + +.fa-cannabis::before { + content: "\f55f"; } + +.fa-circle-play::before { + content: "\f144"; } + +.fa-play-circle::before { + content: "\f144"; } + +.fa-tablets::before { + content: "\f490"; } + +.fa-ethernet::before { + content: "\f796"; } + +.fa-euro-sign::before { + content: "\f153"; } + +.fa-eur::before { + content: "\f153"; } + +.fa-euro::before { + content: "\f153"; } + +.fa-chair::before { + content: "\f6c0"; } + +.fa-circle-check::before { + content: "\f058"; } + +.fa-check-circle::before { + content: "\f058"; } + +.fa-circle-stop::before { + content: "\f28d"; } + +.fa-stop-circle::before { + content: "\f28d"; } + +.fa-compass-drafting::before { + content: "\f568"; } + +.fa-drafting-compass::before { + content: "\f568"; } + +.fa-plate-wheat::before { + content: "\e55a"; } + +.fa-icicles::before { + content: "\f7ad"; } + +.fa-person-shelter::before { + content: "\e54f"; } + +.fa-neuter::before { + content: "\f22c"; } + +.fa-id-badge::before { + content: "\f2c1"; } + +.fa-marker::before { + content: "\f5a1"; } + +.fa-face-laugh-beam::before { + content: "\f59a"; } + +.fa-laugh-beam::before { + content: "\f59a"; } + +.fa-helicopter-symbol::before { + content: "\e502"; } + +.fa-universal-access::before { + content: "\f29a"; } + +.fa-circle-chevron-up::before { + content: "\f139"; } + +.fa-chevron-circle-up::before { + content: "\f139"; } + +.fa-lari-sign::before { + content: "\e1c8"; } + +.fa-volcano::before { + content: "\f770"; } + +.fa-person-walking-dashed-line-arrow-right::before { + content: "\e553"; } + +.fa-sterling-sign::before { + content: "\f154"; } + +.fa-gbp::before { + content: "\f154"; } + +.fa-pound-sign::before { + content: "\f154"; } + +.fa-viruses::before { + content: "\e076"; } + +.fa-square-person-confined::before { + content: "\e577"; } + +.fa-user-tie::before { + content: "\f508"; } + +.fa-arrow-down-long::before { + content: "\f175"; } + +.fa-long-arrow-down::before { + content: "\f175"; } + +.fa-tent-arrow-down-to-line::before { + content: "\e57e"; } + +.fa-certificate::before { + content: "\f0a3"; } + +.fa-reply-all::before { + content: "\f122"; } + +.fa-mail-reply-all::before { + content: "\f122"; } + +.fa-suitcase::before { + content: "\f0f2"; } + +.fa-person-skating::before { + content: "\f7c5"; } + +.fa-skating::before { + content: "\f7c5"; } + +.fa-filter-circle-dollar::before { + content: "\f662"; } + +.fa-funnel-dollar::before { + content: "\f662"; } + +.fa-camera-retro::before { + content: "\f083"; } + +.fa-circle-arrow-down::before { + content: "\f0ab"; } + +.fa-arrow-circle-down::before { + content: "\f0ab"; } + +.fa-file-import::before { + content: "\f56f"; } + +.fa-arrow-right-to-file::before { + content: "\f56f"; } + +.fa-square-arrow-up-right::before { + content: "\f14c"; } + +.fa-external-link-square::before { + content: "\f14c"; } + +.fa-box-open::before { + content: "\f49e"; } + +.fa-scroll::before { + content: "\f70e"; } + +.fa-spa::before { + content: "\f5bb"; } + +.fa-location-pin-lock::before { + content: "\e51f"; } + +.fa-pause::before { + content: "\f04c"; } + +.fa-hill-avalanche::before { + content: "\e507"; } + +.fa-temperature-empty::before { + content: "\f2cb"; } + +.fa-temperature-0::before { + content: "\f2cb"; } + +.fa-thermometer-0::before { + content: "\f2cb"; } + +.fa-thermometer-empty::before { + content: "\f2cb"; } + +.fa-bomb::before { + content: "\f1e2"; } + +.fa-registered::before { + content: "\f25d"; } + +.fa-address-card::before { + content: "\f2bb"; } + +.fa-contact-card::before { + content: "\f2bb"; } + +.fa-vcard::before { + content: "\f2bb"; } + +.fa-scale-unbalanced-flip::before { + content: "\f516"; } + +.fa-balance-scale-right::before { + content: "\f516"; } + +.fa-subscript::before { + content: "\f12c"; } + +.fa-diamond-turn-right::before { + content: "\f5eb"; } + +.fa-directions::before { + content: "\f5eb"; } + +.fa-burst::before { + content: "\e4dc"; } + +.fa-house-laptop::before { + content: "\e066"; } + +.fa-laptop-house::before { + content: "\e066"; } + +.fa-face-tired::before { + content: "\f5c8"; } + +.fa-tired::before { + content: "\f5c8"; } + +.fa-money-bills::before { + content: "\e1f3"; } + +.fa-smog::before { + content: "\f75f"; } + +.fa-crutch::before { + content: "\f7f7"; } + +.fa-cloud-arrow-up::before { + content: "\f0ee"; } + +.fa-cloud-upload::before { + content: "\f0ee"; } + +.fa-cloud-upload-alt::before { + content: "\f0ee"; } + +.fa-palette::before { + content: "\f53f"; } + +.fa-arrows-turn-right::before { + content: "\e4c0"; } + +.fa-vest::before { + content: "\e085"; } + +.fa-ferry::before { + content: "\e4ea"; } + +.fa-arrows-down-to-people::before { + content: "\e4b9"; } + +.fa-seedling::before { + content: "\f4d8"; } + +.fa-sprout::before { + content: "\f4d8"; } + +.fa-left-right::before { + content: "\f337"; } + +.fa-arrows-alt-h::before { + content: "\f337"; } + +.fa-boxes-packing::before { + content: "\e4c7"; } + +.fa-circle-arrow-left::before { + content: "\f0a8"; } + +.fa-arrow-circle-left::before { + content: "\f0a8"; } + +.fa-group-arrows-rotate::before { + content: "\e4f6"; } + +.fa-bowl-food::before { + content: "\e4c6"; } + +.fa-candy-cane::before { + content: "\f786"; } + +.fa-arrow-down-wide-short::before { + content: "\f160"; } + +.fa-sort-amount-asc::before { + content: "\f160"; } + +.fa-sort-amount-down::before { + content: "\f160"; } + +.fa-cloud-bolt::before { + content: "\f76c"; } + +.fa-thunderstorm::before { + content: "\f76c"; } + +.fa-text-slash::before { + content: "\f87d"; } + +.fa-remove-format::before { + content: "\f87d"; } + +.fa-face-smile-wink::before { + content: "\f4da"; } + +.fa-smile-wink::before { + content: "\f4da"; } + +.fa-file-word::before { + content: "\f1c2"; } + +.fa-file-powerpoint::before { + content: "\f1c4"; } + +.fa-arrows-left-right::before { + content: "\f07e"; } + +.fa-arrows-h::before { + content: "\f07e"; } + +.fa-house-lock::before { + content: "\e510"; } + +.fa-cloud-arrow-down::before { + content: "\f0ed"; } + +.fa-cloud-download::before { + content: "\f0ed"; } + +.fa-cloud-download-alt::before { + content: "\f0ed"; } + +.fa-children::before { + content: "\e4e1"; } + +.fa-chalkboard::before { + content: "\f51b"; } + +.fa-blackboard::before { + content: "\f51b"; } + +.fa-user-large-slash::before { + content: "\f4fa"; } + +.fa-user-alt-slash::before { + content: "\f4fa"; } + +.fa-envelope-open::before { + content: "\f2b6"; } + +.fa-handshake-simple-slash::before { + content: "\e05f"; } + +.fa-handshake-alt-slash::before { + content: "\e05f"; } + +.fa-mattress-pillow::before { + content: "\e525"; } + +.fa-guarani-sign::before { + content: "\e19a"; } + +.fa-arrows-rotate::before { + content: "\f021"; } + +.fa-refresh::before { + content: "\f021"; } + +.fa-sync::before { + content: "\f021"; } + +.fa-fire-extinguisher::before { + content: "\f134"; } + +.fa-cruzeiro-sign::before { + content: "\e152"; } + +.fa-greater-than-equal::before { + content: "\f532"; } + +.fa-shield-halved::before { + content: "\f3ed"; } + +.fa-shield-alt::before { + content: "\f3ed"; } + +.fa-book-atlas::before { + content: "\f558"; } + +.fa-atlas::before { + content: "\f558"; } + +.fa-virus::before { + content: "\e074"; } + +.fa-envelope-circle-check::before { + content: "\e4e8"; } + +.fa-layer-group::before { + content: "\f5fd"; } + +.fa-arrows-to-dot::before { + content: "\e4be"; } + +.fa-archway::before { + content: "\f557"; } + +.fa-heart-circle-check::before { + content: "\e4fd"; } + +.fa-house-chimney-crack::before { + content: "\f6f1"; } + +.fa-house-damage::before { + content: "\f6f1"; } + +.fa-file-zipper::before { + content: "\f1c6"; } + +.fa-file-archive::before { + content: "\f1c6"; } + +.fa-square::before { + content: "\f0c8"; } + +.fa-martini-glass-empty::before { + content: "\f000"; } + +.fa-glass-martini::before { + content: "\f000"; } + +.fa-couch::before { + content: "\f4b8"; } + +.fa-cedi-sign::before { + content: "\e0df"; } + +.fa-italic::before { + content: "\f033"; } + +.fa-table-cells-column-lock::before { + content: "\e678"; } + +.fa-church::before { + content: "\f51d"; } + +.fa-comments-dollar::before { + content: "\f653"; } + +.fa-democrat::before { + content: "\f747"; } + +.fa-z::before { + content: "\5a"; } + +.fa-person-skiing::before { + content: "\f7c9"; } + +.fa-skiing::before { + content: "\f7c9"; } + +.fa-road-lock::before { + content: "\e567"; } + +.fa-a::before { + content: "\41"; } + +.fa-temperature-arrow-down::before { + content: "\e03f"; } + +.fa-temperature-down::before { + content: "\e03f"; } + +.fa-feather-pointed::before { + content: "\f56b"; } + +.fa-feather-alt::before { + content: "\f56b"; } + +.fa-p::before { + content: "\50"; } + +.fa-snowflake::before { + content: "\f2dc"; } + +.fa-newspaper::before { + content: "\f1ea"; } + +.fa-rectangle-ad::before { + content: "\f641"; } + +.fa-ad::before { + content: "\f641"; } + +.fa-circle-arrow-right::before { + content: "\f0a9"; } + +.fa-arrow-circle-right::before { + content: "\f0a9"; } + +.fa-filter-circle-xmark::before { + content: "\e17b"; } + +.fa-locust::before { + content: "\e520"; } + +.fa-sort::before { + content: "\f0dc"; } + +.fa-unsorted::before { + content: "\f0dc"; } + +.fa-list-ol::before { + content: "\f0cb"; } + +.fa-list-1-2::before { + content: "\f0cb"; } + +.fa-list-numeric::before { + content: "\f0cb"; } + +.fa-person-dress-burst::before { + content: "\e544"; } + +.fa-money-check-dollar::before { + content: "\f53d"; } + +.fa-money-check-alt::before { + content: "\f53d"; } + +.fa-vector-square::before { + content: "\f5cb"; } + +.fa-bread-slice::before { + content: "\f7ec"; } + +.fa-language::before { + content: "\f1ab"; } + +.fa-face-kiss-wink-heart::before { + content: "\f598"; } + +.fa-kiss-wink-heart::before { + content: "\f598"; } + +.fa-filter::before { + content: "\f0b0"; } + +.fa-question::before { + content: "\3f"; } + +.fa-file-signature::before { + content: "\f573"; } + +.fa-up-down-left-right::before { + content: "\f0b2"; } + +.fa-arrows-alt::before { + content: "\f0b2"; } + +.fa-house-chimney-user::before { + content: "\e065"; } + +.fa-hand-holding-heart::before { + content: "\f4be"; } + +.fa-puzzle-piece::before { + content: "\f12e"; } + +.fa-money-check::before { + content: "\f53c"; } + +.fa-star-half-stroke::before { + content: "\f5c0"; } + +.fa-star-half-alt::before { + content: "\f5c0"; } + +.fa-code::before { + content: "\f121"; } + +.fa-whiskey-glass::before { + content: "\f7a0"; } + +.fa-glass-whiskey::before { + content: "\f7a0"; } + +.fa-building-circle-exclamation::before { + content: "\e4d3"; } + +.fa-magnifying-glass-chart::before { + content: "\e522"; } + +.fa-arrow-up-right-from-square::before { + content: "\f08e"; } + +.fa-external-link::before { + content: "\f08e"; } + +.fa-cubes-stacked::before { + content: "\e4e6"; } + +.fa-won-sign::before { + content: "\f159"; } + +.fa-krw::before { + content: "\f159"; } + +.fa-won::before { + content: "\f159"; } + +.fa-virus-covid::before { + content: "\e4a8"; } + +.fa-austral-sign::before { + content: "\e0a9"; } + +.fa-f::before { + content: "\46"; } + +.fa-leaf::before { + content: "\f06c"; } + +.fa-road::before { + content: "\f018"; } + +.fa-taxi::before { + content: "\f1ba"; } + +.fa-cab::before { + content: "\f1ba"; } + +.fa-person-circle-plus::before { + content: "\e541"; } + +.fa-chart-pie::before { + content: "\f200"; } + +.fa-pie-chart::before { + content: "\f200"; } + +.fa-bolt-lightning::before { + content: "\e0b7"; } + +.fa-sack-xmark::before { + content: "\e56a"; } + +.fa-file-excel::before { + content: "\f1c3"; } + +.fa-file-contract::before { + content: "\f56c"; } + +.fa-fish-fins::before { + content: "\e4f2"; } + +.fa-building-flag::before { + content: "\e4d5"; } + +.fa-face-grin-beam::before { + content: "\f582"; } + +.fa-grin-beam::before { + content: "\f582"; } + +.fa-object-ungroup::before { + content: "\f248"; } + +.fa-poop::before { + content: "\f619"; } + +.fa-location-pin::before { + content: "\f041"; } + +.fa-map-marker::before { + content: "\f041"; } + +.fa-kaaba::before { + content: "\f66b"; } + +.fa-toilet-paper::before { + content: "\f71e"; } + +.fa-helmet-safety::before { + content: "\f807"; } + +.fa-hard-hat::before { + content: "\f807"; } + +.fa-hat-hard::before { + content: "\f807"; } + +.fa-eject::before { + content: "\f052"; } + +.fa-circle-right::before { + content: "\f35a"; } + +.fa-arrow-alt-circle-right::before { + content: "\f35a"; } + +.fa-plane-circle-check::before { + content: "\e555"; } + +.fa-face-rolling-eyes::before { + content: "\f5a5"; } + +.fa-meh-rolling-eyes::before { + content: "\f5a5"; } + +.fa-object-group::before { + content: "\f247"; } + +.fa-chart-line::before { + content: "\f201"; } + +.fa-line-chart::before { + content: "\f201"; } + +.fa-mask-ventilator::before { + content: "\e524"; } + +.fa-arrow-right::before { + content: "\f061"; } + +.fa-signs-post::before { + content: "\f277"; } + +.fa-map-signs::before { + content: "\f277"; } + +.fa-cash-register::before { + content: "\f788"; } + +.fa-person-circle-question::before { + content: "\e542"; } + +.fa-h::before { + content: "\48"; } + +.fa-tarp::before { + content: "\e57b"; } + +.fa-screwdriver-wrench::before { + content: "\f7d9"; } + +.fa-tools::before { + content: "\f7d9"; } + +.fa-arrows-to-eye::before { + content: "\e4bf"; } + +.fa-plug-circle-bolt::before { + content: "\e55b"; } + +.fa-heart::before { + content: "\f004"; } + +.fa-mars-and-venus::before { + content: "\f224"; } + +.fa-house-user::before { + content: "\e1b0"; } + +.fa-home-user::before { + content: "\e1b0"; } + +.fa-dumpster-fire::before { + content: "\f794"; } + +.fa-house-crack::before { + content: "\e3b1"; } + +.fa-martini-glass-citrus::before { + content: "\f561"; } + +.fa-cocktail::before { + content: "\f561"; } + +.fa-face-surprise::before { + content: "\f5c2"; } + +.fa-surprise::before { + content: "\f5c2"; } + +.fa-bottle-water::before { + content: "\e4c5"; } + +.fa-circle-pause::before { + content: "\f28b"; } + +.fa-pause-circle::before { + content: "\f28b"; } + +.fa-toilet-paper-slash::before { + content: "\e072"; } + +.fa-apple-whole::before { + content: "\f5d1"; } + +.fa-apple-alt::before { + content: "\f5d1"; } + +.fa-kitchen-set::before { + content: "\e51a"; } + +.fa-r::before { + content: "\52"; } + +.fa-temperature-quarter::before { + content: "\f2ca"; } + +.fa-temperature-1::before { + content: "\f2ca"; } + +.fa-thermometer-1::before { + content: "\f2ca"; } + +.fa-thermometer-quarter::before { + content: "\f2ca"; } + +.fa-cube::before { + content: "\f1b2"; } + +.fa-bitcoin-sign::before { + content: "\e0b4"; } + +.fa-shield-dog::before { + content: "\e573"; } + +.fa-solar-panel::before { + content: "\f5ba"; } + +.fa-lock-open::before { + content: "\f3c1"; } + +.fa-elevator::before { + content: "\e16d"; } + +.fa-money-bill-transfer::before { + content: "\e528"; } + +.fa-money-bill-trend-up::before { + content: "\e529"; } + +.fa-house-flood-water-circle-arrow-right::before { + content: "\e50f"; } + +.fa-square-poll-horizontal::before { + content: "\f682"; } + +.fa-poll-h::before { + content: "\f682"; } + +.fa-circle::before { + content: "\f111"; } + +.fa-backward-fast::before { + content: "\f049"; } + +.fa-fast-backward::before { + content: "\f049"; } + +.fa-recycle::before { + content: "\f1b8"; } + +.fa-user-astronaut::before { + content: "\f4fb"; } + +.fa-plane-slash::before { + content: "\e069"; } + +.fa-trademark::before { + content: "\f25c"; } + +.fa-basketball::before { + content: "\f434"; } + +.fa-basketball-ball::before { + content: "\f434"; } + +.fa-satellite-dish::before { + content: "\f7c0"; } + +.fa-circle-up::before { + content: "\f35b"; } + +.fa-arrow-alt-circle-up::before { + content: "\f35b"; } + +.fa-mobile-screen-button::before { + content: "\f3cd"; } + +.fa-mobile-alt::before { + content: "\f3cd"; } + +.fa-volume-high::before { + content: "\f028"; } + +.fa-volume-up::before { + content: "\f028"; } + +.fa-users-rays::before { + content: "\e593"; } + +.fa-wallet::before { + content: "\f555"; } + +.fa-clipboard-check::before { + content: "\f46c"; } + +.fa-file-audio::before { + content: "\f1c7"; } + +.fa-burger::before { + content: "\f805"; } + +.fa-hamburger::before { + content: "\f805"; } + +.fa-wrench::before { + content: "\f0ad"; } + +.fa-bugs::before { + content: "\e4d0"; } + +.fa-rupee-sign::before { + content: "\f156"; } + +.fa-rupee::before { + content: "\f156"; } + +.fa-file-image::before { + content: "\f1c5"; } + +.fa-circle-question::before { + content: "\f059"; } + +.fa-question-circle::before { + content: "\f059"; } + +.fa-plane-departure::before { + content: "\f5b0"; } + +.fa-handshake-slash::before { + content: "\e060"; } + +.fa-book-bookmark::before { + content: "\e0bb"; } + +.fa-code-branch::before { + content: "\f126"; } + +.fa-hat-cowboy::before { + content: "\f8c0"; } + +.fa-bridge::before { + content: "\e4c8"; } + +.fa-phone-flip::before { + content: "\f879"; } + +.fa-phone-alt::before { + content: "\f879"; } + +.fa-truck-front::before { + content: "\e2b7"; } + +.fa-cat::before { + content: "\f6be"; } + +.fa-anchor-circle-exclamation::before { + content: "\e4ab"; } + +.fa-truck-field::before { + content: "\e58d"; } + +.fa-route::before { + content: "\f4d7"; } + +.fa-clipboard-question::before { + content: "\e4e3"; } + +.fa-panorama::before { + content: "\e209"; } + +.fa-comment-medical::before { + content: "\f7f5"; } + +.fa-teeth-open::before { + content: "\f62f"; } + +.fa-file-circle-minus::before { + content: "\e4ed"; } + +.fa-tags::before { + content: "\f02c"; } + +.fa-wine-glass::before { + content: "\f4e3"; } + +.fa-forward-fast::before { + content: "\f050"; } + +.fa-fast-forward::before { + content: "\f050"; } + +.fa-face-meh-blank::before { + content: "\f5a4"; } + +.fa-meh-blank::before { + content: "\f5a4"; } + +.fa-square-parking::before { + content: "\f540"; } + +.fa-parking::before { + content: "\f540"; } + +.fa-house-signal::before { + content: "\e012"; } + +.fa-bars-progress::before { + content: "\f828"; } + +.fa-tasks-alt::before { + content: "\f828"; } + +.fa-faucet-drip::before { + content: "\e006"; } + +.fa-cart-flatbed::before { + content: "\f474"; } + +.fa-dolly-flatbed::before { + content: "\f474"; } + +.fa-ban-smoking::before { + content: "\f54d"; } + +.fa-smoking-ban::before { + content: "\f54d"; } + +.fa-terminal::before { + content: "\f120"; } + +.fa-mobile-button::before { + content: "\f10b"; } + +.fa-house-medical-flag::before { + content: "\e514"; } + +.fa-basket-shopping::before { + content: "\f291"; } + +.fa-shopping-basket::before { + content: "\f291"; } + +.fa-tape::before { + content: "\f4db"; } + +.fa-bus-simple::before { + content: "\f55e"; } + +.fa-bus-alt::before { + content: "\f55e"; } + +.fa-eye::before { + content: "\f06e"; } + +.fa-face-sad-cry::before { + content: "\f5b3"; } + +.fa-sad-cry::before { + content: "\f5b3"; } + +.fa-audio-description::before { + content: "\f29e"; } + +.fa-person-military-to-person::before { + content: "\e54c"; } + +.fa-file-shield::before { + content: "\e4f0"; } + +.fa-user-slash::before { + content: "\f506"; } + +.fa-pen::before { + content: "\f304"; } + +.fa-tower-observation::before { + content: "\e586"; } + +.fa-file-code::before { + content: "\f1c9"; } + +.fa-signal::before { + content: "\f012"; } + +.fa-signal-5::before { + content: "\f012"; } + +.fa-signal-perfect::before { + content: "\f012"; } + +.fa-bus::before { + content: "\f207"; } + +.fa-heart-circle-xmark::before { + content: "\e501"; } + +.fa-house-chimney::before { + content: "\e3af"; } + +.fa-home-lg::before { + content: "\e3af"; } + +.fa-window-maximize::before { + content: "\f2d0"; } + +.fa-face-frown::before { + content: "\f119"; } + +.fa-frown::before { + content: "\f119"; } + +.fa-prescription::before { + content: "\f5b1"; } + +.fa-shop::before { + content: "\f54f"; } + +.fa-store-alt::before { + content: "\f54f"; } + +.fa-floppy-disk::before { + content: "\f0c7"; } + +.fa-save::before { + content: "\f0c7"; } + +.fa-vihara::before { + content: "\f6a7"; } + +.fa-scale-unbalanced::before { + content: "\f515"; } + +.fa-balance-scale-left::before { + content: "\f515"; } + +.fa-sort-up::before { + content: "\f0de"; } + +.fa-sort-asc::before { + content: "\f0de"; } + +.fa-comment-dots::before { + content: "\f4ad"; } + +.fa-commenting::before { + content: "\f4ad"; } + +.fa-plant-wilt::before { + content: "\e5aa"; } + +.fa-diamond::before { + content: "\f219"; } + +.fa-face-grin-squint::before { + content: "\f585"; } + +.fa-grin-squint::before { + content: "\f585"; } + +.fa-hand-holding-dollar::before { + content: "\f4c0"; } + +.fa-hand-holding-usd::before { + content: "\f4c0"; } + +.fa-bacterium::before { + content: "\e05a"; } + +.fa-hand-pointer::before { + content: "\f25a"; } + +.fa-drum-steelpan::before { + content: "\f56a"; } + +.fa-hand-scissors::before { + content: "\f257"; } + +.fa-hands-praying::before { + content: "\f684"; } + +.fa-praying-hands::before { + content: "\f684"; } + +.fa-arrow-rotate-right::before { + content: "\f01e"; } + +.fa-arrow-right-rotate::before { + content: "\f01e"; } + +.fa-arrow-rotate-forward::before { + content: "\f01e"; } + +.fa-redo::before { + content: "\f01e"; } + +.fa-biohazard::before { + content: "\f780"; } + +.fa-location-crosshairs::before { + content: "\f601"; } + +.fa-location::before { + content: "\f601"; } + +.fa-mars-double::before { + content: "\f227"; } + +.fa-child-dress::before { + content: "\e59c"; } + +.fa-users-between-lines::before { + content: "\e591"; } + +.fa-lungs-virus::before { + content: "\e067"; } + +.fa-face-grin-tears::before { + content: "\f588"; } + +.fa-grin-tears::before { + content: "\f588"; } + +.fa-phone::before { + content: "\f095"; } + +.fa-calendar-xmark::before { + content: "\f273"; } + +.fa-calendar-times::before { + content: "\f273"; } + +.fa-child-reaching::before { + content: "\e59d"; } + +.fa-head-side-virus::before { + content: "\e064"; } + +.fa-user-gear::before { + content: "\f4fe"; } + +.fa-user-cog::before { + content: "\f4fe"; } + +.fa-arrow-up-1-9::before { + content: "\f163"; } + +.fa-sort-numeric-up::before { + content: "\f163"; } + +.fa-door-closed::before { + content: "\f52a"; } + +.fa-shield-virus::before { + content: "\e06c"; } + +.fa-dice-six::before { + content: "\f526"; } + +.fa-mosquito-net::before { + content: "\e52c"; } + +.fa-bridge-water::before { + content: "\e4ce"; } + +.fa-person-booth::before { + content: "\f756"; } + +.fa-text-width::before { + content: "\f035"; } + +.fa-hat-wizard::before { + content: "\f6e8"; } + +.fa-pen-fancy::before { + content: "\f5ac"; } + +.fa-person-digging::before { + content: "\f85e"; } + +.fa-digging::before { + content: "\f85e"; } + +.fa-trash::before { + content: "\f1f8"; } + +.fa-gauge-simple::before { + content: "\f629"; } + +.fa-gauge-simple-med::before { + content: "\f629"; } + +.fa-tachometer-average::before { + content: "\f629"; } + +.fa-book-medical::before { + content: "\f7e6"; } + +.fa-poo::before { + content: "\f2fe"; } + +.fa-quote-right::before { + content: "\f10e"; } + +.fa-quote-right-alt::before { + content: "\f10e"; } + +.fa-shirt::before { + content: "\f553"; } + +.fa-t-shirt::before { + content: "\f553"; } + +.fa-tshirt::before { + content: "\f553"; } + +.fa-cubes::before { + content: "\f1b3"; } + +.fa-divide::before { + content: "\f529"; } + +.fa-tenge-sign::before { + content: "\f7d7"; } + +.fa-tenge::before { + content: "\f7d7"; } + +.fa-headphones::before { + content: "\f025"; } + +.fa-hands-holding::before { + content: "\f4c2"; } + +.fa-hands-clapping::before { + content: "\e1a8"; } + +.fa-republican::before { + content: "\f75e"; } + +.fa-arrow-left::before { + content: "\f060"; } + +.fa-person-circle-xmark::before { + content: "\e543"; } + +.fa-ruler::before { + content: "\f545"; } + +.fa-align-left::before { + content: "\f036"; } + +.fa-dice-d6::before { + content: "\f6d1"; } + +.fa-restroom::before { + content: "\f7bd"; } + +.fa-j::before { + content: "\4a"; } + +.fa-users-viewfinder::before { + content: "\e595"; } + +.fa-file-video::before { + content: "\f1c8"; } + +.fa-up-right-from-square::before { + content: "\f35d"; } + +.fa-external-link-alt::before { + content: "\f35d"; } + +.fa-table-cells::before { + content: "\f00a"; } + +.fa-th::before { + content: "\f00a"; } + +.fa-file-pdf::before { + content: "\f1c1"; } + +.fa-book-bible::before { + content: "\f647"; } + +.fa-bible::before { + content: "\f647"; } + +.fa-o::before { + content: "\4f"; } + +.fa-suitcase-medical::before { + content: "\f0fa"; } + +.fa-medkit::before { + content: "\f0fa"; } + +.fa-user-secret::before { + content: "\f21b"; } + +.fa-otter::before { + content: "\f700"; } + +.fa-person-dress::before { + content: "\f182"; } + +.fa-female::before { + content: "\f182"; } + +.fa-comment-dollar::before { + content: "\f651"; } + +.fa-business-time::before { + content: "\f64a"; } + +.fa-briefcase-clock::before { + content: "\f64a"; } + +.fa-table-cells-large::before { + content: "\f009"; } + +.fa-th-large::before { + content: "\f009"; } + +.fa-book-tanakh::before { + content: "\f827"; } + +.fa-tanakh::before { + content: "\f827"; } + +.fa-phone-volume::before { + content: "\f2a0"; } + +.fa-volume-control-phone::before { + content: "\f2a0"; } + +.fa-hat-cowboy-side::before { + content: "\f8c1"; } + +.fa-clipboard-user::before { + content: "\f7f3"; } + +.fa-child::before { + content: "\f1ae"; } + +.fa-lira-sign::before { + content: "\f195"; } + +.fa-satellite::before { + content: "\f7bf"; } + +.fa-plane-lock::before { + content: "\e558"; } + +.fa-tag::before { + content: "\f02b"; } + +.fa-comment::before { + content: "\f075"; } + +.fa-cake-candles::before { + content: "\f1fd"; } + +.fa-birthday-cake::before { + content: "\f1fd"; } + +.fa-cake::before { + content: "\f1fd"; } + +.fa-envelope::before { + content: "\f0e0"; } + +.fa-angles-up::before { + content: "\f102"; } + +.fa-angle-double-up::before { + content: "\f102"; } + +.fa-paperclip::before { + content: "\f0c6"; } + +.fa-arrow-right-to-city::before { + content: "\e4b3"; } + +.fa-ribbon::before { + content: "\f4d6"; } + +.fa-lungs::before { + content: "\f604"; } + +.fa-arrow-up-9-1::before { + content: "\f887"; } + +.fa-sort-numeric-up-alt::before { + content: "\f887"; } + +.fa-litecoin-sign::before { + content: "\e1d3"; } + +.fa-border-none::before { + content: "\f850"; } + +.fa-circle-nodes::before { + content: "\e4e2"; } + +.fa-parachute-box::before { + content: "\f4cd"; } + +.fa-indent::before { + content: "\f03c"; } + +.fa-truck-field-un::before { + content: "\e58e"; } + +.fa-hourglass::before { + content: "\f254"; } + +.fa-hourglass-empty::before { + content: "\f254"; } + +.fa-mountain::before { + content: "\f6fc"; } + +.fa-user-doctor::before { + content: "\f0f0"; } + +.fa-user-md::before { + content: "\f0f0"; } + +.fa-circle-info::before { + content: "\f05a"; } + +.fa-info-circle::before { + content: "\f05a"; } + +.fa-cloud-meatball::before { + content: "\f73b"; } + +.fa-camera::before { + content: "\f030"; } + +.fa-camera-alt::before { + content: "\f030"; } + +.fa-square-virus::before { + content: "\e578"; } + +.fa-meteor::before { + content: "\f753"; } + +.fa-car-on::before { + content: "\e4dd"; } + +.fa-sleigh::before { + content: "\f7cc"; } + +.fa-arrow-down-1-9::before { + content: "\f162"; } + +.fa-sort-numeric-asc::before { + content: "\f162"; } + +.fa-sort-numeric-down::before { + content: "\f162"; } + +.fa-hand-holding-droplet::before { + content: "\f4c1"; } + +.fa-hand-holding-water::before { + content: "\f4c1"; } + +.fa-water::before { + content: "\f773"; } + +.fa-calendar-check::before { + content: "\f274"; } + +.fa-braille::before { + content: "\f2a1"; } + +.fa-prescription-bottle-medical::before { + content: "\f486"; } + +.fa-prescription-bottle-alt::before { + content: "\f486"; } + +.fa-landmark::before { + content: "\f66f"; } + +.fa-truck::before { + content: "\f0d1"; } + +.fa-crosshairs::before { + content: "\f05b"; } + +.fa-person-cane::before { + content: "\e53c"; } + +.fa-tent::before { + content: "\e57d"; } + +.fa-vest-patches::before { + content: "\e086"; } + +.fa-check-double::before { + content: "\f560"; } + +.fa-arrow-down-a-z::before { + content: "\f15d"; } + +.fa-sort-alpha-asc::before { + content: "\f15d"; } + +.fa-sort-alpha-down::before { + content: "\f15d"; } + +.fa-money-bill-wheat::before { + content: "\e52a"; } + +.fa-cookie::before { + content: "\f563"; } + +.fa-arrow-rotate-left::before { + content: "\f0e2"; } + +.fa-arrow-left-rotate::before { + content: "\f0e2"; } + +.fa-arrow-rotate-back::before { + content: "\f0e2"; } + +.fa-arrow-rotate-backward::before { + content: "\f0e2"; } + +.fa-undo::before { + content: "\f0e2"; } + +.fa-hard-drive::before { + content: "\f0a0"; } + +.fa-hdd::before { + content: "\f0a0"; } + +.fa-face-grin-squint-tears::before { + content: "\f586"; } + +.fa-grin-squint-tears::before { + content: "\f586"; } + +.fa-dumbbell::before { + content: "\f44b"; } + +.fa-rectangle-list::before { + content: "\f022"; } + +.fa-list-alt::before { + content: "\f022"; } + +.fa-tarp-droplet::before { + content: "\e57c"; } + +.fa-house-medical-circle-check::before { + content: "\e511"; } + +.fa-person-skiing-nordic::before { + content: "\f7ca"; } + +.fa-skiing-nordic::before { + content: "\f7ca"; } + +.fa-calendar-plus::before { + content: "\f271"; } + +.fa-plane-arrival::before { + content: "\f5af"; } + +.fa-circle-left::before { + content: "\f359"; } + +.fa-arrow-alt-circle-left::before { + content: "\f359"; } + +.fa-train-subway::before { + content: "\f239"; } + +.fa-subway::before { + content: "\f239"; } + +.fa-chart-gantt::before { + content: "\e0e4"; } + +.fa-indian-rupee-sign::before { + content: "\e1bc"; } + +.fa-indian-rupee::before { + content: "\e1bc"; } + +.fa-inr::before { + content: "\e1bc"; } + +.fa-crop-simple::before { + content: "\f565"; } + +.fa-crop-alt::before { + content: "\f565"; } + +.fa-money-bill-1::before { + content: "\f3d1"; } + +.fa-money-bill-alt::before { + content: "\f3d1"; } + +.fa-left-long::before { + content: "\f30a"; } + +.fa-long-arrow-alt-left::before { + content: "\f30a"; } + +.fa-dna::before { + content: "\f471"; } + +.fa-virus-slash::before { + content: "\e075"; } + +.fa-minus::before { + content: "\f068"; } + +.fa-subtract::before { + content: "\f068"; } + +.fa-chess::before { + content: "\f439"; } + +.fa-arrow-left-long::before { + content: "\f177"; } + +.fa-long-arrow-left::before { + content: "\f177"; } + +.fa-plug-circle-check::before { + content: "\e55c"; } + +.fa-street-view::before { + content: "\f21d"; } + +.fa-franc-sign::before { + content: "\e18f"; } + +.fa-volume-off::before { + content: "\f026"; } + +.fa-hands-asl-interpreting::before { + content: "\f2a3"; } + +.fa-american-sign-language-interpreting::before { + content: "\f2a3"; } + +.fa-asl-interpreting::before { + content: "\f2a3"; } + +.fa-hands-american-sign-language-interpreting::before { + content: "\f2a3"; } + +.fa-gear::before { + content: "\f013"; } + +.fa-cog::before { + content: "\f013"; } + +.fa-droplet-slash::before { + content: "\f5c7"; } + +.fa-tint-slash::before { + content: "\f5c7"; } + +.fa-mosque::before { + content: "\f678"; } + +.fa-mosquito::before { + content: "\e52b"; } + +.fa-star-of-david::before { + content: "\f69a"; } + +.fa-person-military-rifle::before { + content: "\e54b"; } + +.fa-cart-shopping::before { + content: "\f07a"; } + +.fa-shopping-cart::before { + content: "\f07a"; } + +.fa-vials::before { + content: "\f493"; } + +.fa-plug-circle-plus::before { + content: "\e55f"; } + +.fa-place-of-worship::before { + content: "\f67f"; } + +.fa-grip-vertical::before { + content: "\f58e"; } + +.fa-arrow-turn-up::before { + content: "\f148"; } + +.fa-level-up::before { + content: "\f148"; } + +.fa-u::before { + content: "\55"; } + +.fa-square-root-variable::before { + content: "\f698"; } + +.fa-square-root-alt::before { + content: "\f698"; } + +.fa-clock::before { + content: "\f017"; } + +.fa-clock-four::before { + content: "\f017"; } + +.fa-backward-step::before { + content: "\f048"; } + +.fa-step-backward::before { + content: "\f048"; } + +.fa-pallet::before { + content: "\f482"; } + +.fa-faucet::before { + content: "\e005"; } + +.fa-baseball-bat-ball::before { + content: "\f432"; } + +.fa-s::before { + content: "\53"; } + +.fa-timeline::before { + content: "\e29c"; } + +.fa-keyboard::before { + content: "\f11c"; } + +.fa-caret-down::before { + content: "\f0d7"; } + +.fa-house-chimney-medical::before { + content: "\f7f2"; } + +.fa-clinic-medical::before { + content: "\f7f2"; } + +.fa-temperature-three-quarters::before { + content: "\f2c8"; } + +.fa-temperature-3::before { + content: "\f2c8"; } + +.fa-thermometer-3::before { + content: "\f2c8"; } + +.fa-thermometer-three-quarters::before { + content: "\f2c8"; } + +.fa-mobile-screen::before { + content: "\f3cf"; } + +.fa-mobile-android-alt::before { + content: "\f3cf"; } + +.fa-plane-up::before { + content: "\e22d"; } + +.fa-piggy-bank::before { + content: "\f4d3"; } + +.fa-battery-half::before { + content: "\f242"; } + +.fa-battery-3::before { + content: "\f242"; } + +.fa-mountain-city::before { + content: "\e52e"; } + +.fa-coins::before { + content: "\f51e"; } + +.fa-khanda::before { + content: "\f66d"; } + +.fa-sliders::before { + content: "\f1de"; } + +.fa-sliders-h::before { + content: "\f1de"; } + +.fa-folder-tree::before { + content: "\f802"; } + +.fa-network-wired::before { + content: "\f6ff"; } + +.fa-map-pin::before { + content: "\f276"; } + +.fa-hamsa::before { + content: "\f665"; } + +.fa-cent-sign::before { + content: "\e3f5"; } + +.fa-flask::before { + content: "\f0c3"; } + +.fa-person-pregnant::before { + content: "\e31e"; } + +.fa-wand-sparkles::before { + content: "\f72b"; } + +.fa-ellipsis-vertical::before { + content: "\f142"; } + +.fa-ellipsis-v::before { + content: "\f142"; } + +.fa-ticket::before { + content: "\f145"; } + +.fa-power-off::before { + content: "\f011"; } + +.fa-right-long::before { + content: "\f30b"; } + +.fa-long-arrow-alt-right::before { + content: "\f30b"; } + +.fa-flag-usa::before { + content: "\f74d"; } + +.fa-laptop-file::before { + content: "\e51d"; } + +.fa-tty::before { + content: "\f1e4"; } + +.fa-teletype::before { + content: "\f1e4"; } + +.fa-diagram-next::before { + content: "\e476"; } + +.fa-person-rifle::before { + content: "\e54e"; } + +.fa-house-medical-circle-exclamation::before { + content: "\e512"; } + +.fa-closed-captioning::before { + content: "\f20a"; } + +.fa-person-hiking::before { + content: "\f6ec"; } + +.fa-hiking::before { + content: "\f6ec"; } + +.fa-venus-double::before { + content: "\f226"; } + +.fa-images::before { + content: "\f302"; } + +.fa-calculator::before { + content: "\f1ec"; } + +.fa-people-pulling::before { + content: "\e535"; } + +.fa-n::before { + content: "\4e"; } + +.fa-cable-car::before { + content: "\f7da"; } + +.fa-tram::before { + content: "\f7da"; } + +.fa-cloud-rain::before { + content: "\f73d"; } + +.fa-building-circle-xmark::before { + content: "\e4d4"; } + +.fa-ship::before { + content: "\f21a"; } + +.fa-arrows-down-to-line::before { + content: "\e4b8"; } + +.fa-download::before { + content: "\f019"; } + +.fa-face-grin::before { + content: "\f580"; } + +.fa-grin::before { + content: "\f580"; } + +.fa-delete-left::before { + content: "\f55a"; } + +.fa-backspace::before { + content: "\f55a"; } + +.fa-eye-dropper::before { + content: "\f1fb"; } + +.fa-eye-dropper-empty::before { + content: "\f1fb"; } + +.fa-eyedropper::before { + content: "\f1fb"; } + +.fa-file-circle-check::before { + content: "\e5a0"; } + +.fa-forward::before { + content: "\f04e"; } + +.fa-mobile::before { + content: "\f3ce"; } + +.fa-mobile-android::before { + content: "\f3ce"; } + +.fa-mobile-phone::before { + content: "\f3ce"; } + +.fa-face-meh::before { + content: "\f11a"; } + +.fa-meh::before { + content: "\f11a"; } + +.fa-align-center::before { + content: "\f037"; } + +.fa-book-skull::before { + content: "\f6b7"; } + +.fa-book-dead::before { + content: "\f6b7"; } + +.fa-id-card::before { + content: "\f2c2"; } + +.fa-drivers-license::before { + content: "\f2c2"; } + +.fa-outdent::before { + content: "\f03b"; } + +.fa-dedent::before { + content: "\f03b"; } + +.fa-heart-circle-exclamation::before { + content: "\e4fe"; } + +.fa-house::before { + content: "\f015"; } + +.fa-home::before { + content: "\f015"; } + +.fa-home-alt::before { + content: "\f015"; } + +.fa-home-lg-alt::before { + content: "\f015"; } + +.fa-calendar-week::before { + content: "\f784"; } + +.fa-laptop-medical::before { + content: "\f812"; } + +.fa-b::before { + content: "\42"; } + +.fa-file-medical::before { + content: "\f477"; } + +.fa-dice-one::before { + content: "\f525"; } + +.fa-kiwi-bird::before { + content: "\f535"; } + +.fa-arrow-right-arrow-left::before { + content: "\f0ec"; } + +.fa-exchange::before { + content: "\f0ec"; } + +.fa-rotate-right::before { + content: "\f2f9"; } + +.fa-redo-alt::before { + content: "\f2f9"; } + +.fa-rotate-forward::before { + content: "\f2f9"; } + +.fa-utensils::before { + content: "\f2e7"; } + +.fa-cutlery::before { + content: "\f2e7"; } + +.fa-arrow-up-wide-short::before { + content: "\f161"; } + +.fa-sort-amount-up::before { + content: "\f161"; } + +.fa-mill-sign::before { + content: "\e1ed"; } + +.fa-bowl-rice::before { + content: "\e2eb"; } + +.fa-skull::before { + content: "\f54c"; } + +.fa-tower-broadcast::before { + content: "\f519"; } + +.fa-broadcast-tower::before { + content: "\f519"; } + +.fa-truck-pickup::before { + content: "\f63c"; } + +.fa-up-long::before { + content: "\f30c"; } + +.fa-long-arrow-alt-up::before { + content: "\f30c"; } + +.fa-stop::before { + content: "\f04d"; } + +.fa-code-merge::before { + content: "\f387"; } + +.fa-upload::before { + content: "\f093"; } + +.fa-hurricane::before { + content: "\f751"; } + +.fa-mound::before { + content: "\e52d"; } + +.fa-toilet-portable::before { + content: "\e583"; } + +.fa-compact-disc::before { + content: "\f51f"; } + +.fa-file-arrow-down::before { + content: "\f56d"; } + +.fa-file-download::before { + content: "\f56d"; } + +.fa-caravan::before { + content: "\f8ff"; } + +.fa-shield-cat::before { + content: "\e572"; } + +.fa-bolt::before { + content: "\f0e7"; } + +.fa-zap::before { + content: "\f0e7"; } + +.fa-glass-water::before { + content: "\e4f4"; } + +.fa-oil-well::before { + content: "\e532"; } + +.fa-vault::before { + content: "\e2c5"; } + +.fa-mars::before { + content: "\f222"; } + +.fa-toilet::before { + content: "\f7d8"; } + +.fa-plane-circle-xmark::before { + content: "\e557"; } + +.fa-yen-sign::before { + content: "\f157"; } + +.fa-cny::before { + content: "\f157"; } + +.fa-jpy::before { + content: "\f157"; } + +.fa-rmb::before { + content: "\f157"; } + +.fa-yen::before { + content: "\f157"; } + +.fa-ruble-sign::before { + content: "\f158"; } + +.fa-rouble::before { + content: "\f158"; } + +.fa-rub::before { + content: "\f158"; } + +.fa-ruble::before { + content: "\f158"; } + +.fa-sun::before { + content: "\f185"; } + +.fa-guitar::before { + content: "\f7a6"; } + +.fa-face-laugh-wink::before { + content: "\f59c"; } + +.fa-laugh-wink::before { + content: "\f59c"; } + +.fa-horse-head::before { + content: "\f7ab"; } + +.fa-bore-hole::before { + content: "\e4c3"; } + +.fa-industry::before { + content: "\f275"; } + +.fa-circle-down::before { + content: "\f358"; } + +.fa-arrow-alt-circle-down::before { + content: "\f358"; } + +.fa-arrows-turn-to-dots::before { + content: "\e4c1"; } + +.fa-florin-sign::before { + content: "\e184"; } + +.fa-arrow-down-short-wide::before { + content: "\f884"; } + +.fa-sort-amount-desc::before { + content: "\f884"; } + +.fa-sort-amount-down-alt::before { + content: "\f884"; } + +.fa-less-than::before { + content: "\3c"; } + +.fa-angle-down::before { + content: "\f107"; } + +.fa-car-tunnel::before { + content: "\e4de"; } + +.fa-head-side-cough::before { + content: "\e061"; } + +.fa-grip-lines::before { + content: "\f7a4"; } + +.fa-thumbs-down::before { + content: "\f165"; } + +.fa-user-lock::before { + content: "\f502"; } + +.fa-arrow-right-long::before { + content: "\f178"; } + +.fa-long-arrow-right::before { + content: "\f178"; } + +.fa-anchor-circle-xmark::before { + content: "\e4ac"; } + +.fa-ellipsis::before { + content: "\f141"; } + +.fa-ellipsis-h::before { + content: "\f141"; } + +.fa-chess-pawn::before { + content: "\f443"; } + +.fa-kit-medical::before { + content: "\f479"; } + +.fa-first-aid::before { + content: "\f479"; } + +.fa-person-through-window::before { + content: "\e5a9"; } + +.fa-toolbox::before { + content: "\f552"; } + +.fa-hands-holding-circle::before { + content: "\e4fb"; } + +.fa-bug::before { + content: "\f188"; } + +.fa-credit-card::before { + content: "\f09d"; } + +.fa-credit-card-alt::before { + content: "\f09d"; } + +.fa-car::before { + content: "\f1b9"; } + +.fa-automobile::before { + content: "\f1b9"; } + +.fa-hand-holding-hand::before { + content: "\e4f7"; } + +.fa-book-open-reader::before { + content: "\f5da"; } + +.fa-book-reader::before { + content: "\f5da"; } + +.fa-mountain-sun::before { + content: "\e52f"; } + +.fa-arrows-left-right-to-line::before { + content: "\e4ba"; } + +.fa-dice-d20::before { + content: "\f6cf"; } + +.fa-truck-droplet::before { + content: "\e58c"; } + +.fa-file-circle-xmark::before { + content: "\e5a1"; } + +.fa-temperature-arrow-up::before { + content: "\e040"; } + +.fa-temperature-up::before { + content: "\e040"; } + +.fa-medal::before { + content: "\f5a2"; } + +.fa-bed::before { + content: "\f236"; } + +.fa-square-h::before { + content: "\f0fd"; } + +.fa-h-square::before { + content: "\f0fd"; } + +.fa-podcast::before { + content: "\f2ce"; } + +.fa-temperature-full::before { + content: "\f2c7"; } + +.fa-temperature-4::before { + content: "\f2c7"; } + +.fa-thermometer-4::before { + content: "\f2c7"; } + +.fa-thermometer-full::before { + content: "\f2c7"; } + +.fa-bell::before { + content: "\f0f3"; } + +.fa-superscript::before { + content: "\f12b"; } + +.fa-plug-circle-xmark::before { + content: "\e560"; } + +.fa-star-of-life::before { + content: "\f621"; } + +.fa-phone-slash::before { + content: "\f3dd"; } + +.fa-paint-roller::before { + content: "\f5aa"; } + +.fa-handshake-angle::before { + content: "\f4c4"; } + +.fa-hands-helping::before { + content: "\f4c4"; } + +.fa-location-dot::before { + content: "\f3c5"; } + +.fa-map-marker-alt::before { + content: "\f3c5"; } + +.fa-file::before { + content: "\f15b"; } + +.fa-greater-than::before { + content: "\3e"; } + +.fa-person-swimming::before { + content: "\f5c4"; } + +.fa-swimmer::before { + content: "\f5c4"; } + +.fa-arrow-down::before { + content: "\f063"; } + +.fa-droplet::before { + content: "\f043"; } + +.fa-tint::before { + content: "\f043"; } + +.fa-eraser::before { + content: "\f12d"; } + +.fa-earth-americas::before { + content: "\f57d"; } + +.fa-earth::before { + content: "\f57d"; } + +.fa-earth-america::before { + content: "\f57d"; } + +.fa-globe-americas::before { + content: "\f57d"; } + +.fa-person-burst::before { + content: "\e53b"; } + +.fa-dove::before { + content: "\f4ba"; } + +.fa-battery-empty::before { + content: "\f244"; } + +.fa-battery-0::before { + content: "\f244"; } + +.fa-socks::before { + content: "\f696"; } + +.fa-inbox::before { + content: "\f01c"; } + +.fa-section::before { + content: "\e447"; } + +.fa-gauge-high::before { + content: "\f625"; } + +.fa-tachometer-alt::before { + content: "\f625"; } + +.fa-tachometer-alt-fast::before { + content: "\f625"; } + +.fa-envelope-open-text::before { + content: "\f658"; } + +.fa-hospital::before { + content: "\f0f8"; } + +.fa-hospital-alt::before { + content: "\f0f8"; } + +.fa-hospital-wide::before { + content: "\f0f8"; } + +.fa-wine-bottle::before { + content: "\f72f"; } + +.fa-chess-rook::before { + content: "\f447"; } + +.fa-bars-staggered::before { + content: "\f550"; } + +.fa-reorder::before { + content: "\f550"; } + +.fa-stream::before { + content: "\f550"; } + +.fa-dharmachakra::before { + content: "\f655"; } + +.fa-hotdog::before { + content: "\f80f"; } + +.fa-person-walking-with-cane::before { + content: "\f29d"; } + +.fa-blind::before { + content: "\f29d"; } + +.fa-drum::before { + content: "\f569"; } + +.fa-ice-cream::before { + content: "\f810"; } + +.fa-heart-circle-bolt::before { + content: "\e4fc"; } + +.fa-fax::before { + content: "\f1ac"; } + +.fa-paragraph::before { + content: "\f1dd"; } + +.fa-check-to-slot::before { + content: "\f772"; } + +.fa-vote-yea::before { + content: "\f772"; } + +.fa-star-half::before { + content: "\f089"; } + +.fa-boxes-stacked::before { + content: "\f468"; } + +.fa-boxes::before { + content: "\f468"; } + +.fa-boxes-alt::before { + content: "\f468"; } + +.fa-link::before { + content: "\f0c1"; } + +.fa-chain::before { + content: "\f0c1"; } + +.fa-ear-listen::before { + content: "\f2a2"; } + +.fa-assistive-listening-systems::before { + content: "\f2a2"; } + +.fa-tree-city::before { + content: "\e587"; } + +.fa-play::before { + content: "\f04b"; } + +.fa-font::before { + content: "\f031"; } + +.fa-table-cells-row-lock::before { + content: "\e67a"; } + +.fa-rupiah-sign::before { + content: "\e23d"; } + +.fa-magnifying-glass::before { + content: "\f002"; } + +.fa-search::before { + content: "\f002"; } + +.fa-table-tennis-paddle-ball::before { + content: "\f45d"; } + +.fa-ping-pong-paddle-ball::before { + content: "\f45d"; } + +.fa-table-tennis::before { + content: "\f45d"; } + +.fa-person-dots-from-line::before { + content: "\f470"; } + +.fa-diagnoses::before { + content: "\f470"; } + +.fa-trash-can-arrow-up::before { + content: "\f82a"; } + +.fa-trash-restore-alt::before { + content: "\f82a"; } + +.fa-naira-sign::before { + content: "\e1f6"; } + +.fa-cart-arrow-down::before { + content: "\f218"; } + +.fa-walkie-talkie::before { + content: "\f8ef"; } + +.fa-file-pen::before { + content: "\f31c"; } + +.fa-file-edit::before { + content: "\f31c"; } + +.fa-receipt::before { + content: "\f543"; } + +.fa-square-pen::before { + content: "\f14b"; } + +.fa-pen-square::before { + content: "\f14b"; } + +.fa-pencil-square::before { + content: "\f14b"; } + +.fa-suitcase-rolling::before { + content: "\f5c1"; } + +.fa-person-circle-exclamation::before { + content: "\e53f"; } + +.fa-chevron-down::before { + content: "\f078"; } + +.fa-battery-full::before { + content: "\f240"; } + +.fa-battery::before { + content: "\f240"; } + +.fa-battery-5::before { + content: "\f240"; } + +.fa-skull-crossbones::before { + content: "\f714"; } + +.fa-code-compare::before { + content: "\e13a"; } + +.fa-list-ul::before { + content: "\f0ca"; } + +.fa-list-dots::before { + content: "\f0ca"; } + +.fa-school-lock::before { + content: "\e56f"; } + +.fa-tower-cell::before { + content: "\e585"; } + +.fa-down-long::before { + content: "\f309"; } + +.fa-long-arrow-alt-down::before { + content: "\f309"; } + +.fa-ranking-star::before { + content: "\e561"; } + +.fa-chess-king::before { + content: "\f43f"; } + +.fa-person-harassing::before { + content: "\e549"; } + +.fa-brazilian-real-sign::before { + content: "\e46c"; } + +.fa-landmark-dome::before { + content: "\f752"; } + +.fa-landmark-alt::before { + content: "\f752"; } + +.fa-arrow-up::before { + content: "\f062"; } + +.fa-tv::before { + content: "\f26c"; } + +.fa-television::before { + content: "\f26c"; } + +.fa-tv-alt::before { + content: "\f26c"; } + +.fa-shrimp::before { + content: "\e448"; } + +.fa-list-check::before { + content: "\f0ae"; } + +.fa-tasks::before { + content: "\f0ae"; } + +.fa-jug-detergent::before { + content: "\e519"; } + +.fa-circle-user::before { + content: "\f2bd"; } + +.fa-user-circle::before { + content: "\f2bd"; } + +.fa-user-shield::before { + content: "\f505"; } + +.fa-wind::before { + content: "\f72e"; } + +.fa-car-burst::before { + content: "\f5e1"; } + +.fa-car-crash::before { + content: "\f5e1"; } + +.fa-y::before { + content: "\59"; } + +.fa-person-snowboarding::before { + content: "\f7ce"; } + +.fa-snowboarding::before { + content: "\f7ce"; } + +.fa-truck-fast::before { + content: "\f48b"; } + +.fa-shipping-fast::before { + content: "\f48b"; } + +.fa-fish::before { + content: "\f578"; } + +.fa-user-graduate::before { + content: "\f501"; } + +.fa-circle-half-stroke::before { + content: "\f042"; } + +.fa-adjust::before { + content: "\f042"; } + +.fa-clapperboard::before { + content: "\e131"; } + +.fa-circle-radiation::before { + content: "\f7ba"; } + +.fa-radiation-alt::before { + content: "\f7ba"; } + +.fa-baseball::before { + content: "\f433"; } + +.fa-baseball-ball::before { + content: "\f433"; } + +.fa-jet-fighter-up::before { + content: "\e518"; } + +.fa-diagram-project::before { + content: "\f542"; } + +.fa-project-diagram::before { + content: "\f542"; } + +.fa-copy::before { + content: "\f0c5"; } + +.fa-volume-xmark::before { + content: "\f6a9"; } + +.fa-volume-mute::before { + content: "\f6a9"; } + +.fa-volume-times::before { + content: "\f6a9"; } + +.fa-hand-sparkles::before { + content: "\e05d"; } + +.fa-grip::before { + content: "\f58d"; } + +.fa-grip-horizontal::before { + content: "\f58d"; } + +.fa-share-from-square::before { + content: "\f14d"; } + +.fa-share-square::before { + content: "\f14d"; } + +.fa-child-combatant::before { + content: "\e4e0"; } + +.fa-child-rifle::before { + content: "\e4e0"; } + +.fa-gun::before { + content: "\e19b"; } + +.fa-square-phone::before { + content: "\f098"; } + +.fa-phone-square::before { + content: "\f098"; } + +.fa-plus::before { + content: "\2b"; } + +.fa-add::before { + content: "\2b"; } + +.fa-expand::before { + content: "\f065"; } + +.fa-computer::before { + content: "\e4e5"; } + +.fa-xmark::before { + content: "\f00d"; } + +.fa-close::before { + content: "\f00d"; } + +.fa-multiply::before { + content: "\f00d"; } + +.fa-remove::before { + content: "\f00d"; } + +.fa-times::before { + content: "\f00d"; } + +.fa-arrows-up-down-left-right::before { + content: "\f047"; } + +.fa-arrows::before { + content: "\f047"; } + +.fa-chalkboard-user::before { + content: "\f51c"; } + +.fa-chalkboard-teacher::before { + content: "\f51c"; } + +.fa-peso-sign::before { + content: "\e222"; } + +.fa-building-shield::before { + content: "\e4d8"; } + +.fa-baby::before { + content: "\f77c"; } + +.fa-users-line::before { + content: "\e592"; } + +.fa-quote-left::before { + content: "\f10d"; } + +.fa-quote-left-alt::before { + content: "\f10d"; } + +.fa-tractor::before { + content: "\f722"; } + +.fa-trash-arrow-up::before { + content: "\f829"; } + +.fa-trash-restore::before { + content: "\f829"; } + +.fa-arrow-down-up-lock::before { + content: "\e4b0"; } + +.fa-lines-leaning::before { + content: "\e51e"; } + +.fa-ruler-combined::before { + content: "\f546"; } + +.fa-copyright::before { + content: "\f1f9"; } + +.fa-equals::before { + content: "\3d"; } + +.fa-blender::before { + content: "\f517"; } + +.fa-teeth::before { + content: "\f62e"; } + +.fa-shekel-sign::before { + content: "\f20b"; } + +.fa-ils::before { + content: "\f20b"; } + +.fa-shekel::before { + content: "\f20b"; } + +.fa-sheqel::before { + content: "\f20b"; } + +.fa-sheqel-sign::before { + content: "\f20b"; } + +.fa-map::before { + content: "\f279"; } + +.fa-rocket::before { + content: "\f135"; } + +.fa-photo-film::before { + content: "\f87c"; } + +.fa-photo-video::before { + content: "\f87c"; } + +.fa-folder-minus::before { + content: "\f65d"; } + +.fa-store::before { + content: "\f54e"; } + +.fa-arrow-trend-up::before { + content: "\e098"; } + +.fa-plug-circle-minus::before { + content: "\e55e"; } + +.fa-sign-hanging::before { + content: "\f4d9"; } + +.fa-sign::before { + content: "\f4d9"; } + +.fa-bezier-curve::before { + content: "\f55b"; } + +.fa-bell-slash::before { + content: "\f1f6"; } + +.fa-tablet::before { + content: "\f3fb"; } + +.fa-tablet-android::before { + content: "\f3fb"; } + +.fa-school-flag::before { + content: "\e56e"; } + +.fa-fill::before { + content: "\f575"; } + +.fa-angle-up::before { + content: "\f106"; } + +.fa-drumstick-bite::before { + content: "\f6d7"; } + +.fa-holly-berry::before { + content: "\f7aa"; } + +.fa-chevron-left::before { + content: "\f053"; } + +.fa-bacteria::before { + content: "\e059"; } + +.fa-hand-lizard::before { + content: "\f258"; } + +.fa-notdef::before { + content: "\e1fe"; } + +.fa-disease::before { + content: "\f7fa"; } + +.fa-briefcase-medical::before { + content: "\f469"; } + +.fa-genderless::before { + content: "\f22d"; } + +.fa-chevron-right::before { + content: "\f054"; } + +.fa-retweet::before { + content: "\f079"; } + +.fa-car-rear::before { + content: "\f5de"; } + +.fa-car-alt::before { + content: "\f5de"; } + +.fa-pump-soap::before { + content: "\e06b"; } + +.fa-video-slash::before { + content: "\f4e2"; } + +.fa-battery-quarter::before { + content: "\f243"; } + +.fa-battery-2::before { + content: "\f243"; } + +.fa-radio::before { + content: "\f8d7"; } + +.fa-baby-carriage::before { + content: "\f77d"; } + +.fa-carriage-baby::before { + content: "\f77d"; } + +.fa-traffic-light::before { + content: "\f637"; } + +.fa-thermometer::before { + content: "\f491"; } + +.fa-vr-cardboard::before { + content: "\f729"; } + +.fa-hand-middle-finger::before { + content: "\f806"; } + +.fa-percent::before { + content: "\25"; } + +.fa-percentage::before { + content: "\25"; } + +.fa-truck-moving::before { + content: "\f4df"; } + +.fa-glass-water-droplet::before { + content: "\e4f5"; } + +.fa-display::before { + content: "\e163"; } + +.fa-face-smile::before { + content: "\f118"; } + +.fa-smile::before { + content: "\f118"; } + +.fa-thumbtack::before { + content: "\f08d"; } + +.fa-thumb-tack::before { + content: "\f08d"; } + +.fa-trophy::before { + content: "\f091"; } + +.fa-person-praying::before { + content: "\f683"; } + +.fa-pray::before { + content: "\f683"; } + +.fa-hammer::before { + content: "\f6e3"; } + +.fa-hand-peace::before { + content: "\f25b"; } + +.fa-rotate::before { + content: "\f2f1"; } + +.fa-sync-alt::before { + content: "\f2f1"; } + +.fa-spinner::before { + content: "\f110"; } + +.fa-robot::before { + content: "\f544"; } + +.fa-peace::before { + content: "\f67c"; } + +.fa-gears::before { + content: "\f085"; } + +.fa-cogs::before { + content: "\f085"; } + +.fa-warehouse::before { + content: "\f494"; } + +.fa-arrow-up-right-dots::before { + content: "\e4b7"; } + +.fa-splotch::before { + content: "\f5bc"; } + +.fa-face-grin-hearts::before { + content: "\f584"; } + +.fa-grin-hearts::before { + content: "\f584"; } + +.fa-dice-four::before { + content: "\f524"; } + +.fa-sim-card::before { + content: "\f7c4"; } + +.fa-transgender::before { + content: "\f225"; } + +.fa-transgender-alt::before { + content: "\f225"; } + +.fa-mercury::before { + content: "\f223"; } + +.fa-arrow-turn-down::before { + content: "\f149"; } + +.fa-level-down::before { + content: "\f149"; } + +.fa-person-falling-burst::before { + content: "\e547"; } + +.fa-award::before { + content: "\f559"; } + +.fa-ticket-simple::before { + content: "\f3ff"; } + +.fa-ticket-alt::before { + content: "\f3ff"; } + +.fa-building::before { + content: "\f1ad"; } + +.fa-angles-left::before { + content: "\f100"; } + +.fa-angle-double-left::before { + content: "\f100"; } + +.fa-qrcode::before { + content: "\f029"; } + +.fa-clock-rotate-left::before { + content: "\f1da"; } + +.fa-history::before { + content: "\f1da"; } + +.fa-face-grin-beam-sweat::before { + content: "\f583"; } + +.fa-grin-beam-sweat::before { + content: "\f583"; } + +.fa-file-export::before { + content: "\f56e"; } + +.fa-arrow-right-from-file::before { + content: "\f56e"; } + +.fa-shield::before { + content: "\f132"; } + +.fa-shield-blank::before { + content: "\f132"; } + +.fa-arrow-up-short-wide::before { + content: "\f885"; } + +.fa-sort-amount-up-alt::before { + content: "\f885"; } + +.fa-house-medical::before { + content: "\e3b2"; } + +.fa-golf-ball-tee::before { + content: "\f450"; } + +.fa-golf-ball::before { + content: "\f450"; } + +.fa-circle-chevron-left::before { + content: "\f137"; } + +.fa-chevron-circle-left::before { + content: "\f137"; } + +.fa-house-chimney-window::before { + content: "\e00d"; } + +.fa-pen-nib::before { + content: "\f5ad"; } + +.fa-tent-arrow-turn-left::before { + content: "\e580"; } + +.fa-tents::before { + content: "\e582"; } + +.fa-wand-magic::before { + content: "\f0d0"; } + +.fa-magic::before { + content: "\f0d0"; } + +.fa-dog::before { + content: "\f6d3"; } + +.fa-carrot::before { + content: "\f787"; } + +.fa-moon::before { + content: "\f186"; } + +.fa-wine-glass-empty::before { + content: "\f5ce"; } + +.fa-wine-glass-alt::before { + content: "\f5ce"; } + +.fa-cheese::before { + content: "\f7ef"; } + +.fa-yin-yang::before { + content: "\f6ad"; } + +.fa-music::before { + content: "\f001"; } + +.fa-code-commit::before { + content: "\f386"; } + +.fa-temperature-low::before { + content: "\f76b"; } + +.fa-person-biking::before { + content: "\f84a"; } + +.fa-biking::before { + content: "\f84a"; } + +.fa-broom::before { + content: "\f51a"; } + +.fa-shield-heart::before { + content: "\e574"; } + +.fa-gopuram::before { + content: "\f664"; } + +.fa-earth-oceania::before { + content: "\e47b"; } + +.fa-globe-oceania::before { + content: "\e47b"; } + +.fa-square-xmark::before { + content: "\f2d3"; } + +.fa-times-square::before { + content: "\f2d3"; } + +.fa-xmark-square::before { + content: "\f2d3"; } + +.fa-hashtag::before { + content: "\23"; } + +.fa-up-right-and-down-left-from-center::before { + content: "\f424"; } + +.fa-expand-alt::before { + content: "\f424"; } + +.fa-oil-can::before { + content: "\f613"; } + +.fa-t::before { + content: "\54"; } + +.fa-hippo::before { + content: "\f6ed"; } + +.fa-chart-column::before { + content: "\e0e3"; } + +.fa-infinity::before { + content: "\f534"; } + +.fa-vial-circle-check::before { + content: "\e596"; } + +.fa-person-arrow-down-to-line::before { + content: "\e538"; } + +.fa-voicemail::before { + content: "\f897"; } + +.fa-fan::before { + content: "\f863"; } + +.fa-person-walking-luggage::before { + content: "\e554"; } + +.fa-up-down::before { + content: "\f338"; } + +.fa-arrows-alt-v::before { + content: "\f338"; } + +.fa-cloud-moon-rain::before { + content: "\f73c"; } + +.fa-calendar::before { + content: "\f133"; } + +.fa-trailer::before { + content: "\e041"; } + +.fa-bahai::before { + content: "\f666"; } + +.fa-haykal::before { + content: "\f666"; } + +.fa-sd-card::before { + content: "\f7c2"; } + +.fa-dragon::before { + content: "\f6d5"; } + +.fa-shoe-prints::before { + content: "\f54b"; } + +.fa-circle-plus::before { + content: "\f055"; } + +.fa-plus-circle::before { + content: "\f055"; } + +.fa-face-grin-tongue-wink::before { + content: "\f58b"; } + +.fa-grin-tongue-wink::before { + content: "\f58b"; } + +.fa-hand-holding::before { + content: "\f4bd"; } + +.fa-plug-circle-exclamation::before { + content: "\e55d"; } + +.fa-link-slash::before { + content: "\f127"; } + +.fa-chain-broken::before { + content: "\f127"; } + +.fa-chain-slash::before { + content: "\f127"; } + +.fa-unlink::before { + content: "\f127"; } + +.fa-clone::before { + content: "\f24d"; } + +.fa-person-walking-arrow-loop-left::before { + content: "\e551"; } + +.fa-arrow-up-z-a::before { + content: "\f882"; } + +.fa-sort-alpha-up-alt::before { + content: "\f882"; } + +.fa-fire-flame-curved::before { + content: "\f7e4"; } + +.fa-fire-alt::before { + content: "\f7e4"; } + +.fa-tornado::before { + content: "\f76f"; } + +.fa-file-circle-plus::before { + content: "\e494"; } + +.fa-book-quran::before { + content: "\f687"; } + +.fa-quran::before { + content: "\f687"; } + +.fa-anchor::before { + content: "\f13d"; } + +.fa-border-all::before { + content: "\f84c"; } + +.fa-face-angry::before { + content: "\f556"; } + +.fa-angry::before { + content: "\f556"; } + +.fa-cookie-bite::before { + content: "\f564"; } + +.fa-arrow-trend-down::before { + content: "\e097"; } + +.fa-rss::before { + content: "\f09e"; } + +.fa-feed::before { + content: "\f09e"; } + +.fa-draw-polygon::before { + content: "\f5ee"; } + +.fa-scale-balanced::before { + content: "\f24e"; } + +.fa-balance-scale::before { + content: "\f24e"; } + +.fa-gauge-simple-high::before { + content: "\f62a"; } + +.fa-tachometer::before { + content: "\f62a"; } + +.fa-tachometer-fast::before { + content: "\f62a"; } + +.fa-shower::before { + content: "\f2cc"; } + +.fa-desktop::before { + content: "\f390"; } + +.fa-desktop-alt::before { + content: "\f390"; } + +.fa-m::before { + content: "\4d"; } + +.fa-table-list::before { + content: "\f00b"; } + +.fa-th-list::before { + content: "\f00b"; } + +.fa-comment-sms::before { + content: "\f7cd"; } + +.fa-sms::before { + content: "\f7cd"; } + +.fa-book::before { + content: "\f02d"; } + +.fa-user-plus::before { + content: "\f234"; } + +.fa-check::before { + content: "\f00c"; } + +.fa-battery-three-quarters::before { + content: "\f241"; } + +.fa-battery-4::before { + content: "\f241"; } + +.fa-house-circle-check::before { + content: "\e509"; } + +.fa-angle-left::before { + content: "\f104"; } + +.fa-diagram-successor::before { + content: "\e47a"; } + +.fa-truck-arrow-right::before { + content: "\e58b"; } + +.fa-arrows-split-up-and-left::before { + content: "\e4bc"; } + +.fa-hand-fist::before { + content: "\f6de"; } + +.fa-fist-raised::before { + content: "\f6de"; } + +.fa-cloud-moon::before { + content: "\f6c3"; } + +.fa-briefcase::before { + content: "\f0b1"; } + +.fa-person-falling::before { + content: "\e546"; } + +.fa-image-portrait::before { + content: "\f3e0"; } + +.fa-portrait::before { + content: "\f3e0"; } + +.fa-user-tag::before { + content: "\f507"; } + +.fa-rug::before { + content: "\e569"; } + +.fa-earth-europe::before { + content: "\f7a2"; } + +.fa-globe-europe::before { + content: "\f7a2"; } + +.fa-cart-flatbed-suitcase::before { + content: "\f59d"; } + +.fa-luggage-cart::before { + content: "\f59d"; } + +.fa-rectangle-xmark::before { + content: "\f410"; } + +.fa-rectangle-times::before { + content: "\f410"; } + +.fa-times-rectangle::before { + content: "\f410"; } + +.fa-window-close::before { + content: "\f410"; } + +.fa-baht-sign::before { + content: "\e0ac"; } + +.fa-book-open::before { + content: "\f518"; } + +.fa-book-journal-whills::before { + content: "\f66a"; } + +.fa-journal-whills::before { + content: "\f66a"; } + +.fa-handcuffs::before { + content: "\e4f8"; } + +.fa-triangle-exclamation::before { + content: "\f071"; } + +.fa-exclamation-triangle::before { + content: "\f071"; } + +.fa-warning::before { + content: "\f071"; } + +.fa-database::before { + content: "\f1c0"; } + +.fa-share::before { + content: "\f064"; } + +.fa-mail-forward::before { + content: "\f064"; } + +.fa-bottle-droplet::before { + content: "\e4c4"; } + +.fa-mask-face::before { + content: "\e1d7"; } + +.fa-hill-rockslide::before { + content: "\e508"; } + +.fa-right-left::before { + content: "\f362"; } + +.fa-exchange-alt::before { + content: "\f362"; } + +.fa-paper-plane::before { + content: "\f1d8"; } + +.fa-road-circle-exclamation::before { + content: "\e565"; } + +.fa-dungeon::before { + content: "\f6d9"; } + +.fa-align-right::before { + content: "\f038"; } + +.fa-money-bill-1-wave::before { + content: "\f53b"; } + +.fa-money-bill-wave-alt::before { + content: "\f53b"; } + +.fa-life-ring::before { + content: "\f1cd"; } + +.fa-hands::before { + content: "\f2a7"; } + +.fa-sign-language::before { + content: "\f2a7"; } + +.fa-signing::before { + content: "\f2a7"; } + +.fa-calendar-day::before { + content: "\f783"; } + +.fa-water-ladder::before { + content: "\f5c5"; } + +.fa-ladder-water::before { + content: "\f5c5"; } + +.fa-swimming-pool::before { + content: "\f5c5"; } + +.fa-arrows-up-down::before { + content: "\f07d"; } + +.fa-arrows-v::before { + content: "\f07d"; } + +.fa-face-grimace::before { + content: "\f57f"; } + +.fa-grimace::before { + content: "\f57f"; } + +.fa-wheelchair-move::before { + content: "\e2ce"; } + +.fa-wheelchair-alt::before { + content: "\e2ce"; } + +.fa-turn-down::before { + content: "\f3be"; } + +.fa-level-down-alt::before { + content: "\f3be"; } + +.fa-person-walking-arrow-right::before { + content: "\e552"; } + +.fa-square-envelope::before { + content: "\f199"; } + +.fa-envelope-square::before { + content: "\f199"; } + +.fa-dice::before { + content: "\f522"; } + +.fa-bowling-ball::before { + content: "\f436"; } + +.fa-brain::before { + content: "\f5dc"; } + +.fa-bandage::before { + content: "\f462"; } + +.fa-band-aid::before { + content: "\f462"; } + +.fa-calendar-minus::before { + content: "\f272"; } + +.fa-circle-xmark::before { + content: "\f057"; } + +.fa-times-circle::before { + content: "\f057"; } + +.fa-xmark-circle::before { + content: "\f057"; } + +.fa-gifts::before { + content: "\f79c"; } + +.fa-hotel::before { + content: "\f594"; } + +.fa-earth-asia::before { + content: "\f57e"; } + +.fa-globe-asia::before { + content: "\f57e"; } + +.fa-id-card-clip::before { + content: "\f47f"; } + +.fa-id-card-alt::before { + content: "\f47f"; } + +.fa-magnifying-glass-plus::before { + content: "\f00e"; } + +.fa-search-plus::before { + content: "\f00e"; } + +.fa-thumbs-up::before { + content: "\f164"; } + +.fa-user-clock::before { + content: "\f4fd"; } + +.fa-hand-dots::before { + content: "\f461"; } + +.fa-allergies::before { + content: "\f461"; } + +.fa-file-invoice::before { + content: "\f570"; } + +.fa-window-minimize::before { + content: "\f2d1"; } + +.fa-mug-saucer::before { + content: "\f0f4"; } + +.fa-coffee::before { + content: "\f0f4"; } + +.fa-brush::before { + content: "\f55d"; } + +.fa-mask::before { + content: "\f6fa"; } + +.fa-magnifying-glass-minus::before { + content: "\f010"; } + +.fa-search-minus::before { + content: "\f010"; } + +.fa-ruler-vertical::before { + content: "\f548"; } + +.fa-user-large::before { + content: "\f406"; } + +.fa-user-alt::before { + content: "\f406"; } + +.fa-train-tram::before { + content: "\e5b4"; } + +.fa-user-nurse::before { + content: "\f82f"; } + +.fa-syringe::before { + content: "\f48e"; } + +.fa-cloud-sun::before { + content: "\f6c4"; } + +.fa-stopwatch-20::before { + content: "\e06f"; } + +.fa-square-full::before { + content: "\f45c"; } + +.fa-magnet::before { + content: "\f076"; } + +.fa-jar::before { + content: "\e516"; } + +.fa-note-sticky::before { + content: "\f249"; } + +.fa-sticky-note::before { + content: "\f249"; } + +.fa-bug-slash::before { + content: "\e490"; } + +.fa-arrow-up-from-water-pump::before { + content: "\e4b6"; } + +.fa-bone::before { + content: "\f5d7"; } + +.fa-user-injured::before { + content: "\f728"; } + +.fa-face-sad-tear::before { + content: "\f5b4"; } + +.fa-sad-tear::before { + content: "\f5b4"; } + +.fa-plane::before { + content: "\f072"; } + +.fa-tent-arrows-down::before { + content: "\e581"; } + +.fa-exclamation::before { + content: "\21"; } + +.fa-arrows-spin::before { + content: "\e4bb"; } + +.fa-print::before { + content: "\f02f"; } + +.fa-turkish-lira-sign::before { + content: "\e2bb"; } + +.fa-try::before { + content: "\e2bb"; } + +.fa-turkish-lira::before { + content: "\e2bb"; } + +.fa-dollar-sign::before { + content: "\24"; } + +.fa-dollar::before { + content: "\24"; } + +.fa-usd::before { + content: "\24"; } + +.fa-x::before { + content: "\58"; } + +.fa-magnifying-glass-dollar::before { + content: "\f688"; } + +.fa-search-dollar::before { + content: "\f688"; } + +.fa-users-gear::before { + content: "\f509"; } + +.fa-users-cog::before { + content: "\f509"; } + +.fa-person-military-pointing::before { + content: "\e54a"; } + +.fa-building-columns::before { + content: "\f19c"; } + +.fa-bank::before { + content: "\f19c"; } + +.fa-institution::before { + content: "\f19c"; } + +.fa-museum::before { + content: "\f19c"; } + +.fa-university::before { + content: "\f19c"; } + +.fa-umbrella::before { + content: "\f0e9"; } + +.fa-trowel::before { + content: "\e589"; } + +.fa-d::before { + content: "\44"; } + +.fa-stapler::before { + content: "\e5af"; } + +.fa-masks-theater::before { + content: "\f630"; } + +.fa-theater-masks::before { + content: "\f630"; } + +.fa-kip-sign::before { + content: "\e1c4"; } + +.fa-hand-point-left::before { + content: "\f0a5"; } + +.fa-handshake-simple::before { + content: "\f4c6"; } + +.fa-handshake-alt::before { + content: "\f4c6"; } + +.fa-jet-fighter::before { + content: "\f0fb"; } + +.fa-fighter-jet::before { + content: "\f0fb"; } + +.fa-square-share-nodes::before { + content: "\f1e1"; } + +.fa-share-alt-square::before { + content: "\f1e1"; } + +.fa-barcode::before { + content: "\f02a"; } + +.fa-plus-minus::before { + content: "\e43c"; } + +.fa-video::before { + content: "\f03d"; } + +.fa-video-camera::before { + content: "\f03d"; } + +.fa-graduation-cap::before { + content: "\f19d"; } + +.fa-mortar-board::before { + content: "\f19d"; } + +.fa-hand-holding-medical::before { + content: "\e05c"; } + +.fa-person-circle-check::before { + content: "\e53e"; } + +.fa-turn-up::before { + content: "\f3bf"; } + +.fa-level-up-alt::before { + content: "\f3bf"; } + +.sr-only, +.fa-sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border-width: 0; } + +.sr-only-focusable:not(:focus), +.fa-sr-only-focusable:not(:focus) { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border-width: 0; } +:root, :host { + --fa-style-family-brands: 'Font Awesome 6 Brands'; + --fa-font-brands: normal 400 1em/1 'Font Awesome 6 Brands'; } + +@font-face { + font-family: 'Font Awesome 6 Brands'; + font-style: normal; + font-weight: 400; + font-display: block; + src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype"); } + +.fab, +.fa-brands { + font-weight: 400; } + +.fa-monero:before { + content: "\f3d0"; } + +.fa-hooli:before { + content: "\f427"; } + +.fa-yelp:before { + content: "\f1e9"; } + +.fa-cc-visa:before { + content: "\f1f0"; } + +.fa-lastfm:before { + content: "\f202"; } + +.fa-shopware:before { + content: "\f5b5"; } + +.fa-creative-commons-nc:before { + content: "\f4e8"; } + +.fa-aws:before { + content: "\f375"; } + +.fa-redhat:before { + content: "\f7bc"; } + +.fa-yoast:before { + content: "\f2b1"; } + +.fa-cloudflare:before { + content: "\e07d"; } + +.fa-ups:before { + content: "\f7e0"; } + +.fa-pixiv:before { + content: "\e640"; } + +.fa-wpexplorer:before { + content: "\f2de"; } + +.fa-dyalog:before { + content: "\f399"; } + +.fa-bity:before { + content: "\f37a"; } + +.fa-stackpath:before { + content: "\f842"; } + +.fa-buysellads:before { + content: "\f20d"; } + +.fa-first-order:before { + content: "\f2b0"; } + +.fa-modx:before { + content: "\f285"; } + +.fa-guilded:before { + content: "\e07e"; } + +.fa-vnv:before { + content: "\f40b"; } + +.fa-square-js:before { + content: "\f3b9"; } + +.fa-js-square:before { + content: "\f3b9"; } + +.fa-microsoft:before { + content: "\f3ca"; } + +.fa-qq:before { + content: "\f1d6"; } + +.fa-orcid:before { + content: "\f8d2"; } + +.fa-java:before { + content: "\f4e4"; } + +.fa-invision:before { + content: "\f7b0"; } + +.fa-creative-commons-pd-alt:before { + content: "\f4ed"; } + +.fa-centercode:before { + content: "\f380"; } + +.fa-glide-g:before { + content: "\f2a6"; } + +.fa-drupal:before { + content: "\f1a9"; } + +.fa-jxl:before { + content: "\e67b"; } + +.fa-hire-a-helper:before { + content: "\f3b0"; } + +.fa-creative-commons-by:before { + content: "\f4e7"; } + +.fa-unity:before { + content: "\e049"; } + +.fa-whmcs:before { + content: "\f40d"; } + +.fa-rocketchat:before { + content: "\f3e8"; } + +.fa-vk:before { + content: "\f189"; } + +.fa-untappd:before { + content: "\f405"; } + +.fa-mailchimp:before { + content: "\f59e"; } + +.fa-css3-alt:before { + content: "\f38b"; } + +.fa-square-reddit:before { + content: "\f1a2"; } + +.fa-reddit-square:before { + content: "\f1a2"; } + +.fa-vimeo-v:before { + content: "\f27d"; } + +.fa-contao:before { + content: "\f26d"; } + +.fa-square-font-awesome:before { + content: "\e5ad"; } + +.fa-deskpro:before { + content: "\f38f"; } + +.fa-brave:before { + content: "\e63c"; } + +.fa-sistrix:before { + content: "\f3ee"; } + +.fa-square-instagram:before { + content: "\e055"; } + +.fa-instagram-square:before { + content: "\e055"; } + +.fa-battle-net:before { + content: "\f835"; } + +.fa-the-red-yeti:before { + content: "\f69d"; } + +.fa-square-hacker-news:before { + content: "\f3af"; } + +.fa-hacker-news-square:before { + content: "\f3af"; } + +.fa-edge:before { + content: "\f282"; } + +.fa-threads:before { + content: "\e618"; } + +.fa-napster:before { + content: "\f3d2"; } + +.fa-square-snapchat:before { + content: "\f2ad"; } + +.fa-snapchat-square:before { + content: "\f2ad"; } + +.fa-google-plus-g:before { + content: "\f0d5"; } + +.fa-artstation:before { + content: "\f77a"; } + +.fa-markdown:before { + content: "\f60f"; } + +.fa-sourcetree:before { + content: "\f7d3"; } + +.fa-google-plus:before { + content: "\f2b3"; } + +.fa-diaspora:before { + content: "\f791"; } + +.fa-foursquare:before { + content: "\f180"; } + +.fa-stack-overflow:before { + content: "\f16c"; } + +.fa-github-alt:before { + content: "\f113"; } + +.fa-phoenix-squadron:before { + content: "\f511"; } + +.fa-pagelines:before { + content: "\f18c"; } + +.fa-algolia:before { + content: "\f36c"; } + +.fa-red-river:before { + content: "\f3e3"; } + +.fa-creative-commons-sa:before { + content: "\f4ef"; } + +.fa-safari:before { + content: "\f267"; } + +.fa-google:before { + content: "\f1a0"; } + +.fa-square-font-awesome-stroke:before { + content: "\f35c"; } + +.fa-font-awesome-alt:before { + content: "\f35c"; } + +.fa-atlassian:before { + content: "\f77b"; } + +.fa-linkedin-in:before { + content: "\f0e1"; } + +.fa-digital-ocean:before { + content: "\f391"; } + +.fa-nimblr:before { + content: "\f5a8"; } + +.fa-chromecast:before { + content: "\f838"; } + +.fa-evernote:before { + content: "\f839"; } + +.fa-hacker-news:before { + content: "\f1d4"; } + +.fa-creative-commons-sampling:before { + content: "\f4f0"; } + +.fa-adversal:before { + content: "\f36a"; } + +.fa-creative-commons:before { + content: "\f25e"; } + +.fa-watchman-monitoring:before { + content: "\e087"; } + +.fa-fonticons:before { + content: "\f280"; } + +.fa-weixin:before { + content: "\f1d7"; } + +.fa-shirtsinbulk:before { + content: "\f214"; } + +.fa-codepen:before { + content: "\f1cb"; } + +.fa-git-alt:before { + content: "\f841"; } + +.fa-lyft:before { + content: "\f3c3"; } + +.fa-rev:before { + content: "\f5b2"; } + +.fa-windows:before { + content: "\f17a"; } + +.fa-wizards-of-the-coast:before { + content: "\f730"; } + +.fa-square-viadeo:before { + content: "\f2aa"; } + +.fa-viadeo-square:before { + content: "\f2aa"; } + +.fa-meetup:before { + content: "\f2e0"; } + +.fa-centos:before { + content: "\f789"; } + +.fa-adn:before { + content: "\f170"; } + +.fa-cloudsmith:before { + content: "\f384"; } + +.fa-opensuse:before { + content: "\e62b"; } + +.fa-pied-piper-alt:before { + content: "\f1a8"; } + +.fa-square-dribbble:before { + content: "\f397"; } + +.fa-dribbble-square:before { + content: "\f397"; } + +.fa-codiepie:before { + content: "\f284"; } + +.fa-node:before { + content: "\f419"; } + +.fa-mix:before { + content: "\f3cb"; } + +.fa-steam:before { + content: "\f1b6"; } + +.fa-cc-apple-pay:before { + content: "\f416"; } + +.fa-scribd:before { + content: "\f28a"; } + +.fa-debian:before { + content: "\e60b"; } + +.fa-openid:before { + content: "\f19b"; } + +.fa-instalod:before { + content: "\e081"; } + +.fa-expeditedssl:before { + content: "\f23e"; } + +.fa-sellcast:before { + content: "\f2da"; } + +.fa-square-twitter:before { + content: "\f081"; } + +.fa-twitter-square:before { + content: "\f081"; } + +.fa-r-project:before { + content: "\f4f7"; } + +.fa-delicious:before { + content: "\f1a5"; } + +.fa-freebsd:before { + content: "\f3a4"; } + +.fa-vuejs:before { + content: "\f41f"; } + +.fa-accusoft:before { + content: "\f369"; } + +.fa-ioxhost:before { + content: "\f208"; } + +.fa-fonticons-fi:before { + content: "\f3a2"; } + +.fa-app-store:before { + content: "\f36f"; } + +.fa-cc-mastercard:before { + content: "\f1f1"; } + +.fa-itunes-note:before { + content: "\f3b5"; } + +.fa-golang:before { + content: "\e40f"; } + +.fa-kickstarter:before { + content: "\f3bb"; } + +.fa-square-kickstarter:before { + content: "\f3bb"; } + +.fa-grav:before { + content: "\f2d6"; } + +.fa-weibo:before { + content: "\f18a"; } + +.fa-uncharted:before { + content: "\e084"; } + +.fa-firstdraft:before { + content: "\f3a1"; } + +.fa-square-youtube:before { + content: "\f431"; } + +.fa-youtube-square:before { + content: "\f431"; } + +.fa-wikipedia-w:before { + content: "\f266"; } + +.fa-wpressr:before { + content: "\f3e4"; } + +.fa-rendact:before { + content: "\f3e4"; } + +.fa-angellist:before { + content: "\f209"; } + +.fa-galactic-republic:before { + content: "\f50c"; } + +.fa-nfc-directional:before { + content: "\e530"; } + +.fa-skype:before { + content: "\f17e"; } + +.fa-joget:before { + content: "\f3b7"; } + +.fa-fedora:before { + content: "\f798"; } + +.fa-stripe-s:before { + content: "\f42a"; } + +.fa-meta:before { + content: "\e49b"; } + +.fa-laravel:before { + content: "\f3bd"; } + +.fa-hotjar:before { + content: "\f3b1"; } + +.fa-bluetooth-b:before { + content: "\f294"; } + +.fa-square-letterboxd:before { + content: "\e62e"; } + +.fa-sticker-mule:before { + content: "\f3f7"; } + +.fa-creative-commons-zero:before { + content: "\f4f3"; } + +.fa-hips:before { + content: "\f452"; } + +.fa-behance:before { + content: "\f1b4"; } + +.fa-reddit:before { + content: "\f1a1"; } + +.fa-discord:before { + content: "\f392"; } + +.fa-chrome:before { + content: "\f268"; } + +.fa-app-store-ios:before { + content: "\f370"; } + +.fa-cc-discover:before { + content: "\f1f2"; } + +.fa-wpbeginner:before { + content: "\f297"; } + +.fa-confluence:before { + content: "\f78d"; } + +.fa-shoelace:before { + content: "\e60c"; } + +.fa-mdb:before { + content: "\f8ca"; } + +.fa-dochub:before { + content: "\f394"; } + +.fa-accessible-icon:before { + content: "\f368"; } + +.fa-ebay:before { + content: "\f4f4"; } + +.fa-amazon:before { + content: "\f270"; } + +.fa-unsplash:before { + content: "\e07c"; } + +.fa-yarn:before { + content: "\f7e3"; } + +.fa-square-steam:before { + content: "\f1b7"; } + +.fa-steam-square:before { + content: "\f1b7"; } + +.fa-500px:before { + content: "\f26e"; } + +.fa-square-vimeo:before { + content: "\f194"; } + +.fa-vimeo-square:before { + content: "\f194"; } + +.fa-asymmetrik:before { + content: "\f372"; } + +.fa-font-awesome:before { + content: "\f2b4"; } + +.fa-font-awesome-flag:before { + content: "\f2b4"; } + +.fa-font-awesome-logo-full:before { + content: "\f2b4"; } + +.fa-gratipay:before { + content: "\f184"; } + +.fa-apple:before { + content: "\f179"; } + +.fa-hive:before { + content: "\e07f"; } + +.fa-gitkraken:before { + content: "\f3a6"; } + +.fa-keybase:before { + content: "\f4f5"; } + +.fa-apple-pay:before { + content: "\f415"; } + +.fa-padlet:before { + content: "\e4a0"; } + +.fa-amazon-pay:before { + content: "\f42c"; } + +.fa-square-github:before { + content: "\f092"; } + +.fa-github-square:before { + content: "\f092"; } + +.fa-stumbleupon:before { + content: "\f1a4"; } + +.fa-fedex:before { + content: "\f797"; } + +.fa-phoenix-framework:before { + content: "\f3dc"; } + +.fa-shopify:before { + content: "\e057"; } + +.fa-neos:before { + content: "\f612"; } + +.fa-square-threads:before { + content: "\e619"; } + +.fa-hackerrank:before { + content: "\f5f7"; } + +.fa-researchgate:before { + content: "\f4f8"; } + +.fa-swift:before { + content: "\f8e1"; } + +.fa-angular:before { + content: "\f420"; } + +.fa-speakap:before { + content: "\f3f3"; } + +.fa-angrycreative:before { + content: "\f36e"; } + +.fa-y-combinator:before { + content: "\f23b"; } + +.fa-empire:before { + content: "\f1d1"; } + +.fa-envira:before { + content: "\f299"; } + +.fa-google-scholar:before { + content: "\e63b"; } + +.fa-square-gitlab:before { + content: "\e5ae"; } + +.fa-gitlab-square:before { + content: "\e5ae"; } + +.fa-studiovinari:before { + content: "\f3f8"; } + +.fa-pied-piper:before { + content: "\f2ae"; } + +.fa-wordpress:before { + content: "\f19a"; } + +.fa-product-hunt:before { + content: "\f288"; } + +.fa-firefox:before { + content: "\f269"; } + +.fa-linode:before { + content: "\f2b8"; } + +.fa-goodreads:before { + content: "\f3a8"; } + +.fa-square-odnoklassniki:before { + content: "\f264"; } + +.fa-odnoklassniki-square:before { + content: "\f264"; } + +.fa-jsfiddle:before { + content: "\f1cc"; } + +.fa-sith:before { + content: "\f512"; } + +.fa-themeisle:before { + content: "\f2b2"; } + +.fa-page4:before { + content: "\f3d7"; } + +.fa-hashnode:before { + content: "\e499"; } + +.fa-react:before { + content: "\f41b"; } + +.fa-cc-paypal:before { + content: "\f1f4"; } + +.fa-squarespace:before { + content: "\f5be"; } + +.fa-cc-stripe:before { + content: "\f1f5"; } + +.fa-creative-commons-share:before { + content: "\f4f2"; } + +.fa-bitcoin:before { + content: "\f379"; } + +.fa-keycdn:before { + content: "\f3ba"; } + +.fa-opera:before { + content: "\f26a"; } + +.fa-itch-io:before { + content: "\f83a"; } + +.fa-umbraco:before { + content: "\f8e8"; } + +.fa-galactic-senate:before { + content: "\f50d"; } + +.fa-ubuntu:before { + content: "\f7df"; } + +.fa-draft2digital:before { + content: "\f396"; } + +.fa-stripe:before { + content: "\f429"; } + +.fa-houzz:before { + content: "\f27c"; } + +.fa-gg:before { + content: "\f260"; } + +.fa-dhl:before { + content: "\f790"; } + +.fa-square-pinterest:before { + content: "\f0d3"; } + +.fa-pinterest-square:before { + content: "\f0d3"; } + +.fa-xing:before { + content: "\f168"; } + +.fa-blackberry:before { + content: "\f37b"; } + +.fa-creative-commons-pd:before { + content: "\f4ec"; } + +.fa-playstation:before { + content: "\f3df"; } + +.fa-quinscape:before { + content: "\f459"; } + +.fa-less:before { + content: "\f41d"; } + +.fa-blogger-b:before { + content: "\f37d"; } + +.fa-opencart:before { + content: "\f23d"; } + +.fa-vine:before { + content: "\f1ca"; } + +.fa-signal-messenger:before { + content: "\e663"; } + +.fa-paypal:before { + content: "\f1ed"; } + +.fa-gitlab:before { + content: "\f296"; } + +.fa-typo3:before { + content: "\f42b"; } + +.fa-reddit-alien:before { + content: "\f281"; } + +.fa-yahoo:before { + content: "\f19e"; } + +.fa-dailymotion:before { + content: "\e052"; } + +.fa-affiliatetheme:before { + content: "\f36b"; } + +.fa-pied-piper-pp:before { + content: "\f1a7"; } + +.fa-bootstrap:before { + content: "\f836"; } + +.fa-odnoklassniki:before { + content: "\f263"; } + +.fa-nfc-symbol:before { + content: "\e531"; } + +.fa-mintbit:before { + content: "\e62f"; } + +.fa-ethereum:before { + content: "\f42e"; } + +.fa-speaker-deck:before { + content: "\f83c"; } + +.fa-creative-commons-nc-eu:before { + content: "\f4e9"; } + +.fa-patreon:before { + content: "\f3d9"; } + +.fa-avianex:before { + content: "\f374"; } + +.fa-ello:before { + content: "\f5f1"; } + +.fa-gofore:before { + content: "\f3a7"; } + +.fa-bimobject:before { + content: "\f378"; } + +.fa-brave-reverse:before { + content: "\e63d"; } + +.fa-facebook-f:before { + content: "\f39e"; } + +.fa-square-google-plus:before { + content: "\f0d4"; } + +.fa-google-plus-square:before { + content: "\f0d4"; } + +.fa-web-awesome:before { + content: "\e682"; } + +.fa-mandalorian:before { + content: "\f50f"; } + +.fa-first-order-alt:before { + content: "\f50a"; } + +.fa-osi:before { + content: "\f41a"; } + +.fa-google-wallet:before { + content: "\f1ee"; } + +.fa-d-and-d-beyond:before { + content: "\f6ca"; } + +.fa-periscope:before { + content: "\f3da"; } + +.fa-fulcrum:before { + content: "\f50b"; } + +.fa-cloudscale:before { + content: "\f383"; } + +.fa-forumbee:before { + content: "\f211"; } + +.fa-mizuni:before { + content: "\f3cc"; } + +.fa-schlix:before { + content: "\f3ea"; } + +.fa-square-xing:before { + content: "\f169"; } + +.fa-xing-square:before { + content: "\f169"; } + +.fa-bandcamp:before { + content: "\f2d5"; } + +.fa-wpforms:before { + content: "\f298"; } + +.fa-cloudversify:before { + content: "\f385"; } + +.fa-usps:before { + content: "\f7e1"; } + +.fa-megaport:before { + content: "\f5a3"; } + +.fa-magento:before { + content: "\f3c4"; } + +.fa-spotify:before { + content: "\f1bc"; } + +.fa-optin-monster:before { + content: "\f23c"; } + +.fa-fly:before { + content: "\f417"; } + +.fa-aviato:before { + content: "\f421"; } + +.fa-itunes:before { + content: "\f3b4"; } + +.fa-cuttlefish:before { + content: "\f38c"; } + +.fa-blogger:before { + content: "\f37c"; } + +.fa-flickr:before { + content: "\f16e"; } + +.fa-viber:before { + content: "\f409"; } + +.fa-soundcloud:before { + content: "\f1be"; } + +.fa-digg:before { + content: "\f1a6"; } + +.fa-tencent-weibo:before { + content: "\f1d5"; } + +.fa-letterboxd:before { + content: "\e62d"; } + +.fa-symfony:before { + content: "\f83d"; } + +.fa-maxcdn:before { + content: "\f136"; } + +.fa-etsy:before { + content: "\f2d7"; } + +.fa-facebook-messenger:before { + content: "\f39f"; } + +.fa-audible:before { + content: "\f373"; } + +.fa-think-peaks:before { + content: "\f731"; } + +.fa-bilibili:before { + content: "\e3d9"; } + +.fa-erlang:before { + content: "\f39d"; } + +.fa-x-twitter:before { + content: "\e61b"; } + +.fa-cotton-bureau:before { + content: "\f89e"; } + +.fa-dashcube:before { + content: "\f210"; } + +.fa-42-group:before { + content: "\e080"; } + +.fa-innosoft:before { + content: "\e080"; } + +.fa-stack-exchange:before { + content: "\f18d"; } + +.fa-elementor:before { + content: "\f430"; } + +.fa-square-pied-piper:before { + content: "\e01e"; } + +.fa-pied-piper-square:before { + content: "\e01e"; } + +.fa-creative-commons-nd:before { + content: "\f4eb"; } + +.fa-palfed:before { + content: "\f3d8"; } + +.fa-superpowers:before { + content: "\f2dd"; } + +.fa-resolving:before { + content: "\f3e7"; } + +.fa-xbox:before { + content: "\f412"; } + +.fa-square-web-awesome-stroke:before { + content: "\e684"; } + +.fa-searchengin:before { + content: "\f3eb"; } + +.fa-tiktok:before { + content: "\e07b"; } + +.fa-square-facebook:before { + content: "\f082"; } + +.fa-facebook-square:before { + content: "\f082"; } + +.fa-renren:before { + content: "\f18b"; } + +.fa-linux:before { + content: "\f17c"; } + +.fa-glide:before { + content: "\f2a5"; } + +.fa-linkedin:before { + content: "\f08c"; } + +.fa-hubspot:before { + content: "\f3b2"; } + +.fa-deploydog:before { + content: "\f38e"; } + +.fa-twitch:before { + content: "\f1e8"; } + +.fa-ravelry:before { + content: "\f2d9"; } + +.fa-mixer:before { + content: "\e056"; } + +.fa-square-lastfm:before { + content: "\f203"; } + +.fa-lastfm-square:before { + content: "\f203"; } + +.fa-vimeo:before { + content: "\f40a"; } + +.fa-mendeley:before { + content: "\f7b3"; } + +.fa-uniregistry:before { + content: "\f404"; } + +.fa-figma:before { + content: "\f799"; } + +.fa-creative-commons-remix:before { + content: "\f4ee"; } + +.fa-cc-amazon-pay:before { + content: "\f42d"; } + +.fa-dropbox:before { + content: "\f16b"; } + +.fa-instagram:before { + content: "\f16d"; } + +.fa-cmplid:before { + content: "\e360"; } + +.fa-upwork:before { + content: "\e641"; } + +.fa-facebook:before { + content: "\f09a"; } + +.fa-gripfire:before { + content: "\f3ac"; } + +.fa-jedi-order:before { + content: "\f50e"; } + +.fa-uikit:before { + content: "\f403"; } + +.fa-fort-awesome-alt:before { + content: "\f3a3"; } + +.fa-phabricator:before { + content: "\f3db"; } + +.fa-ussunnah:before { + content: "\f407"; } + +.fa-earlybirds:before { + content: "\f39a"; } + +.fa-trade-federation:before { + content: "\f513"; } + +.fa-autoprefixer:before { + content: "\f41c"; } + +.fa-whatsapp:before { + content: "\f232"; } + +.fa-square-upwork:before { + content: "\e67c"; } + +.fa-slideshare:before { + content: "\f1e7"; } + +.fa-google-play:before { + content: "\f3ab"; } + +.fa-viadeo:before { + content: "\f2a9"; } + +.fa-line:before { + content: "\f3c0"; } + +.fa-google-drive:before { + content: "\f3aa"; } + +.fa-servicestack:before { + content: "\f3ec"; } + +.fa-simplybuilt:before { + content: "\f215"; } + +.fa-bitbucket:before { + content: "\f171"; } + +.fa-imdb:before { + content: "\f2d8"; } + +.fa-deezer:before { + content: "\e077"; } + +.fa-raspberry-pi:before { + content: "\f7bb"; } + +.fa-jira:before { + content: "\f7b1"; } + +.fa-docker:before { + content: "\f395"; } + +.fa-screenpal:before { + content: "\e570"; } + +.fa-bluetooth:before { + content: "\f293"; } + +.fa-gitter:before { + content: "\f426"; } + +.fa-d-and-d:before { + content: "\f38d"; } + +.fa-microblog:before { + content: "\e01a"; } + +.fa-cc-diners-club:before { + content: "\f24c"; } + +.fa-gg-circle:before { + content: "\f261"; } + +.fa-pied-piper-hat:before { + content: "\f4e5"; } + +.fa-kickstarter-k:before { + content: "\f3bc"; } + +.fa-yandex:before { + content: "\f413"; } + +.fa-readme:before { + content: "\f4d5"; } + +.fa-html5:before { + content: "\f13b"; } + +.fa-sellsy:before { + content: "\f213"; } + +.fa-square-web-awesome:before { + content: "\e683"; } + +.fa-sass:before { + content: "\f41e"; } + +.fa-wirsindhandwerk:before { + content: "\e2d0"; } + +.fa-wsh:before { + content: "\e2d0"; } + +.fa-buromobelexperte:before { + content: "\f37f"; } + +.fa-salesforce:before { + content: "\f83b"; } + +.fa-octopus-deploy:before { + content: "\e082"; } + +.fa-medapps:before { + content: "\f3c6"; } + +.fa-ns8:before { + content: "\f3d5"; } + +.fa-pinterest-p:before { + content: "\f231"; } + +.fa-apper:before { + content: "\f371"; } + +.fa-fort-awesome:before { + content: "\f286"; } + +.fa-waze:before { + content: "\f83f"; } + +.fa-bluesky:before { + content: "\e671"; } + +.fa-cc-jcb:before { + content: "\f24b"; } + +.fa-snapchat:before { + content: "\f2ab"; } + +.fa-snapchat-ghost:before { + content: "\f2ab"; } + +.fa-fantasy-flight-games:before { + content: "\f6dc"; } + +.fa-rust:before { + content: "\e07a"; } + +.fa-wix:before { + content: "\f5cf"; } + +.fa-square-behance:before { + content: "\f1b5"; } + +.fa-behance-square:before { + content: "\f1b5"; } + +.fa-supple:before { + content: "\f3f9"; } + +.fa-webflow:before { + content: "\e65c"; } + +.fa-rebel:before { + content: "\f1d0"; } + +.fa-css3:before { + content: "\f13c"; } + +.fa-staylinked:before { + content: "\f3f5"; } + +.fa-kaggle:before { + content: "\f5fa"; } + +.fa-space-awesome:before { + content: "\e5ac"; } + +.fa-deviantart:before { + content: "\f1bd"; } + +.fa-cpanel:before { + content: "\f388"; } + +.fa-goodreads-g:before { + content: "\f3a9"; } + +.fa-square-git:before { + content: "\f1d2"; } + +.fa-git-square:before { + content: "\f1d2"; } + +.fa-square-tumblr:before { + content: "\f174"; } + +.fa-tumblr-square:before { + content: "\f174"; } + +.fa-trello:before { + content: "\f181"; } + +.fa-creative-commons-nc-jp:before { + content: "\f4ea"; } + +.fa-get-pocket:before { + content: "\f265"; } + +.fa-perbyte:before { + content: "\e083"; } + +.fa-grunt:before { + content: "\f3ad"; } + +.fa-weebly:before { + content: "\f5cc"; } + +.fa-connectdevelop:before { + content: "\f20e"; } + +.fa-leanpub:before { + content: "\f212"; } + +.fa-black-tie:before { + content: "\f27e"; } + +.fa-themeco:before { + content: "\f5c6"; } + +.fa-python:before { + content: "\f3e2"; } + +.fa-android:before { + content: "\f17b"; } + +.fa-bots:before { + content: "\e340"; } + +.fa-free-code-camp:before { + content: "\f2c5"; } + +.fa-hornbill:before { + content: "\f592"; } + +.fa-js:before { + content: "\f3b8"; } + +.fa-ideal:before { + content: "\e013"; } + +.fa-git:before { + content: "\f1d3"; } + +.fa-dev:before { + content: "\f6cc"; } + +.fa-sketch:before { + content: "\f7c6"; } + +.fa-yandex-international:before { + content: "\f414"; } + +.fa-cc-amex:before { + content: "\f1f3"; } + +.fa-uber:before { + content: "\f402"; } + +.fa-github:before { + content: "\f09b"; } + +.fa-php:before { + content: "\f457"; } + +.fa-alipay:before { + content: "\f642"; } + +.fa-youtube:before { + content: "\f167"; } + +.fa-skyatlas:before { + content: "\f216"; } + +.fa-firefox-browser:before { + content: "\e007"; } + +.fa-replyd:before { + content: "\f3e6"; } + +.fa-suse:before { + content: "\f7d6"; } + +.fa-jenkins:before { + content: "\f3b6"; } + +.fa-twitter:before { + content: "\f099"; } + +.fa-rockrms:before { + content: "\f3e9"; } + +.fa-pinterest:before { + content: "\f0d2"; } + +.fa-buffer:before { + content: "\f837"; } + +.fa-npm:before { + content: "\f3d4"; } + +.fa-yammer:before { + content: "\f840"; } + +.fa-btc:before { + content: "\f15a"; } + +.fa-dribbble:before { + content: "\f17d"; } + +.fa-stumbleupon-circle:before { + content: "\f1a3"; } + +.fa-internet-explorer:before { + content: "\f26b"; } + +.fa-stubber:before { + content: "\e5c7"; } + +.fa-telegram:before { + content: "\f2c6"; } + +.fa-telegram-plane:before { + content: "\f2c6"; } + +.fa-old-republic:before { + content: "\f510"; } + +.fa-odysee:before { + content: "\e5c6"; } + +.fa-square-whatsapp:before { + content: "\f40c"; } + +.fa-whatsapp-square:before { + content: "\f40c"; } + +.fa-node-js:before { + content: "\f3d3"; } + +.fa-edge-legacy:before { + content: "\e078"; } + +.fa-slack:before { + content: "\f198"; } + +.fa-slack-hash:before { + content: "\f198"; } + +.fa-medrt:before { + content: "\f3c8"; } + +.fa-usb:before { + content: "\f287"; } + +.fa-tumblr:before { + content: "\f173"; } + +.fa-vaadin:before { + content: "\f408"; } + +.fa-quora:before { + content: "\f2c4"; } + +.fa-square-x-twitter:before { + content: "\e61a"; } + +.fa-reacteurope:before { + content: "\f75d"; } + +.fa-medium:before { + content: "\f23a"; } + +.fa-medium-m:before { + content: "\f23a"; } + +.fa-amilia:before { + content: "\f36d"; } + +.fa-mixcloud:before { + content: "\f289"; } + +.fa-flipboard:before { + content: "\f44d"; } + +.fa-viacoin:before { + content: "\f237"; } + +.fa-critical-role:before { + content: "\f6c9"; } + +.fa-sitrox:before { + content: "\e44a"; } + +.fa-discourse:before { + content: "\f393"; } + +.fa-joomla:before { + content: "\f1aa"; } + +.fa-mastodon:before { + content: "\f4f6"; } + +.fa-airbnb:before { + content: "\f834"; } + +.fa-wolf-pack-battalion:before { + content: "\f514"; } + +.fa-buy-n-large:before { + content: "\f8a6"; } + +.fa-gulp:before { + content: "\f3ae"; } + +.fa-creative-commons-sampling-plus:before { + content: "\f4f1"; } + +.fa-strava:before { + content: "\f428"; } + +.fa-ember:before { + content: "\f423"; } + +.fa-canadian-maple-leaf:before { + content: "\f785"; } + +.fa-teamspeak:before { + content: "\f4f9"; } + +.fa-pushed:before { + content: "\f3e1"; } + +.fa-wordpress-simple:before { + content: "\f411"; } + +.fa-nutritionix:before { + content: "\f3d6"; } + +.fa-wodu:before { + content: "\e088"; } + +.fa-google-pay:before { + content: "\e079"; } + +.fa-intercom:before { + content: "\f7af"; } + +.fa-zhihu:before { + content: "\f63f"; } + +.fa-korvue:before { + content: "\f42f"; } + +.fa-pix:before { + content: "\e43a"; } + +.fa-steam-symbol:before { + content: "\f3f6"; } +:root, :host { + --fa-style-family-classic: 'Font Awesome 6 Free'; + --fa-font-regular: normal 400 1em/1 'Font Awesome 6 Free'; } + +@font-face { + font-family: 'Font Awesome 6 Free'; + font-style: normal; + font-weight: 400; + font-display: block; + src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype"); } + +.far, +.fa-regular { + font-weight: 400; } +:root, :host { + --fa-style-family-classic: 'Font Awesome 6 Free'; + --fa-font-solid: normal 900 1em/1 'Font Awesome 6 Free'; } + +@font-face { + font-family: 'Font Awesome 6 Free'; + font-style: normal; + font-weight: 900; + font-display: block; + src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype"); } + +.fas, +.fa-solid { + font-weight: 900; } +@font-face { + font-family: 'Font Awesome 5 Brands'; + font-display: block; + font-weight: 400; + src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype"); } + +@font-face { + font-family: 'Font Awesome 5 Free'; + font-display: block; + font-weight: 900; + src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype"); } + +@font-face { + font-family: 'Font Awesome 5 Free'; + font-display: block; + font-weight: 400; + src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype"); } +@font-face { + font-family: 'FontAwesome'; + font-display: block; + src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype"); } + +@font-face { + font-family: 'FontAwesome'; + font-display: block; + src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype"); } + +@font-face { + font-family: 'FontAwesome'; + font-display: block; + src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype"); } + +@font-face { + font-family: 'FontAwesome'; + font-display: block; + src: url("../webfonts/fa-v4compatibility.woff2") format("woff2"), url("../webfonts/fa-v4compatibility.ttf") format("truetype"); } diff --git a/docs/deps/font-awesome-6.5.2/css/all.min.css b/docs/deps/font-awesome-6.5.2/css/all.min.css new file mode 100644 index 00000000..269bceea --- /dev/null +++ b/docs/deps/font-awesome-6.5.2/css/all.min.css @@ -0,0 +1,9 @@ +/*! + * Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + * Copyright 2024 Fonticons, Inc. + */ +.fa{font-family:var(--fa-style-family,"Font Awesome 6 Free");font-weight:var(--fa-style,900)}.fa,.fa-brands,.fa-classic,.fa-regular,.fa-sharp,.fa-solid,.fab,.far,.fas{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:var(--fa-display,inline-block);font-style:normal;font-variant:normal;line-height:1;text-rendering:auto}.fa-classic,.fa-regular,.fa-solid,.far,.fas{font-family:"Font Awesome 6 Free"}.fa-brands,.fab{font-family:"Font Awesome 6 Brands"}.fa-1x{font-size:1em}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-6x{font-size:6em}.fa-7x{font-size:7em}.fa-8x{font-size:8em}.fa-9x{font-size:9em}.fa-10x{font-size:10em}.fa-2xs{font-size:.625em;line-height:.1em;vertical-align:.225em}.fa-xs{font-size:.75em;line-height:.08333em;vertical-align:.125em}.fa-sm{font-size:.875em;line-height:.07143em;vertical-align:.05357em}.fa-lg{font-size:1.25em;line-height:.05em;vertical-align:-.075em}.fa-xl{font-size:1.5em;line-height:.04167em;vertical-align:-.125em}.fa-2xl{font-size:2em;line-height:.03125em;vertical-align:-.1875em}.fa-fw{text-align:center;width:1.25em}.fa-ul{list-style-type:none;margin-left:var(--fa-li-margin,2.5em);padding-left:0}.fa-ul>li{position:relative}.fa-li{left:calc(var(--fa-li-width, 2em)*-1);position:absolute;text-align:center;width:var(--fa-li-width,2em);line-height:inherit}.fa-border{border-radius:var(--fa-border-radius,.1em);border:var(--fa-border-width,.08em) var(--fa-border-style,solid) var(--fa-border-color,#eee);padding:var(--fa-border-padding,.2em .25em .15em)}.fa-pull-left{float:left;margin-right:var(--fa-pull-margin,.3em)}.fa-pull-right{float:right;margin-left:var(--fa-pull-margin,.3em)}.fa-beat{-webkit-animation-name:fa-beat;animation-name:fa-beat;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,ease-in-out);animation-timing-function:var(--fa-animation-timing,ease-in-out)}.fa-bounce{-webkit-animation-name:fa-bounce;animation-name:fa-bounce;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.28,.84,.42,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.28,.84,.42,1))}.fa-fade{-webkit-animation-name:fa-fade;animation-name:fa-fade;-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1))}.fa-beat-fade,.fa-fade{-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s)}.fa-beat-fade{-webkit-animation-name:fa-beat-fade;animation-name:fa-beat-fade;-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1))}.fa-flip{-webkit-animation-name:fa-flip;animation-name:fa-flip;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,ease-in-out);animation-timing-function:var(--fa-animation-timing,ease-in-out)}.fa-shake{-webkit-animation-name:fa-shake;animation-name:fa-shake;-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,linear);animation-timing-function:var(--fa-animation-timing,linear)}.fa-shake,.fa-spin{-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal)}.fa-spin{-webkit-animation-name:fa-spin;animation-name:fa-spin;-webkit-animation-duration:var(--fa-animation-duration,2s);animation-duration:var(--fa-animation-duration,2s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,linear);animation-timing-function:var(--fa-animation-timing,linear)}.fa-spin-reverse{--fa-animation-direction:reverse}.fa-pulse,.fa-spin-pulse{-webkit-animation-name:fa-spin;animation-name:fa-spin;-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,steps(8));animation-timing-function:var(--fa-animation-timing,steps(8))}@media (prefers-reduced-motion:reduce){.fa-beat,.fa-beat-fade,.fa-bounce,.fa-fade,.fa-flip,.fa-pulse,.fa-shake,.fa-spin,.fa-spin-pulse{-webkit-animation-delay:-1ms;animation-delay:-1ms;-webkit-animation-duration:1ms;animation-duration:1ms;-webkit-animation-iteration-count:1;animation-iteration-count:1;-webkit-transition-delay:0s;transition-delay:0s;-webkit-transition-duration:0s;transition-duration:0s}}@-webkit-keyframes fa-beat{0%,90%{-webkit-transform:scale(1);transform:scale(1)}45%{-webkit-transform:scale(var(--fa-beat-scale,1.25));transform:scale(var(--fa-beat-scale,1.25))}}@keyframes fa-beat{0%,90%{-webkit-transform:scale(1);transform:scale(1)}45%{-webkit-transform:scale(var(--fa-beat-scale,1.25));transform:scale(var(--fa-beat-scale,1.25))}}@-webkit-keyframes fa-bounce{0%{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}10%{-webkit-transform:scale(var(--fa-bounce-start-scale-x,1.1),var(--fa-bounce-start-scale-y,.9)) translateY(0);transform:scale(var(--fa-bounce-start-scale-x,1.1),var(--fa-bounce-start-scale-y,.9)) translateY(0)}30%{-webkit-transform:scale(var(--fa-bounce-jump-scale-x,.9),var(--fa-bounce-jump-scale-y,1.1)) translateY(var(--fa-bounce-height,-.5em));transform:scale(var(--fa-bounce-jump-scale-x,.9),var(--fa-bounce-jump-scale-y,1.1)) translateY(var(--fa-bounce-height,-.5em))}50%{-webkit-transform:scale(var(--fa-bounce-land-scale-x,1.05),var(--fa-bounce-land-scale-y,.95)) translateY(0);transform:scale(var(--fa-bounce-land-scale-x,1.05),var(--fa-bounce-land-scale-y,.95)) translateY(0)}57%{-webkit-transform:scale(1) translateY(var(--fa-bounce-rebound,-.125em));transform:scale(1) translateY(var(--fa-bounce-rebound,-.125em))}64%{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}to{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}}@keyframes fa-bounce{0%{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}10%{-webkit-transform:scale(var(--fa-bounce-start-scale-x,1.1),var(--fa-bounce-start-scale-y,.9)) translateY(0);transform:scale(var(--fa-bounce-start-scale-x,1.1),var(--fa-bounce-start-scale-y,.9)) translateY(0)}30%{-webkit-transform:scale(var(--fa-bounce-jump-scale-x,.9),var(--fa-bounce-jump-scale-y,1.1)) translateY(var(--fa-bounce-height,-.5em));transform:scale(var(--fa-bounce-jump-scale-x,.9),var(--fa-bounce-jump-scale-y,1.1)) translateY(var(--fa-bounce-height,-.5em))}50%{-webkit-transform:scale(var(--fa-bounce-land-scale-x,1.05),var(--fa-bounce-land-scale-y,.95)) translateY(0);transform:scale(var(--fa-bounce-land-scale-x,1.05),var(--fa-bounce-land-scale-y,.95)) translateY(0)}57%{-webkit-transform:scale(1) translateY(var(--fa-bounce-rebound,-.125em));transform:scale(1) translateY(var(--fa-bounce-rebound,-.125em))}64%{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}to{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}}@-webkit-keyframes fa-fade{50%{opacity:var(--fa-fade-opacity,.4)}}@keyframes fa-fade{50%{opacity:var(--fa-fade-opacity,.4)}}@-webkit-keyframes fa-beat-fade{0%,to{opacity:var(--fa-beat-fade-opacity,.4);-webkit-transform:scale(1);transform:scale(1)}50%{opacity:1;-webkit-transform:scale(var(--fa-beat-fade-scale,1.125));transform:scale(var(--fa-beat-fade-scale,1.125))}}@keyframes fa-beat-fade{0%,to{opacity:var(--fa-beat-fade-opacity,.4);-webkit-transform:scale(1);transform:scale(1)}50%{opacity:1;-webkit-transform:scale(var(--fa-beat-fade-scale,1.125));transform:scale(var(--fa-beat-fade-scale,1.125))}}@-webkit-keyframes fa-flip{50%{-webkit-transform:rotate3d(var(--fa-flip-x,0),var(--fa-flip-y,1),var(--fa-flip-z,0),var(--fa-flip-angle,-180deg));transform:rotate3d(var(--fa-flip-x,0),var(--fa-flip-y,1),var(--fa-flip-z,0),var(--fa-flip-angle,-180deg))}}@keyframes fa-flip{50%{-webkit-transform:rotate3d(var(--fa-flip-x,0),var(--fa-flip-y,1),var(--fa-flip-z,0),var(--fa-flip-angle,-180deg));transform:rotate3d(var(--fa-flip-x,0),var(--fa-flip-y,1),var(--fa-flip-z,0),var(--fa-flip-angle,-180deg))}}@-webkit-keyframes fa-shake{0%{-webkit-transform:rotate(-15deg);transform:rotate(-15deg)}4%{-webkit-transform:rotate(15deg);transform:rotate(15deg)}8%,24%{-webkit-transform:rotate(-18deg);transform:rotate(-18deg)}12%,28%{-webkit-transform:rotate(18deg);transform:rotate(18deg)}16%{-webkit-transform:rotate(-22deg);transform:rotate(-22deg)}20%{-webkit-transform:rotate(22deg);transform:rotate(22deg)}32%{-webkit-transform:rotate(-12deg);transform:rotate(-12deg)}36%{-webkit-transform:rotate(12deg);transform:rotate(12deg)}40%,to{-webkit-transform:rotate(0deg);transform:rotate(0deg)}}@keyframes fa-shake{0%{-webkit-transform:rotate(-15deg);transform:rotate(-15deg)}4%{-webkit-transform:rotate(15deg);transform:rotate(15deg)}8%,24%{-webkit-transform:rotate(-18deg);transform:rotate(-18deg)}12%,28%{-webkit-transform:rotate(18deg);transform:rotate(18deg)}16%{-webkit-transform:rotate(-22deg);transform:rotate(-22deg)}20%{-webkit-transform:rotate(22deg);transform:rotate(22deg)}32%{-webkit-transform:rotate(-12deg);transform:rotate(-12deg)}36%{-webkit-transform:rotate(12deg);transform:rotate(12deg)}40%,to{-webkit-transform:rotate(0deg);transform:rotate(0deg)}}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}.fa-rotate-90{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-webkit-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-webkit-transform:scaleX(-1);transform:scaleX(-1)}.fa-flip-vertical{-webkit-transform:scaleY(-1);transform:scaleY(-1)}.fa-flip-both,.fa-flip-horizontal.fa-flip-vertical{-webkit-transform:scale(-1);transform:scale(-1)}.fa-rotate-by{-webkit-transform:rotate(var(--fa-rotate-angle,0));transform:rotate(var(--fa-rotate-angle,0))}.fa-stack{display:inline-block;height:2em;line-height:2em;position:relative;vertical-align:middle;width:2.5em}.fa-stack-1x,.fa-stack-2x{left:0;position:absolute;text-align:center;width:100%;z-index:var(--fa-stack-z-index,auto)}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:var(--fa-inverse,#fff)} + +.fa-0:before{content:"\30"}.fa-1:before{content:"\31"}.fa-2:before{content:"\32"}.fa-3:before{content:"\33"}.fa-4:before{content:"\34"}.fa-5:before{content:"\35"}.fa-6:before{content:"\36"}.fa-7:before{content:"\37"}.fa-8:before{content:"\38"}.fa-9:before{content:"\39"}.fa-fill-drip:before{content:"\f576"}.fa-arrows-to-circle:before{content:"\e4bd"}.fa-chevron-circle-right:before,.fa-circle-chevron-right:before{content:"\f138"}.fa-at:before{content:"\40"}.fa-trash-alt:before,.fa-trash-can:before{content:"\f2ed"}.fa-text-height:before{content:"\f034"}.fa-user-times:before,.fa-user-xmark:before{content:"\f235"}.fa-stethoscope:before{content:"\f0f1"}.fa-comment-alt:before,.fa-message:before{content:"\f27a"}.fa-info:before{content:"\f129"}.fa-compress-alt:before,.fa-down-left-and-up-right-to-center:before{content:"\f422"}.fa-explosion:before{content:"\e4e9"}.fa-file-alt:before,.fa-file-lines:before,.fa-file-text:before{content:"\f15c"}.fa-wave-square:before{content:"\f83e"}.fa-ring:before{content:"\f70b"}.fa-building-un:before{content:"\e4d9"}.fa-dice-three:before{content:"\f527"}.fa-calendar-alt:before,.fa-calendar-days:before{content:"\f073"}.fa-anchor-circle-check:before{content:"\e4aa"}.fa-building-circle-arrow-right:before{content:"\e4d1"}.fa-volleyball-ball:before,.fa-volleyball:before{content:"\f45f"}.fa-arrows-up-to-line:before{content:"\e4c2"}.fa-sort-desc:before,.fa-sort-down:before{content:"\f0dd"}.fa-circle-minus:before,.fa-minus-circle:before{content:"\f056"}.fa-door-open:before{content:"\f52b"}.fa-right-from-bracket:before,.fa-sign-out-alt:before{content:"\f2f5"}.fa-atom:before{content:"\f5d2"}.fa-soap:before{content:"\e06e"}.fa-heart-music-camera-bolt:before,.fa-icons:before{content:"\f86d"}.fa-microphone-alt-slash:before,.fa-microphone-lines-slash:before{content:"\f539"}.fa-bridge-circle-check:before{content:"\e4c9"}.fa-pump-medical:before{content:"\e06a"}.fa-fingerprint:before{content:"\f577"}.fa-hand-point-right:before{content:"\f0a4"}.fa-magnifying-glass-location:before,.fa-search-location:before{content:"\f689"}.fa-forward-step:before,.fa-step-forward:before{content:"\f051"}.fa-face-smile-beam:before,.fa-smile-beam:before{content:"\f5b8"}.fa-flag-checkered:before{content:"\f11e"}.fa-football-ball:before,.fa-football:before{content:"\f44e"}.fa-school-circle-exclamation:before{content:"\e56c"}.fa-crop:before{content:"\f125"}.fa-angle-double-down:before,.fa-angles-down:before{content:"\f103"}.fa-users-rectangle:before{content:"\e594"}.fa-people-roof:before{content:"\e537"}.fa-people-line:before{content:"\e534"}.fa-beer-mug-empty:before,.fa-beer:before{content:"\f0fc"}.fa-diagram-predecessor:before{content:"\e477"}.fa-arrow-up-long:before,.fa-long-arrow-up:before{content:"\f176"}.fa-burn:before,.fa-fire-flame-simple:before{content:"\f46a"}.fa-male:before,.fa-person:before{content:"\f183"}.fa-laptop:before{content:"\f109"}.fa-file-csv:before{content:"\f6dd"}.fa-menorah:before{content:"\f676"}.fa-truck-plane:before{content:"\e58f"}.fa-record-vinyl:before{content:"\f8d9"}.fa-face-grin-stars:before,.fa-grin-stars:before{content:"\f587"}.fa-bong:before{content:"\f55c"}.fa-pastafarianism:before,.fa-spaghetti-monster-flying:before{content:"\f67b"}.fa-arrow-down-up-across-line:before{content:"\e4af"}.fa-spoon:before,.fa-utensil-spoon:before{content:"\f2e5"}.fa-jar-wheat:before{content:"\e517"}.fa-envelopes-bulk:before,.fa-mail-bulk:before{content:"\f674"}.fa-file-circle-exclamation:before{content:"\e4eb"}.fa-circle-h:before,.fa-hospital-symbol:before{content:"\f47e"}.fa-pager:before{content:"\f815"}.fa-address-book:before,.fa-contact-book:before{content:"\f2b9"}.fa-strikethrough:before{content:"\f0cc"}.fa-k:before{content:"\4b"}.fa-landmark-flag:before{content:"\e51c"}.fa-pencil-alt:before,.fa-pencil:before{content:"\f303"}.fa-backward:before{content:"\f04a"}.fa-caret-right:before{content:"\f0da"}.fa-comments:before{content:"\f086"}.fa-file-clipboard:before,.fa-paste:before{content:"\f0ea"}.fa-code-pull-request:before{content:"\e13c"}.fa-clipboard-list:before{content:"\f46d"}.fa-truck-loading:before,.fa-truck-ramp-box:before{content:"\f4de"}.fa-user-check:before{content:"\f4fc"}.fa-vial-virus:before{content:"\e597"}.fa-sheet-plastic:before{content:"\e571"}.fa-blog:before{content:"\f781"}.fa-user-ninja:before{content:"\f504"}.fa-person-arrow-up-from-line:before{content:"\e539"}.fa-scroll-torah:before,.fa-torah:before{content:"\f6a0"}.fa-broom-ball:before,.fa-quidditch-broom-ball:before,.fa-quidditch:before{content:"\f458"}.fa-toggle-off:before{content:"\f204"}.fa-archive:before,.fa-box-archive:before{content:"\f187"}.fa-person-drowning:before{content:"\e545"}.fa-arrow-down-9-1:before,.fa-sort-numeric-desc:before,.fa-sort-numeric-down-alt:before{content:"\f886"}.fa-face-grin-tongue-squint:before,.fa-grin-tongue-squint:before{content:"\f58a"}.fa-spray-can:before{content:"\f5bd"}.fa-truck-monster:before{content:"\f63b"}.fa-w:before{content:"\57"}.fa-earth-africa:before,.fa-globe-africa:before{content:"\f57c"}.fa-rainbow:before{content:"\f75b"}.fa-circle-notch:before{content:"\f1ce"}.fa-tablet-alt:before,.fa-tablet-screen-button:before{content:"\f3fa"}.fa-paw:before{content:"\f1b0"}.fa-cloud:before{content:"\f0c2"}.fa-trowel-bricks:before{content:"\e58a"}.fa-face-flushed:before,.fa-flushed:before{content:"\f579"}.fa-hospital-user:before{content:"\f80d"}.fa-tent-arrow-left-right:before{content:"\e57f"}.fa-gavel:before,.fa-legal:before{content:"\f0e3"}.fa-binoculars:before{content:"\f1e5"}.fa-microphone-slash:before{content:"\f131"}.fa-box-tissue:before{content:"\e05b"}.fa-motorcycle:before{content:"\f21c"}.fa-bell-concierge:before,.fa-concierge-bell:before{content:"\f562"}.fa-pen-ruler:before,.fa-pencil-ruler:before{content:"\f5ae"}.fa-people-arrows-left-right:before,.fa-people-arrows:before{content:"\e068"}.fa-mars-and-venus-burst:before{content:"\e523"}.fa-caret-square-right:before,.fa-square-caret-right:before{content:"\f152"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-sun-plant-wilt:before{content:"\e57a"}.fa-toilets-portable:before{content:"\e584"}.fa-hockey-puck:before{content:"\f453"}.fa-table:before{content:"\f0ce"}.fa-magnifying-glass-arrow-right:before{content:"\e521"}.fa-digital-tachograph:before,.fa-tachograph-digital:before{content:"\f566"}.fa-users-slash:before{content:"\e073"}.fa-clover:before{content:"\e139"}.fa-mail-reply:before,.fa-reply:before{content:"\f3e5"}.fa-star-and-crescent:before{content:"\f699"}.fa-house-fire:before{content:"\e50c"}.fa-minus-square:before,.fa-square-minus:before{content:"\f146"}.fa-helicopter:before{content:"\f533"}.fa-compass:before{content:"\f14e"}.fa-caret-square-down:before,.fa-square-caret-down:before{content:"\f150"}.fa-file-circle-question:before{content:"\e4ef"}.fa-laptop-code:before{content:"\f5fc"}.fa-swatchbook:before{content:"\f5c3"}.fa-prescription-bottle:before{content:"\f485"}.fa-bars:before,.fa-navicon:before{content:"\f0c9"}.fa-people-group:before{content:"\e533"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-heart-broken:before,.fa-heart-crack:before{content:"\f7a9"}.fa-external-link-square-alt:before,.fa-square-up-right:before{content:"\f360"}.fa-face-kiss-beam:before,.fa-kiss-beam:before{content:"\f597"}.fa-film:before{content:"\f008"}.fa-ruler-horizontal:before{content:"\f547"}.fa-people-robbery:before{content:"\e536"}.fa-lightbulb:before{content:"\f0eb"}.fa-caret-left:before{content:"\f0d9"}.fa-circle-exclamation:before,.fa-exclamation-circle:before{content:"\f06a"}.fa-school-circle-xmark:before{content:"\e56d"}.fa-arrow-right-from-bracket:before,.fa-sign-out:before{content:"\f08b"}.fa-chevron-circle-down:before,.fa-circle-chevron-down:before{content:"\f13a"}.fa-unlock-alt:before,.fa-unlock-keyhole:before{content:"\f13e"}.fa-cloud-showers-heavy:before{content:"\f740"}.fa-headphones-alt:before,.fa-headphones-simple:before{content:"\f58f"}.fa-sitemap:before{content:"\f0e8"}.fa-circle-dollar-to-slot:before,.fa-donate:before{content:"\f4b9"}.fa-memory:before{content:"\f538"}.fa-road-spikes:before{content:"\e568"}.fa-fire-burner:before{content:"\e4f1"}.fa-flag:before{content:"\f024"}.fa-hanukiah:before{content:"\f6e6"}.fa-feather:before{content:"\f52d"}.fa-volume-down:before,.fa-volume-low:before{content:"\f027"}.fa-comment-slash:before{content:"\f4b3"}.fa-cloud-sun-rain:before{content:"\f743"}.fa-compress:before{content:"\f066"}.fa-wheat-alt:before,.fa-wheat-awn:before{content:"\e2cd"}.fa-ankh:before{content:"\f644"}.fa-hands-holding-child:before{content:"\e4fa"}.fa-asterisk:before{content:"\2a"}.fa-check-square:before,.fa-square-check:before{content:"\f14a"}.fa-peseta-sign:before{content:"\e221"}.fa-header:before,.fa-heading:before{content:"\f1dc"}.fa-ghost:before{content:"\f6e2"}.fa-list-squares:before,.fa-list:before{content:"\f03a"}.fa-phone-square-alt:before,.fa-square-phone-flip:before{content:"\f87b"}.fa-cart-plus:before{content:"\f217"}.fa-gamepad:before{content:"\f11b"}.fa-circle-dot:before,.fa-dot-circle:before{content:"\f192"}.fa-dizzy:before,.fa-face-dizzy:before{content:"\f567"}.fa-egg:before{content:"\f7fb"}.fa-house-medical-circle-xmark:before{content:"\e513"}.fa-campground:before{content:"\f6bb"}.fa-folder-plus:before{content:"\f65e"}.fa-futbol-ball:before,.fa-futbol:before,.fa-soccer-ball:before{content:"\f1e3"}.fa-paint-brush:before,.fa-paintbrush:before{content:"\f1fc"}.fa-lock:before{content:"\f023"}.fa-gas-pump:before{content:"\f52f"}.fa-hot-tub-person:before,.fa-hot-tub:before{content:"\f593"}.fa-map-location:before,.fa-map-marked:before{content:"\f59f"}.fa-house-flood-water:before{content:"\e50e"}.fa-tree:before{content:"\f1bb"}.fa-bridge-lock:before{content:"\e4cc"}.fa-sack-dollar:before{content:"\f81d"}.fa-edit:before,.fa-pen-to-square:before{content:"\f044"}.fa-car-side:before{content:"\f5e4"}.fa-share-alt:before,.fa-share-nodes:before{content:"\f1e0"}.fa-heart-circle-minus:before{content:"\e4ff"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-microscope:before{content:"\f610"}.fa-sink:before{content:"\e06d"}.fa-bag-shopping:before,.fa-shopping-bag:before{content:"\f290"}.fa-arrow-down-z-a:before,.fa-sort-alpha-desc:before,.fa-sort-alpha-down-alt:before{content:"\f881"}.fa-mitten:before{content:"\f7b5"}.fa-person-rays:before{content:"\e54d"}.fa-users:before{content:"\f0c0"}.fa-eye-slash:before{content:"\f070"}.fa-flask-vial:before{content:"\e4f3"}.fa-hand-paper:before,.fa-hand:before{content:"\f256"}.fa-om:before{content:"\f679"}.fa-worm:before{content:"\e599"}.fa-house-circle-xmark:before{content:"\e50b"}.fa-plug:before{content:"\f1e6"}.fa-chevron-up:before{content:"\f077"}.fa-hand-spock:before{content:"\f259"}.fa-stopwatch:before{content:"\f2f2"}.fa-face-kiss:before,.fa-kiss:before{content:"\f596"}.fa-bridge-circle-xmark:before{content:"\e4cb"}.fa-face-grin-tongue:before,.fa-grin-tongue:before{content:"\f589"}.fa-chess-bishop:before{content:"\f43a"}.fa-face-grin-wink:before,.fa-grin-wink:before{content:"\f58c"}.fa-deaf:before,.fa-deafness:before,.fa-ear-deaf:before,.fa-hard-of-hearing:before{content:"\f2a4"}.fa-road-circle-check:before{content:"\e564"}.fa-dice-five:before{content:"\f523"}.fa-rss-square:before,.fa-square-rss:before{content:"\f143"}.fa-land-mine-on:before{content:"\e51b"}.fa-i-cursor:before{content:"\f246"}.fa-stamp:before{content:"\f5bf"}.fa-stairs:before{content:"\e289"}.fa-i:before{content:"\49"}.fa-hryvnia-sign:before,.fa-hryvnia:before{content:"\f6f2"}.fa-pills:before{content:"\f484"}.fa-face-grin-wide:before,.fa-grin-alt:before{content:"\f581"}.fa-tooth:before{content:"\f5c9"}.fa-v:before{content:"\56"}.fa-bangladeshi-taka-sign:before{content:"\e2e6"}.fa-bicycle:before{content:"\f206"}.fa-rod-asclepius:before,.fa-rod-snake:before,.fa-staff-aesculapius:before,.fa-staff-snake:before{content:"\e579"}.fa-head-side-cough-slash:before{content:"\e062"}.fa-ambulance:before,.fa-truck-medical:before{content:"\f0f9"}.fa-wheat-awn-circle-exclamation:before{content:"\e598"}.fa-snowman:before{content:"\f7d0"}.fa-mortar-pestle:before{content:"\f5a7"}.fa-road-barrier:before{content:"\e562"}.fa-school:before{content:"\f549"}.fa-igloo:before{content:"\f7ae"}.fa-joint:before{content:"\f595"}.fa-angle-right:before{content:"\f105"}.fa-horse:before{content:"\f6f0"}.fa-q:before{content:"\51"}.fa-g:before{content:"\47"}.fa-notes-medical:before{content:"\f481"}.fa-temperature-2:before,.fa-temperature-half:before,.fa-thermometer-2:before,.fa-thermometer-half:before{content:"\f2c9"}.fa-dong-sign:before{content:"\e169"}.fa-capsules:before{content:"\f46b"}.fa-poo-bolt:before,.fa-poo-storm:before{content:"\f75a"}.fa-face-frown-open:before,.fa-frown-open:before{content:"\f57a"}.fa-hand-point-up:before{content:"\f0a6"}.fa-money-bill:before{content:"\f0d6"}.fa-bookmark:before{content:"\f02e"}.fa-align-justify:before{content:"\f039"}.fa-umbrella-beach:before{content:"\f5ca"}.fa-helmet-un:before{content:"\e503"}.fa-bullseye:before{content:"\f140"}.fa-bacon:before{content:"\f7e5"}.fa-hand-point-down:before{content:"\f0a7"}.fa-arrow-up-from-bracket:before{content:"\e09a"}.fa-folder-blank:before,.fa-folder:before{content:"\f07b"}.fa-file-medical-alt:before,.fa-file-waveform:before{content:"\f478"}.fa-radiation:before{content:"\f7b9"}.fa-chart-simple:before{content:"\e473"}.fa-mars-stroke:before{content:"\f229"}.fa-vial:before{content:"\f492"}.fa-dashboard:before,.fa-gauge-med:before,.fa-gauge:before,.fa-tachometer-alt-average:before{content:"\f624"}.fa-magic-wand-sparkles:before,.fa-wand-magic-sparkles:before{content:"\e2ca"}.fa-e:before{content:"\45"}.fa-pen-alt:before,.fa-pen-clip:before{content:"\f305"}.fa-bridge-circle-exclamation:before{content:"\e4ca"}.fa-user:before{content:"\f007"}.fa-school-circle-check:before{content:"\e56b"}.fa-dumpster:before{content:"\f793"}.fa-shuttle-van:before,.fa-van-shuttle:before{content:"\f5b6"}.fa-building-user:before{content:"\e4da"}.fa-caret-square-left:before,.fa-square-caret-left:before{content:"\f191"}.fa-highlighter:before{content:"\f591"}.fa-key:before{content:"\f084"}.fa-bullhorn:before{content:"\f0a1"}.fa-globe:before{content:"\f0ac"}.fa-synagogue:before{content:"\f69b"}.fa-person-half-dress:before{content:"\e548"}.fa-road-bridge:before{content:"\e563"}.fa-location-arrow:before{content:"\f124"}.fa-c:before{content:"\43"}.fa-tablet-button:before{content:"\f10a"}.fa-building-lock:before{content:"\e4d6"}.fa-pizza-slice:before{content:"\f818"}.fa-money-bill-wave:before{content:"\f53a"}.fa-area-chart:before,.fa-chart-area:before{content:"\f1fe"}.fa-house-flag:before{content:"\e50d"}.fa-person-circle-minus:before{content:"\e540"}.fa-ban:before,.fa-cancel:before{content:"\f05e"}.fa-camera-rotate:before{content:"\e0d8"}.fa-air-freshener:before,.fa-spray-can-sparkles:before{content:"\f5d0"}.fa-star:before{content:"\f005"}.fa-repeat:before{content:"\f363"}.fa-cross:before{content:"\f654"}.fa-box:before{content:"\f466"}.fa-venus-mars:before{content:"\f228"}.fa-arrow-pointer:before,.fa-mouse-pointer:before{content:"\f245"}.fa-expand-arrows-alt:before,.fa-maximize:before{content:"\f31e"}.fa-charging-station:before{content:"\f5e7"}.fa-shapes:before,.fa-triangle-circle-square:before{content:"\f61f"}.fa-random:before,.fa-shuffle:before{content:"\f074"}.fa-person-running:before,.fa-running:before{content:"\f70c"}.fa-mobile-retro:before{content:"\e527"}.fa-grip-lines-vertical:before{content:"\f7a5"}.fa-spider:before{content:"\f717"}.fa-hands-bound:before{content:"\e4f9"}.fa-file-invoice-dollar:before{content:"\f571"}.fa-plane-circle-exclamation:before{content:"\e556"}.fa-x-ray:before{content:"\f497"}.fa-spell-check:before{content:"\f891"}.fa-slash:before{content:"\f715"}.fa-computer-mouse:before,.fa-mouse:before{content:"\f8cc"}.fa-arrow-right-to-bracket:before,.fa-sign-in:before{content:"\f090"}.fa-shop-slash:before,.fa-store-alt-slash:before{content:"\e070"}.fa-server:before{content:"\f233"}.fa-virus-covid-slash:before{content:"\e4a9"}.fa-shop-lock:before{content:"\e4a5"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-blender-phone:before{content:"\f6b6"}.fa-building-wheat:before{content:"\e4db"}.fa-person-breastfeeding:before{content:"\e53a"}.fa-right-to-bracket:before,.fa-sign-in-alt:before{content:"\f2f6"}.fa-venus:before{content:"\f221"}.fa-passport:before{content:"\f5ab"}.fa-heart-pulse:before,.fa-heartbeat:before{content:"\f21e"}.fa-people-carry-box:before,.fa-people-carry:before{content:"\f4ce"}.fa-temperature-high:before{content:"\f769"}.fa-microchip:before{content:"\f2db"}.fa-crown:before{content:"\f521"}.fa-weight-hanging:before{content:"\f5cd"}.fa-xmarks-lines:before{content:"\e59a"}.fa-file-prescription:before{content:"\f572"}.fa-weight-scale:before,.fa-weight:before{content:"\f496"}.fa-user-friends:before,.fa-user-group:before{content:"\f500"}.fa-arrow-up-a-z:before,.fa-sort-alpha-up:before{content:"\f15e"}.fa-chess-knight:before{content:"\f441"}.fa-face-laugh-squint:before,.fa-laugh-squint:before{content:"\f59b"}.fa-wheelchair:before{content:"\f193"}.fa-arrow-circle-up:before,.fa-circle-arrow-up:before{content:"\f0aa"}.fa-toggle-on:before{content:"\f205"}.fa-person-walking:before,.fa-walking:before{content:"\f554"}.fa-l:before{content:"\4c"}.fa-fire:before{content:"\f06d"}.fa-bed-pulse:before,.fa-procedures:before{content:"\f487"}.fa-shuttle-space:before,.fa-space-shuttle:before{content:"\f197"}.fa-face-laugh:before,.fa-laugh:before{content:"\f599"}.fa-folder-open:before{content:"\f07c"}.fa-heart-circle-plus:before{content:"\e500"}.fa-code-fork:before{content:"\e13b"}.fa-city:before{content:"\f64f"}.fa-microphone-alt:before,.fa-microphone-lines:before{content:"\f3c9"}.fa-pepper-hot:before{content:"\f816"}.fa-unlock:before{content:"\f09c"}.fa-colon-sign:before{content:"\e140"}.fa-headset:before{content:"\f590"}.fa-store-slash:before{content:"\e071"}.fa-road-circle-xmark:before{content:"\e566"}.fa-user-minus:before{content:"\f503"}.fa-mars-stroke-up:before,.fa-mars-stroke-v:before{content:"\f22a"}.fa-champagne-glasses:before,.fa-glass-cheers:before{content:"\f79f"}.fa-clipboard:before{content:"\f328"}.fa-house-circle-exclamation:before{content:"\e50a"}.fa-file-arrow-up:before,.fa-file-upload:before{content:"\f574"}.fa-wifi-3:before,.fa-wifi-strong:before,.fa-wifi:before{content:"\f1eb"}.fa-bath:before,.fa-bathtub:before{content:"\f2cd"}.fa-underline:before{content:"\f0cd"}.fa-user-edit:before,.fa-user-pen:before{content:"\f4ff"}.fa-signature:before{content:"\f5b7"}.fa-stroopwafel:before{content:"\f551"}.fa-bold:before{content:"\f032"}.fa-anchor-lock:before{content:"\e4ad"}.fa-building-ngo:before{content:"\e4d7"}.fa-manat-sign:before{content:"\e1d5"}.fa-not-equal:before{content:"\f53e"}.fa-border-style:before,.fa-border-top-left:before{content:"\f853"}.fa-map-location-dot:before,.fa-map-marked-alt:before{content:"\f5a0"}.fa-jedi:before{content:"\f669"}.fa-poll:before,.fa-square-poll-vertical:before{content:"\f681"}.fa-mug-hot:before{content:"\f7b6"}.fa-battery-car:before,.fa-car-battery:before{content:"\f5df"}.fa-gift:before{content:"\f06b"}.fa-dice-two:before{content:"\f528"}.fa-chess-queen:before{content:"\f445"}.fa-glasses:before{content:"\f530"}.fa-chess-board:before{content:"\f43c"}.fa-building-circle-check:before{content:"\e4d2"}.fa-person-chalkboard:before{content:"\e53d"}.fa-mars-stroke-h:before,.fa-mars-stroke-right:before{content:"\f22b"}.fa-hand-back-fist:before,.fa-hand-rock:before{content:"\f255"}.fa-caret-square-up:before,.fa-square-caret-up:before{content:"\f151"}.fa-cloud-showers-water:before{content:"\e4e4"}.fa-bar-chart:before,.fa-chart-bar:before{content:"\f080"}.fa-hands-bubbles:before,.fa-hands-wash:before{content:"\e05e"}.fa-less-than-equal:before{content:"\f537"}.fa-train:before{content:"\f238"}.fa-eye-low-vision:before,.fa-low-vision:before{content:"\f2a8"}.fa-crow:before{content:"\f520"}.fa-sailboat:before{content:"\e445"}.fa-window-restore:before{content:"\f2d2"}.fa-plus-square:before,.fa-square-plus:before{content:"\f0fe"}.fa-torii-gate:before{content:"\f6a1"}.fa-frog:before{content:"\f52e"}.fa-bucket:before{content:"\e4cf"}.fa-image:before{content:"\f03e"}.fa-microphone:before{content:"\f130"}.fa-cow:before{content:"\f6c8"}.fa-caret-up:before{content:"\f0d8"}.fa-screwdriver:before{content:"\f54a"}.fa-folder-closed:before{content:"\e185"}.fa-house-tsunami:before{content:"\e515"}.fa-square-nfi:before{content:"\e576"}.fa-arrow-up-from-ground-water:before{content:"\e4b5"}.fa-glass-martini-alt:before,.fa-martini-glass:before{content:"\f57b"}.fa-rotate-back:before,.fa-rotate-backward:before,.fa-rotate-left:before,.fa-undo-alt:before{content:"\f2ea"}.fa-columns:before,.fa-table-columns:before{content:"\f0db"}.fa-lemon:before{content:"\f094"}.fa-head-side-mask:before{content:"\e063"}.fa-handshake:before{content:"\f2b5"}.fa-gem:before{content:"\f3a5"}.fa-dolly-box:before,.fa-dolly:before{content:"\f472"}.fa-smoking:before{content:"\f48d"}.fa-compress-arrows-alt:before,.fa-minimize:before{content:"\f78c"}.fa-monument:before{content:"\f5a6"}.fa-snowplow:before{content:"\f7d2"}.fa-angle-double-right:before,.fa-angles-right:before{content:"\f101"}.fa-cannabis:before{content:"\f55f"}.fa-circle-play:before,.fa-play-circle:before{content:"\f144"}.fa-tablets:before{content:"\f490"}.fa-ethernet:before{content:"\f796"}.fa-eur:before,.fa-euro-sign:before,.fa-euro:before{content:"\f153"}.fa-chair:before{content:"\f6c0"}.fa-check-circle:before,.fa-circle-check:before{content:"\f058"}.fa-circle-stop:before,.fa-stop-circle:before{content:"\f28d"}.fa-compass-drafting:before,.fa-drafting-compass:before{content:"\f568"}.fa-plate-wheat:before{content:"\e55a"}.fa-icicles:before{content:"\f7ad"}.fa-person-shelter:before{content:"\e54f"}.fa-neuter:before{content:"\f22c"}.fa-id-badge:before{content:"\f2c1"}.fa-marker:before{content:"\f5a1"}.fa-face-laugh-beam:before,.fa-laugh-beam:before{content:"\f59a"}.fa-helicopter-symbol:before{content:"\e502"}.fa-universal-access:before{content:"\f29a"}.fa-chevron-circle-up:before,.fa-circle-chevron-up:before{content:"\f139"}.fa-lari-sign:before{content:"\e1c8"}.fa-volcano:before{content:"\f770"}.fa-person-walking-dashed-line-arrow-right:before{content:"\e553"}.fa-gbp:before,.fa-pound-sign:before,.fa-sterling-sign:before{content:"\f154"}.fa-viruses:before{content:"\e076"}.fa-square-person-confined:before{content:"\e577"}.fa-user-tie:before{content:"\f508"}.fa-arrow-down-long:before,.fa-long-arrow-down:before{content:"\f175"}.fa-tent-arrow-down-to-line:before{content:"\e57e"}.fa-certificate:before{content:"\f0a3"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-suitcase:before{content:"\f0f2"}.fa-person-skating:before,.fa-skating:before{content:"\f7c5"}.fa-filter-circle-dollar:before,.fa-funnel-dollar:before{content:"\f662"}.fa-camera-retro:before{content:"\f083"}.fa-arrow-circle-down:before,.fa-circle-arrow-down:before{content:"\f0ab"}.fa-arrow-right-to-file:before,.fa-file-import:before{content:"\f56f"}.fa-external-link-square:before,.fa-square-arrow-up-right:before{content:"\f14c"}.fa-box-open:before{content:"\f49e"}.fa-scroll:before{content:"\f70e"}.fa-spa:before{content:"\f5bb"}.fa-location-pin-lock:before{content:"\e51f"}.fa-pause:before{content:"\f04c"}.fa-hill-avalanche:before{content:"\e507"}.fa-temperature-0:before,.fa-temperature-empty:before,.fa-thermometer-0:before,.fa-thermometer-empty:before{content:"\f2cb"}.fa-bomb:before{content:"\f1e2"}.fa-registered:before{content:"\f25d"}.fa-address-card:before,.fa-contact-card:before,.fa-vcard:before{content:"\f2bb"}.fa-balance-scale-right:before,.fa-scale-unbalanced-flip:before{content:"\f516"}.fa-subscript:before{content:"\f12c"}.fa-diamond-turn-right:before,.fa-directions:before{content:"\f5eb"}.fa-burst:before{content:"\e4dc"}.fa-house-laptop:before,.fa-laptop-house:before{content:"\e066"}.fa-face-tired:before,.fa-tired:before{content:"\f5c8"}.fa-money-bills:before{content:"\e1f3"}.fa-smog:before{content:"\f75f"}.fa-crutch:before{content:"\f7f7"}.fa-cloud-arrow-up:before,.fa-cloud-upload-alt:before,.fa-cloud-upload:before{content:"\f0ee"}.fa-palette:before{content:"\f53f"}.fa-arrows-turn-right:before{content:"\e4c0"}.fa-vest:before{content:"\e085"}.fa-ferry:before{content:"\e4ea"}.fa-arrows-down-to-people:before{content:"\e4b9"}.fa-seedling:before,.fa-sprout:before{content:"\f4d8"}.fa-arrows-alt-h:before,.fa-left-right:before{content:"\f337"}.fa-boxes-packing:before{content:"\e4c7"}.fa-arrow-circle-left:before,.fa-circle-arrow-left:before{content:"\f0a8"}.fa-group-arrows-rotate:before{content:"\e4f6"}.fa-bowl-food:before{content:"\e4c6"}.fa-candy-cane:before{content:"\f786"}.fa-arrow-down-wide-short:before,.fa-sort-amount-asc:before,.fa-sort-amount-down:before{content:"\f160"}.fa-cloud-bolt:before,.fa-thunderstorm:before{content:"\f76c"}.fa-remove-format:before,.fa-text-slash:before{content:"\f87d"}.fa-face-smile-wink:before,.fa-smile-wink:before{content:"\f4da"}.fa-file-word:before{content:"\f1c2"}.fa-file-powerpoint:before{content:"\f1c4"}.fa-arrows-h:before,.fa-arrows-left-right:before{content:"\f07e"}.fa-house-lock:before{content:"\e510"}.fa-cloud-arrow-down:before,.fa-cloud-download-alt:before,.fa-cloud-download:before{content:"\f0ed"}.fa-children:before{content:"\e4e1"}.fa-blackboard:before,.fa-chalkboard:before{content:"\f51b"}.fa-user-alt-slash:before,.fa-user-large-slash:before{content:"\f4fa"}.fa-envelope-open:before{content:"\f2b6"}.fa-handshake-alt-slash:before,.fa-handshake-simple-slash:before{content:"\e05f"}.fa-mattress-pillow:before{content:"\e525"}.fa-guarani-sign:before{content:"\e19a"}.fa-arrows-rotate:before,.fa-refresh:before,.fa-sync:before{content:"\f021"}.fa-fire-extinguisher:before{content:"\f134"}.fa-cruzeiro-sign:before{content:"\e152"}.fa-greater-than-equal:before{content:"\f532"}.fa-shield-alt:before,.fa-shield-halved:before{content:"\f3ed"}.fa-atlas:before,.fa-book-atlas:before{content:"\f558"}.fa-virus:before{content:"\e074"}.fa-envelope-circle-check:before{content:"\e4e8"}.fa-layer-group:before{content:"\f5fd"}.fa-arrows-to-dot:before{content:"\e4be"}.fa-archway:before{content:"\f557"}.fa-heart-circle-check:before{content:"\e4fd"}.fa-house-chimney-crack:before,.fa-house-damage:before{content:"\f6f1"}.fa-file-archive:before,.fa-file-zipper:before{content:"\f1c6"}.fa-square:before{content:"\f0c8"}.fa-glass-martini:before,.fa-martini-glass-empty:before{content:"\f000"}.fa-couch:before{content:"\f4b8"}.fa-cedi-sign:before{content:"\e0df"}.fa-italic:before{content:"\f033"}.fa-table-cells-column-lock:before{content:"\e678"}.fa-church:before{content:"\f51d"}.fa-comments-dollar:before{content:"\f653"}.fa-democrat:before{content:"\f747"}.fa-z:before{content:"\5a"}.fa-person-skiing:before,.fa-skiing:before{content:"\f7c9"}.fa-road-lock:before{content:"\e567"}.fa-a:before{content:"\41"}.fa-temperature-arrow-down:before,.fa-temperature-down:before{content:"\e03f"}.fa-feather-alt:before,.fa-feather-pointed:before{content:"\f56b"}.fa-p:before{content:"\50"}.fa-snowflake:before{content:"\f2dc"}.fa-newspaper:before{content:"\f1ea"}.fa-ad:before,.fa-rectangle-ad:before{content:"\f641"}.fa-arrow-circle-right:before,.fa-circle-arrow-right:before{content:"\f0a9"}.fa-filter-circle-xmark:before{content:"\e17b"}.fa-locust:before{content:"\e520"}.fa-sort:before,.fa-unsorted:before{content:"\f0dc"}.fa-list-1-2:before,.fa-list-numeric:before,.fa-list-ol:before{content:"\f0cb"}.fa-person-dress-burst:before{content:"\e544"}.fa-money-check-alt:before,.fa-money-check-dollar:before{content:"\f53d"}.fa-vector-square:before{content:"\f5cb"}.fa-bread-slice:before{content:"\f7ec"}.fa-language:before{content:"\f1ab"}.fa-face-kiss-wink-heart:before,.fa-kiss-wink-heart:before{content:"\f598"}.fa-filter:before{content:"\f0b0"}.fa-question:before{content:"\3f"}.fa-file-signature:before{content:"\f573"}.fa-arrows-alt:before,.fa-up-down-left-right:before{content:"\f0b2"}.fa-house-chimney-user:before{content:"\e065"}.fa-hand-holding-heart:before{content:"\f4be"}.fa-puzzle-piece:before{content:"\f12e"}.fa-money-check:before{content:"\f53c"}.fa-star-half-alt:before,.fa-star-half-stroke:before{content:"\f5c0"}.fa-code:before{content:"\f121"}.fa-glass-whiskey:before,.fa-whiskey-glass:before{content:"\f7a0"}.fa-building-circle-exclamation:before{content:"\e4d3"}.fa-magnifying-glass-chart:before{content:"\e522"}.fa-arrow-up-right-from-square:before,.fa-external-link:before{content:"\f08e"}.fa-cubes-stacked:before{content:"\e4e6"}.fa-krw:before,.fa-won-sign:before,.fa-won:before{content:"\f159"}.fa-virus-covid:before{content:"\e4a8"}.fa-austral-sign:before{content:"\e0a9"}.fa-f:before{content:"\46"}.fa-leaf:before{content:"\f06c"}.fa-road:before{content:"\f018"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-person-circle-plus:before{content:"\e541"}.fa-chart-pie:before,.fa-pie-chart:before{content:"\f200"}.fa-bolt-lightning:before{content:"\e0b7"}.fa-sack-xmark:before{content:"\e56a"}.fa-file-excel:before{content:"\f1c3"}.fa-file-contract:before{content:"\f56c"}.fa-fish-fins:before{content:"\e4f2"}.fa-building-flag:before{content:"\e4d5"}.fa-face-grin-beam:before,.fa-grin-beam:before{content:"\f582"}.fa-object-ungroup:before{content:"\f248"}.fa-poop:before{content:"\f619"}.fa-location-pin:before,.fa-map-marker:before{content:"\f041"}.fa-kaaba:before{content:"\f66b"}.fa-toilet-paper:before{content:"\f71e"}.fa-hard-hat:before,.fa-hat-hard:before,.fa-helmet-safety:before{content:"\f807"}.fa-eject:before{content:"\f052"}.fa-arrow-alt-circle-right:before,.fa-circle-right:before{content:"\f35a"}.fa-plane-circle-check:before{content:"\e555"}.fa-face-rolling-eyes:before,.fa-meh-rolling-eyes:before{content:"\f5a5"}.fa-object-group:before{content:"\f247"}.fa-chart-line:before,.fa-line-chart:before{content:"\f201"}.fa-mask-ventilator:before{content:"\e524"}.fa-arrow-right:before{content:"\f061"}.fa-map-signs:before,.fa-signs-post:before{content:"\f277"}.fa-cash-register:before{content:"\f788"}.fa-person-circle-question:before{content:"\e542"}.fa-h:before{content:"\48"}.fa-tarp:before{content:"\e57b"}.fa-screwdriver-wrench:before,.fa-tools:before{content:"\f7d9"}.fa-arrows-to-eye:before{content:"\e4bf"}.fa-plug-circle-bolt:before{content:"\e55b"}.fa-heart:before{content:"\f004"}.fa-mars-and-venus:before{content:"\f224"}.fa-home-user:before,.fa-house-user:before{content:"\e1b0"}.fa-dumpster-fire:before{content:"\f794"}.fa-house-crack:before{content:"\e3b1"}.fa-cocktail:before,.fa-martini-glass-citrus:before{content:"\f561"}.fa-face-surprise:before,.fa-surprise:before{content:"\f5c2"}.fa-bottle-water:before{content:"\e4c5"}.fa-circle-pause:before,.fa-pause-circle:before{content:"\f28b"}.fa-toilet-paper-slash:before{content:"\e072"}.fa-apple-alt:before,.fa-apple-whole:before{content:"\f5d1"}.fa-kitchen-set:before{content:"\e51a"}.fa-r:before{content:"\52"}.fa-temperature-1:before,.fa-temperature-quarter:before,.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:"\f2ca"}.fa-cube:before{content:"\f1b2"}.fa-bitcoin-sign:before{content:"\e0b4"}.fa-shield-dog:before{content:"\e573"}.fa-solar-panel:before{content:"\f5ba"}.fa-lock-open:before{content:"\f3c1"}.fa-elevator:before{content:"\e16d"}.fa-money-bill-transfer:before{content:"\e528"}.fa-money-bill-trend-up:before{content:"\e529"}.fa-house-flood-water-circle-arrow-right:before{content:"\e50f"}.fa-poll-h:before,.fa-square-poll-horizontal:before{content:"\f682"}.fa-circle:before{content:"\f111"}.fa-backward-fast:before,.fa-fast-backward:before{content:"\f049"}.fa-recycle:before{content:"\f1b8"}.fa-user-astronaut:before{content:"\f4fb"}.fa-plane-slash:before{content:"\e069"}.fa-trademark:before{content:"\f25c"}.fa-basketball-ball:before,.fa-basketball:before{content:"\f434"}.fa-satellite-dish:before{content:"\f7c0"}.fa-arrow-alt-circle-up:before,.fa-circle-up:before{content:"\f35b"}.fa-mobile-alt:before,.fa-mobile-screen-button:before{content:"\f3cd"}.fa-volume-high:before,.fa-volume-up:before{content:"\f028"}.fa-users-rays:before{content:"\e593"}.fa-wallet:before{content:"\f555"}.fa-clipboard-check:before{content:"\f46c"}.fa-file-audio:before{content:"\f1c7"}.fa-burger:before,.fa-hamburger:before{content:"\f805"}.fa-wrench:before{content:"\f0ad"}.fa-bugs:before{content:"\e4d0"}.fa-rupee-sign:before,.fa-rupee:before{content:"\f156"}.fa-file-image:before{content:"\f1c5"}.fa-circle-question:before,.fa-question-circle:before{content:"\f059"}.fa-plane-departure:before{content:"\f5b0"}.fa-handshake-slash:before{content:"\e060"}.fa-book-bookmark:before{content:"\e0bb"}.fa-code-branch:before{content:"\f126"}.fa-hat-cowboy:before{content:"\f8c0"}.fa-bridge:before{content:"\e4c8"}.fa-phone-alt:before,.fa-phone-flip:before{content:"\f879"}.fa-truck-front:before{content:"\e2b7"}.fa-cat:before{content:"\f6be"}.fa-anchor-circle-exclamation:before{content:"\e4ab"}.fa-truck-field:before{content:"\e58d"}.fa-route:before{content:"\f4d7"}.fa-clipboard-question:before{content:"\e4e3"}.fa-panorama:before{content:"\e209"}.fa-comment-medical:before{content:"\f7f5"}.fa-teeth-open:before{content:"\f62f"}.fa-file-circle-minus:before{content:"\e4ed"}.fa-tags:before{content:"\f02c"}.fa-wine-glass:before{content:"\f4e3"}.fa-fast-forward:before,.fa-forward-fast:before{content:"\f050"}.fa-face-meh-blank:before,.fa-meh-blank:before{content:"\f5a4"}.fa-parking:before,.fa-square-parking:before{content:"\f540"}.fa-house-signal:before{content:"\e012"}.fa-bars-progress:before,.fa-tasks-alt:before{content:"\f828"}.fa-faucet-drip:before{content:"\e006"}.fa-cart-flatbed:before,.fa-dolly-flatbed:before{content:"\f474"}.fa-ban-smoking:before,.fa-smoking-ban:before{content:"\f54d"}.fa-terminal:before{content:"\f120"}.fa-mobile-button:before{content:"\f10b"}.fa-house-medical-flag:before{content:"\e514"}.fa-basket-shopping:before,.fa-shopping-basket:before{content:"\f291"}.fa-tape:before{content:"\f4db"}.fa-bus-alt:before,.fa-bus-simple:before{content:"\f55e"}.fa-eye:before{content:"\f06e"}.fa-face-sad-cry:before,.fa-sad-cry:before{content:"\f5b3"}.fa-audio-description:before{content:"\f29e"}.fa-person-military-to-person:before{content:"\e54c"}.fa-file-shield:before{content:"\e4f0"}.fa-user-slash:before{content:"\f506"}.fa-pen:before{content:"\f304"}.fa-tower-observation:before{content:"\e586"}.fa-file-code:before{content:"\f1c9"}.fa-signal-5:before,.fa-signal-perfect:before,.fa-signal:before{content:"\f012"}.fa-bus:before{content:"\f207"}.fa-heart-circle-xmark:before{content:"\e501"}.fa-home-lg:before,.fa-house-chimney:before{content:"\e3af"}.fa-window-maximize:before{content:"\f2d0"}.fa-face-frown:before,.fa-frown:before{content:"\f119"}.fa-prescription:before{content:"\f5b1"}.fa-shop:before,.fa-store-alt:before{content:"\f54f"}.fa-floppy-disk:before,.fa-save:before{content:"\f0c7"}.fa-vihara:before{content:"\f6a7"}.fa-balance-scale-left:before,.fa-scale-unbalanced:before{content:"\f515"}.fa-sort-asc:before,.fa-sort-up:before{content:"\f0de"}.fa-comment-dots:before,.fa-commenting:before{content:"\f4ad"}.fa-plant-wilt:before{content:"\e5aa"}.fa-diamond:before{content:"\f219"}.fa-face-grin-squint:before,.fa-grin-squint:before{content:"\f585"}.fa-hand-holding-dollar:before,.fa-hand-holding-usd:before{content:"\f4c0"}.fa-bacterium:before{content:"\e05a"}.fa-hand-pointer:before{content:"\f25a"}.fa-drum-steelpan:before{content:"\f56a"}.fa-hand-scissors:before{content:"\f257"}.fa-hands-praying:before,.fa-praying-hands:before{content:"\f684"}.fa-arrow-right-rotate:before,.fa-arrow-rotate-forward:before,.fa-arrow-rotate-right:before,.fa-redo:before{content:"\f01e"}.fa-biohazard:before{content:"\f780"}.fa-location-crosshairs:before,.fa-location:before{content:"\f601"}.fa-mars-double:before{content:"\f227"}.fa-child-dress:before{content:"\e59c"}.fa-users-between-lines:before{content:"\e591"}.fa-lungs-virus:before{content:"\e067"}.fa-face-grin-tears:before,.fa-grin-tears:before{content:"\f588"}.fa-phone:before{content:"\f095"}.fa-calendar-times:before,.fa-calendar-xmark:before{content:"\f273"}.fa-child-reaching:before{content:"\e59d"}.fa-head-side-virus:before{content:"\e064"}.fa-user-cog:before,.fa-user-gear:before{content:"\f4fe"}.fa-arrow-up-1-9:before,.fa-sort-numeric-up:before{content:"\f163"}.fa-door-closed:before{content:"\f52a"}.fa-shield-virus:before{content:"\e06c"}.fa-dice-six:before{content:"\f526"}.fa-mosquito-net:before{content:"\e52c"}.fa-bridge-water:before{content:"\e4ce"}.fa-person-booth:before{content:"\f756"}.fa-text-width:before{content:"\f035"}.fa-hat-wizard:before{content:"\f6e8"}.fa-pen-fancy:before{content:"\f5ac"}.fa-digging:before,.fa-person-digging:before{content:"\f85e"}.fa-trash:before{content:"\f1f8"}.fa-gauge-simple-med:before,.fa-gauge-simple:before,.fa-tachometer-average:before{content:"\f629"}.fa-book-medical:before{content:"\f7e6"}.fa-poo:before{content:"\f2fe"}.fa-quote-right-alt:before,.fa-quote-right:before{content:"\f10e"}.fa-shirt:before,.fa-t-shirt:before,.fa-tshirt:before{content:"\f553"}.fa-cubes:before{content:"\f1b3"}.fa-divide:before{content:"\f529"}.fa-tenge-sign:before,.fa-tenge:before{content:"\f7d7"}.fa-headphones:before{content:"\f025"}.fa-hands-holding:before{content:"\f4c2"}.fa-hands-clapping:before{content:"\e1a8"}.fa-republican:before{content:"\f75e"}.fa-arrow-left:before{content:"\f060"}.fa-person-circle-xmark:before{content:"\e543"}.fa-ruler:before{content:"\f545"}.fa-align-left:before{content:"\f036"}.fa-dice-d6:before{content:"\f6d1"}.fa-restroom:before{content:"\f7bd"}.fa-j:before{content:"\4a"}.fa-users-viewfinder:before{content:"\e595"}.fa-file-video:before{content:"\f1c8"}.fa-external-link-alt:before,.fa-up-right-from-square:before{content:"\f35d"}.fa-table-cells:before,.fa-th:before{content:"\f00a"}.fa-file-pdf:before{content:"\f1c1"}.fa-bible:before,.fa-book-bible:before{content:"\f647"}.fa-o:before{content:"\4f"}.fa-medkit:before,.fa-suitcase-medical:before{content:"\f0fa"}.fa-user-secret:before{content:"\f21b"}.fa-otter:before{content:"\f700"}.fa-female:before,.fa-person-dress:before{content:"\f182"}.fa-comment-dollar:before{content:"\f651"}.fa-briefcase-clock:before,.fa-business-time:before{content:"\f64a"}.fa-table-cells-large:before,.fa-th-large:before{content:"\f009"}.fa-book-tanakh:before,.fa-tanakh:before{content:"\f827"}.fa-phone-volume:before,.fa-volume-control-phone:before{content:"\f2a0"}.fa-hat-cowboy-side:before{content:"\f8c1"}.fa-clipboard-user:before{content:"\f7f3"}.fa-child:before{content:"\f1ae"}.fa-lira-sign:before{content:"\f195"}.fa-satellite:before{content:"\f7bf"}.fa-plane-lock:before{content:"\e558"}.fa-tag:before{content:"\f02b"}.fa-comment:before{content:"\f075"}.fa-birthday-cake:before,.fa-cake-candles:before,.fa-cake:before{content:"\f1fd"}.fa-envelope:before{content:"\f0e0"}.fa-angle-double-up:before,.fa-angles-up:before{content:"\f102"}.fa-paperclip:before{content:"\f0c6"}.fa-arrow-right-to-city:before{content:"\e4b3"}.fa-ribbon:before{content:"\f4d6"}.fa-lungs:before{content:"\f604"}.fa-arrow-up-9-1:before,.fa-sort-numeric-up-alt:before{content:"\f887"}.fa-litecoin-sign:before{content:"\e1d3"}.fa-border-none:before{content:"\f850"}.fa-circle-nodes:before{content:"\e4e2"}.fa-parachute-box:before{content:"\f4cd"}.fa-indent:before{content:"\f03c"}.fa-truck-field-un:before{content:"\e58e"}.fa-hourglass-empty:before,.fa-hourglass:before{content:"\f254"}.fa-mountain:before{content:"\f6fc"}.fa-user-doctor:before,.fa-user-md:before{content:"\f0f0"}.fa-circle-info:before,.fa-info-circle:before{content:"\f05a"}.fa-cloud-meatball:before{content:"\f73b"}.fa-camera-alt:before,.fa-camera:before{content:"\f030"}.fa-square-virus:before{content:"\e578"}.fa-meteor:before{content:"\f753"}.fa-car-on:before{content:"\e4dd"}.fa-sleigh:before{content:"\f7cc"}.fa-arrow-down-1-9:before,.fa-sort-numeric-asc:before,.fa-sort-numeric-down:before{content:"\f162"}.fa-hand-holding-droplet:before,.fa-hand-holding-water:before{content:"\f4c1"}.fa-water:before{content:"\f773"}.fa-calendar-check:before{content:"\f274"}.fa-braille:before{content:"\f2a1"}.fa-prescription-bottle-alt:before,.fa-prescription-bottle-medical:before{content:"\f486"}.fa-landmark:before{content:"\f66f"}.fa-truck:before{content:"\f0d1"}.fa-crosshairs:before{content:"\f05b"}.fa-person-cane:before{content:"\e53c"}.fa-tent:before{content:"\e57d"}.fa-vest-patches:before{content:"\e086"}.fa-check-double:before{content:"\f560"}.fa-arrow-down-a-z:before,.fa-sort-alpha-asc:before,.fa-sort-alpha-down:before{content:"\f15d"}.fa-money-bill-wheat:before{content:"\e52a"}.fa-cookie:before{content:"\f563"}.fa-arrow-left-rotate:before,.fa-arrow-rotate-back:before,.fa-arrow-rotate-backward:before,.fa-arrow-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-hard-drive:before,.fa-hdd:before{content:"\f0a0"}.fa-face-grin-squint-tears:before,.fa-grin-squint-tears:before{content:"\f586"}.fa-dumbbell:before{content:"\f44b"}.fa-list-alt:before,.fa-rectangle-list:before{content:"\f022"}.fa-tarp-droplet:before{content:"\e57c"}.fa-house-medical-circle-check:before{content:"\e511"}.fa-person-skiing-nordic:before,.fa-skiing-nordic:before{content:"\f7ca"}.fa-calendar-plus:before{content:"\f271"}.fa-plane-arrival:before{content:"\f5af"}.fa-arrow-alt-circle-left:before,.fa-circle-left:before{content:"\f359"}.fa-subway:before,.fa-train-subway:before{content:"\f239"}.fa-chart-gantt:before{content:"\e0e4"}.fa-indian-rupee-sign:before,.fa-indian-rupee:before,.fa-inr:before{content:"\e1bc"}.fa-crop-alt:before,.fa-crop-simple:before{content:"\f565"}.fa-money-bill-1:before,.fa-money-bill-alt:before{content:"\f3d1"}.fa-left-long:before,.fa-long-arrow-alt-left:before{content:"\f30a"}.fa-dna:before{content:"\f471"}.fa-virus-slash:before{content:"\e075"}.fa-minus:before,.fa-subtract:before{content:"\f068"}.fa-chess:before{content:"\f439"}.fa-arrow-left-long:before,.fa-long-arrow-left:before{content:"\f177"}.fa-plug-circle-check:before{content:"\e55c"}.fa-street-view:before{content:"\f21d"}.fa-franc-sign:before{content:"\e18f"}.fa-volume-off:before{content:"\f026"}.fa-american-sign-language-interpreting:before,.fa-asl-interpreting:before,.fa-hands-american-sign-language-interpreting:before,.fa-hands-asl-interpreting:before{content:"\f2a3"}.fa-cog:before,.fa-gear:before{content:"\f013"}.fa-droplet-slash:before,.fa-tint-slash:before{content:"\f5c7"}.fa-mosque:before{content:"\f678"}.fa-mosquito:before{content:"\e52b"}.fa-star-of-david:before{content:"\f69a"}.fa-person-military-rifle:before{content:"\e54b"}.fa-cart-shopping:before,.fa-shopping-cart:before{content:"\f07a"}.fa-vials:before{content:"\f493"}.fa-plug-circle-plus:before{content:"\e55f"}.fa-place-of-worship:before{content:"\f67f"}.fa-grip-vertical:before{content:"\f58e"}.fa-arrow-turn-up:before,.fa-level-up:before{content:"\f148"}.fa-u:before{content:"\55"}.fa-square-root-alt:before,.fa-square-root-variable:before{content:"\f698"}.fa-clock-four:before,.fa-clock:before{content:"\f017"}.fa-backward-step:before,.fa-step-backward:before{content:"\f048"}.fa-pallet:before{content:"\f482"}.fa-faucet:before{content:"\e005"}.fa-baseball-bat-ball:before{content:"\f432"}.fa-s:before{content:"\53"}.fa-timeline:before{content:"\e29c"}.fa-keyboard:before{content:"\f11c"}.fa-caret-down:before{content:"\f0d7"}.fa-clinic-medical:before,.fa-house-chimney-medical:before{content:"\f7f2"}.fa-temperature-3:before,.fa-temperature-three-quarters:before,.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:"\f2c8"}.fa-mobile-android-alt:before,.fa-mobile-screen:before{content:"\f3cf"}.fa-plane-up:before{content:"\e22d"}.fa-piggy-bank:before{content:"\f4d3"}.fa-battery-3:before,.fa-battery-half:before{content:"\f242"}.fa-mountain-city:before{content:"\e52e"}.fa-coins:before{content:"\f51e"}.fa-khanda:before{content:"\f66d"}.fa-sliders-h:before,.fa-sliders:before{content:"\f1de"}.fa-folder-tree:before{content:"\f802"}.fa-network-wired:before{content:"\f6ff"}.fa-map-pin:before{content:"\f276"}.fa-hamsa:before{content:"\f665"}.fa-cent-sign:before{content:"\e3f5"}.fa-flask:before{content:"\f0c3"}.fa-person-pregnant:before{content:"\e31e"}.fa-wand-sparkles:before{content:"\f72b"}.fa-ellipsis-v:before,.fa-ellipsis-vertical:before{content:"\f142"}.fa-ticket:before{content:"\f145"}.fa-power-off:before{content:"\f011"}.fa-long-arrow-alt-right:before,.fa-right-long:before{content:"\f30b"}.fa-flag-usa:before{content:"\f74d"}.fa-laptop-file:before{content:"\e51d"}.fa-teletype:before,.fa-tty:before{content:"\f1e4"}.fa-diagram-next:before{content:"\e476"}.fa-person-rifle:before{content:"\e54e"}.fa-house-medical-circle-exclamation:before{content:"\e512"}.fa-closed-captioning:before{content:"\f20a"}.fa-hiking:before,.fa-person-hiking:before{content:"\f6ec"}.fa-venus-double:before{content:"\f226"}.fa-images:before{content:"\f302"}.fa-calculator:before{content:"\f1ec"}.fa-people-pulling:before{content:"\e535"}.fa-n:before{content:"\4e"}.fa-cable-car:before,.fa-tram:before{content:"\f7da"}.fa-cloud-rain:before{content:"\f73d"}.fa-building-circle-xmark:before{content:"\e4d4"}.fa-ship:before{content:"\f21a"}.fa-arrows-down-to-line:before{content:"\e4b8"}.fa-download:before{content:"\f019"}.fa-face-grin:before,.fa-grin:before{content:"\f580"}.fa-backspace:before,.fa-delete-left:before{content:"\f55a"}.fa-eye-dropper-empty:before,.fa-eye-dropper:before,.fa-eyedropper:before{content:"\f1fb"}.fa-file-circle-check:before{content:"\e5a0"}.fa-forward:before{content:"\f04e"}.fa-mobile-android:before,.fa-mobile-phone:before,.fa-mobile:before{content:"\f3ce"}.fa-face-meh:before,.fa-meh:before{content:"\f11a"}.fa-align-center:before{content:"\f037"}.fa-book-dead:before,.fa-book-skull:before{content:"\f6b7"}.fa-drivers-license:before,.fa-id-card:before{content:"\f2c2"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-heart-circle-exclamation:before{content:"\e4fe"}.fa-home-alt:before,.fa-home-lg-alt:before,.fa-home:before,.fa-house:before{content:"\f015"}.fa-calendar-week:before{content:"\f784"}.fa-laptop-medical:before{content:"\f812"}.fa-b:before{content:"\42"}.fa-file-medical:before{content:"\f477"}.fa-dice-one:before{content:"\f525"}.fa-kiwi-bird:before{content:"\f535"}.fa-arrow-right-arrow-left:before,.fa-exchange:before{content:"\f0ec"}.fa-redo-alt:before,.fa-rotate-forward:before,.fa-rotate-right:before{content:"\f2f9"}.fa-cutlery:before,.fa-utensils:before{content:"\f2e7"}.fa-arrow-up-wide-short:before,.fa-sort-amount-up:before{content:"\f161"}.fa-mill-sign:before{content:"\e1ed"}.fa-bowl-rice:before{content:"\e2eb"}.fa-skull:before{content:"\f54c"}.fa-broadcast-tower:before,.fa-tower-broadcast:before{content:"\f519"}.fa-truck-pickup:before{content:"\f63c"}.fa-long-arrow-alt-up:before,.fa-up-long:before{content:"\f30c"}.fa-stop:before{content:"\f04d"}.fa-code-merge:before{content:"\f387"}.fa-upload:before{content:"\f093"}.fa-hurricane:before{content:"\f751"}.fa-mound:before{content:"\e52d"}.fa-toilet-portable:before{content:"\e583"}.fa-compact-disc:before{content:"\f51f"}.fa-file-arrow-down:before,.fa-file-download:before{content:"\f56d"}.fa-caravan:before{content:"\f8ff"}.fa-shield-cat:before{content:"\e572"}.fa-bolt:before,.fa-zap:before{content:"\f0e7"}.fa-glass-water:before{content:"\e4f4"}.fa-oil-well:before{content:"\e532"}.fa-vault:before{content:"\e2c5"}.fa-mars:before{content:"\f222"}.fa-toilet:before{content:"\f7d8"}.fa-plane-circle-xmark:before{content:"\e557"}.fa-cny:before,.fa-jpy:before,.fa-rmb:before,.fa-yen-sign:before,.fa-yen:before{content:"\f157"}.fa-rouble:before,.fa-rub:before,.fa-ruble-sign:before,.fa-ruble:before{content:"\f158"}.fa-sun:before{content:"\f185"}.fa-guitar:before{content:"\f7a6"}.fa-face-laugh-wink:before,.fa-laugh-wink:before{content:"\f59c"}.fa-horse-head:before{content:"\f7ab"}.fa-bore-hole:before{content:"\e4c3"}.fa-industry:before{content:"\f275"}.fa-arrow-alt-circle-down:before,.fa-circle-down:before{content:"\f358"}.fa-arrows-turn-to-dots:before{content:"\e4c1"}.fa-florin-sign:before{content:"\e184"}.fa-arrow-down-short-wide:before,.fa-sort-amount-desc:before,.fa-sort-amount-down-alt:before{content:"\f884"}.fa-less-than:before{content:"\3c"}.fa-angle-down:before{content:"\f107"}.fa-car-tunnel:before{content:"\e4de"}.fa-head-side-cough:before{content:"\e061"}.fa-grip-lines:before{content:"\f7a4"}.fa-thumbs-down:before{content:"\f165"}.fa-user-lock:before{content:"\f502"}.fa-arrow-right-long:before,.fa-long-arrow-right:before{content:"\f178"}.fa-anchor-circle-xmark:before{content:"\e4ac"}.fa-ellipsis-h:before,.fa-ellipsis:before{content:"\f141"}.fa-chess-pawn:before{content:"\f443"}.fa-first-aid:before,.fa-kit-medical:before{content:"\f479"}.fa-person-through-window:before{content:"\e5a9"}.fa-toolbox:before{content:"\f552"}.fa-hands-holding-circle:before{content:"\e4fb"}.fa-bug:before{content:"\f188"}.fa-credit-card-alt:before,.fa-credit-card:before{content:"\f09d"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-hand-holding-hand:before{content:"\e4f7"}.fa-book-open-reader:before,.fa-book-reader:before{content:"\f5da"}.fa-mountain-sun:before{content:"\e52f"}.fa-arrows-left-right-to-line:before{content:"\e4ba"}.fa-dice-d20:before{content:"\f6cf"}.fa-truck-droplet:before{content:"\e58c"}.fa-file-circle-xmark:before{content:"\e5a1"}.fa-temperature-arrow-up:before,.fa-temperature-up:before{content:"\e040"}.fa-medal:before{content:"\f5a2"}.fa-bed:before{content:"\f236"}.fa-h-square:before,.fa-square-h:before{content:"\f0fd"}.fa-podcast:before{content:"\f2ce"}.fa-temperature-4:before,.fa-temperature-full:before,.fa-thermometer-4:before,.fa-thermometer-full:before{content:"\f2c7"}.fa-bell:before{content:"\f0f3"}.fa-superscript:before{content:"\f12b"}.fa-plug-circle-xmark:before{content:"\e560"}.fa-star-of-life:before{content:"\f621"}.fa-phone-slash:before{content:"\f3dd"}.fa-paint-roller:before{content:"\f5aa"}.fa-hands-helping:before,.fa-handshake-angle:before{content:"\f4c4"}.fa-location-dot:before,.fa-map-marker-alt:before{content:"\f3c5"}.fa-file:before{content:"\f15b"}.fa-greater-than:before{content:"\3e"}.fa-person-swimming:before,.fa-swimmer:before{content:"\f5c4"}.fa-arrow-down:before{content:"\f063"}.fa-droplet:before,.fa-tint:before{content:"\f043"}.fa-eraser:before{content:"\f12d"}.fa-earth-america:before,.fa-earth-americas:before,.fa-earth:before,.fa-globe-americas:before{content:"\f57d"}.fa-person-burst:before{content:"\e53b"}.fa-dove:before{content:"\f4ba"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-socks:before{content:"\f696"}.fa-inbox:before{content:"\f01c"}.fa-section:before{content:"\e447"}.fa-gauge-high:before,.fa-tachometer-alt-fast:before,.fa-tachometer-alt:before{content:"\f625"}.fa-envelope-open-text:before{content:"\f658"}.fa-hospital-alt:before,.fa-hospital-wide:before,.fa-hospital:before{content:"\f0f8"}.fa-wine-bottle:before{content:"\f72f"}.fa-chess-rook:before{content:"\f447"}.fa-bars-staggered:before,.fa-reorder:before,.fa-stream:before{content:"\f550"}.fa-dharmachakra:before{content:"\f655"}.fa-hotdog:before{content:"\f80f"}.fa-blind:before,.fa-person-walking-with-cane:before{content:"\f29d"}.fa-drum:before{content:"\f569"}.fa-ice-cream:before{content:"\f810"}.fa-heart-circle-bolt:before{content:"\e4fc"}.fa-fax:before{content:"\f1ac"}.fa-paragraph:before{content:"\f1dd"}.fa-check-to-slot:before,.fa-vote-yea:before{content:"\f772"}.fa-star-half:before{content:"\f089"}.fa-boxes-alt:before,.fa-boxes-stacked:before,.fa-boxes:before{content:"\f468"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-assistive-listening-systems:before,.fa-ear-listen:before{content:"\f2a2"}.fa-tree-city:before{content:"\e587"}.fa-play:before{content:"\f04b"}.fa-font:before{content:"\f031"}.fa-table-cells-row-lock:before{content:"\e67a"}.fa-rupiah-sign:before{content:"\e23d"}.fa-magnifying-glass:before,.fa-search:before{content:"\f002"}.fa-ping-pong-paddle-ball:before,.fa-table-tennis-paddle-ball:before,.fa-table-tennis:before{content:"\f45d"}.fa-diagnoses:before,.fa-person-dots-from-line:before{content:"\f470"}.fa-trash-can-arrow-up:before,.fa-trash-restore-alt:before{content:"\f82a"}.fa-naira-sign:before{content:"\e1f6"}.fa-cart-arrow-down:before{content:"\f218"}.fa-walkie-talkie:before{content:"\f8ef"}.fa-file-edit:before,.fa-file-pen:before{content:"\f31c"}.fa-receipt:before{content:"\f543"}.fa-pen-square:before,.fa-pencil-square:before,.fa-square-pen:before{content:"\f14b"}.fa-suitcase-rolling:before{content:"\f5c1"}.fa-person-circle-exclamation:before{content:"\e53f"}.fa-chevron-down:before{content:"\f078"}.fa-battery-5:before,.fa-battery-full:before,.fa-battery:before{content:"\f240"}.fa-skull-crossbones:before{content:"\f714"}.fa-code-compare:before{content:"\e13a"}.fa-list-dots:before,.fa-list-ul:before{content:"\f0ca"}.fa-school-lock:before{content:"\e56f"}.fa-tower-cell:before{content:"\e585"}.fa-down-long:before,.fa-long-arrow-alt-down:before{content:"\f309"}.fa-ranking-star:before{content:"\e561"}.fa-chess-king:before{content:"\f43f"}.fa-person-harassing:before{content:"\e549"}.fa-brazilian-real-sign:before{content:"\e46c"}.fa-landmark-alt:before,.fa-landmark-dome:before{content:"\f752"}.fa-arrow-up:before{content:"\f062"}.fa-television:before,.fa-tv-alt:before,.fa-tv:before{content:"\f26c"}.fa-shrimp:before{content:"\e448"}.fa-list-check:before,.fa-tasks:before{content:"\f0ae"}.fa-jug-detergent:before{content:"\e519"}.fa-circle-user:before,.fa-user-circle:before{content:"\f2bd"}.fa-user-shield:before{content:"\f505"}.fa-wind:before{content:"\f72e"}.fa-car-burst:before,.fa-car-crash:before{content:"\f5e1"}.fa-y:before{content:"\59"}.fa-person-snowboarding:before,.fa-snowboarding:before{content:"\f7ce"}.fa-shipping-fast:before,.fa-truck-fast:before{content:"\f48b"}.fa-fish:before{content:"\f578"}.fa-user-graduate:before{content:"\f501"}.fa-adjust:before,.fa-circle-half-stroke:before{content:"\f042"}.fa-clapperboard:before{content:"\e131"}.fa-circle-radiation:before,.fa-radiation-alt:before{content:"\f7ba"}.fa-baseball-ball:before,.fa-baseball:before{content:"\f433"}.fa-jet-fighter-up:before{content:"\e518"}.fa-diagram-project:before,.fa-project-diagram:before{content:"\f542"}.fa-copy:before{content:"\f0c5"}.fa-volume-mute:before,.fa-volume-times:before,.fa-volume-xmark:before{content:"\f6a9"}.fa-hand-sparkles:before{content:"\e05d"}.fa-grip-horizontal:before,.fa-grip:before{content:"\f58d"}.fa-share-from-square:before,.fa-share-square:before{content:"\f14d"}.fa-child-combatant:before,.fa-child-rifle:before{content:"\e4e0"}.fa-gun:before{content:"\e19b"}.fa-phone-square:before,.fa-square-phone:before{content:"\f098"}.fa-add:before,.fa-plus:before{content:"\2b"}.fa-expand:before{content:"\f065"}.fa-computer:before{content:"\e4e5"}.fa-close:before,.fa-multiply:before,.fa-remove:before,.fa-times:before,.fa-xmark:before{content:"\f00d"}.fa-arrows-up-down-left-right:before,.fa-arrows:before{content:"\f047"}.fa-chalkboard-teacher:before,.fa-chalkboard-user:before{content:"\f51c"}.fa-peso-sign:before{content:"\e222"}.fa-building-shield:before{content:"\e4d8"}.fa-baby:before{content:"\f77c"}.fa-users-line:before{content:"\e592"}.fa-quote-left-alt:before,.fa-quote-left:before{content:"\f10d"}.fa-tractor:before{content:"\f722"}.fa-trash-arrow-up:before,.fa-trash-restore:before{content:"\f829"}.fa-arrow-down-up-lock:before{content:"\e4b0"}.fa-lines-leaning:before{content:"\e51e"}.fa-ruler-combined:before{content:"\f546"}.fa-copyright:before{content:"\f1f9"}.fa-equals:before{content:"\3d"}.fa-blender:before{content:"\f517"}.fa-teeth:before{content:"\f62e"}.fa-ils:before,.fa-shekel-sign:before,.fa-shekel:before,.fa-sheqel-sign:before,.fa-sheqel:before{content:"\f20b"}.fa-map:before{content:"\f279"}.fa-rocket:before{content:"\f135"}.fa-photo-film:before,.fa-photo-video:before{content:"\f87c"}.fa-folder-minus:before{content:"\f65d"}.fa-store:before{content:"\f54e"}.fa-arrow-trend-up:before{content:"\e098"}.fa-plug-circle-minus:before{content:"\e55e"}.fa-sign-hanging:before,.fa-sign:before{content:"\f4d9"}.fa-bezier-curve:before{content:"\f55b"}.fa-bell-slash:before{content:"\f1f6"}.fa-tablet-android:before,.fa-tablet:before{content:"\f3fb"}.fa-school-flag:before{content:"\e56e"}.fa-fill:before{content:"\f575"}.fa-angle-up:before{content:"\f106"}.fa-drumstick-bite:before{content:"\f6d7"}.fa-holly-berry:before{content:"\f7aa"}.fa-chevron-left:before{content:"\f053"}.fa-bacteria:before{content:"\e059"}.fa-hand-lizard:before{content:"\f258"}.fa-notdef:before{content:"\e1fe"}.fa-disease:before{content:"\f7fa"}.fa-briefcase-medical:before{content:"\f469"}.fa-genderless:before{content:"\f22d"}.fa-chevron-right:before{content:"\f054"}.fa-retweet:before{content:"\f079"}.fa-car-alt:before,.fa-car-rear:before{content:"\f5de"}.fa-pump-soap:before{content:"\e06b"}.fa-video-slash:before{content:"\f4e2"}.fa-battery-2:before,.fa-battery-quarter:before{content:"\f243"}.fa-radio:before{content:"\f8d7"}.fa-baby-carriage:before,.fa-carriage-baby:before{content:"\f77d"}.fa-traffic-light:before{content:"\f637"}.fa-thermometer:before{content:"\f491"}.fa-vr-cardboard:before{content:"\f729"}.fa-hand-middle-finger:before{content:"\f806"}.fa-percent:before,.fa-percentage:before{content:"\25"}.fa-truck-moving:before{content:"\f4df"}.fa-glass-water-droplet:before{content:"\e4f5"}.fa-display:before{content:"\e163"}.fa-face-smile:before,.fa-smile:before{content:"\f118"}.fa-thumb-tack:before,.fa-thumbtack:before{content:"\f08d"}.fa-trophy:before{content:"\f091"}.fa-person-praying:before,.fa-pray:before{content:"\f683"}.fa-hammer:before{content:"\f6e3"}.fa-hand-peace:before{content:"\f25b"}.fa-rotate:before,.fa-sync-alt:before{content:"\f2f1"}.fa-spinner:before{content:"\f110"}.fa-robot:before{content:"\f544"}.fa-peace:before{content:"\f67c"}.fa-cogs:before,.fa-gears:before{content:"\f085"}.fa-warehouse:before{content:"\f494"}.fa-arrow-up-right-dots:before{content:"\e4b7"}.fa-splotch:before{content:"\f5bc"}.fa-face-grin-hearts:before,.fa-grin-hearts:before{content:"\f584"}.fa-dice-four:before{content:"\f524"}.fa-sim-card:before{content:"\f7c4"}.fa-transgender-alt:before,.fa-transgender:before{content:"\f225"}.fa-mercury:before{content:"\f223"}.fa-arrow-turn-down:before,.fa-level-down:before{content:"\f149"}.fa-person-falling-burst:before{content:"\e547"}.fa-award:before{content:"\f559"}.fa-ticket-alt:before,.fa-ticket-simple:before{content:"\f3ff"}.fa-building:before{content:"\f1ad"}.fa-angle-double-left:before,.fa-angles-left:before{content:"\f100"}.fa-qrcode:before{content:"\f029"}.fa-clock-rotate-left:before,.fa-history:before{content:"\f1da"}.fa-face-grin-beam-sweat:before,.fa-grin-beam-sweat:before{content:"\f583"}.fa-arrow-right-from-file:before,.fa-file-export:before{content:"\f56e"}.fa-shield-blank:before,.fa-shield:before{content:"\f132"}.fa-arrow-up-short-wide:before,.fa-sort-amount-up-alt:before{content:"\f885"}.fa-house-medical:before{content:"\e3b2"}.fa-golf-ball-tee:before,.fa-golf-ball:before{content:"\f450"}.fa-chevron-circle-left:before,.fa-circle-chevron-left:before{content:"\f137"}.fa-house-chimney-window:before{content:"\e00d"}.fa-pen-nib:before{content:"\f5ad"}.fa-tent-arrow-turn-left:before{content:"\e580"}.fa-tents:before{content:"\e582"}.fa-magic:before,.fa-wand-magic:before{content:"\f0d0"}.fa-dog:before{content:"\f6d3"}.fa-carrot:before{content:"\f787"}.fa-moon:before{content:"\f186"}.fa-wine-glass-alt:before,.fa-wine-glass-empty:before{content:"\f5ce"}.fa-cheese:before{content:"\f7ef"}.fa-yin-yang:before{content:"\f6ad"}.fa-music:before{content:"\f001"}.fa-code-commit:before{content:"\f386"}.fa-temperature-low:before{content:"\f76b"}.fa-biking:before,.fa-person-biking:before{content:"\f84a"}.fa-broom:before{content:"\f51a"}.fa-shield-heart:before{content:"\e574"}.fa-gopuram:before{content:"\f664"}.fa-earth-oceania:before,.fa-globe-oceania:before{content:"\e47b"}.fa-square-xmark:before,.fa-times-square:before,.fa-xmark-square:before{content:"\f2d3"}.fa-hashtag:before{content:"\23"}.fa-expand-alt:before,.fa-up-right-and-down-left-from-center:before{content:"\f424"}.fa-oil-can:before{content:"\f613"}.fa-t:before{content:"\54"}.fa-hippo:before{content:"\f6ed"}.fa-chart-column:before{content:"\e0e3"}.fa-infinity:before{content:"\f534"}.fa-vial-circle-check:before{content:"\e596"}.fa-person-arrow-down-to-line:before{content:"\e538"}.fa-voicemail:before{content:"\f897"}.fa-fan:before{content:"\f863"}.fa-person-walking-luggage:before{content:"\e554"}.fa-arrows-alt-v:before,.fa-up-down:before{content:"\f338"}.fa-cloud-moon-rain:before{content:"\f73c"}.fa-calendar:before{content:"\f133"}.fa-trailer:before{content:"\e041"}.fa-bahai:before,.fa-haykal:before{content:"\f666"}.fa-sd-card:before{content:"\f7c2"}.fa-dragon:before{content:"\f6d5"}.fa-shoe-prints:before{content:"\f54b"}.fa-circle-plus:before,.fa-plus-circle:before{content:"\f055"}.fa-face-grin-tongue-wink:before,.fa-grin-tongue-wink:before{content:"\f58b"}.fa-hand-holding:before{content:"\f4bd"}.fa-plug-circle-exclamation:before{content:"\e55d"}.fa-chain-broken:before,.fa-chain-slash:before,.fa-link-slash:before,.fa-unlink:before{content:"\f127"}.fa-clone:before{content:"\f24d"}.fa-person-walking-arrow-loop-left:before{content:"\e551"}.fa-arrow-up-z-a:before,.fa-sort-alpha-up-alt:before{content:"\f882"}.fa-fire-alt:before,.fa-fire-flame-curved:before{content:"\f7e4"}.fa-tornado:before{content:"\f76f"}.fa-file-circle-plus:before{content:"\e494"}.fa-book-quran:before,.fa-quran:before{content:"\f687"}.fa-anchor:before{content:"\f13d"}.fa-border-all:before{content:"\f84c"}.fa-angry:before,.fa-face-angry:before{content:"\f556"}.fa-cookie-bite:before{content:"\f564"}.fa-arrow-trend-down:before{content:"\e097"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-draw-polygon:before{content:"\f5ee"}.fa-balance-scale:before,.fa-scale-balanced:before{content:"\f24e"}.fa-gauge-simple-high:before,.fa-tachometer-fast:before,.fa-tachometer:before{content:"\f62a"}.fa-shower:before{content:"\f2cc"}.fa-desktop-alt:before,.fa-desktop:before{content:"\f390"}.fa-m:before{content:"\4d"}.fa-table-list:before,.fa-th-list:before{content:"\f00b"}.fa-comment-sms:before,.fa-sms:before{content:"\f7cd"}.fa-book:before{content:"\f02d"}.fa-user-plus:before{content:"\f234"}.fa-check:before{content:"\f00c"}.fa-battery-4:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-house-circle-check:before{content:"\e509"}.fa-angle-left:before{content:"\f104"}.fa-diagram-successor:before{content:"\e47a"}.fa-truck-arrow-right:before{content:"\e58b"}.fa-arrows-split-up-and-left:before{content:"\e4bc"}.fa-fist-raised:before,.fa-hand-fist:before{content:"\f6de"}.fa-cloud-moon:before{content:"\f6c3"}.fa-briefcase:before{content:"\f0b1"}.fa-person-falling:before{content:"\e546"}.fa-image-portrait:before,.fa-portrait:before{content:"\f3e0"}.fa-user-tag:before{content:"\f507"}.fa-rug:before{content:"\e569"}.fa-earth-europe:before,.fa-globe-europe:before{content:"\f7a2"}.fa-cart-flatbed-suitcase:before,.fa-luggage-cart:before{content:"\f59d"}.fa-rectangle-times:before,.fa-rectangle-xmark:before,.fa-times-rectangle:before,.fa-window-close:before{content:"\f410"}.fa-baht-sign:before{content:"\e0ac"}.fa-book-open:before{content:"\f518"}.fa-book-journal-whills:before,.fa-journal-whills:before{content:"\f66a"}.fa-handcuffs:before{content:"\e4f8"}.fa-exclamation-triangle:before,.fa-triangle-exclamation:before,.fa-warning:before{content:"\f071"}.fa-database:before{content:"\f1c0"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-bottle-droplet:before{content:"\e4c4"}.fa-mask-face:before{content:"\e1d7"}.fa-hill-rockslide:before{content:"\e508"}.fa-exchange-alt:before,.fa-right-left:before{content:"\f362"}.fa-paper-plane:before{content:"\f1d8"}.fa-road-circle-exclamation:before{content:"\e565"}.fa-dungeon:before{content:"\f6d9"}.fa-align-right:before{content:"\f038"}.fa-money-bill-1-wave:before,.fa-money-bill-wave-alt:before{content:"\f53b"}.fa-life-ring:before{content:"\f1cd"}.fa-hands:before,.fa-sign-language:before,.fa-signing:before{content:"\f2a7"}.fa-calendar-day:before{content:"\f783"}.fa-ladder-water:before,.fa-swimming-pool:before,.fa-water-ladder:before{content:"\f5c5"}.fa-arrows-up-down:before,.fa-arrows-v:before{content:"\f07d"}.fa-face-grimace:before,.fa-grimace:before{content:"\f57f"}.fa-wheelchair-alt:before,.fa-wheelchair-move:before{content:"\e2ce"}.fa-level-down-alt:before,.fa-turn-down:before{content:"\f3be"}.fa-person-walking-arrow-right:before{content:"\e552"}.fa-envelope-square:before,.fa-square-envelope:before{content:"\f199"}.fa-dice:before{content:"\f522"}.fa-bowling-ball:before{content:"\f436"}.fa-brain:before{content:"\f5dc"}.fa-band-aid:before,.fa-bandage:before{content:"\f462"}.fa-calendar-minus:before{content:"\f272"}.fa-circle-xmark:before,.fa-times-circle:before,.fa-xmark-circle:before{content:"\f057"}.fa-gifts:before{content:"\f79c"}.fa-hotel:before{content:"\f594"}.fa-earth-asia:before,.fa-globe-asia:before{content:"\f57e"}.fa-id-card-alt:before,.fa-id-card-clip:before{content:"\f47f"}.fa-magnifying-glass-plus:before,.fa-search-plus:before{content:"\f00e"}.fa-thumbs-up:before{content:"\f164"}.fa-user-clock:before{content:"\f4fd"}.fa-allergies:before,.fa-hand-dots:before{content:"\f461"}.fa-file-invoice:before{content:"\f570"}.fa-window-minimize:before{content:"\f2d1"}.fa-coffee:before,.fa-mug-saucer:before{content:"\f0f4"}.fa-brush:before{content:"\f55d"}.fa-mask:before{content:"\f6fa"}.fa-magnifying-glass-minus:before,.fa-search-minus:before{content:"\f010"}.fa-ruler-vertical:before{content:"\f548"}.fa-user-alt:before,.fa-user-large:before{content:"\f406"}.fa-train-tram:before{content:"\e5b4"}.fa-user-nurse:before{content:"\f82f"}.fa-syringe:before{content:"\f48e"}.fa-cloud-sun:before{content:"\f6c4"}.fa-stopwatch-20:before{content:"\e06f"}.fa-square-full:before{content:"\f45c"}.fa-magnet:before{content:"\f076"}.fa-jar:before{content:"\e516"}.fa-note-sticky:before,.fa-sticky-note:before{content:"\f249"}.fa-bug-slash:before{content:"\e490"}.fa-arrow-up-from-water-pump:before{content:"\e4b6"}.fa-bone:before{content:"\f5d7"}.fa-user-injured:before{content:"\f728"}.fa-face-sad-tear:before,.fa-sad-tear:before{content:"\f5b4"}.fa-plane:before{content:"\f072"}.fa-tent-arrows-down:before{content:"\e581"}.fa-exclamation:before{content:"\21"}.fa-arrows-spin:before{content:"\e4bb"}.fa-print:before{content:"\f02f"}.fa-try:before,.fa-turkish-lira-sign:before,.fa-turkish-lira:before{content:"\e2bb"}.fa-dollar-sign:before,.fa-dollar:before,.fa-usd:before{content:"\24"}.fa-x:before{content:"\58"}.fa-magnifying-glass-dollar:before,.fa-search-dollar:before{content:"\f688"}.fa-users-cog:before,.fa-users-gear:before{content:"\f509"}.fa-person-military-pointing:before{content:"\e54a"}.fa-bank:before,.fa-building-columns:before,.fa-institution:before,.fa-museum:before,.fa-university:before{content:"\f19c"}.fa-umbrella:before{content:"\f0e9"}.fa-trowel:before{content:"\e589"}.fa-d:before{content:"\44"}.fa-stapler:before{content:"\e5af"}.fa-masks-theater:before,.fa-theater-masks:before{content:"\f630"}.fa-kip-sign:before{content:"\e1c4"}.fa-hand-point-left:before{content:"\f0a5"}.fa-handshake-alt:before,.fa-handshake-simple:before{content:"\f4c6"}.fa-fighter-jet:before,.fa-jet-fighter:before{content:"\f0fb"}.fa-share-alt-square:before,.fa-square-share-nodes:before{content:"\f1e1"}.fa-barcode:before{content:"\f02a"}.fa-plus-minus:before{content:"\e43c"}.fa-video-camera:before,.fa-video:before{content:"\f03d"}.fa-graduation-cap:before,.fa-mortar-board:before{content:"\f19d"}.fa-hand-holding-medical:before{content:"\e05c"}.fa-person-circle-check:before{content:"\e53e"}.fa-level-up-alt:before,.fa-turn-up:before{content:"\f3bf"} +.fa-sr-only,.fa-sr-only-focusable:not(:focus),.sr-only,.sr-only-focusable:not(:focus){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}:host,:root{--fa-style-family-brands:"Font Awesome 6 Brands";--fa-font-brands:normal 400 1em/1 "Font Awesome 6 Brands"}@font-face{font-family:"Font Awesome 6 Brands";font-style:normal;font-weight:400;font-display:block;src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype"); }.fa-brands,.fab{font-weight:400}.fa-monero:before{content:"\f3d0"}.fa-hooli:before{content:"\f427"}.fa-yelp:before{content:"\f1e9"}.fa-cc-visa:before{content:"\f1f0"}.fa-lastfm:before{content:"\f202"}.fa-shopware:before{content:"\f5b5"}.fa-creative-commons-nc:before{content:"\f4e8"}.fa-aws:before{content:"\f375"}.fa-redhat:before{content:"\f7bc"}.fa-yoast:before{content:"\f2b1"}.fa-cloudflare:before{content:"\e07d"}.fa-ups:before{content:"\f7e0"}.fa-pixiv:before{content:"\e640"}.fa-wpexplorer:before{content:"\f2de"}.fa-dyalog:before{content:"\f399"}.fa-bity:before{content:"\f37a"}.fa-stackpath:before{content:"\f842"}.fa-buysellads:before{content:"\f20d"}.fa-first-order:before{content:"\f2b0"}.fa-modx:before{content:"\f285"}.fa-guilded:before{content:"\e07e"}.fa-vnv:before{content:"\f40b"}.fa-js-square:before,.fa-square-js:before{content:"\f3b9"}.fa-microsoft:before{content:"\f3ca"}.fa-qq:before{content:"\f1d6"}.fa-orcid:before{content:"\f8d2"}.fa-java:before{content:"\f4e4"}.fa-invision:before{content:"\f7b0"}.fa-creative-commons-pd-alt:before{content:"\f4ed"}.fa-centercode:before{content:"\f380"}.fa-glide-g:before{content:"\f2a6"}.fa-drupal:before{content:"\f1a9"}.fa-jxl:before{content:"\e67b"}.fa-hire-a-helper:before{content:"\f3b0"}.fa-creative-commons-by:before{content:"\f4e7"}.fa-unity:before{content:"\e049"}.fa-whmcs:before{content:"\f40d"}.fa-rocketchat:before{content:"\f3e8"}.fa-vk:before{content:"\f189"}.fa-untappd:before{content:"\f405"}.fa-mailchimp:before{content:"\f59e"}.fa-css3-alt:before{content:"\f38b"}.fa-reddit-square:before,.fa-square-reddit:before{content:"\f1a2"}.fa-vimeo-v:before{content:"\f27d"}.fa-contao:before{content:"\f26d"}.fa-square-font-awesome:before{content:"\e5ad"}.fa-deskpro:before{content:"\f38f"}.fa-brave:before{content:"\e63c"}.fa-sistrix:before{content:"\f3ee"}.fa-instagram-square:before,.fa-square-instagram:before{content:"\e055"}.fa-battle-net:before{content:"\f835"}.fa-the-red-yeti:before{content:"\f69d"}.fa-hacker-news-square:before,.fa-square-hacker-news:before{content:"\f3af"}.fa-edge:before{content:"\f282"}.fa-threads:before{content:"\e618"}.fa-napster:before{content:"\f3d2"}.fa-snapchat-square:before,.fa-square-snapchat:before{content:"\f2ad"}.fa-google-plus-g:before{content:"\f0d5"}.fa-artstation:before{content:"\f77a"}.fa-markdown:before{content:"\f60f"}.fa-sourcetree:before{content:"\f7d3"}.fa-google-plus:before{content:"\f2b3"}.fa-diaspora:before{content:"\f791"}.fa-foursquare:before{content:"\f180"}.fa-stack-overflow:before{content:"\f16c"}.fa-github-alt:before{content:"\f113"}.fa-phoenix-squadron:before{content:"\f511"}.fa-pagelines:before{content:"\f18c"}.fa-algolia:before{content:"\f36c"}.fa-red-river:before{content:"\f3e3"}.fa-creative-commons-sa:before{content:"\f4ef"}.fa-safari:before{content:"\f267"}.fa-google:before{content:"\f1a0"}.fa-font-awesome-alt:before,.fa-square-font-awesome-stroke:before{content:"\f35c"}.fa-atlassian:before{content:"\f77b"}.fa-linkedin-in:before{content:"\f0e1"}.fa-digital-ocean:before{content:"\f391"}.fa-nimblr:before{content:"\f5a8"}.fa-chromecast:before{content:"\f838"}.fa-evernote:before{content:"\f839"}.fa-hacker-news:before{content:"\f1d4"}.fa-creative-commons-sampling:before{content:"\f4f0"}.fa-adversal:before{content:"\f36a"}.fa-creative-commons:before{content:"\f25e"}.fa-watchman-monitoring:before{content:"\e087"}.fa-fonticons:before{content:"\f280"}.fa-weixin:before{content:"\f1d7"}.fa-shirtsinbulk:before{content:"\f214"}.fa-codepen:before{content:"\f1cb"}.fa-git-alt:before{content:"\f841"}.fa-lyft:before{content:"\f3c3"}.fa-rev:before{content:"\f5b2"}.fa-windows:before{content:"\f17a"}.fa-wizards-of-the-coast:before{content:"\f730"}.fa-square-viadeo:before,.fa-viadeo-square:before{content:"\f2aa"}.fa-meetup:before{content:"\f2e0"}.fa-centos:before{content:"\f789"}.fa-adn:before{content:"\f170"}.fa-cloudsmith:before{content:"\f384"}.fa-opensuse:before{content:"\e62b"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-dribbble-square:before,.fa-square-dribbble:before{content:"\f397"}.fa-codiepie:before{content:"\f284"}.fa-node:before{content:"\f419"}.fa-mix:before{content:"\f3cb"}.fa-steam:before{content:"\f1b6"}.fa-cc-apple-pay:before{content:"\f416"}.fa-scribd:before{content:"\f28a"}.fa-debian:before{content:"\e60b"}.fa-openid:before{content:"\f19b"}.fa-instalod:before{content:"\e081"}.fa-expeditedssl:before{content:"\f23e"}.fa-sellcast:before{content:"\f2da"}.fa-square-twitter:before,.fa-twitter-square:before{content:"\f081"}.fa-r-project:before{content:"\f4f7"}.fa-delicious:before{content:"\f1a5"}.fa-freebsd:before{content:"\f3a4"}.fa-vuejs:before{content:"\f41f"}.fa-accusoft:before{content:"\f369"}.fa-ioxhost:before{content:"\f208"}.fa-fonticons-fi:before{content:"\f3a2"}.fa-app-store:before{content:"\f36f"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-itunes-note:before{content:"\f3b5"}.fa-golang:before{content:"\e40f"}.fa-kickstarter:before,.fa-square-kickstarter:before{content:"\f3bb"}.fa-grav:before{content:"\f2d6"}.fa-weibo:before{content:"\f18a"}.fa-uncharted:before{content:"\e084"}.fa-firstdraft:before{content:"\f3a1"}.fa-square-youtube:before,.fa-youtube-square:before{content:"\f431"}.fa-wikipedia-w:before{content:"\f266"}.fa-rendact:before,.fa-wpressr:before{content:"\f3e4"}.fa-angellist:before{content:"\f209"}.fa-galactic-republic:before{content:"\f50c"}.fa-nfc-directional:before{content:"\e530"}.fa-skype:before{content:"\f17e"}.fa-joget:before{content:"\f3b7"}.fa-fedora:before{content:"\f798"}.fa-stripe-s:before{content:"\f42a"}.fa-meta:before{content:"\e49b"}.fa-laravel:before{content:"\f3bd"}.fa-hotjar:before{content:"\f3b1"}.fa-bluetooth-b:before{content:"\f294"}.fa-square-letterboxd:before{content:"\e62e"}.fa-sticker-mule:before{content:"\f3f7"}.fa-creative-commons-zero:before{content:"\f4f3"}.fa-hips:before{content:"\f452"}.fa-behance:before{content:"\f1b4"}.fa-reddit:before{content:"\f1a1"}.fa-discord:before{content:"\f392"}.fa-chrome:before{content:"\f268"}.fa-app-store-ios:before{content:"\f370"}.fa-cc-discover:before{content:"\f1f2"}.fa-wpbeginner:before{content:"\f297"}.fa-confluence:before{content:"\f78d"}.fa-shoelace:before{content:"\e60c"}.fa-mdb:before{content:"\f8ca"}.fa-dochub:before{content:"\f394"}.fa-accessible-icon:before{content:"\f368"}.fa-ebay:before{content:"\f4f4"}.fa-amazon:before{content:"\f270"}.fa-unsplash:before{content:"\e07c"}.fa-yarn:before{content:"\f7e3"}.fa-square-steam:before,.fa-steam-square:before{content:"\f1b7"}.fa-500px:before{content:"\f26e"}.fa-square-vimeo:before,.fa-vimeo-square:before{content:"\f194"}.fa-asymmetrik:before{content:"\f372"}.fa-font-awesome-flag:before,.fa-font-awesome-logo-full:before,.fa-font-awesome:before{content:"\f2b4"}.fa-gratipay:before{content:"\f184"}.fa-apple:before{content:"\f179"}.fa-hive:before{content:"\e07f"}.fa-gitkraken:before{content:"\f3a6"}.fa-keybase:before{content:"\f4f5"}.fa-apple-pay:before{content:"\f415"}.fa-padlet:before{content:"\e4a0"}.fa-amazon-pay:before{content:"\f42c"}.fa-github-square:before,.fa-square-github:before{content:"\f092"}.fa-stumbleupon:before{content:"\f1a4"}.fa-fedex:before{content:"\f797"}.fa-phoenix-framework:before{content:"\f3dc"}.fa-shopify:before{content:"\e057"}.fa-neos:before{content:"\f612"}.fa-square-threads:before{content:"\e619"}.fa-hackerrank:before{content:"\f5f7"}.fa-researchgate:before{content:"\f4f8"}.fa-swift:before{content:"\f8e1"}.fa-angular:before{content:"\f420"}.fa-speakap:before{content:"\f3f3"}.fa-angrycreative:before{content:"\f36e"}.fa-y-combinator:before{content:"\f23b"}.fa-empire:before{content:"\f1d1"}.fa-envira:before{content:"\f299"}.fa-google-scholar:before{content:"\e63b"}.fa-gitlab-square:before,.fa-square-gitlab:before{content:"\e5ae"}.fa-studiovinari:before{content:"\f3f8"}.fa-pied-piper:before{content:"\f2ae"}.fa-wordpress:before{content:"\f19a"}.fa-product-hunt:before{content:"\f288"}.fa-firefox:before{content:"\f269"}.fa-linode:before{content:"\f2b8"}.fa-goodreads:before{content:"\f3a8"}.fa-odnoklassniki-square:before,.fa-square-odnoklassniki:before{content:"\f264"}.fa-jsfiddle:before{content:"\f1cc"}.fa-sith:before{content:"\f512"}.fa-themeisle:before{content:"\f2b2"}.fa-page4:before{content:"\f3d7"}.fa-hashnode:before{content:"\e499"}.fa-react:before{content:"\f41b"}.fa-cc-paypal:before{content:"\f1f4"}.fa-squarespace:before{content:"\f5be"}.fa-cc-stripe:before{content:"\f1f5"}.fa-creative-commons-share:before{content:"\f4f2"}.fa-bitcoin:before{content:"\f379"}.fa-keycdn:before{content:"\f3ba"}.fa-opera:before{content:"\f26a"}.fa-itch-io:before{content:"\f83a"}.fa-umbraco:before{content:"\f8e8"}.fa-galactic-senate:before{content:"\f50d"}.fa-ubuntu:before{content:"\f7df"}.fa-draft2digital:before{content:"\f396"}.fa-stripe:before{content:"\f429"}.fa-houzz:before{content:"\f27c"}.fa-gg:before{content:"\f260"}.fa-dhl:before{content:"\f790"}.fa-pinterest-square:before,.fa-square-pinterest:before{content:"\f0d3"}.fa-xing:before{content:"\f168"}.fa-blackberry:before{content:"\f37b"}.fa-creative-commons-pd:before{content:"\f4ec"}.fa-playstation:before{content:"\f3df"}.fa-quinscape:before{content:"\f459"}.fa-less:before{content:"\f41d"}.fa-blogger-b:before{content:"\f37d"}.fa-opencart:before{content:"\f23d"}.fa-vine:before{content:"\f1ca"}.fa-signal-messenger:before{content:"\e663"}.fa-paypal:before{content:"\f1ed"}.fa-gitlab:before{content:"\f296"}.fa-typo3:before{content:"\f42b"}.fa-reddit-alien:before{content:"\f281"}.fa-yahoo:before{content:"\f19e"}.fa-dailymotion:before{content:"\e052"}.fa-affiliatetheme:before{content:"\f36b"}.fa-pied-piper-pp:before{content:"\f1a7"}.fa-bootstrap:before{content:"\f836"}.fa-odnoklassniki:before{content:"\f263"}.fa-nfc-symbol:before{content:"\e531"}.fa-mintbit:before{content:"\e62f"}.fa-ethereum:before{content:"\f42e"}.fa-speaker-deck:before{content:"\f83c"}.fa-creative-commons-nc-eu:before{content:"\f4e9"}.fa-patreon:before{content:"\f3d9"}.fa-avianex:before{content:"\f374"}.fa-ello:before{content:"\f5f1"}.fa-gofore:before{content:"\f3a7"}.fa-bimobject:before{content:"\f378"}.fa-brave-reverse:before{content:"\e63d"}.fa-facebook-f:before{content:"\f39e"}.fa-google-plus-square:before,.fa-square-google-plus:before{content:"\f0d4"}.fa-web-awesome:before{content:"\e682"}.fa-mandalorian:before{content:"\f50f"}.fa-first-order-alt:before{content:"\f50a"}.fa-osi:before{content:"\f41a"}.fa-google-wallet:before{content:"\f1ee"}.fa-d-and-d-beyond:before{content:"\f6ca"}.fa-periscope:before{content:"\f3da"}.fa-fulcrum:before{content:"\f50b"}.fa-cloudscale:before{content:"\f383"}.fa-forumbee:before{content:"\f211"}.fa-mizuni:before{content:"\f3cc"}.fa-schlix:before{content:"\f3ea"}.fa-square-xing:before,.fa-xing-square:before{content:"\f169"}.fa-bandcamp:before{content:"\f2d5"}.fa-wpforms:before{content:"\f298"}.fa-cloudversify:before{content:"\f385"}.fa-usps:before{content:"\f7e1"}.fa-megaport:before{content:"\f5a3"}.fa-magento:before{content:"\f3c4"}.fa-spotify:before{content:"\f1bc"}.fa-optin-monster:before{content:"\f23c"}.fa-fly:before{content:"\f417"}.fa-aviato:before{content:"\f421"}.fa-itunes:before{content:"\f3b4"}.fa-cuttlefish:before{content:"\f38c"}.fa-blogger:before{content:"\f37c"}.fa-flickr:before{content:"\f16e"}.fa-viber:before{content:"\f409"}.fa-soundcloud:before{content:"\f1be"}.fa-digg:before{content:"\f1a6"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-letterboxd:before{content:"\e62d"}.fa-symfony:before{content:"\f83d"}.fa-maxcdn:before{content:"\f136"}.fa-etsy:before{content:"\f2d7"}.fa-facebook-messenger:before{content:"\f39f"}.fa-audible:before{content:"\f373"}.fa-think-peaks:before{content:"\f731"}.fa-bilibili:before{content:"\e3d9"}.fa-erlang:before{content:"\f39d"}.fa-x-twitter:before{content:"\e61b"}.fa-cotton-bureau:before{content:"\f89e"}.fa-dashcube:before{content:"\f210"}.fa-42-group:before,.fa-innosoft:before{content:"\e080"}.fa-stack-exchange:before{content:"\f18d"}.fa-elementor:before{content:"\f430"}.fa-pied-piper-square:before,.fa-square-pied-piper:before{content:"\e01e"}.fa-creative-commons-nd:before{content:"\f4eb"}.fa-palfed:before{content:"\f3d8"}.fa-superpowers:before{content:"\f2dd"}.fa-resolving:before{content:"\f3e7"}.fa-xbox:before{content:"\f412"}.fa-square-web-awesome-stroke:before{content:"\e684"}.fa-searchengin:before{content:"\f3eb"}.fa-tiktok:before{content:"\e07b"}.fa-facebook-square:before,.fa-square-facebook:before{content:"\f082"}.fa-renren:before{content:"\f18b"}.fa-linux:before{content:"\f17c"}.fa-glide:before{content:"\f2a5"}.fa-linkedin:before{content:"\f08c"}.fa-hubspot:before{content:"\f3b2"}.fa-deploydog:before{content:"\f38e"}.fa-twitch:before{content:"\f1e8"}.fa-ravelry:before{content:"\f2d9"}.fa-mixer:before{content:"\e056"}.fa-lastfm-square:before,.fa-square-lastfm:before{content:"\f203"}.fa-vimeo:before{content:"\f40a"}.fa-mendeley:before{content:"\f7b3"}.fa-uniregistry:before{content:"\f404"}.fa-figma:before{content:"\f799"}.fa-creative-commons-remix:before{content:"\f4ee"}.fa-cc-amazon-pay:before{content:"\f42d"}.fa-dropbox:before{content:"\f16b"}.fa-instagram:before{content:"\f16d"}.fa-cmplid:before{content:"\e360"}.fa-upwork:before{content:"\e641"}.fa-facebook:before{content:"\f09a"}.fa-gripfire:before{content:"\f3ac"}.fa-jedi-order:before{content:"\f50e"}.fa-uikit:before{content:"\f403"}.fa-fort-awesome-alt:before{content:"\f3a3"}.fa-phabricator:before{content:"\f3db"}.fa-ussunnah:before{content:"\f407"}.fa-earlybirds:before{content:"\f39a"}.fa-trade-federation:before{content:"\f513"}.fa-autoprefixer:before{content:"\f41c"}.fa-whatsapp:before{content:"\f232"}.fa-square-upwork:before{content:"\e67c"}.fa-slideshare:before{content:"\f1e7"}.fa-google-play:before{content:"\f3ab"}.fa-viadeo:before{content:"\f2a9"}.fa-line:before{content:"\f3c0"}.fa-google-drive:before{content:"\f3aa"}.fa-servicestack:before{content:"\f3ec"}.fa-simplybuilt:before{content:"\f215"}.fa-bitbucket:before{content:"\f171"}.fa-imdb:before{content:"\f2d8"}.fa-deezer:before{content:"\e077"}.fa-raspberry-pi:before{content:"\f7bb"}.fa-jira:before{content:"\f7b1"}.fa-docker:before{content:"\f395"}.fa-screenpal:before{content:"\e570"}.fa-bluetooth:before{content:"\f293"}.fa-gitter:before{content:"\f426"}.fa-d-and-d:before{content:"\f38d"}.fa-microblog:before{content:"\e01a"}.fa-cc-diners-club:before{content:"\f24c"}.fa-gg-circle:before{content:"\f261"}.fa-pied-piper-hat:before{content:"\f4e5"}.fa-kickstarter-k:before{content:"\f3bc"}.fa-yandex:before{content:"\f413"}.fa-readme:before{content:"\f4d5"}.fa-html5:before{content:"\f13b"}.fa-sellsy:before{content:"\f213"}.fa-square-web-awesome:before{content:"\e683"}.fa-sass:before{content:"\f41e"}.fa-wirsindhandwerk:before,.fa-wsh:before{content:"\e2d0"}.fa-buromobelexperte:before{content:"\f37f"}.fa-salesforce:before{content:"\f83b"}.fa-octopus-deploy:before{content:"\e082"}.fa-medapps:before{content:"\f3c6"}.fa-ns8:before{content:"\f3d5"}.fa-pinterest-p:before{content:"\f231"}.fa-apper:before{content:"\f371"}.fa-fort-awesome:before{content:"\f286"}.fa-waze:before{content:"\f83f"}.fa-bluesky:before{content:"\e671"}.fa-cc-jcb:before{content:"\f24b"}.fa-snapchat-ghost:before,.fa-snapchat:before{content:"\f2ab"}.fa-fantasy-flight-games:before{content:"\f6dc"}.fa-rust:before{content:"\e07a"}.fa-wix:before{content:"\f5cf"}.fa-behance-square:before,.fa-square-behance:before{content:"\f1b5"}.fa-supple:before{content:"\f3f9"}.fa-webflow:before{content:"\e65c"}.fa-rebel:before{content:"\f1d0"}.fa-css3:before{content:"\f13c"}.fa-staylinked:before{content:"\f3f5"}.fa-kaggle:before{content:"\f5fa"}.fa-space-awesome:before{content:"\e5ac"}.fa-deviantart:before{content:"\f1bd"}.fa-cpanel:before{content:"\f388"}.fa-goodreads-g:before{content:"\f3a9"}.fa-git-square:before,.fa-square-git:before{content:"\f1d2"}.fa-square-tumblr:before,.fa-tumblr-square:before{content:"\f174"}.fa-trello:before{content:"\f181"}.fa-creative-commons-nc-jp:before{content:"\f4ea"}.fa-get-pocket:before{content:"\f265"}.fa-perbyte:before{content:"\e083"}.fa-grunt:before{content:"\f3ad"}.fa-weebly:before{content:"\f5cc"}.fa-connectdevelop:before{content:"\f20e"}.fa-leanpub:before{content:"\f212"}.fa-black-tie:before{content:"\f27e"}.fa-themeco:before{content:"\f5c6"}.fa-python:before{content:"\f3e2"}.fa-android:before{content:"\f17b"}.fa-bots:before{content:"\e340"}.fa-free-code-camp:before{content:"\f2c5"}.fa-hornbill:before{content:"\f592"}.fa-js:before{content:"\f3b8"}.fa-ideal:before{content:"\e013"}.fa-git:before{content:"\f1d3"}.fa-dev:before{content:"\f6cc"}.fa-sketch:before{content:"\f7c6"}.fa-yandex-international:before{content:"\f414"}.fa-cc-amex:before{content:"\f1f3"}.fa-uber:before{content:"\f402"}.fa-github:before{content:"\f09b"}.fa-php:before{content:"\f457"}.fa-alipay:before{content:"\f642"}.fa-youtube:before{content:"\f167"}.fa-skyatlas:before{content:"\f216"}.fa-firefox-browser:before{content:"\e007"}.fa-replyd:before{content:"\f3e6"}.fa-suse:before{content:"\f7d6"}.fa-jenkins:before{content:"\f3b6"}.fa-twitter:before{content:"\f099"}.fa-rockrms:before{content:"\f3e9"}.fa-pinterest:before{content:"\f0d2"}.fa-buffer:before{content:"\f837"}.fa-npm:before{content:"\f3d4"}.fa-yammer:before{content:"\f840"}.fa-btc:before{content:"\f15a"}.fa-dribbble:before{content:"\f17d"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-internet-explorer:before{content:"\f26b"}.fa-stubber:before{content:"\e5c7"}.fa-telegram-plane:before,.fa-telegram:before{content:"\f2c6"}.fa-old-republic:before{content:"\f510"}.fa-odysee:before{content:"\e5c6"}.fa-square-whatsapp:before,.fa-whatsapp-square:before{content:"\f40c"}.fa-node-js:before{content:"\f3d3"}.fa-edge-legacy:before{content:"\e078"}.fa-slack-hash:before,.fa-slack:before{content:"\f198"}.fa-medrt:before{content:"\f3c8"}.fa-usb:before{content:"\f287"}.fa-tumblr:before{content:"\f173"}.fa-vaadin:before{content:"\f408"}.fa-quora:before{content:"\f2c4"}.fa-square-x-twitter:before{content:"\e61a"}.fa-reacteurope:before{content:"\f75d"}.fa-medium-m:before,.fa-medium:before{content:"\f23a"}.fa-amilia:before{content:"\f36d"}.fa-mixcloud:before{content:"\f289"}.fa-flipboard:before{content:"\f44d"}.fa-viacoin:before{content:"\f237"}.fa-critical-role:before{content:"\f6c9"}.fa-sitrox:before{content:"\e44a"}.fa-discourse:before{content:"\f393"}.fa-joomla:before{content:"\f1aa"}.fa-mastodon:before{content:"\f4f6"}.fa-airbnb:before{content:"\f834"}.fa-wolf-pack-battalion:before{content:"\f514"}.fa-buy-n-large:before{content:"\f8a6"}.fa-gulp:before{content:"\f3ae"}.fa-creative-commons-sampling-plus:before{content:"\f4f1"}.fa-strava:before{content:"\f428"}.fa-ember:before{content:"\f423"}.fa-canadian-maple-leaf:before{content:"\f785"}.fa-teamspeak:before{content:"\f4f9"}.fa-pushed:before{content:"\f3e1"}.fa-wordpress-simple:before{content:"\f411"}.fa-nutritionix:before{content:"\f3d6"}.fa-wodu:before{content:"\e088"}.fa-google-pay:before{content:"\e079"}.fa-intercom:before{content:"\f7af"}.fa-zhihu:before{content:"\f63f"}.fa-korvue:before{content:"\f42f"}.fa-pix:before{content:"\e43a"}.fa-steam-symbol:before{content:"\f3f6"}:host,:root{--fa-font-regular:normal 400 1em/1 "Font Awesome 6 Free"}@font-face{font-family:"Font Awesome 6 Free";font-style:normal;font-weight:400;font-display:block;src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype"); }.fa-regular,.far{font-weight:400}:host,:root{--fa-style-family-classic:"Font Awesome 6 Free";--fa-font-solid:normal 900 1em/1 "Font Awesome 6 Free"}@font-face{font-family:"Font Awesome 6 Free";font-style:normal;font-weight:900;font-display:block;src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype"); }.fa-solid,.fas{font-weight:900}@font-face{font-family:"Font Awesome 5 Brands";font-display:block;font-weight:400;src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype"); }@font-face{font-family:"Font Awesome 5 Free";font-display:block;font-weight:900;src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype"); }@font-face{font-family:"Font Awesome 5 Free";font-display:block;font-weight:400;src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype"); }@font-face{font-family:"FontAwesome";font-display:block;src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype"); }@font-face{font-family:"FontAwesome";font-display:block;src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype"); }@font-face{font-family:"FontAwesome";font-display:block;src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype"); }@font-face{font-family:"FontAwesome";font-display:block;src: url("../webfonts/fa-v4compatibility.woff2") format("woff2"), url("../webfonts/fa-v4compatibility.ttf") format("truetype"); } \ No newline at end of file diff --git a/docs/deps/font-awesome-6.5.2/css/v4-shims.css b/docs/deps/font-awesome-6.5.2/css/v4-shims.css new file mode 100644 index 00000000..ea60ea4d --- /dev/null +++ b/docs/deps/font-awesome-6.5.2/css/v4-shims.css @@ -0,0 +1,2194 @@ +/*! + * Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + * Copyright 2024 Fonticons, Inc. + */ +.fa.fa-glass:before { + content: "\f000"; } + +.fa.fa-envelope-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-envelope-o:before { + content: "\f0e0"; } + +.fa.fa-star-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-star-o:before { + content: "\f005"; } + +.fa.fa-remove:before { + content: "\f00d"; } + +.fa.fa-close:before { + content: "\f00d"; } + +.fa.fa-gear:before { + content: "\f013"; } + +.fa.fa-trash-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-trash-o:before { + content: "\f2ed"; } + +.fa.fa-home:before { + content: "\f015"; } + +.fa.fa-file-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-o:before { + content: "\f15b"; } + +.fa.fa-clock-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-clock-o:before { + content: "\f017"; } + +.fa.fa-arrow-circle-o-down { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-arrow-circle-o-down:before { + content: "\f358"; } + +.fa.fa-arrow-circle-o-up { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-arrow-circle-o-up:before { + content: "\f35b"; } + +.fa.fa-play-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-play-circle-o:before { + content: "\f144"; } + +.fa.fa-repeat:before { + content: "\f01e"; } + +.fa.fa-rotate-right:before { + content: "\f01e"; } + +.fa.fa-refresh:before { + content: "\f021"; } + +.fa.fa-list-alt { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-list-alt:before { + content: "\f022"; } + +.fa.fa-dedent:before { + content: "\f03b"; } + +.fa.fa-video-camera:before { + content: "\f03d"; } + +.fa.fa-picture-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-picture-o:before { + content: "\f03e"; } + +.fa.fa-photo { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-photo:before { + content: "\f03e"; } + +.fa.fa-image { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-image:before { + content: "\f03e"; } + +.fa.fa-map-marker:before { + content: "\f3c5"; } + +.fa.fa-pencil-square-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-pencil-square-o:before { + content: "\f044"; } + +.fa.fa-edit { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-edit:before { + content: "\f044"; } + +.fa.fa-share-square-o:before { + content: "\f14d"; } + +.fa.fa-check-square-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-check-square-o:before { + content: "\f14a"; } + +.fa.fa-arrows:before { + content: "\f0b2"; } + +.fa.fa-times-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-times-circle-o:before { + content: "\f057"; } + +.fa.fa-check-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-check-circle-o:before { + content: "\f058"; } + +.fa.fa-mail-forward:before { + content: "\f064"; } + +.fa.fa-expand:before { + content: "\f424"; } + +.fa.fa-compress:before { + content: "\f422"; } + +.fa.fa-eye { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-eye-slash { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-warning:before { + content: "\f071"; } + +.fa.fa-calendar:before { + content: "\f073"; } + +.fa.fa-arrows-v:before { + content: "\f338"; } + +.fa.fa-arrows-h:before { + content: "\f337"; } + +.fa.fa-bar-chart:before { + content: "\e0e3"; } + +.fa.fa-bar-chart-o:before { + content: "\e0e3"; } + +.fa.fa-twitter-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-twitter-square:before { + content: "\f081"; } + +.fa.fa-facebook-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-facebook-square:before { + content: "\f082"; } + +.fa.fa-gears:before { + content: "\f085"; } + +.fa.fa-thumbs-o-up { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-thumbs-o-up:before { + content: "\f164"; } + +.fa.fa-thumbs-o-down { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-thumbs-o-down:before { + content: "\f165"; } + +.fa.fa-heart-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-heart-o:before { + content: "\f004"; } + +.fa.fa-sign-out:before { + content: "\f2f5"; } + +.fa.fa-linkedin-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-linkedin-square:before { + content: "\f08c"; } + +.fa.fa-thumb-tack:before { + content: "\f08d"; } + +.fa.fa-external-link:before { + content: "\f35d"; } + +.fa.fa-sign-in:before { + content: "\f2f6"; } + +.fa.fa-github-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-github-square:before { + content: "\f092"; } + +.fa.fa-lemon-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-lemon-o:before { + content: "\f094"; } + +.fa.fa-square-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-square-o:before { + content: "\f0c8"; } + +.fa.fa-bookmark-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-bookmark-o:before { + content: "\f02e"; } + +.fa.fa-twitter { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-facebook { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-facebook:before { + content: "\f39e"; } + +.fa.fa-facebook-f { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-facebook-f:before { + content: "\f39e"; } + +.fa.fa-github { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-credit-card { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-feed:before { + content: "\f09e"; } + +.fa.fa-hdd-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hdd-o:before { + content: "\f0a0"; } + +.fa.fa-hand-o-right { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-o-right:before { + content: "\f0a4"; } + +.fa.fa-hand-o-left { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-o-left:before { + content: "\f0a5"; } + +.fa.fa-hand-o-up { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-o-up:before { + content: "\f0a6"; } + +.fa.fa-hand-o-down { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-o-down:before { + content: "\f0a7"; } + +.fa.fa-globe:before { + content: "\f57d"; } + +.fa.fa-tasks:before { + content: "\f828"; } + +.fa.fa-arrows-alt:before { + content: "\f31e"; } + +.fa.fa-group:before { + content: "\f0c0"; } + +.fa.fa-chain:before { + content: "\f0c1"; } + +.fa.fa-cut:before { + content: "\f0c4"; } + +.fa.fa-files-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-files-o:before { + content: "\f0c5"; } + +.fa.fa-floppy-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-floppy-o:before { + content: "\f0c7"; } + +.fa.fa-save { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-save:before { + content: "\f0c7"; } + +.fa.fa-navicon:before { + content: "\f0c9"; } + +.fa.fa-reorder:before { + content: "\f0c9"; } + +.fa.fa-magic:before { + content: "\e2ca"; } + +.fa.fa-pinterest { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-pinterest-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-pinterest-square:before { + content: "\f0d3"; } + +.fa.fa-google-plus-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-google-plus-square:before { + content: "\f0d4"; } + +.fa.fa-google-plus { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-google-plus:before { + content: "\f0d5"; } + +.fa.fa-money:before { + content: "\f3d1"; } + +.fa.fa-unsorted:before { + content: "\f0dc"; } + +.fa.fa-sort-desc:before { + content: "\f0dd"; } + +.fa.fa-sort-asc:before { + content: "\f0de"; } + +.fa.fa-linkedin { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-linkedin:before { + content: "\f0e1"; } + +.fa.fa-rotate-left:before { + content: "\f0e2"; } + +.fa.fa-legal:before { + content: "\f0e3"; } + +.fa.fa-tachometer:before { + content: "\f625"; } + +.fa.fa-dashboard:before { + content: "\f625"; } + +.fa.fa-comment-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-comment-o:before { + content: "\f075"; } + +.fa.fa-comments-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-comments-o:before { + content: "\f086"; } + +.fa.fa-flash:before { + content: "\f0e7"; } + +.fa.fa-clipboard:before { + content: "\f0ea"; } + +.fa.fa-lightbulb-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-lightbulb-o:before { + content: "\f0eb"; } + +.fa.fa-exchange:before { + content: "\f362"; } + +.fa.fa-cloud-download:before { + content: "\f0ed"; } + +.fa.fa-cloud-upload:before { + content: "\f0ee"; } + +.fa.fa-bell-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-bell-o:before { + content: "\f0f3"; } + +.fa.fa-cutlery:before { + content: "\f2e7"; } + +.fa.fa-file-text-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-text-o:before { + content: "\f15c"; } + +.fa.fa-building-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-building-o:before { + content: "\f1ad"; } + +.fa.fa-hospital-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hospital-o:before { + content: "\f0f8"; } + +.fa.fa-tablet:before { + content: "\f3fa"; } + +.fa.fa-mobile:before { + content: "\f3cd"; } + +.fa.fa-mobile-phone:before { + content: "\f3cd"; } + +.fa.fa-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-circle-o:before { + content: "\f111"; } + +.fa.fa-mail-reply:before { + content: "\f3e5"; } + +.fa.fa-github-alt { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-folder-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-folder-o:before { + content: "\f07b"; } + +.fa.fa-folder-open-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-folder-open-o:before { + content: "\f07c"; } + +.fa.fa-smile-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-smile-o:before { + content: "\f118"; } + +.fa.fa-frown-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-frown-o:before { + content: "\f119"; } + +.fa.fa-meh-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-meh-o:before { + content: "\f11a"; } + +.fa.fa-keyboard-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-keyboard-o:before { + content: "\f11c"; } + +.fa.fa-flag-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-flag-o:before { + content: "\f024"; } + +.fa.fa-mail-reply-all:before { + content: "\f122"; } + +.fa.fa-star-half-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-star-half-o:before { + content: "\f5c0"; } + +.fa.fa-star-half-empty { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-star-half-empty:before { + content: "\f5c0"; } + +.fa.fa-star-half-full { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-star-half-full:before { + content: "\f5c0"; } + +.fa.fa-code-fork:before { + content: "\f126"; } + +.fa.fa-chain-broken:before { + content: "\f127"; } + +.fa.fa-unlink:before { + content: "\f127"; } + +.fa.fa-calendar-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-calendar-o:before { + content: "\f133"; } + +.fa.fa-maxcdn { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-html5 { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-css3 { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-unlock-alt:before { + content: "\f09c"; } + +.fa.fa-minus-square-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-minus-square-o:before { + content: "\f146"; } + +.fa.fa-level-up:before { + content: "\f3bf"; } + +.fa.fa-level-down:before { + content: "\f3be"; } + +.fa.fa-pencil-square:before { + content: "\f14b"; } + +.fa.fa-external-link-square:before { + content: "\f360"; } + +.fa.fa-compass { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-caret-square-o-down { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-caret-square-o-down:before { + content: "\f150"; } + +.fa.fa-toggle-down { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-toggle-down:before { + content: "\f150"; } + +.fa.fa-caret-square-o-up { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-caret-square-o-up:before { + content: "\f151"; } + +.fa.fa-toggle-up { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-toggle-up:before { + content: "\f151"; } + +.fa.fa-caret-square-o-right { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-caret-square-o-right:before { + content: "\f152"; } + +.fa.fa-toggle-right { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-toggle-right:before { + content: "\f152"; } + +.fa.fa-eur:before { + content: "\f153"; } + +.fa.fa-euro:before { + content: "\f153"; } + +.fa.fa-gbp:before { + content: "\f154"; } + +.fa.fa-usd:before { + content: "\24"; } + +.fa.fa-dollar:before { + content: "\24"; } + +.fa.fa-inr:before { + content: "\e1bc"; } + +.fa.fa-rupee:before { + content: "\e1bc"; } + +.fa.fa-jpy:before { + content: "\f157"; } + +.fa.fa-cny:before { + content: "\f157"; } + +.fa.fa-rmb:before { + content: "\f157"; } + +.fa.fa-yen:before { + content: "\f157"; } + +.fa.fa-rub:before { + content: "\f158"; } + +.fa.fa-ruble:before { + content: "\f158"; } + +.fa.fa-rouble:before { + content: "\f158"; } + +.fa.fa-krw:before { + content: "\f159"; } + +.fa.fa-won:before { + content: "\f159"; } + +.fa.fa-btc { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-bitcoin { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-bitcoin:before { + content: "\f15a"; } + +.fa.fa-file-text:before { + content: "\f15c"; } + +.fa.fa-sort-alpha-asc:before { + content: "\f15d"; } + +.fa.fa-sort-alpha-desc:before { + content: "\f881"; } + +.fa.fa-sort-amount-asc:before { + content: "\f884"; } + +.fa.fa-sort-amount-desc:before { + content: "\f160"; } + +.fa.fa-sort-numeric-asc:before { + content: "\f162"; } + +.fa.fa-sort-numeric-desc:before { + content: "\f886"; } + +.fa.fa-youtube-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-youtube-square:before { + content: "\f431"; } + +.fa.fa-youtube { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-xing { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-xing-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-xing-square:before { + content: "\f169"; } + +.fa.fa-youtube-play { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-youtube-play:before { + content: "\f167"; } + +.fa.fa-dropbox { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-stack-overflow { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-instagram { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-flickr { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-adn { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-bitbucket { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-bitbucket-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-bitbucket-square:before { + content: "\f171"; } + +.fa.fa-tumblr { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-tumblr-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-tumblr-square:before { + content: "\f174"; } + +.fa.fa-long-arrow-down:before { + content: "\f309"; } + +.fa.fa-long-arrow-up:before { + content: "\f30c"; } + +.fa.fa-long-arrow-left:before { + content: "\f30a"; } + +.fa.fa-long-arrow-right:before { + content: "\f30b"; } + +.fa.fa-apple { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-windows { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-android { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-linux { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-dribbble { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-skype { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-foursquare { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-trello { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-gratipay { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-gittip { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-gittip:before { + content: "\f184"; } + +.fa.fa-sun-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-sun-o:before { + content: "\f185"; } + +.fa.fa-moon-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-moon-o:before { + content: "\f186"; } + +.fa.fa-vk { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-weibo { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-renren { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-pagelines { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-stack-exchange { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-arrow-circle-o-right { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-arrow-circle-o-right:before { + content: "\f35a"; } + +.fa.fa-arrow-circle-o-left { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-arrow-circle-o-left:before { + content: "\f359"; } + +.fa.fa-caret-square-o-left { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-caret-square-o-left:before { + content: "\f191"; } + +.fa.fa-toggle-left { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-toggle-left:before { + content: "\f191"; } + +.fa.fa-dot-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-dot-circle-o:before { + content: "\f192"; } + +.fa.fa-vimeo-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-vimeo-square:before { + content: "\f194"; } + +.fa.fa-try:before { + content: "\e2bb"; } + +.fa.fa-turkish-lira:before { + content: "\e2bb"; } + +.fa.fa-plus-square-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-plus-square-o:before { + content: "\f0fe"; } + +.fa.fa-slack { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wordpress { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-openid { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-institution:before { + content: "\f19c"; } + +.fa.fa-bank:before { + content: "\f19c"; } + +.fa.fa-mortar-board:before { + content: "\f19d"; } + +.fa.fa-yahoo { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-google { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-reddit { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-reddit-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-reddit-square:before { + content: "\f1a2"; } + +.fa.fa-stumbleupon-circle { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-stumbleupon { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-delicious { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-digg { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-pied-piper-pp { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-pied-piper-alt { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-drupal { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-joomla { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-behance { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-behance-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-behance-square:before { + content: "\f1b5"; } + +.fa.fa-steam { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-steam-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-steam-square:before { + content: "\f1b7"; } + +.fa.fa-automobile:before { + content: "\f1b9"; } + +.fa.fa-cab:before { + content: "\f1ba"; } + +.fa.fa-spotify { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-deviantart { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-soundcloud { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-file-pdf-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-pdf-o:before { + content: "\f1c1"; } + +.fa.fa-file-word-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-word-o:before { + content: "\f1c2"; } + +.fa.fa-file-excel-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-excel-o:before { + content: "\f1c3"; } + +.fa.fa-file-powerpoint-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-powerpoint-o:before { + content: "\f1c4"; } + +.fa.fa-file-image-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-image-o:before { + content: "\f1c5"; } + +.fa.fa-file-photo-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-photo-o:before { + content: "\f1c5"; } + +.fa.fa-file-picture-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-picture-o:before { + content: "\f1c5"; } + +.fa.fa-file-archive-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-archive-o:before { + content: "\f1c6"; } + +.fa.fa-file-zip-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-zip-o:before { + content: "\f1c6"; } + +.fa.fa-file-audio-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-audio-o:before { + content: "\f1c7"; } + +.fa.fa-file-sound-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-sound-o:before { + content: "\f1c7"; } + +.fa.fa-file-video-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-video-o:before { + content: "\f1c8"; } + +.fa.fa-file-movie-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-movie-o:before { + content: "\f1c8"; } + +.fa.fa-file-code-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-file-code-o:before { + content: "\f1c9"; } + +.fa.fa-vine { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-codepen { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-jsfiddle { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-life-bouy:before { + content: "\f1cd"; } + +.fa.fa-life-buoy:before { + content: "\f1cd"; } + +.fa.fa-life-saver:before { + content: "\f1cd"; } + +.fa.fa-support:before { + content: "\f1cd"; } + +.fa.fa-circle-o-notch:before { + content: "\f1ce"; } + +.fa.fa-rebel { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-ra { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-ra:before { + content: "\f1d0"; } + +.fa.fa-resistance { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-resistance:before { + content: "\f1d0"; } + +.fa.fa-empire { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-ge { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-ge:before { + content: "\f1d1"; } + +.fa.fa-git-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-git-square:before { + content: "\f1d2"; } + +.fa.fa-git { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-hacker-news { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-y-combinator-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-y-combinator-square:before { + content: "\f1d4"; } + +.fa.fa-yc-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-yc-square:before { + content: "\f1d4"; } + +.fa.fa-tencent-weibo { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-qq { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-weixin { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wechat { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wechat:before { + content: "\f1d7"; } + +.fa.fa-send:before { + content: "\f1d8"; } + +.fa.fa-paper-plane-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-paper-plane-o:before { + content: "\f1d8"; } + +.fa.fa-send-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-send-o:before { + content: "\f1d8"; } + +.fa.fa-circle-thin { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-circle-thin:before { + content: "\f111"; } + +.fa.fa-header:before { + content: "\f1dc"; } + +.fa.fa-futbol-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-futbol-o:before { + content: "\f1e3"; } + +.fa.fa-soccer-ball-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-soccer-ball-o:before { + content: "\f1e3"; } + +.fa.fa-slideshare { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-twitch { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-yelp { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-newspaper-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-newspaper-o:before { + content: "\f1ea"; } + +.fa.fa-paypal { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-google-wallet { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-cc-visa { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-cc-mastercard { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-cc-discover { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-cc-amex { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-cc-paypal { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-cc-stripe { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-bell-slash-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-bell-slash-o:before { + content: "\f1f6"; } + +.fa.fa-trash:before { + content: "\f2ed"; } + +.fa.fa-copyright { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-eyedropper:before { + content: "\f1fb"; } + +.fa.fa-area-chart:before { + content: "\f1fe"; } + +.fa.fa-pie-chart:before { + content: "\f200"; } + +.fa.fa-line-chart:before { + content: "\f201"; } + +.fa.fa-lastfm { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-lastfm-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-lastfm-square:before { + content: "\f203"; } + +.fa.fa-ioxhost { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-angellist { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-cc { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-cc:before { + content: "\f20a"; } + +.fa.fa-ils:before { + content: "\f20b"; } + +.fa.fa-shekel:before { + content: "\f20b"; } + +.fa.fa-sheqel:before { + content: "\f20b"; } + +.fa.fa-buysellads { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-connectdevelop { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-dashcube { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-forumbee { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-leanpub { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-sellsy { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-shirtsinbulk { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-simplybuilt { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-skyatlas { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-diamond { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-diamond:before { + content: "\f3a5"; } + +.fa.fa-transgender:before { + content: "\f224"; } + +.fa.fa-intersex:before { + content: "\f224"; } + +.fa.fa-transgender-alt:before { + content: "\f225"; } + +.fa.fa-facebook-official { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-facebook-official:before { + content: "\f09a"; } + +.fa.fa-pinterest-p { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-whatsapp { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-hotel:before { + content: "\f236"; } + +.fa.fa-viacoin { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-medium { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-y-combinator { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-yc { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-yc:before { + content: "\f23b"; } + +.fa.fa-optin-monster { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-opencart { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-expeditedssl { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-battery-4:before { + content: "\f240"; } + +.fa.fa-battery:before { + content: "\f240"; } + +.fa.fa-battery-3:before { + content: "\f241"; } + +.fa.fa-battery-2:before { + content: "\f242"; } + +.fa.fa-battery-1:before { + content: "\f243"; } + +.fa.fa-battery-0:before { + content: "\f244"; } + +.fa.fa-object-group { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-object-ungroup { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-sticky-note-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-sticky-note-o:before { + content: "\f249"; } + +.fa.fa-cc-jcb { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-cc-diners-club { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-clone { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hourglass-o:before { + content: "\f254"; } + +.fa.fa-hourglass-1:before { + content: "\f251"; } + +.fa.fa-hourglass-2:before { + content: "\f252"; } + +.fa.fa-hourglass-3:before { + content: "\f253"; } + +.fa.fa-hand-rock-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-rock-o:before { + content: "\f255"; } + +.fa.fa-hand-grab-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-grab-o:before { + content: "\f255"; } + +.fa.fa-hand-paper-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-paper-o:before { + content: "\f256"; } + +.fa.fa-hand-stop-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-stop-o:before { + content: "\f256"; } + +.fa.fa-hand-scissors-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-scissors-o:before { + content: "\f257"; } + +.fa.fa-hand-lizard-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-lizard-o:before { + content: "\f258"; } + +.fa.fa-hand-spock-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-spock-o:before { + content: "\f259"; } + +.fa.fa-hand-pointer-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-pointer-o:before { + content: "\f25a"; } + +.fa.fa-hand-peace-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-hand-peace-o:before { + content: "\f25b"; } + +.fa.fa-registered { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-creative-commons { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-gg { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-gg-circle { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-odnoklassniki { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-odnoklassniki-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-odnoklassniki-square:before { + content: "\f264"; } + +.fa.fa-get-pocket { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wikipedia-w { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-safari { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-chrome { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-firefox { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-opera { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-internet-explorer { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-television:before { + content: "\f26c"; } + +.fa.fa-contao { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-500px { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-amazon { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-calendar-plus-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-calendar-plus-o:before { + content: "\f271"; } + +.fa.fa-calendar-minus-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-calendar-minus-o:before { + content: "\f272"; } + +.fa.fa-calendar-times-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-calendar-times-o:before { + content: "\f273"; } + +.fa.fa-calendar-check-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-calendar-check-o:before { + content: "\f274"; } + +.fa.fa-map-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-map-o:before { + content: "\f279"; } + +.fa.fa-commenting:before { + content: "\f4ad"; } + +.fa.fa-commenting-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-commenting-o:before { + content: "\f4ad"; } + +.fa.fa-houzz { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-vimeo { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-vimeo:before { + content: "\f27d"; } + +.fa.fa-black-tie { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-fonticons { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-reddit-alien { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-edge { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-credit-card-alt:before { + content: "\f09d"; } + +.fa.fa-codiepie { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-modx { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-fort-awesome { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-usb { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-product-hunt { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-mixcloud { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-scribd { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-pause-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-pause-circle-o:before { + content: "\f28b"; } + +.fa.fa-stop-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-stop-circle-o:before { + content: "\f28d"; } + +.fa.fa-bluetooth { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-bluetooth-b { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-gitlab { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wpbeginner { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wpforms { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-envira { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wheelchair-alt { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wheelchair-alt:before { + content: "\f368"; } + +.fa.fa-question-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-question-circle-o:before { + content: "\f059"; } + +.fa.fa-volume-control-phone:before { + content: "\f2a0"; } + +.fa.fa-asl-interpreting:before { + content: "\f2a3"; } + +.fa.fa-deafness:before { + content: "\f2a4"; } + +.fa.fa-hard-of-hearing:before { + content: "\f2a4"; } + +.fa.fa-glide { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-glide-g { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-signing:before { + content: "\f2a7"; } + +.fa.fa-viadeo { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-viadeo-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-viadeo-square:before { + content: "\f2aa"; } + +.fa.fa-snapchat { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-snapchat-ghost { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-snapchat-ghost:before { + content: "\f2ab"; } + +.fa.fa-snapchat-square { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-snapchat-square:before { + content: "\f2ad"; } + +.fa.fa-pied-piper { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-first-order { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-yoast { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-themeisle { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-google-plus-official { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-google-plus-official:before { + content: "\f2b3"; } + +.fa.fa-google-plus-circle { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-google-plus-circle:before { + content: "\f2b3"; } + +.fa.fa-font-awesome { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-fa { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-fa:before { + content: "\f2b4"; } + +.fa.fa-handshake-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-handshake-o:before { + content: "\f2b5"; } + +.fa.fa-envelope-open-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-envelope-open-o:before { + content: "\f2b6"; } + +.fa.fa-linode { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-address-book-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-address-book-o:before { + content: "\f2b9"; } + +.fa.fa-vcard:before { + content: "\f2bb"; } + +.fa.fa-address-card-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-address-card-o:before { + content: "\f2bb"; } + +.fa.fa-vcard-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-vcard-o:before { + content: "\f2bb"; } + +.fa.fa-user-circle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-user-circle-o:before { + content: "\f2bd"; } + +.fa.fa-user-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-user-o:before { + content: "\f007"; } + +.fa.fa-id-badge { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-drivers-license:before { + content: "\f2c2"; } + +.fa.fa-id-card-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-id-card-o:before { + content: "\f2c2"; } + +.fa.fa-drivers-license-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-drivers-license-o:before { + content: "\f2c2"; } + +.fa.fa-quora { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-free-code-camp { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-telegram { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-thermometer-4:before { + content: "\f2c7"; } + +.fa.fa-thermometer:before { + content: "\f2c7"; } + +.fa.fa-thermometer-3:before { + content: "\f2c8"; } + +.fa.fa-thermometer-2:before { + content: "\f2c9"; } + +.fa.fa-thermometer-1:before { + content: "\f2ca"; } + +.fa.fa-thermometer-0:before { + content: "\f2cb"; } + +.fa.fa-bathtub:before { + content: "\f2cd"; } + +.fa.fa-s15:before { + content: "\f2cd"; } + +.fa.fa-window-maximize { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-window-restore { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-times-rectangle:before { + content: "\f410"; } + +.fa.fa-window-close-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-window-close-o:before { + content: "\f410"; } + +.fa.fa-times-rectangle-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-times-rectangle-o:before { + content: "\f410"; } + +.fa.fa-bandcamp { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-grav { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-etsy { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-imdb { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-ravelry { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-eercast { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-eercast:before { + content: "\f2da"; } + +.fa.fa-snowflake-o { + font-family: 'Font Awesome 6 Free'; + font-weight: 400; } + +.fa.fa-snowflake-o:before { + content: "\f2dc"; } + +.fa.fa-superpowers { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-wpexplorer { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } + +.fa.fa-meetup { + font-family: 'Font Awesome 6 Brands'; + font-weight: 400; } diff --git a/docs/deps/font-awesome-6.5.2/css/v4-shims.min.css b/docs/deps/font-awesome-6.5.2/css/v4-shims.min.css new file mode 100644 index 00000000..09baf5fc --- /dev/null +++ b/docs/deps/font-awesome-6.5.2/css/v4-shims.min.css @@ -0,0 +1,6 @@ +/*! + * Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + * Copyright 2024 Fonticons, Inc. + */ +.fa.fa-glass:before{content:"\f000"}.fa.fa-envelope-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-envelope-o:before{content:"\f0e0"}.fa.fa-star-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-star-o:before{content:"\f005"}.fa.fa-close:before,.fa.fa-remove:before{content:"\f00d"}.fa.fa-gear:before{content:"\f013"}.fa.fa-trash-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-trash-o:before{content:"\f2ed"}.fa.fa-home:before{content:"\f015"}.fa.fa-file-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-o:before{content:"\f15b"}.fa.fa-clock-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-clock-o:before{content:"\f017"}.fa.fa-arrow-circle-o-down{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-arrow-circle-o-down:before{content:"\f358"}.fa.fa-arrow-circle-o-up{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-arrow-circle-o-up:before{content:"\f35b"}.fa.fa-play-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-play-circle-o:before{content:"\f144"}.fa.fa-repeat:before,.fa.fa-rotate-right:before{content:"\f01e"}.fa.fa-refresh:before{content:"\f021"}.fa.fa-list-alt{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-list-alt:before{content:"\f022"}.fa.fa-dedent:before{content:"\f03b"}.fa.fa-video-camera:before{content:"\f03d"}.fa.fa-picture-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-picture-o:before{content:"\f03e"}.fa.fa-photo{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-photo:before{content:"\f03e"}.fa.fa-image{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-image:before{content:"\f03e"}.fa.fa-map-marker:before{content:"\f3c5"}.fa.fa-pencil-square-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-pencil-square-o:before{content:"\f044"}.fa.fa-edit{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-edit:before{content:"\f044"}.fa.fa-share-square-o:before{content:"\f14d"}.fa.fa-check-square-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-check-square-o:before{content:"\f14a"}.fa.fa-arrows:before{content:"\f0b2"}.fa.fa-times-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-times-circle-o:before{content:"\f057"}.fa.fa-check-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-check-circle-o:before{content:"\f058"}.fa.fa-mail-forward:before{content:"\f064"}.fa.fa-expand:before{content:"\f424"}.fa.fa-compress:before{content:"\f422"}.fa.fa-eye,.fa.fa-eye-slash{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-warning:before{content:"\f071"}.fa.fa-calendar:before{content:"\f073"}.fa.fa-arrows-v:before{content:"\f338"}.fa.fa-arrows-h:before{content:"\f337"}.fa.fa-bar-chart-o:before,.fa.fa-bar-chart:before{content:"\e0e3"}.fa.fa-twitter-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-twitter-square:before{content:"\f081"}.fa.fa-facebook-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-facebook-square:before{content:"\f082"}.fa.fa-gears:before{content:"\f085"}.fa.fa-thumbs-o-up{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-thumbs-o-up:before{content:"\f164"}.fa.fa-thumbs-o-down{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-thumbs-o-down:before{content:"\f165"}.fa.fa-heart-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-heart-o:before{content:"\f004"}.fa.fa-sign-out:before{content:"\f2f5"}.fa.fa-linkedin-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-linkedin-square:before{content:"\f08c"}.fa.fa-thumb-tack:before{content:"\f08d"}.fa.fa-external-link:before{content:"\f35d"}.fa.fa-sign-in:before{content:"\f2f6"}.fa.fa-github-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-github-square:before{content:"\f092"}.fa.fa-lemon-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-lemon-o:before{content:"\f094"}.fa.fa-square-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-square-o:before{content:"\f0c8"}.fa.fa-bookmark-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-bookmark-o:before{content:"\f02e"}.fa.fa-facebook,.fa.fa-twitter{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-facebook:before{content:"\f39e"}.fa.fa-facebook-f{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-facebook-f:before{content:"\f39e"}.fa.fa-github{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-credit-card{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-feed:before{content:"\f09e"}.fa.fa-hdd-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hdd-o:before{content:"\f0a0"}.fa.fa-hand-o-right{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-o-right:before{content:"\f0a4"}.fa.fa-hand-o-left{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-o-left:before{content:"\f0a5"}.fa.fa-hand-o-up{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-o-up:before{content:"\f0a6"}.fa.fa-hand-o-down{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-o-down:before{content:"\f0a7"}.fa.fa-globe:before{content:"\f57d"}.fa.fa-tasks:before{content:"\f828"}.fa.fa-arrows-alt:before{content:"\f31e"}.fa.fa-group:before{content:"\f0c0"}.fa.fa-chain:before{content:"\f0c1"}.fa.fa-cut:before{content:"\f0c4"}.fa.fa-files-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-files-o:before{content:"\f0c5"}.fa.fa-floppy-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-floppy-o:before{content:"\f0c7"}.fa.fa-save{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-save:before{content:"\f0c7"}.fa.fa-navicon:before,.fa.fa-reorder:before{content:"\f0c9"}.fa.fa-magic:before{content:"\e2ca"}.fa.fa-pinterest,.fa.fa-pinterest-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-pinterest-square:before{content:"\f0d3"}.fa.fa-google-plus-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-google-plus-square:before{content:"\f0d4"}.fa.fa-google-plus{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-google-plus:before{content:"\f0d5"}.fa.fa-money:before{content:"\f3d1"}.fa.fa-unsorted:before{content:"\f0dc"}.fa.fa-sort-desc:before{content:"\f0dd"}.fa.fa-sort-asc:before{content:"\f0de"}.fa.fa-linkedin{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-linkedin:before{content:"\f0e1"}.fa.fa-rotate-left:before{content:"\f0e2"}.fa.fa-legal:before{content:"\f0e3"}.fa.fa-dashboard:before,.fa.fa-tachometer:before{content:"\f625"}.fa.fa-comment-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-comment-o:before{content:"\f075"}.fa.fa-comments-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-comments-o:before{content:"\f086"}.fa.fa-flash:before{content:"\f0e7"}.fa.fa-clipboard:before{content:"\f0ea"}.fa.fa-lightbulb-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-lightbulb-o:before{content:"\f0eb"}.fa.fa-exchange:before{content:"\f362"}.fa.fa-cloud-download:before{content:"\f0ed"}.fa.fa-cloud-upload:before{content:"\f0ee"}.fa.fa-bell-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-bell-o:before{content:"\f0f3"}.fa.fa-cutlery:before{content:"\f2e7"}.fa.fa-file-text-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-text-o:before{content:"\f15c"}.fa.fa-building-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-building-o:before{content:"\f1ad"}.fa.fa-hospital-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hospital-o:before{content:"\f0f8"}.fa.fa-tablet:before{content:"\f3fa"}.fa.fa-mobile-phone:before,.fa.fa-mobile:before{content:"\f3cd"}.fa.fa-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-circle-o:before{content:"\f111"}.fa.fa-mail-reply:before{content:"\f3e5"}.fa.fa-github-alt{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-folder-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-folder-o:before{content:"\f07b"}.fa.fa-folder-open-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-folder-open-o:before{content:"\f07c"}.fa.fa-smile-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-smile-o:before{content:"\f118"}.fa.fa-frown-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-frown-o:before{content:"\f119"}.fa.fa-meh-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-meh-o:before{content:"\f11a"}.fa.fa-keyboard-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-keyboard-o:before{content:"\f11c"}.fa.fa-flag-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-flag-o:before{content:"\f024"}.fa.fa-mail-reply-all:before{content:"\f122"}.fa.fa-star-half-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-star-half-o:before{content:"\f5c0"}.fa.fa-star-half-empty{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-star-half-empty:before{content:"\f5c0"}.fa.fa-star-half-full{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-star-half-full:before{content:"\f5c0"}.fa.fa-code-fork:before{content:"\f126"}.fa.fa-chain-broken:before,.fa.fa-unlink:before{content:"\f127"}.fa.fa-calendar-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-calendar-o:before{content:"\f133"}.fa.fa-css3,.fa.fa-html5,.fa.fa-maxcdn{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-unlock-alt:before{content:"\f09c"}.fa.fa-minus-square-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-minus-square-o:before{content:"\f146"}.fa.fa-level-up:before{content:"\f3bf"}.fa.fa-level-down:before{content:"\f3be"}.fa.fa-pencil-square:before{content:"\f14b"}.fa.fa-external-link-square:before{content:"\f360"}.fa.fa-compass{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-caret-square-o-down{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-caret-square-o-down:before{content:"\f150"}.fa.fa-toggle-down{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-toggle-down:before{content:"\f150"}.fa.fa-caret-square-o-up{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-caret-square-o-up:before{content:"\f151"}.fa.fa-toggle-up{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-toggle-up:before{content:"\f151"}.fa.fa-caret-square-o-right{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-caret-square-o-right:before{content:"\f152"}.fa.fa-toggle-right{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-toggle-right:before{content:"\f152"}.fa.fa-eur:before,.fa.fa-euro:before{content:"\f153"}.fa.fa-gbp:before{content:"\f154"}.fa.fa-dollar:before,.fa.fa-usd:before{content:"\24"}.fa.fa-inr:before,.fa.fa-rupee:before{content:"\e1bc"}.fa.fa-cny:before,.fa.fa-jpy:before,.fa.fa-rmb:before,.fa.fa-yen:before{content:"\f157"}.fa.fa-rouble:before,.fa.fa-rub:before,.fa.fa-ruble:before{content:"\f158"}.fa.fa-krw:before,.fa.fa-won:before{content:"\f159"}.fa.fa-bitcoin,.fa.fa-btc{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-bitcoin:before{content:"\f15a"}.fa.fa-file-text:before{content:"\f15c"}.fa.fa-sort-alpha-asc:before{content:"\f15d"}.fa.fa-sort-alpha-desc:before{content:"\f881"}.fa.fa-sort-amount-asc:before{content:"\f884"}.fa.fa-sort-amount-desc:before{content:"\f160"}.fa.fa-sort-numeric-asc:before{content:"\f162"}.fa.fa-sort-numeric-desc:before{content:"\f886"}.fa.fa-youtube-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-youtube-square:before{content:"\f431"}.fa.fa-xing,.fa.fa-xing-square,.fa.fa-youtube{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-xing-square:before{content:"\f169"}.fa.fa-youtube-play{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-youtube-play:before{content:"\f167"}.fa.fa-adn,.fa.fa-bitbucket,.fa.fa-bitbucket-square,.fa.fa-dropbox,.fa.fa-flickr,.fa.fa-instagram,.fa.fa-stack-overflow{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-bitbucket-square:before{content:"\f171"}.fa.fa-tumblr,.fa.fa-tumblr-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-tumblr-square:before{content:"\f174"}.fa.fa-long-arrow-down:before{content:"\f309"}.fa.fa-long-arrow-up:before{content:"\f30c"}.fa.fa-long-arrow-left:before{content:"\f30a"}.fa.fa-long-arrow-right:before{content:"\f30b"}.fa.fa-android,.fa.fa-apple,.fa.fa-dribbble,.fa.fa-foursquare,.fa.fa-gittip,.fa.fa-gratipay,.fa.fa-linux,.fa.fa-skype,.fa.fa-trello,.fa.fa-windows{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-gittip:before{content:"\f184"}.fa.fa-sun-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-sun-o:before{content:"\f185"}.fa.fa-moon-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-moon-o:before{content:"\f186"}.fa.fa-pagelines,.fa.fa-renren,.fa.fa-stack-exchange,.fa.fa-vk,.fa.fa-weibo{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-arrow-circle-o-right{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-arrow-circle-o-right:before{content:"\f35a"}.fa.fa-arrow-circle-o-left{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-arrow-circle-o-left:before{content:"\f359"}.fa.fa-caret-square-o-left{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-caret-square-o-left:before{content:"\f191"}.fa.fa-toggle-left{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-toggle-left:before{content:"\f191"}.fa.fa-dot-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-dot-circle-o:before{content:"\f192"}.fa.fa-vimeo-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-vimeo-square:before{content:"\f194"}.fa.fa-try:before,.fa.fa-turkish-lira:before{content:"\e2bb"}.fa.fa-plus-square-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-plus-square-o:before{content:"\f0fe"}.fa.fa-openid,.fa.fa-slack,.fa.fa-wordpress{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-bank:before,.fa.fa-institution:before{content:"\f19c"}.fa.fa-mortar-board:before{content:"\f19d"}.fa.fa-google,.fa.fa-reddit,.fa.fa-reddit-square,.fa.fa-yahoo{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-reddit-square:before{content:"\f1a2"}.fa.fa-behance,.fa.fa-behance-square,.fa.fa-delicious,.fa.fa-digg,.fa.fa-drupal,.fa.fa-joomla,.fa.fa-pied-piper-alt,.fa.fa-pied-piper-pp,.fa.fa-stumbleupon,.fa.fa-stumbleupon-circle{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-behance-square:before{content:"\f1b5"}.fa.fa-steam,.fa.fa-steam-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-steam-square:before{content:"\f1b7"}.fa.fa-automobile:before{content:"\f1b9"}.fa.fa-cab:before{content:"\f1ba"}.fa.fa-deviantart,.fa.fa-soundcloud,.fa.fa-spotify{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-file-pdf-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-pdf-o:before{content:"\f1c1"}.fa.fa-file-word-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-word-o:before{content:"\f1c2"}.fa.fa-file-excel-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-excel-o:before{content:"\f1c3"}.fa.fa-file-powerpoint-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-powerpoint-o:before{content:"\f1c4"}.fa.fa-file-image-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-image-o:before{content:"\f1c5"}.fa.fa-file-photo-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-photo-o:before{content:"\f1c5"}.fa.fa-file-picture-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-picture-o:before{content:"\f1c5"}.fa.fa-file-archive-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-archive-o:before{content:"\f1c6"}.fa.fa-file-zip-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-zip-o:before{content:"\f1c6"}.fa.fa-file-audio-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-audio-o:before{content:"\f1c7"}.fa.fa-file-sound-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-sound-o:before{content:"\f1c7"}.fa.fa-file-video-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-video-o:before{content:"\f1c8"}.fa.fa-file-movie-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-movie-o:before{content:"\f1c8"}.fa.fa-file-code-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-file-code-o:before{content:"\f1c9"}.fa.fa-codepen,.fa.fa-jsfiddle,.fa.fa-vine{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-life-bouy:before,.fa.fa-life-buoy:before,.fa.fa-life-saver:before,.fa.fa-support:before{content:"\f1cd"}.fa.fa-circle-o-notch:before{content:"\f1ce"}.fa.fa-ra,.fa.fa-rebel{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-ra:before{content:"\f1d0"}.fa.fa-resistance{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-resistance:before{content:"\f1d0"}.fa.fa-empire,.fa.fa-ge{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-ge:before{content:"\f1d1"}.fa.fa-git-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-git-square:before{content:"\f1d2"}.fa.fa-git,.fa.fa-hacker-news,.fa.fa-y-combinator-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-y-combinator-square:before{content:"\f1d4"}.fa.fa-yc-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-yc-square:before{content:"\f1d4"}.fa.fa-qq,.fa.fa-tencent-weibo,.fa.fa-wechat,.fa.fa-weixin{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-wechat:before{content:"\f1d7"}.fa.fa-send:before{content:"\f1d8"}.fa.fa-paper-plane-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-paper-plane-o:before{content:"\f1d8"}.fa.fa-send-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-send-o:before{content:"\f1d8"}.fa.fa-circle-thin{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-circle-thin:before{content:"\f111"}.fa.fa-header:before{content:"\f1dc"}.fa.fa-futbol-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-futbol-o:before{content:"\f1e3"}.fa.fa-soccer-ball-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-soccer-ball-o:before{content:"\f1e3"}.fa.fa-slideshare,.fa.fa-twitch,.fa.fa-yelp{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-newspaper-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-newspaper-o:before{content:"\f1ea"}.fa.fa-cc-amex,.fa.fa-cc-discover,.fa.fa-cc-mastercard,.fa.fa-cc-paypal,.fa.fa-cc-stripe,.fa.fa-cc-visa,.fa.fa-google-wallet,.fa.fa-paypal{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-bell-slash-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-bell-slash-o:before{content:"\f1f6"}.fa.fa-trash:before{content:"\f2ed"}.fa.fa-copyright{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-eyedropper:before{content:"\f1fb"}.fa.fa-area-chart:before{content:"\f1fe"}.fa.fa-pie-chart:before{content:"\f200"}.fa.fa-line-chart:before{content:"\f201"}.fa.fa-lastfm,.fa.fa-lastfm-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-lastfm-square:before{content:"\f203"}.fa.fa-angellist,.fa.fa-ioxhost{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-cc{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-cc:before{content:"\f20a"}.fa.fa-ils:before,.fa.fa-shekel:before,.fa.fa-sheqel:before{content:"\f20b"}.fa.fa-buysellads,.fa.fa-connectdevelop,.fa.fa-dashcube,.fa.fa-forumbee,.fa.fa-leanpub,.fa.fa-sellsy,.fa.fa-shirtsinbulk,.fa.fa-simplybuilt,.fa.fa-skyatlas{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-diamond{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-diamond:before{content:"\f3a5"}.fa.fa-intersex:before,.fa.fa-transgender:before{content:"\f224"}.fa.fa-transgender-alt:before{content:"\f225"}.fa.fa-facebook-official{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-facebook-official:before{content:"\f09a"}.fa.fa-pinterest-p,.fa.fa-whatsapp{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-hotel:before{content:"\f236"}.fa.fa-medium,.fa.fa-viacoin,.fa.fa-y-combinator,.fa.fa-yc{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-yc:before{content:"\f23b"}.fa.fa-expeditedssl,.fa.fa-opencart,.fa.fa-optin-monster{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-battery-4:before,.fa.fa-battery:before{content:"\f240"}.fa.fa-battery-3:before{content:"\f241"}.fa.fa-battery-2:before{content:"\f242"}.fa.fa-battery-1:before{content:"\f243"}.fa.fa-battery-0:before{content:"\f244"}.fa.fa-object-group,.fa.fa-object-ungroup,.fa.fa-sticky-note-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-sticky-note-o:before{content:"\f249"}.fa.fa-cc-diners-club,.fa.fa-cc-jcb{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-clone{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hourglass-o:before{content:"\f254"}.fa.fa-hourglass-1:before{content:"\f251"}.fa.fa-hourglass-2:before{content:"\f252"}.fa.fa-hourglass-3:before{content:"\f253"}.fa.fa-hand-rock-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-rock-o:before{content:"\f255"}.fa.fa-hand-grab-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-grab-o:before{content:"\f255"}.fa.fa-hand-paper-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-paper-o:before{content:"\f256"}.fa.fa-hand-stop-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-stop-o:before{content:"\f256"}.fa.fa-hand-scissors-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-scissors-o:before{content:"\f257"}.fa.fa-hand-lizard-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-lizard-o:before{content:"\f258"}.fa.fa-hand-spock-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-spock-o:before{content:"\f259"}.fa.fa-hand-pointer-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-pointer-o:before{content:"\f25a"}.fa.fa-hand-peace-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-hand-peace-o:before{content:"\f25b"}.fa.fa-registered{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-creative-commons,.fa.fa-gg,.fa.fa-gg-circle,.fa.fa-odnoklassniki,.fa.fa-odnoklassniki-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-odnoklassniki-square:before{content:"\f264"}.fa.fa-chrome,.fa.fa-firefox,.fa.fa-get-pocket,.fa.fa-internet-explorer,.fa.fa-opera,.fa.fa-safari,.fa.fa-wikipedia-w{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-television:before{content:"\f26c"}.fa.fa-500px,.fa.fa-amazon,.fa.fa-contao{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-calendar-plus-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-calendar-plus-o:before{content:"\f271"}.fa.fa-calendar-minus-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-calendar-minus-o:before{content:"\f272"}.fa.fa-calendar-times-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-calendar-times-o:before{content:"\f273"}.fa.fa-calendar-check-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-calendar-check-o:before{content:"\f274"}.fa.fa-map-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-map-o:before{content:"\f279"}.fa.fa-commenting:before{content:"\f4ad"}.fa.fa-commenting-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-commenting-o:before{content:"\f4ad"}.fa.fa-houzz,.fa.fa-vimeo{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-vimeo:before{content:"\f27d"}.fa.fa-black-tie,.fa.fa-edge,.fa.fa-fonticons,.fa.fa-reddit-alien{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-credit-card-alt:before{content:"\f09d"}.fa.fa-codiepie,.fa.fa-fort-awesome,.fa.fa-mixcloud,.fa.fa-modx,.fa.fa-product-hunt,.fa.fa-scribd,.fa.fa-usb{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-pause-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-pause-circle-o:before{content:"\f28b"}.fa.fa-stop-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-stop-circle-o:before{content:"\f28d"}.fa.fa-bluetooth,.fa.fa-bluetooth-b,.fa.fa-envira,.fa.fa-gitlab,.fa.fa-wheelchair-alt,.fa.fa-wpbeginner,.fa.fa-wpforms{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-wheelchair-alt:before{content:"\f368"}.fa.fa-question-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-question-circle-o:before{content:"\f059"}.fa.fa-volume-control-phone:before{content:"\f2a0"}.fa.fa-asl-interpreting:before{content:"\f2a3"}.fa.fa-deafness:before,.fa.fa-hard-of-hearing:before{content:"\f2a4"}.fa.fa-glide,.fa.fa-glide-g{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-signing:before{content:"\f2a7"}.fa.fa-viadeo,.fa.fa-viadeo-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-viadeo-square:before{content:"\f2aa"}.fa.fa-snapchat,.fa.fa-snapchat-ghost{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-snapchat-ghost:before{content:"\f2ab"}.fa.fa-snapchat-square{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-snapchat-square:before{content:"\f2ad"}.fa.fa-first-order,.fa.fa-google-plus-official,.fa.fa-pied-piper,.fa.fa-themeisle,.fa.fa-yoast{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-google-plus-official:before{content:"\f2b3"}.fa.fa-google-plus-circle{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-google-plus-circle:before{content:"\f2b3"}.fa.fa-fa,.fa.fa-font-awesome{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-fa:before{content:"\f2b4"}.fa.fa-handshake-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-handshake-o:before{content:"\f2b5"}.fa.fa-envelope-open-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-envelope-open-o:before{content:"\f2b6"}.fa.fa-linode{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-address-book-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-address-book-o:before{content:"\f2b9"}.fa.fa-vcard:before{content:"\f2bb"}.fa.fa-address-card-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-address-card-o:before{content:"\f2bb"}.fa.fa-vcard-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-vcard-o:before{content:"\f2bb"}.fa.fa-user-circle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-user-circle-o:before{content:"\f2bd"}.fa.fa-user-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-user-o:before{content:"\f007"}.fa.fa-id-badge{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-drivers-license:before{content:"\f2c2"}.fa.fa-id-card-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-id-card-o:before{content:"\f2c2"}.fa.fa-drivers-license-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-drivers-license-o:before{content:"\f2c2"}.fa.fa-free-code-camp,.fa.fa-quora,.fa.fa-telegram{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-thermometer-4:before,.fa.fa-thermometer:before{content:"\f2c7"}.fa.fa-thermometer-3:before{content:"\f2c8"}.fa.fa-thermometer-2:before{content:"\f2c9"}.fa.fa-thermometer-1:before{content:"\f2ca"}.fa.fa-thermometer-0:before{content:"\f2cb"}.fa.fa-bathtub:before,.fa.fa-s15:before{content:"\f2cd"}.fa.fa-window-maximize,.fa.fa-window-restore{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-times-rectangle:before{content:"\f410"}.fa.fa-window-close-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-window-close-o:before{content:"\f410"}.fa.fa-times-rectangle-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-times-rectangle-o:before{content:"\f410"}.fa.fa-bandcamp,.fa.fa-eercast,.fa.fa-etsy,.fa.fa-grav,.fa.fa-imdb,.fa.fa-ravelry{font-family:"Font Awesome 6 Brands";font-weight:400}.fa.fa-eercast:before{content:"\f2da"}.fa.fa-snowflake-o{font-family:"Font Awesome 6 Free";font-weight:400}.fa.fa-snowflake-o:before{content:"\f2dc"}.fa.fa-meetup,.fa.fa-superpowers,.fa.fa-wpexplorer{font-family:"Font Awesome 6 Brands";font-weight:400} \ No newline at end of file diff --git a/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf b/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf new file mode 100644 index 00000000..1fbb1f7c Binary files /dev/null and b/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf differ diff --git a/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 b/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 new file mode 100644 index 00000000..5d280216 Binary files /dev/null and b/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 differ diff --git a/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf b/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf new file mode 100644 index 00000000..549d68dc Binary files /dev/null and b/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf differ diff --git a/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 b/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 new file mode 100644 index 00000000..18400d7f Binary files /dev/null and b/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 differ diff --git a/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf b/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf new file mode 100644 index 00000000..bb2a8695 Binary files /dev/null and b/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf differ diff --git a/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 b/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 new file mode 100644 index 00000000..758dd4f6 Binary files /dev/null and b/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 differ diff --git a/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf b/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf new file mode 100644 index 00000000..8c5864c4 Binary files /dev/null and b/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf differ diff --git a/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 b/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 new file mode 100644 index 00000000..f94bec22 Binary files /dev/null and b/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 differ diff --git a/docs/index.html b/docs/index.html index 0d5e2a7f..44832322 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,16 +6,15 @@ mapgl: WebGL Maps in R with Mapbox and MapLibre • mapgl - - - - - - + + + + + - - + + @@ -29,7 +28,7 @@ mapgl - 0.1.4 + 0.2.2.9000 @@ -79,6 +82,7 @@
  • Using layers: an overview

  • Fundamentals of map design with mapgl

  • Using mapgl with Shiny

  • +
  • Building story maps with mapgl

  • Links

    @@ -122,7 +128,7 @@

    Citation

    Developers

    @@ -137,7 +143,7 @@

    Developers

    diff --git a/docs/news/index.html b/docs/news/index.html index d647dff2..a5342db8 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -1,5 +1,5 @@ -Changelog • mapgl +Changelog • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,9 +37,55 @@
    +
    +

    mapgl (development version)

    +
    • Enhanced draw control functionality with improved feature editing capabilities: +
      • Added ability to load existing features from map sources into the draw control for editing either when initializing the draw control or via add_features_to_draw() +
      • +
      • Fixed vertex styling to properly highlight selected vertices during editing
      • +
      • Extended draw control support to compare views, enabling feature editing in side-by-side map comparisons
      • +
      • Improved compatibility with both Mapbox GL JS and MapLibre GL JS
      • +
    • +
    • Fixed hover_options for vector tile sources in MapLibre (#67): +
      • Added proper source layer handling for vector tiles when using hover effects
      • +
      • Now works correctly with PMTiles and other vector tile sources that include feature IDs
      • +
      • Note: Vector tiles must include feature IDs for hover effects to work. GeoJSON sources automatically generate IDs.
      • +
    • +
    • Enhanced tooltip functionality with expression support: +
      • Tooltips can now use expressions for dynamic content generation
      • +
      • Use get_column() to reference feature properties in tooltips
      • +
      • Added concat() helper function for combining strings and expressions
      • +
      • Example: tooltip = concat("<strong>Name:</strong> ", get_column("name"), "<br>Value: ", get_column("value")) +
      • +
      • Works with both regular tooltips and set_tooltip() in Shiny applications
      • +
    • +
    +
    +

    mapgl 0.2.2

    CRAN release: 2025-05-23

    +
    • Added mapboxgl_view() and maplibre_view() functions for quick visualization of sf objects with automatic geometry detection and column-based styling (#102).
    • +
    • Added support for rain and snow effects on Mapbox GL maps with set_rain() and set_snow() functions.
    • +
    • Added add_globe_control() for MapLibre maps, allowing users to toggle between “mercator” and “globe” projections.
    • +
    • Fixed issue with set_style() in Shiny applications for both Mapbox and MapLibre maps (#99).
    • +
    • Fixed namespacing issue in get_drawn_features() for Shiny modules (#95).
    • +
    • Improved compare functionality with better control support and swiper color customization.
    • +
    +
    +

    mapgl 0.2.1

    CRAN release: 2025-03-18

    +
    • Improved styling and positioning behavior of the layers control. Users can now customize the appearance of the layers control, and the layers control is collapsed by default with cleaner appearance. Added ability to link legends to specific layers with the new layer_id parameter in add_legend(). When a layer is toggled in the layers control, its associated legend will automatically show or hide.
    • +
    • Added support for custom legend positioning with new margin parameters (margin_top, margin_right, margin_bottom, margin_left) that allow fine-grained control over legend placement.
    • +
    • Fixed layers control toggle button state to correctly reflect the initial visibility of layers, resolving the issue with layers set to visibility = "none" showing as active in the control.
    • +
    • Support for the compare() plugin in Shiny applications, with new rendering and proxy functions for comparison apps in Mapbox and MapLibre.
    • +
    • New mode parameter in compare() allowing users to choose between "swipe" mode with a comparison slider, and "sync" mode which displays synchronized maps side-by-side.
    • +
    • Updates throughout the codebase to allow features to be used in comparison maps via Shiny proxy sessions.
    • +
    +
    +

    mapgl 0.2.0

    CRAN release: 2025-01-13

    +

    mapgl 0.1.4

    CRAN release: 2024-11-01

    diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 9757bf9e..1a99c65f 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -152,3 +152,11 @@ async function searchFuse(query, callback) { }); }); })(window.jQuery || window.$) + +document.addEventListener('keydown', function(event) { + // Check if the pressed key is '/' + if (event.key === '/') { + event.preventDefault(); // Prevent any default action associated with the '/' key + document.getElementById('search-input').focus(); // Set focus to the search input + } +}); diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 80122ff9..6d3aced7 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,12 +1,13 @@ -pandoc: '3.2' -pkgdown: 2.0.9.9000 -pkgdown_sha: 5c1d34d1950ff53d20a9a1d590a04c160bdb2099 +pandoc: '3.4' +pkgdown: 2.1.3.9000 +pkgdown_sha: f950aed41af49c732ba7884d0806c3641a7b94b3 articles: getting-started: getting-started.html layers-overview: layers-overview.html map-design: map-design.html shiny: shiny.html -last_built: 2024-11-01T15:13Z + story-maps: story-maps.html +last_built: 2025-06-07T21:18Z urls: reference: https://walker-data.com/mapgl/reference article: https://walker-data.com/mapgl/articles diff --git a/docs/reference/add_categorical_legend.html b/docs/reference/add_categorical_legend.html index 65517761..b4924b91 100644 --- a/docs/reference/add_categorical_legend.html +++ b/docs/reference/add_categorical_legend.html @@ -1,5 +1,5 @@ -Add a categorical legend to a Mapbox GL map — add_categorical_legend • mapglAdd a categorical legend to a Mapbox GL map — add_categorical_legend • mapgl Skip to contents @@ -9,7 +9,7 @@ mapgl - 0.1.4 + 0.2.2.9000 -
    @@ -36,7 +39,7 @@ @@ -104,6 +112,26 @@

    Argumentswidth

    The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default.

    + +
    layer_id
    +

    The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled.

    + + +
    margin_top
    +

    Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning).

    + + +
    margin_right
    +

    Custom right margin in pixels. Default is NULL.

    + + +
    margin_bottom
    +

    Custom bottom margin in pixels. Default is NULL.

    + + +
    margin_left
    +

    Custom left margin in pixels. Default is NULL.

    +

    Value

    @@ -138,7 +166,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_circle_layer.html b/docs/reference/add_circle_layer.html index cba94e1a..e0120563 100644 --- a/docs/reference/add_circle_layer.html +++ b/docs/reference/add_circle_layer.html @@ -1,5 +1,5 @@ -Add a circle layer to a Mapbox GL map — add_circle_layer • mapgl +Add a circle layer to a Mapbox GL map — add_circle_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -188,18 +191,18 @@

    Examplesset.seed(1234) # Define the bounding box for Washington DC (approximately) -bbox <- st_bbox( +bbox <- st_bbox( c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), - crs = st_crs(4326) + crs = st_crs(4326) ) # Generate 30 random points within the bounding box -random_points <- st_as_sf( +random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox["xmin"], bbox["xmax"]), @@ -259,7 +262,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_continuous_legend.html b/docs/reference/add_continuous_legend.html index be1d1488..ea9abf5a 100644 --- a/docs/reference/add_continuous_legend.html +++ b/docs/reference/add_continuous_legend.html @@ -1,5 +1,5 @@ -Add a continuous legend — add_continuous_legend • mapgl +Add a continuous legend — add_continuous_legend • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@ @@ -91,6 +99,26 @@

    Argumentswidth

    The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default.

    + +
    layer_id
    +

    The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled.

    + + +
    margin_top
    +

    Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning).

    + + +
    margin_right
    +

    Custom right margin in pixels. Default is NULL.

    + + +
    margin_bottom
    +

    Custom bottom margin in pixels. Default is NULL.

    + + +
    margin_left
    +

    Custom left margin in pixels. Default is NULL.

    +

    Value

    @@ -106,7 +134,7 @@

    Value

    diff --git a/docs/reference/add_control.html b/docs/reference/add_control.html new file mode 100644 index 00000000..39bc6170 --- /dev/null +++ b/docs/reference/add_control.html @@ -0,0 +1,121 @@ + +Add a custom control to a map — add_control • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function adds a custom control to a Mapbox GL or MapLibre GL map. +It allows you to create custom HTML element controls and add them to the map.

    +
    + +
    +

    Usage

    +
    add_control(map, html, position = "top-right", className = NULL, ...)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by the mapboxgl or maplibre functions.

    + + +
    html
    +

    Character string containing the HTML content for the control.

    + + +
    position
    +

    The position of the control. Can be one of "top-left", "top-right", +"bottom-left", or "bottom-right". Default is "top-right".

    + + +
    className
    +

    Optional CSS class name for the control container.

    + + +
    ...
    +

    Additional arguments passed to the JavaScript side.

    + +
    +
    +

    Value

    +

    The modified map object with the custom control added.

    +
    + +
    +

    Examples

    +
    if (FALSE) { # \dontrun{
    +library(mapgl)
    +
    +maplibre() |>
    +  add_control(
    +    html = "<div style='background-color: white; padding: 5px;'>
    +             <p>Custom HTML</p>
    +             <img src='path/to/image.png' alt='image'/>
    +            </div>",
    +    position = "top-left"
    +  )
    +} # }
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/add_draw_control.html b/docs/reference/add_draw_control.html index 2d504304..32bb995d 100644 --- a/docs/reference/add_draw_control.html +++ b/docs/reference/add_draw_control.html @@ -1,5 +1,5 @@ -Add a draw control to a map — add_draw_control • mapgl +Add a draw control to a map — add_draw_control • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@ @@ -80,6 +91,39 @@

    Arguments +
    source
    +

    A character string specifying a source ID to add to the draw control. +Default is NULL.

    + + +
    point_color
    +

    Color for point features. Default is "#3bb2d0" (light blue).

    + + +
    line_color
    +

    Color for line features. Default is "#3bb2d0" (light blue).

    + + +
    fill_color
    +

    Fill color for polygon features. Default is "#3bb2d0" (light blue).

    + + +
    fill_opacity
    +

    Fill opacity for polygon features. Default is 0.1.

    + + +
    active_color
    +

    Color for active (selected) features. Default is "#fbb03b" (orange).

    + + +
    vertex_radius
    +

    Radius of vertex points in pixels. Default is 5.

    + + +
    line_width
    +

    Width of lines in pixels. Default is 2.

    + +
    ...

    Additional named arguments. See https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md#options for a list of options.

    @@ -100,6 +144,25 @@

    Examples zoom = 9 ) |> add_draw_control() + +# With initial features from a source +library(tigris) +tx <- counties(state = "TX", cb = TRUE) +mapboxgl(bounds = tx) |> + add_source(id = "tx", data = tx) |> + add_draw_control(source = "tx") + +# With custom styling +mapboxgl() |> + add_draw_control( + point_color = "#ff0000", + line_color = "#00ff00", + fill_color = "#0000ff", + fill_opacity = 0.3, + active_color = "#ff00ff", + vertex_radius = 7, + line_width = 3 + ) } # } @@ -112,7 +175,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_features_to_draw.html b/docs/reference/add_features_to_draw.html new file mode 100644 index 00000000..82b242b1 --- /dev/null +++ b/docs/reference/add_features_to_draw.html @@ -0,0 +1,117 @@ + +Add features to an existing draw control — add_features_to_draw • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function adds features from an existing source to a draw control on a map.

    +
    + +
    +

    Usage

    +
    add_features_to_draw(map, source, clear_existing = FALSE)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object with a draw control already added

    + + +
    source
    +

    Character string specifying a source ID to get features from

    + + +
    clear_existing
    +

    Logical, whether to clear existing drawn features before adding new ones. Default is FALSE.

    + +
    +
    +

    Value

    +

    The modified map object

    +
    + +
    +

    Examples

    +
    if (FALSE) { # \dontrun{
    +library(mapgl)
    +library(tigris)
    +
    +# Add features from an existing source
    +tx <- counties(state = "TX", cb = TRUE)
    +mapboxgl(bounds = tx) |>
    +  add_source(id = "tx", data = tx) |>
    +  add_draw_control() |>
    +  add_features_to_draw(source = "tx")
    +  
    +# In a Shiny app
    +observeEvent(input$load_data, {
    +  mapboxgl_proxy("map") |>
    +    add_features_to_draw(
    +      source = "dynamic_data",
    +      clear_existing = TRUE
    +    )
    +})
    +} # }
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/add_fill_extrusion_layer.html b/docs/reference/add_fill_extrusion_layer.html index d1240f21..3113e3b2 100644 --- a/docs/reference/add_fill_extrusion_layer.html +++ b/docs/reference/add_fill_extrusion_layer.html @@ -1,5 +1,5 @@ -Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer • mapgl +Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -207,7 +210,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_fill_layer.html b/docs/reference/add_fill_layer.html index b90fd5ca..dce2f4b4 100644 --- a/docs/reference/add_fill_layer.html +++ b/docs/reference/add_fill_layer.html @@ -1,5 +1,5 @@ -Add a fill layer to a map — add_fill_layer • mapgl +Add a fill layer to a map — add_fill_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -210,7 +213,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_fullscreen_control.html b/docs/reference/add_fullscreen_control.html index 713061f1..c5032487 100644 --- a/docs/reference/add_fullscreen_control.html +++ b/docs/reference/add_fullscreen_control.html @@ -1,5 +1,5 @@ -Add a fullscreen control to a map — add_fullscreen_control • mapgl +Add a fullscreen control to a map — add_fullscreen_control • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -88,7 +91,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_geocoder_control.html b/docs/reference/add_geocoder_control.html index 52668cfb..07da2fec 100644 --- a/docs/reference/add_geocoder_control.html +++ b/docs/reference/add_geocoder_control.html @@ -1,5 +1,5 @@ -Add a geocoder control to a map — add_geocoder_control • mapglAdd a geocoder control to a map — add_geocoder_control • mapglmapgl - 0.1.4 + 0.2.2.9000 - @@ -40,7 +43,7 @@
    @@ -113,7 +116,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_geolocate_control.html b/docs/reference/add_geolocate_control.html index 94cd3935..d0bd888a 100644 --- a/docs/reference/add_geolocate_control.html +++ b/docs/reference/add_geolocate_control.html @@ -1,5 +1,5 @@ -Add a geolocate control to a map — add_geolocate_control • mapglAdd a geolocate control to a map — add_geolocate_control • mapgl Skip to contents @@ -9,7 +9,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -36,7 +39,7 @@
    @@ -129,7 +132,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_globe_control.html b/docs/reference/add_globe_control.html new file mode 100644 index 00000000..863aa505 --- /dev/null +++ b/docs/reference/add_globe_control.html @@ -0,0 +1,103 @@ + +Add a globe control to a map — add_globe_control • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function adds a globe control to a MapLibre GL map that allows toggling +between "mercator" and "globe" projections with a single click.

    +
    + +
    +

    Usage

    +
    add_globe_control(map, position = "top-right")
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by the maplibre function.

    + + +
    position
    +

    The position of the control. Can be one of "top-left", "top-right", +"bottom-left", or "bottom-right". Default is "top-right".

    + +
    +
    +

    Value

    +

    The modified map object with the globe control added.

    +
    + +
    +

    Examples

    +
    if (FALSE) { # \dontrun{
    +library(mapgl)
    +
    +maplibre() |>
    +    add_globe_control(position = "top-right")
    +} # }
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/add_globe_minimap.html b/docs/reference/add_globe_minimap.html index 52c6a16f..ee97fd6d 100644 --- a/docs/reference/add_globe_minimap.html +++ b/docs/reference/add_globe_minimap.html @@ -1,5 +1,5 @@ -Add a Globe Minimap to a map — add_globe_minimap • mapgl +Add a Globe Minimap to a map — add_globe_minimap • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -114,7 +117,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_h3j_source.html b/docs/reference/add_h3j_source.html new file mode 100644 index 00000000..4e89157c --- /dev/null +++ b/docs/reference/add_h3j_source.html @@ -0,0 +1,123 @@ + +Add a hexagon source from the H3 geospatial indexing system. — add_h3j_source • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Add a hexagon source from the H3 geospatial indexing system.

    +
    + +
    +

    Usage

    +
    add_h3j_source(map, id, url)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by the mapboxgl or maplibre function.

    + + +
    id
    +

    A unique ID for the source.

    + + +
    url
    +

    A URL pointing to the vector tile source.

    + +
    +
    +

    References

    +

    https://h3geo.org, https://github.com/INSPIDE/h3j-h3t

    +
    + +
    +

    Examples

    +
    if (FALSE) { # interactive()
    +url = "https://inspide.github.io/h3j-h3t/examples/h3j/sample.h3j"
    +maplibre(center=c(-3.704, 40.417), zoom=15, pitch=30) |>
    +  add_h3j_source("h3j_testsource",
    +                  url = url
    +  )  |>
    +  add_fill_extrusion_layer(
    +    id = "h3j_testlayer",
    +    source = "h3j_testsource",
    +    fill_extrusion_color = interpolate(
    +      column = "value",
    +      values = c(0, 21.864),
    +      stops = c("#430254", "#f83c70")
    +    ),
    +    fill_extrusion_height = list(
    +      "interpolate",
    +      list("linear"),
    +      list("zoom"),
    +      14,
    +      0,
    +      15.05,
    +      list("*", 10, list("get", "value"))
    +    ),
    +    fill_extrusion_opacity = 0.7
    +  )
    +}
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/add_heatmap_layer.html b/docs/reference/add_heatmap_layer.html index 5f7f14f4..86977bd2 100644 --- a/docs/reference/add_heatmap_layer.html +++ b/docs/reference/add_heatmap_layer.html @@ -1,5 +1,5 @@ -Add a heatmap layer to a Mapbox GL map — add_heatmap_layer • mapgl +Add a heatmap layer to a Mapbox GL map — add_heatmap_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -181,7 +184,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_image.html b/docs/reference/add_image.html index 3f69effa..95632aa3 100644 --- a/docs/reference/add_image.html +++ b/docs/reference/add_image.html @@ -1,5 +1,5 @@ -Add an image to the map — add_image • mapglAdd an image to the map — add_image • mapgl Skip to contents @@ -9,7 +9,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -36,7 +39,7 @@
    @@ -134,7 +137,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_image_source.html b/docs/reference/add_image_source.html index 36773f07..98236dd4 100644 --- a/docs/reference/add_image_source.html +++ b/docs/reference/add_image_source.html @@ -1,5 +1,5 @@ -Add an image source to a Mapbox GL or Maplibre GL map — add_image_source • mapgl +Add an image source to a Mapbox GL or Maplibre GL map — add_image_source • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -96,7 +99,7 @@

    Value

    diff --git a/docs/reference/add_layer.html b/docs/reference/add_layer.html index 17fd2195..9a4ff1bd 100644 --- a/docs/reference/add_layer.html +++ b/docs/reference/add_layer.html @@ -1,5 +1,5 @@ -Add a layer to a map from a source — add_layer • mapgl +Add a layer to a map from a source — add_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -176,7 +179,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_layers_control.html b/docs/reference/add_layers_control.html index 95384fbb..2050ebc4 100644 --- a/docs/reference/add_layers_control.html +++ b/docs/reference/add_layers_control.html @@ -1,5 +1,5 @@ -Add a layers control to the map — add_layers_control • mapgl +Add a layers control to the map — add_layers_control • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@ @@ -71,6 +80,31 @@

    Argumentscollapsible

    Whether the control should be collapsible.

    + +
    use_icon
    +

    Whether to use a stacked layers icon instead of the "Layers" text when collapsed. Only applies when collapsible = TRUE.

    + + +
    background_color
    +

    The background color for the layers control; this will be the +color used for inactive layer items.

    + + +
    active_color
    +

    The background color for active layer items.

    + + +
    hover_color
    +

    The background color for layer items when hovered.

    + + +
    active_text_color
    +

    The text color for active layer items.

    + + +
    inactive_text_color
    +

    The text color for inactive layer items.

    + @@ -112,7 +150,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_legend.html b/docs/reference/add_legend.html index cc92fd0e..96353a01 100644 --- a/docs/reference/add_legend.html +++ b/docs/reference/add_legend.html @@ -1,5 +1,5 @@ -Add a legend to a Mapbox GL map — add_legend • mapgl +Add a legend to a Mapbox GL map — add_legend • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@ @@ -98,9 +107,33 @@

    Argumentsunique_id +

    Optional. A unique identifier for the legend. If not provided, a random ID will be generated.

    + +
    width

    The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default.

    + +
    layer_id
    +

    The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled.

    + + +
    margin_top
    +

    Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning).

    + + +
    margin_right
    +

    Custom right margin in pixels. Default is NULL.

    + + +
    margin_bottom
    +

    Custom bottom margin in pixels. Default is NULL.

    + + +
    margin_left
    +

    Custom left margin in pixels. Default is NULL.

    +

    Value

    @@ -116,7 +149,7 @@

    Value

    diff --git a/docs/reference/add_line_layer.html b/docs/reference/add_line_layer.html index 64d64649..6db297c8 100644 --- a/docs/reference/add_line_layer.html +++ b/docs/reference/add_line_layer.html @@ -1,5 +1,5 @@ -Add a line layer to a map — add_line_layer • mapgl +Add a line layer to a map — add_line_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -275,7 +278,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_markers.html b/docs/reference/add_markers.html index 97063ab6..3591c57b 100644 --- a/docs/reference/add_markers.html +++ b/docs/reference/add_markers.html @@ -1,5 +1,5 @@ -Add markers to a Mapbox GL or Maplibre GL map — add_markers • mapgl +Add markers to a Mapbox GL or Maplibre GL map — add_markers • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -133,7 +136,7 @@

    Examples) # Create an sf POINT object -points_sf <- st_as_sf(data.frame( +points_sf <- st_as_sf(data.frame( id = c("marker4", "marker5"), lon = c(-74.006, -73.935242), lat = c(40.7128, 40.730610) @@ -161,7 +164,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_navigation_control.html b/docs/reference/add_navigation_control.html index 20004ff2..1fe52fc9 100644 --- a/docs/reference/add_navigation_control.html +++ b/docs/reference/add_navigation_control.html @@ -1,5 +1,5 @@ -Add a navigation control to a map — add_navigation_control • mapgl +Add a navigation control to a map — add_navigation_control • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -106,7 +109,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_raster_dem_source.html b/docs/reference/add_raster_dem_source.html index 29bd1be0..07bf2315 100644 --- a/docs/reference/add_raster_dem_source.html +++ b/docs/reference/add_raster_dem_source.html @@ -1,5 +1,5 @@ -Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source • mapgl +Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -85,7 +88,7 @@

    Value

    diff --git a/docs/reference/add_raster_layer.html b/docs/reference/add_raster_layer.html index 85138cca..5d1dbc6e 100644 --- a/docs/reference/add_raster_layer.html +++ b/docs/reference/add_raster_layer.html @@ -1,5 +1,5 @@ -Add a raster layer to a Mapbox GL map — add_raster_layer • mapgl +Add a raster layer to a Mapbox GL map — add_raster_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -177,7 +180,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_raster_source.html b/docs/reference/add_raster_source.html index 68ea9a30..fe081c3a 100644 --- a/docs/reference/add_raster_source.html +++ b/docs/reference/add_raster_source.html @@ -1,5 +1,5 @@ -Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source • mapgl +Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -96,7 +99,7 @@

    Value

    diff --git a/docs/reference/add_reset_control.html b/docs/reference/add_reset_control.html index b9fa9331..21a2501a 100644 --- a/docs/reference/add_reset_control.html +++ b/docs/reference/add_reset_control.html @@ -1,5 +1,5 @@ -Add a reset control to a map — add_reset_control • mapglAdd a reset control to a map — add_reset_control • mapgl Skip to contents @@ -9,7 +9,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -36,7 +39,7 @@
    @@ -94,7 +97,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_scale_control.html b/docs/reference/add_scale_control.html index ac7aa407..3a5a12d2 100644 --- a/docs/reference/add_scale_control.html +++ b/docs/reference/add_scale_control.html @@ -1,5 +1,5 @@ -Add a scale control to a map — add_scale_control • mapgl +Add a scale control to a map — add_scale_control • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -96,7 +99,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_source.html b/docs/reference/add_source.html index c1b49e44..59f95075 100644 --- a/docs/reference/add_source.html +++ b/docs/reference/add_source.html @@ -1,5 +1,5 @@ -Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source • mapgl +Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/add_symbol_layer.html b/docs/reference/add_symbol_layer.html index 83ce5581..71c00c0d 100644 --- a/docs/reference/add_symbol_layer.html +++ b/docs/reference/add_symbol_layer.html @@ -1,5 +1,5 @@ -Add a symbol layer to a map — add_symbol_layer • mapgl +Add a symbol layer to a map — add_symbol_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,6 +84,7 @@

    Usage symbol_sort_key = NULL, symbol_spacing = NULL, symbol_z_elevate = NULL, + symbol_z_offset = NULL, symbol_z_order = NULL, text_allow_overlap = NULL, text_anchor = NULL, @@ -275,7 +279,12 @@

    Argumentssymbol_z_elevate -

    Elevates the symbol z-axis.

    +

    If TRUE, positions the symbol on top of a fill-extrusion layer. +Requires symbol_placement to be set to "point" and symbol-z-order to be set to "auto".

    + + +
    symbol_z_offset
    +

    The elevation of the symbol, in meters. Use get_column() to get elevations from a column in the dataset.

    symbol_z_order
    @@ -458,18 +467,18 @@

    Examplesset.seed(1234) # Define the bounding box for Washington DC (approximately) -bbox <- st_bbox( +bbox <- st_bbox( c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), - crs = st_crs(4326) + crs = st_crs(4326) ) # Generate 30 random points within the bounding box -random_points <- st_as_sf( +random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox["xmin"], bbox["xmax"]), @@ -506,7 +515,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/add_vector_source.html b/docs/reference/add_vector_source.html index 652f878a..7a397dc4 100644 --- a/docs/reference/add_vector_source.html +++ b/docs/reference/add_vector_source.html @@ -1,5 +1,5 @@ -Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source • mapgl +Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -77,7 +80,7 @@

    Value

    diff --git a/docs/reference/add_video_source.html b/docs/reference/add_video_source.html index 30e9bfcb..8f15e0df 100644 --- a/docs/reference/add_video_source.html +++ b/docs/reference/add_video_source.html @@ -1,5 +1,5 @@ -Add a video source to a Mapbox GL or Maplibre GL map — add_video_source • mapgl +Add a video source to a Mapbox GL or Maplibre GL map — add_video_source • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/carto_style.html b/docs/reference/carto_style.html index 1a427771..7dd719c1 100644 --- a/docs/reference/carto_style.html +++ b/docs/reference/carto_style.html @@ -1,5 +1,5 @@ -Get CARTO Style URL — carto_style • mapgl +Get CARTO Style URL — carto_style • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -69,7 +72,7 @@

    Value

    diff --git a/docs/reference/clear_controls.html b/docs/reference/clear_controls.html index 0ac2ae70..325e690c 100644 --- a/docs/reference/clear_controls.html +++ b/docs/reference/clear_controls.html @@ -1,5 +1,5 @@ -Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls • mapgl +Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -69,7 +72,7 @@

    Value

    diff --git a/docs/reference/clear_layer.html b/docs/reference/clear_layer.html index f5567e0c..d06633fb 100644 --- a/docs/reference/clear_layer.html +++ b/docs/reference/clear_layer.html @@ -1,5 +1,5 @@ -Clear a layer from a map using a proxy — clear_layer • mapgl +Clear a layer from a map using a proxy — clear_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -73,7 +76,7 @@

    Value

    diff --git a/docs/reference/clear_legend.html b/docs/reference/clear_legend.html index 186ccfd9..0f72db78 100644 --- a/docs/reference/clear_legend.html +++ b/docs/reference/clear_legend.html @@ -1,5 +1,5 @@ -Clear legend from a map in a proxy session — clear_legend • mapgl +Clear legend(s) from a map in a proxy session — clear_legend • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -33,18 +36,18 @@
    -

    Clear legend from a map in a proxy session

    +

    Clear legend(s) from a map in a proxy session

    Usage

    -
    clear_legend(map)
    +
    clear_legend(map, legend_ids = NULL)
    @@ -54,10 +57,14 @@

    Argumentsmap

    A map object created by the mapboxgl_proxy or maplibre_proxy function.

    + +
    legend_ids
    +

    Optional. A character vector of legend IDs to clear. If not provided, all legends will be cleared.

    +

    Value

    -

    The updated map object with the legend cleared.

    +

    The updated map object with the specified legend(s) cleared.

    diff --git a/docs/reference/clear_markers.html b/docs/reference/clear_markers.html index e5c33339..0c91511a 100644 --- a/docs/reference/clear_markers.html +++ b/docs/reference/clear_markers.html @@ -1,5 +1,5 @@ -Clear markers from a map in a Shiny session — clear_markers • mapgl +Clear markers from a map in a Shiny session — clear_markers • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 -
    @@ -34,7 +37,7 @@
    @@ -69,7 +72,7 @@

    Value

    diff --git a/docs/reference/cluster_options.html b/docs/reference/cluster_options.html index 52986afd..c75041a7 100644 --- a/docs/reference/cluster_options.html +++ b/docs/reference/cluster_options.html @@ -1,5 +1,5 @@ -Prepare cluster options for circle layers — cluster_options • mapgl +Prepare cluster options for circle layers — cluster_options • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -169,7 +172,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/compare.html b/docs/reference/compare.html index 881f4768..6e4a3da0 100644 --- a/docs/reference/compare.html +++ b/docs/reference/compare.html @@ -1,5 +1,5 @@ -Create a Compare slider widget — compare • mapgl +Create a Compare widget — compare • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -33,13 +36,13 @@
    -

    This function creates a comparison view between two Mapbox GL or Maplibre GL maps, allowing users to swipe between the two maps to compare different styles or data layers.

    +

    This function creates a comparison view between two Mapbox GL or Maplibre GL maps, allowing users to either swipe between the two maps or view them side-by-side with synchronized navigation.

    @@ -80,30 +85,109 @@

    Argumentsmousemove -

    A logical value indicating whether to enable swiping during cursor movement (rather than only when clicked).

    +

    A logical value indicating whether to enable swiping during cursor movement (rather than only when clicked). Only applicable when mode="swipe".

    orientation
    -

    A string specifying the orientation of the swiper, either "horizontal" or "vertical".

    +

    A string specifying the orientation of the swiper or the side-by-side layout, either "horizontal" or "vertical".

    + + +
    mode
    +

    A string specifying the comparison mode: "swipe" (default) for a swipeable comparison with a slider, or "sync" for synchronized maps displayed next to each other.

    + + +
    swiper_color
    +

    An optional CSS color value (e.g., "#000000", "rgb(0,0,0)", "black") to customize the color of the swiper handle. Only applicable when mode="swipe".

    Value

    A comparison widget.

    +
    +

    Details

    + +
    +

    Comparison modes

    + + +

    The compare() function supports two modes:

    • mode="swipe" (default) - Creates a swipeable interface with a slider to reveal portions of each map

    • +
    • mode="sync" - Places the maps next to each other with synchronized navigation

    • +

    In both modes, navigation (panning, zooming, rotating, tilting) is synchronized between the maps.

    +
    + +
    +

    Using the compare widget in Shiny

    + + +

    The compare widget can be used in Shiny applications with the following functions:

    After creating a compare widget in a Shiny app, you can use the proxy functions to update either the "before" +(left/top) or "after" (right/bottom) map. The proxy objects work with all the regular map update functions like set_style(), +set_paint_property(), etc.

    +

    To get a proxy that targets a specific map in the comparison:

    +

    # Access the left/top map
    +left_proxy <- maplibre_compare_proxy("compare_id", map_side = "before")
    +
    +# Access the right/bottom map
    +right_proxy <- maplibre_compare_proxy("compare_id", map_side = "after")

    +

    The compare widget also provides Shiny input values for view state and clicks. For a compare widget with ID "mycompare", you'll have:

    • input$mycompare_before_view - View state (center, zoom, bearing, pitch) of the left/top map

    • +
    • input$mycompare_after_view - View state of the right/bottom map

    • +
    • input$mycompare_before_click - Click events on the left/top map

    • +
    • input$mycompare_after_click - Click events on the right/bottom map

    • +
    + +

    Examples

    if (FALSE) { # \dontrun{
     library(mapgl)
     
    -library(mapgl)
    -
     m1 <- mapboxgl(style = mapbox_style("light"))
    -
     m2 <- mapboxgl(style = mapbox_style("dark"))
     
    +# Default swipe mode
     compare(m1, m2)
    +
    +# Synchronized side-by-side mode
    +compare(m1, m2, mode = "sync")
    +
    +# Custom swiper color
    +compare(m1, m2, swiper_color = "#FF0000")  # Red swiper
    +
    +# Shiny example
    +library(shiny)
    +
    +ui <- fluidPage(
    +  maplibreCompareOutput("comparison")
    +)
    +
    +server <- function(input, output, session) {
    +  output$comparison <- renderMaplibreCompare({
    +    compare(
    +      maplibre(style = carto_style("positron")),
    +      maplibre(style = carto_style("dark-matter")),
    +      mode = "sync"
    +    )
    +  })
    +
    +# Update the right map
    +  observe({
    +    right_proxy <- maplibre_compare_proxy("comparison", map_side = "after")
    +    set_style(right_proxy, carto_style("voyager"))
    +  })
    +  
    +  # Example with custom swiper color
    +  output$comparison2 <- renderMaplibreCompare({
    +    compare(
    +      maplibre(style = carto_style("positron")),
    +      maplibre(style = carto_style("dark-matter")),
    +      swiper_color = "#3498db"  # Blue swiper
    +    )
    +  })
    +}
     } # }
     
    @@ -116,7 +200,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/concat.html b/docs/reference/concat.html new file mode 100644 index 00000000..b05a5c5b --- /dev/null +++ b/docs/reference/concat.html @@ -0,0 +1,119 @@ + +Create a concatenation expression — concat • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function creates a concatenation expression that combines multiple values or expressions into a single string. +Useful for creating dynamic tooltips or labels.

    +
    + +
    +

    Usage

    +
    concat(...)
    +
    + +
    +

    Arguments

    + + +
    ...
    +

    Values or expressions to concatenate. Can be strings, numbers, or other expressions like get_column().

    + +
    +
    +

    Value

    +

    A list representing the concatenation expression.

    +
    + +
    +

    Examples

    +
    # Create a dynamic tooltip
    +concat("<strong>Name:</strong> ", get_column("name"), "<br>Value: ", get_column("value"))
    +#> [[1]]
    +#> [1] "concat"
    +#> 
    +#> [[2]]
    +#> [1] "<strong>Name:</strong> "
    +#> 
    +#> [[3]]
    +#> [[3]][[1]]
    +#> [1] "get"
    +#> 
    +#> [[3]][[2]]
    +#> [1] "name"
    +#> 
    +#> 
    +#> [[4]]
    +#> [1] "<br>Value: "
    +#> 
    +#> [[5]]
    +#> [[5]][[1]]
    +#> [1] "get"
    +#> 
    +#> [[5]][[2]]
    +#> [1] "value"
    +#> 
    +#> 
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/ease_to.html b/docs/reference/ease_to.html index 98e93532..484aef84 100644 --- a/docs/reference/ease_to.html +++ b/docs/reference/ease_to.html @@ -1,5 +1,5 @@ -Ease to a given view — ease_to • mapgl +Ease to a given view — ease_to • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/fit_bounds.html b/docs/reference/fit_bounds.html index 2c83487d..ac099021 100644 --- a/docs/reference/fit_bounds.html +++ b/docs/reference/fit_bounds.html @@ -1,5 +1,5 @@ -Fit the map to a bounding box — fit_bounds • mapgl +Fit the map to a bounding box — fit_bounds • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/fly_to.html b/docs/reference/fly_to.html index 79d459fe..5ee81f3f 100644 --- a/docs/reference/fly_to.html +++ b/docs/reference/fly_to.html @@ -1,5 +1,5 @@ -Fly to a given view — fly_to • mapgl +Fly to a given view — fly_to • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/get_column.html b/docs/reference/get_column.html index e41e04b6..ed7aa2f5 100644 --- a/docs/reference/get_column.html +++ b/docs/reference/get_column.html @@ -1,5 +1,5 @@ -Get column or property for use in mapping — get_column • mapgl +Get column or property for use in mapping — get_column • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -69,7 +72,7 @@

    Value

    diff --git a/docs/reference/get_drawn_features.html b/docs/reference/get_drawn_features.html index 63ed9340..bcbcb18c 100644 --- a/docs/reference/get_drawn_features.html +++ b/docs/reference/get_drawn_features.html @@ -1,5 +1,5 @@ -Get drawn features from the map — get_drawn_features • mapgl +Get drawn features from the map — get_drawn_features • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -104,7 +107,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 03a177c1..aead03e4 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,5 +1,5 @@ -Package index • mapgl +Package index • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -37,9 +40,9 @@
    -

    All functions

    - +

    Creating Maps

    +

    Functions to initialize Mapbox GL and MapLibre GL maps

    @@ -49,34 +52,45 @@

    All functionsadd_categorical_legend() + mapboxgl() -
    Add a categorical legend to a Mapbox GL map
    +
    Initialize a Mapbox GL Map
    - add_circle_layer() + maplibre()
    -
    Add a circle layer to a Mapbox GL map
    +
    Initialize a Maplibre GL Map
    - add_continuous_legend() + mapboxgl_view()
    -
    Add a continuous legend
    +
    Quick visualization of geometries with Mapbox GL
    - add_draw_control() + maplibre_view()
    -
    Add a draw control to a map
    -
    +
    Quick visualization of geometries with MapLibre GL
    +

    +

    Adding Layers

    + +

    Functions to add various types of visualization layers to your map

    + + +
    + - add_fill_extrusion_layer() + + +
    + + add_layer()
    -
    Add a fill-extrusion layer to a Mapbox GL map
    +
    Add a layer to a map from a source
    add_fill_layer() @@ -85,196 +99,275 @@

    All functionsadd_fullscreen_control() + add_line_layer()

    -
    Add a fullscreen control to a map
    +
    Add a line layer to a map
    - add_geocoder_control() + add_circle_layer()
    -
    Add a geocoder control to a map
    +
    Add a circle layer to a Mapbox GL map
    - add_geolocate_control() + add_heatmap_layer()
    -
    Add a geolocate control to a map
    +
    Add a heatmap layer to a Mapbox GL map
    - add_globe_minimap() + add_fill_extrusion_layer()
    -
    Add a Globe Minimap to a map
    +
    Add a fill-extrusion layer to a Mapbox GL map
    - add_heatmap_layer() + add_raster_layer()
    -
    Add a heatmap layer to a Mapbox GL map
    +
    Add a raster layer to a Mapbox GL map
    - add_image() + add_symbol_layer()
    -
    Add an image to the map
    -
    +
    Add a symbol layer to a map
    +
    +

    Data Sources

    + +

    Functions to add different types of data sources

    + + +
    + + - add_image_source() + +
    + + add_source()
    -
    Add an image source to a Mapbox GL or Maplibre GL map
    +
    Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map
    - add_layer() + add_vector_source()
    -
    Add a layer to a map from a source
    +
    Add a vector tile source to a Mapbox GL or Maplibre GL map
    - add_layers_control() + add_raster_source()
    -
    Add a layers control to the map
    +
    Add a raster tile source to a Mapbox GL or Maplibre GL map
    - add_legend() + add_raster_dem_source()
    -
    Add a legend to a Mapbox GL map
    +
    Add a raster DEM source to a Mapbox GL or Maplibre GL map
    - add_line_layer() + add_image_source()
    -
    Add a line layer to a map
    +
    Add an image source to a Mapbox GL or Maplibre GL map
    - add_markers() + add_video_source()
    -
    Add markers to a Mapbox GL or Maplibre GL map
    +
    Add a video source to a Mapbox GL or Maplibre GL map
    + add_h3j_source() + +
    +
    Add a hexagon source from the H3 geospatial indexing system.
    +
    +

    Map Controls

    + +

    Functions to add interactive controls to your map

    + + +
    + + + + +
    + add_navigation_control()
    Add a navigation control to a map
    - add_raster_dem_source() + add_fullscreen_control()
    -
    Add a raster DEM source to a Mapbox GL or Maplibre GL map
    +
    Add a fullscreen control to a map
    - add_raster_layer() + add_scale_control()
    -
    Add a raster layer to a Mapbox GL map
    +
    Add a scale control to a map
    - add_raster_source() + add_layers_control()
    -
    Add a raster tile source to a Mapbox GL or Maplibre GL map
    +
    Add a layers control to the map
    - add_reset_control() + add_draw_control()
    -
    Add a reset control to a map
    +
    Add a draw control to a map
    - add_scale_control() + add_geocoder_control()
    -
    Add a scale control to a map
    +
    Add a geocoder control to a map
    - add_source() + add_reset_control()
    -
    Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map
    +
    Add a reset control to a map
    - add_symbol_layer() + add_geolocate_control()
    -
    Add a symbol layer to a map
    +
    Add a geolocate control to a map
    - add_vector_source() + add_globe_control()
    -
    Add a vector tile source to a Mapbox GL or Maplibre GL map
    +
    Add a globe control to a map
    - add_video_source() + add_control()
    -
    Add a video source to a Mapbox GL or Maplibre GL map
    +
    Add a custom control to a map
    - carto_style() + clear_controls()
    -
    Get CARTO Style URL
    +
    Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app
    +
    +

    Legends

    + +

    Functions for adding and managing map legends

    + + +
    + + + + +
    + + add_legend() + +
    +
    Add a legend to a Mapbox GL map
    - clear_controls() + add_categorical_legend()
    -
    Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app
    +
    Add a categorical legend to a Mapbox GL map
    - clear_layer() + add_continuous_legend()
    -
    Clear a layer from a map using a proxy
    +
    Add a continuous legend
    clear_legend()
    -
    Clear legend from a map in a proxy session
    +
    Clear legend(s) from a map in a proxy session
    +
    +

    Markers

    + +

    Functions for adding and managing markers

    + + +
    + + + + +
    + + add_markers() + +
    +
    Add markers to a Mapbox GL or Maplibre GL map
    clear_markers()
    Clear markers from a map in a Shiny session
    +
    +

    Styling Helpers

    + +

    Functions to help with map styling and expressions

    + + +
    + + + + +
    + + mapbox_style() + +
    +
    Get Mapbox Style URL
    - cluster_options() + maptiler_style()
    -
    Prepare cluster options for circle layers
    +
    Get MapTiler Style URL
    - compare() + carto_style()
    -
    Create a Compare slider widget
    +
    Get CARTO Style URL
    - ease_to() + interpolate()
    -
    Ease to a given view
    +
    Create an interpolation expression
    - fit_bounds() + match_expr()
    -
    Fit the map to a bounding box
    +
    Create a match expression
    - fly_to() + step_expr()
    -
    Fly to a given view
    +
    Create a step expression
    get_column() @@ -283,16 +376,51 @@

    All functionsget_drawn_features() + concat()

    -
    Get drawn features from the map
    +
    Create a concatenation expression
    - interpolate() + number_format()
    -
    Create an interpolation expression
    +
    Create a number formatting expression
    +
    + + cluster_options() + +
    +
    Prepare cluster options for circle layers
    +
    +

    Camera and View

    + +

    Functions to control map camera and viewport

    + + +
    + + + + +
    + + fit_bounds() + +
    +
    Fit the map to a bounding box
    +
    + + fly_to() + +
    +
    Fly to a given view
    +
    + + ease_to() + +
    +
    Ease to a given view
    jump_to() @@ -301,64 +429,145 @@

    All functionsmapbox_style() + set_view()

    -
    Get Mapbox Style URL
    +
    Set the map center and zoom level
    +
    +

    Map Configuration

    + +

    Functions to configure map appearance and behavior

    + + +
    + + + + +
    + + set_style() + +
    +
    Update the style of a map
    - mapboxgl() + set_projection()
    -
    Initialize a Mapbox GL Map
    +
    Set Projection for a Mapbox/Maplibre Map
    - mapboxglOutput() + set_terrain()
    -
    Create a Mapbox GL output element for Shiny
    +
    Set terrain properties on a map
    - mapboxgl_proxy() + set_fog()
    -
    Create a proxy object for a Mapbox GL map in Shiny
    +
    Set fog on a Mapbox GL map
    - maplibre() + set_rain()
    -
    Initialize a Maplibre GL Map
    +
    Set rain effect on a Mapbox GL map
    - maplibreOutput() + set_snow()
    -
    Create a Maplibre GL output element for Shiny
    +
    Set snow effect on a Mapbox GL map
    - maplibre_proxy() + set_config_property()
    -
    Create a proxy object for a Maplibre GL map in Shiny
    +
    Set a configuration property for a Mapbox GL map
    +
    +

    Layer Management

    + +

    Functions to modify and manage existing layers

    + + +
    + + + + +
    + + set_filter() + +
    +
    Set a filter on a map layer
    - maptiler_style() + set_paint_property()
    -
    Get MapTiler Style URL
    +
    Set a paint property on a map layer
    - match_expr() + set_layout_property()
    -
    Create a match expression
    +
    Set a layout property on a map layer
    +
    + + set_tooltip() + +
    +
    Set tooltip on a map layer
    +
    + + set_popup() + +
    +
    Set popup on a map layer
    +
    + + set_source() + +
    +
    Set source of a map layer
    +
    + + clear_layer() + +
    +
    Clear a layer from a map using a proxy
    move_layer()
    Move a layer to a different z-position
    +
    +

    Shiny Integration

    + +

    Functions for using mapgl in Shiny applications

    + + +
    + + + + +
    + + mapboxglOutput() + +
    +
    Create a Mapbox GL output element for Shiny
    +
    + + maplibreOutput() + +
    +
    Create a Maplibre GL output element for Shiny
    renderMapboxgl() @@ -373,60 +582,137 @@

    All functionsset_config_property() + mapboxgl_proxy()

    -
    Set a configuration property for a Mapbox GL map
    +
    Create a proxy object for a Mapbox GL map in Shiny
    - set_filter() + maplibre_proxy()
    -
    Set a filter on a map layer
    +
    Create a proxy object for a Maplibre GL map in Shiny
    - set_fog() + mapboxglCompareOutput()
    -
    Set fog on a Mapbox GL map
    +
    Create a Mapbox GL Compare output element for Shiny
    - set_layout_property() + maplibreCompareOutput()
    -
    Set a layout property on a map layer
    +
    Create a Maplibre GL Compare output element for Shiny
    - set_paint_property() + renderMapboxglCompare()
    -
    Set a paint property on a map layer
    +
    Render a Mapbox GL Compare output element in Shiny
    - set_style() + renderMaplibreCompare()
    -
    Update the style of a map
    +
    Render a Maplibre GL Compare output element in Shiny
    - set_terrain() + mapboxgl_compare_proxy()
    -
    Set terrain properties on a map
    +
    Create a proxy object for a Mapbox GL Compare widget in Shiny
    - set_view() + maplibre_compare_proxy()
    -
    Set the map center and zoom level
    +
    Create a proxy object for a Maplibre GL Compare widget in Shiny
    +
    +

    Advanced Features

    + +

    Functions for advanced mapping features

    + + +
    + + + + +
    + + compare() + +
    +
    Create a Compare widget
    - step_expr() + add_globe_minimap()
    -
    Create a step expression
    +
    Add a Globe Minimap to a map
    +
    + + add_image() + +
    +
    Add an image to the map
    +
    + + get_drawn_features() + +
    +
    Get drawn features from the map
    +
    + + add_features_to_draw() + +
    +
    Add features to an existing draw control
    +
    +

    Story Maps

    + +

    Functions for creating scrollytelling story maps

    + + +
    + + + + +
    + + story_map() + +
    +
    Create a scrollytelling story map
    +
    + + story_maplibre() + +
    +
    Create a scrollytelling story map with MapLibre
    +
    + + story_leaflet() + +
    +
    Create a scrollytelling story map with Leaflet
    +
    + + story_section() + +
    +
    Create a story section for story maps
    +
    + + on_section() + +
    +
    Observe events on story map section transitions
    - + diff --git a/docs/reference/interpolate.html b/docs/reference/interpolate.html index 1af95590..37abfd0b 100644 --- a/docs/reference/interpolate.html +++ b/docs/reference/interpolate.html @@ -1,5 +1,5 @@ -Create an interpolation expression — interpolate • mapgl +Create an interpolation expression — interpolate • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -134,7 +137,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/jump_to.html b/docs/reference/jump_to.html index 3b6886d4..7f4b602b 100644 --- a/docs/reference/jump_to.html +++ b/docs/reference/jump_to.html @@ -1,5 +1,5 @@ -Jump to a given view — jump_to • mapgl +Jump to a given view — jump_to • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/mapbox_style.html b/docs/reference/mapbox_style.html index a5ffa5f6..2af6953d 100644 --- a/docs/reference/mapbox_style.html +++ b/docs/reference/mapbox_style.html @@ -1,5 +1,5 @@ -Get Mapbox Style URL — mapbox_style • mapgl +Get Mapbox Style URL — mapbox_style • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -69,7 +72,7 @@

    Value

    diff --git a/docs/reference/mapboxgl.html b/docs/reference/mapboxgl.html index 656cdb71..427cacc3 100644 --- a/docs/reference/mapboxgl.html +++ b/docs/reference/mapboxgl.html @@ -1,5 +1,5 @@ -Initialize a Mapbox GL Map — mapboxgl • mapgl +Initialize a Mapbox GL Map — mapboxgl • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -89,7 +92,7 @@

    Argumentsparallels -

    A vector of two numbers representing the standard parellels of the projection. Only available when the projection is "albers" or "lambertConformalConic".

    +

    A vector of two numbers representing the standard parallels of the projection. Only available when the projection is "albers" or "lambertConformalConic".

    access_token
    @@ -133,7 +136,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/mapboxglCompareOutput.html b/docs/reference/mapboxglCompareOutput.html new file mode 100644 index 00000000..5d68985b --- /dev/null +++ b/docs/reference/mapboxglCompareOutput.html @@ -0,0 +1,93 @@ + +Create a Mapbox GL Compare output element for Shiny — mapboxglCompareOutput • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Create a Mapbox GL Compare output element for Shiny

    +
    + +
    +

    Usage

    +
    mapboxglCompareOutput(outputId, width = "100%", height = "400px")
    +
    + +
    +

    Arguments

    + + +
    outputId
    +

    The output variable to read from

    + + +
    width
    +

    The width of the element

    + + +
    height
    +

    The height of the element

    + +
    +
    +

    Value

    +

    A Mapbox GL Compare output element for use in a Shiny UI

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/mapboxglOutput.html b/docs/reference/mapboxglOutput.html index 514c8cf7..bdf43aec 100644 --- a/docs/reference/mapboxglOutput.html +++ b/docs/reference/mapboxglOutput.html @@ -1,5 +1,5 @@ -Create a Mapbox GL output element for Shiny — mapboxglOutput • mapgl +Create a Mapbox GL output element for Shiny — mapboxglOutput • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -77,7 +80,7 @@

    Value

    diff --git a/docs/reference/mapboxgl_compare_proxy.html b/docs/reference/mapboxgl_compare_proxy.html new file mode 100644 index 00000000..227d5dba --- /dev/null +++ b/docs/reference/mapboxgl_compare_proxy.html @@ -0,0 +1,97 @@ + +Create a proxy object for a Mapbox GL Compare widget in Shiny — mapboxgl_compare_proxy • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function allows updates to be sent to an existing Mapbox GL Compare widget in a Shiny application.

    +
    + +
    +

    Usage

    +
    mapboxgl_compare_proxy(
    +  compareId,
    +  session = shiny::getDefaultReactiveDomain(),
    +  map_side = "before"
    +)
    +
    + +
    +

    Arguments

    + + +
    compareId
    +

    The ID of the compare output element.

    + + +
    session
    +

    The Shiny session object.

    + + +
    map_side
    +

    Which map side to target in the compare widget, either "before" or "after".

    + +
    +
    +

    Value

    +

    A proxy object for the Mapbox GL Compare widget.

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/mapboxgl_proxy.html b/docs/reference/mapboxgl_proxy.html index d75a54b0..ffd465b2 100644 --- a/docs/reference/mapboxgl_proxy.html +++ b/docs/reference/mapboxgl_proxy.html @@ -1,5 +1,5 @@ -Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy • mapgl +Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -73,7 +76,7 @@

    Value

    diff --git a/docs/reference/mapboxgl_view.html b/docs/reference/mapboxgl_view.html new file mode 100644 index 00000000..8ec1fe23 --- /dev/null +++ b/docs/reference/mapboxgl_view.html @@ -0,0 +1,127 @@ + +Quick visualization of geometries with Mapbox GL — mapboxgl_view • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function provides a quick way to visualize sf geometries using Mapbox GL JS. +It automatically detects the geometry type and applies appropriate styling.

    +
    + +
    +

    Usage

    +
    mapboxgl_view(
    +  data,
    +  column = NULL,
    +  n = NULL,
    +  style = mapbox_style("light"),
    +  ...
    +)
    +
    + +
    +

    Arguments

    + + +
    data
    +

    An sf object to visualize

    + + +
    column
    +

    The name of the column to visualize. If NULL (default), geometries are shown with default styling.

    + + +
    n
    +

    Number of quantile breaks for numeric columns. If specified, uses step_expr() instead of interpolate().

    + + +
    style
    +

    The Mapbox style to use. Defaults to mapbox_style("light").

    + + +
    ...
    +

    Additional arguments passed to mapboxgl()

    + +
    +
    +

    Value

    +

    A Mapbox GL map object

    +
    + +
    +

    Examples

    +
    if (FALSE) { # \dontrun{
    +library(sf)
    +nc <- st_read(system.file("shape/nc.shp", package = "sf"))
    +
    +# Basic view
    +mapboxgl_view(nc)
    +
    +# View with column visualization
    +mapboxgl_view(nc, column = "AREA")
    +
    +# View with quantile breaks
    +mapboxgl_view(nc, column = "AREA", n = 5)
    +} # }
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/mapgl-package.html b/docs/reference/mapgl-package.html index 88b2e905..da2382fb 100644 --- a/docs/reference/mapgl-package.html +++ b/docs/reference/mapgl-package.html @@ -1,5 +1,5 @@ -mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' — mapgl-package • mapglmapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' — mapgl-package • mapgl Skip to contents @@ -9,7 +9,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -36,7 +39,7 @@
    @@ -49,6 +52,7 @@
    @@ -65,7 +69,7 @@

    Author<

    diff --git a/docs/reference/maplibre.html b/docs/reference/maplibre.html index 659bae81..e1b49aa5 100644 --- a/docs/reference/maplibre.html +++ b/docs/reference/maplibre.html @@ -1,5 +1,5 @@ -Initialize a Maplibre GL Map — maplibre • mapgl +Initialize a Maplibre GL Map — maplibre • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -118,7 +121,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/maplibreCompareOutput.html b/docs/reference/maplibreCompareOutput.html new file mode 100644 index 00000000..767dd4b8 --- /dev/null +++ b/docs/reference/maplibreCompareOutput.html @@ -0,0 +1,93 @@ + +Create a Maplibre GL Compare output element for Shiny — maplibreCompareOutput • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Create a Maplibre GL Compare output element for Shiny

    +
    + +
    +

    Usage

    +
    maplibreCompareOutput(outputId, width = "100%", height = "400px")
    +
    + +
    +

    Arguments

    + + +
    outputId
    +

    The output variable to read from

    + + +
    width
    +

    The width of the element

    + + +
    height
    +

    The height of the element

    + +
    +
    +

    Value

    +

    A Maplibre GL Compare output element for use in a Shiny UI

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/maplibreOutput.html b/docs/reference/maplibreOutput.html index fdd4f92e..d67f2b04 100644 --- a/docs/reference/maplibreOutput.html +++ b/docs/reference/maplibreOutput.html @@ -1,5 +1,5 @@ -Create a Maplibre GL output element for Shiny — maplibreOutput • mapgl +Create a Maplibre GL output element for Shiny — maplibreOutput • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -77,7 +80,7 @@

    Value

    diff --git a/docs/reference/maplibre_compare_proxy.html b/docs/reference/maplibre_compare_proxy.html new file mode 100644 index 00000000..33a81d68 --- /dev/null +++ b/docs/reference/maplibre_compare_proxy.html @@ -0,0 +1,97 @@ + +Create a proxy object for a Maplibre GL Compare widget in Shiny — maplibre_compare_proxy • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function allows updates to be sent to an existing Maplibre GL Compare widget in a Shiny application.

    +
    + +
    +

    Usage

    +
    maplibre_compare_proxy(
    +  compareId,
    +  session = shiny::getDefaultReactiveDomain(),
    +  map_side = "before"
    +)
    +
    + +
    +

    Arguments

    + + +
    compareId
    +

    The ID of the compare output element.

    + + +
    session
    +

    The Shiny session object.

    + + +
    map_side
    +

    Which map side to target in the compare widget, either "before" or "after".

    + +
    +
    +

    Value

    +

    A proxy object for the Maplibre GL Compare widget.

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/maplibre_proxy.html b/docs/reference/maplibre_proxy.html index 571cfaad..d778be23 100644 --- a/docs/reference/maplibre_proxy.html +++ b/docs/reference/maplibre_proxy.html @@ -1,5 +1,5 @@ -Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy • mapgl +Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -73,7 +76,7 @@

    Value

    diff --git a/docs/reference/maplibre_view.html b/docs/reference/maplibre_view.html new file mode 100644 index 00000000..2c9eff66 --- /dev/null +++ b/docs/reference/maplibre_view.html @@ -0,0 +1,127 @@ + +Quick visualization of geometries with MapLibre GL — maplibre_view • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function provides a quick way to visualize sf geometries using MapLibre GL JS. +It automatically detects the geometry type and applies appropriate styling.

    +
    + +
    +

    Usage

    +
    maplibre_view(
    +  data,
    +  column = NULL,
    +  n = NULL,
    +  style = carto_style("positron"),
    +  ...
    +)
    +
    + +
    +

    Arguments

    + + +
    data
    +

    An sf object to visualize

    + + +
    column
    +

    The name of the column to visualize. If NULL (default), geometries are shown with default styling.

    + + +
    n
    +

    Number of quantile breaks for numeric columns. If specified, uses step_expr() instead of interpolate().

    + + +
    style
    +

    The MapLibre style to use. Defaults to carto_style("positron").

    + + +
    ...
    +

    Additional arguments passed to maplibre()

    + +
    +
    +

    Value

    +

    A MapLibre GL map object

    +
    + +
    +

    Examples

    +
    if (FALSE) { # \dontrun{
    +library(sf)
    +nc <- st_read(system.file("shape/nc.shp", package = "sf"))
    +
    +# Basic view
    +maplibre_view(nc)
    +
    +# View with column visualization
    +maplibre_view(nc, column = "AREA")
    +
    +# View with quantile breaks
    +maplibre_view(nc, column = "AREA", n = 5)
    +} # }
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/maptiler_style.html b/docs/reference/maptiler_style.html index df3ed1fd..40785024 100644 --- a/docs/reference/maptiler_style.html +++ b/docs/reference/maptiler_style.html @@ -1,5 +1,5 @@ -Get MapTiler Style URL — maptiler_style • mapgl +Get MapTiler Style URL — maptiler_style • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -73,7 +76,7 @@

    Value

    diff --git a/docs/reference/match_expr.html b/docs/reference/match_expr.html index 97f56c9a..18588714 100644 --- a/docs/reference/match_expr.html +++ b/docs/reference/match_expr.html @@ -1,5 +1,5 @@ -Create a match expression — match_expr • mapgl +Create a match expression — match_expr • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -127,7 +130,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/move_layer.html b/docs/reference/move_layer.html index 9cb7cf7f..10c9b6b5 100644 --- a/docs/reference/move_layer.html +++ b/docs/reference/move_layer.html @@ -1,5 +1,5 @@ -Move a layer to a different z-position — move_layer • mapgl +Move a layer to a different z-position — move_layer • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -77,7 +80,7 @@

    Value

    diff --git a/docs/reference/number_format.html b/docs/reference/number_format.html new file mode 100644 index 00000000..afa81e1e --- /dev/null +++ b/docs/reference/number_format.html @@ -0,0 +1,313 @@ + +Create a number formatting expression — number_format • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function creates a number formatting expression that formats numeric values +according to locale-specific conventions. It can be used in tooltips, popups, +and text fields for symbol layers.

    +
    + +
    +

    Usage

    +
    number_format(
    +  column,
    +  locale = "en-US",
    +  style = "decimal",
    +  currency = NULL,
    +  unit = NULL,
    +  minimum_fraction_digits = NULL,
    +  maximum_fraction_digits = NULL,
    +  minimum_integer_digits = NULL,
    +  use_grouping = NULL,
    +  notation = NULL,
    +  compact_display = NULL
    +)
    +
    + +
    +

    Arguments

    + + +
    column
    +

    The name of the column containing the numeric value to format. +Can also be an expression that evaluates to a number.

    + + +
    locale
    +

    A string specifying the locale to use for formatting (e.g., "en-US", +"de-DE", "fr-FR"). Defaults to "en-US".

    + + +
    style
    +

    The formatting style to use. Options include:

    • "decimal" (default): Plain number formatting

    • +
    • "currency": Currency formatting (requires currency parameter)

    • +
    • "percent": Percentage formatting (multiplies by 100 and adds %)

    • +
    • "unit": Unit formatting (requires unit parameter)

    • +
    + + +
    currency
    +

    For style = "currency", the ISO 4217 currency code (e.g., "USD", "EUR", "GBP").

    + + +
    unit
    +

    For style = "unit", the unit to use (e.g., "kilometer", "mile", "liter").

    + + +
    minimum_fraction_digits
    +

    The minimum number of fraction digits to display.

    + + +
    maximum_fraction_digits
    +

    The maximum number of fraction digits to display.

    + + +
    minimum_integer_digits
    +

    The minimum number of integer digits to display.

    + + +
    use_grouping
    +

    Whether to use grouping separators (e.g., thousands separators). +Defaults to TRUE.

    + + +
    notation
    +

    The formatting notation. Options include:

    • "standard" (default): Regular notation

    • +
    • "scientific": Scientific notation

    • +
    • "engineering": Engineering notation

    • +
    • "compact": Compact notation (e.g., "1.2K", "3.4M")

    • +
    + + +
    compact_display
    +

    For notation = "compact", whether to use "short" (default) +or "long" form.

    + +
    +
    +

    Value

    +

    A list representing the number-format expression.

    +
    + +
    +

    Examples

    +
    # Basic number formatting with thousands separators
    +number_format("population")
    +#> [[1]]
    +#> [1] "number-format"
    +#> 
    +#> [[2]]
    +#> [[2]][[1]]
    +#> [1] "get"
    +#> 
    +#> [[2]][[2]]
    +#> [1] "population"
    +#> 
    +#> 
    +#> [[3]]
    +#> [[3]]$locale
    +#> [1] "en-US"
    +#> 
    +#> [[3]]$style
    +#> [1] "decimal"
    +#> 
    +#> 
    +
    +# Currency formatting
    +number_format("income", style = "currency", currency = "USD")
    +#> [[1]]
    +#> [1] "number-format"
    +#> 
    +#> [[2]]
    +#> [[2]][[1]]
    +#> [1] "get"
    +#> 
    +#> [[2]][[2]]
    +#> [1] "income"
    +#> 
    +#> 
    +#> [[3]]
    +#> [[3]]$locale
    +#> [1] "en-US"
    +#> 
    +#> [[3]]$style
    +#> [1] "currency"
    +#> 
    +#> [[3]]$currency
    +#> [1] "USD"
    +#> 
    +#> 
    +
    +# Percentage with 1 decimal place
    +number_format("rate", style = "percent", maximum_fraction_digits = 1)
    +#> [[1]]
    +#> [1] "number-format"
    +#> 
    +#> [[2]]
    +#> [[2]][[1]]
    +#> [1] "get"
    +#> 
    +#> [[2]][[2]]
    +#> [1] "rate"
    +#> 
    +#> 
    +#> [[3]]
    +#> [[3]]$locale
    +#> [1] "en-US"
    +#> 
    +#> [[3]]$style
    +#> [1] "percent"
    +#> 
    +#> [[3]]$`max-fraction-digits`
    +#> [1] 1
    +#> 
    +#> 
    +
    +# Compact notation for large numbers
    +number_format("population", notation = "compact")
    +#> [[1]]
    +#> [1] "number-format"
    +#> 
    +#> [[2]]
    +#> [[2]][[1]]
    +#> [1] "get"
    +#> 
    +#> [[2]][[2]]
    +#> [1] "population"
    +#> 
    +#> 
    +#> [[3]]
    +#> [[3]]$locale
    +#> [1] "en-US"
    +#> 
    +#> [[3]]$style
    +#> [1] "decimal"
    +#> 
    +#> [[3]]$notation
    +#> [1] "compact"
    +#> 
    +#> 
    +
    +# Using within a tooltip
    +concat("Population: ", number_format("population", notation = "compact"))
    +#> [[1]]
    +#> [1] "concat"
    +#> 
    +#> [[2]]
    +#> [1] "Population: "
    +#> 
    +#> [[3]]
    +#> [[3]][[1]]
    +#> [1] "number-format"
    +#> 
    +#> [[3]][[2]]
    +#> [[3]][[2]][[1]]
    +#> [1] "get"
    +#> 
    +#> [[3]][[2]][[2]]
    +#> [1] "population"
    +#> 
    +#> 
    +#> [[3]][[3]]
    +#> [[3]][[3]]$locale
    +#> [1] "en-US"
    +#> 
    +#> [[3]][[3]]$style
    +#> [1] "decimal"
    +#> 
    +#> [[3]][[3]]$notation
    +#> [1] "compact"
    +#> 
    +#> 
    +#> 
    +
    +# Using with get_column()
    +number_format(get_column("value"), style = "currency", currency = "EUR")
    +#> [[1]]
    +#> [1] "number-format"
    +#> 
    +#> [[2]]
    +#> [[2]][[1]]
    +#> [1] "get"
    +#> 
    +#> [[2]][[2]]
    +#> [1] "value"
    +#> 
    +#> 
    +#> [[3]]
    +#> [[3]]$locale
    +#> [1] "en-US"
    +#> 
    +#> [[3]]$style
    +#> [1] "currency"
    +#> 
    +#> [[3]]$currency
    +#> [1] "EUR"
    +#> 
    +#> 
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/on_section.html b/docs/reference/on_section.html new file mode 100644 index 00000000..bb4d7ef3 --- /dev/null +++ b/docs/reference/on_section.html @@ -0,0 +1,95 @@ + +Observe events on story map section transitions — on_section • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    For a given story_section(), you may want to trigger an event when the section becomes visible. +This function wraps shiny::observeEvent() to allow you to modify the state of your map or +invoke other Shiny actions on user scroll.

    +
    + +
    +

    Usage

    +
    on_section(map_id, section_id, handler)
    +
    + +
    +

    Arguments

    + + +
    map_id
    +

    The ID of your map output

    + + +
    section_id
    +

    The ID of the section to trigger on, defined in story_section()

    + + +
    handler
    +

    Expression to execute when section becomes visible.

    + +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/renderMapboxgl.html b/docs/reference/renderMapboxgl.html index d5945093..349e7a2e 100644 --- a/docs/reference/renderMapboxgl.html +++ b/docs/reference/renderMapboxgl.html @@ -1,5 +1,5 @@ -Render a Mapbox GL output element in Shiny — renderMapboxgl • mapgl +Render a Mapbox GL output element in Shiny — renderMapboxgl • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -77,7 +80,7 @@

    Value

    diff --git a/docs/reference/renderMapboxglCompare.html b/docs/reference/renderMapboxglCompare.html new file mode 100644 index 00000000..310fa7f3 --- /dev/null +++ b/docs/reference/renderMapboxglCompare.html @@ -0,0 +1,93 @@ + +Render a Mapbox GL Compare output element in Shiny — renderMapboxglCompare • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Render a Mapbox GL Compare output element in Shiny

    +
    + +
    +

    Usage

    +
    renderMapboxglCompare(expr, env = parent.frame(), quoted = FALSE)
    +
    + +
    +

    Arguments

    + + +
    expr
    +

    An expression that generates a Mapbox GL Compare map

    + + +
    env
    +

    The environment in which to evaluate expr

    + + +
    quoted
    +

    Is expr a quoted expression

    + +
    +
    +

    Value

    +

    A rendered Mapbox GL Compare map for use in a Shiny server

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/renderMaplibre.html b/docs/reference/renderMaplibre.html index 0d084797..12117d9e 100644 --- a/docs/reference/renderMaplibre.html +++ b/docs/reference/renderMaplibre.html @@ -1,5 +1,5 @@ -Render a Maplibre GL output element in Shiny — renderMaplibre • mapgl +Render a Maplibre GL output element in Shiny — renderMaplibre • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -77,7 +80,7 @@

    Value

    diff --git a/docs/reference/renderMaplibreCompare.html b/docs/reference/renderMaplibreCompare.html new file mode 100644 index 00000000..2b2ec02a --- /dev/null +++ b/docs/reference/renderMaplibreCompare.html @@ -0,0 +1,93 @@ + +Render a Maplibre GL Compare output element in Shiny — renderMaplibreCompare • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Render a Maplibre GL Compare output element in Shiny

    +
    + +
    +

    Usage

    +
    renderMaplibreCompare(expr, env = parent.frame(), quoted = FALSE)
    +
    + +
    +

    Arguments

    + + +
    expr
    +

    An expression that generates a Maplibre GL Compare map

    + + +
    env
    +

    The environment in which to evaluate expr

    + + +
    quoted
    +

    Is expr a quoted expression

    + +
    +
    +

    Value

    +

    A rendered Maplibre GL Compare map for use in a Shiny server

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/set_config_property.html b/docs/reference/set_config_property.html index 0e36bfa3..d0104ed6 100644 --- a/docs/reference/set_config_property.html +++ b/docs/reference/set_config_property.html @@ -1,5 +1,5 @@ -Set a configuration property for a Mapbox GL map — set_config_property • mapgl +Set a configuration property for a Mapbox GL map — set_config_property • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/set_filter.html b/docs/reference/set_filter.html index 20e975d4..a8d19061 100644 --- a/docs/reference/set_filter.html +++ b/docs/reference/set_filter.html @@ -1,5 +1,5 @@ -Set a filter on a map layer — set_filter • mapgl +Set a filter on a map layer — set_filter • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -77,7 +80,7 @@

    Value

    diff --git a/docs/reference/set_fog.html b/docs/reference/set_fog.html index 165f614a..b9d8192e 100644 --- a/docs/reference/set_fog.html +++ b/docs/reference/set_fog.html @@ -1,5 +1,5 @@ -Set fog on a Mapbox GL map — set_fog • mapgl +Set fog on a Mapbox GL map — set_fog • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -101,7 +104,7 @@

    Value

    diff --git a/docs/reference/set_layout_property.html b/docs/reference/set_layout_property.html index e9e5ad45..babda6b3 100644 --- a/docs/reference/set_layout_property.html +++ b/docs/reference/set_layout_property.html @@ -1,5 +1,5 @@ -Set a layout property on a map layer — set_layout_property • mapgl +Set a layout property on a map layer — set_layout_property • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/set_paint_property.html b/docs/reference/set_paint_property.html index 930126fe..10d45df9 100644 --- a/docs/reference/set_paint_property.html +++ b/docs/reference/set_paint_property.html @@ -1,5 +1,5 @@ -Set a paint property on a map layer — set_paint_property • mapgl +Set a paint property on a map layer — set_paint_property • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -81,7 +84,7 @@

    Value

    diff --git a/docs/reference/set_popup.html b/docs/reference/set_popup.html new file mode 100644 index 00000000..bc7b8cd5 --- /dev/null +++ b/docs/reference/set_popup.html @@ -0,0 +1,93 @@ + +Set popup on a map layer — set_popup • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Set popup on a map layer

    +
    + +
    +

    Usage

    +
    set_popup(map, layer, popup)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by the mapboxgl or maplibre function, or a proxy object.

    + + +
    layer
    +

    The ID of the layer to update.

    + + +
    popup
    +

    The name of the popup property or an expression to set.

    + +
    +
    +

    Value

    +

    The updated map object.

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/set_projection.html b/docs/reference/set_projection.html new file mode 100644 index 00000000..ffda3ece --- /dev/null +++ b/docs/reference/set_projection.html @@ -0,0 +1,89 @@ + +Set Projection for a Mapbox/Maplibre Map — set_projection • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    This function sets the projection dynamically after map initialization.

    +
    + +
    +

    Usage

    +
    set_projection(map, projection)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by mapboxgl() or maplibre() functions, or their respective proxy objects

    + + +
    projection
    +

    A string representing the projection name (e.g., "mercator", "globe", "albers", "equalEarth", etc.)

    + +
    +
    +

    Value

    +

    The modified map object

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/set_rain.html b/docs/reference/set_rain.html new file mode 100644 index 00000000..7fdc6696 --- /dev/null +++ b/docs/reference/set_rain.html @@ -0,0 +1,167 @@ + +Set rain effect on a Mapbox GL map — set_rain • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Set rain effect on a Mapbox GL map

    +
    + +
    +

    Usage

    +
    set_rain(
    +  map,
    +  density = 0.5,
    +  intensity = 1,
    +  color = "#a8adbc",
    +  opacity = 0.7,
    +  center_thinning = 0.57,
    +  direction = c(0, 80),
    +  droplet_size = c(2.6, 18.2),
    +  distortion_strength = 0.7,
    +  vignette = 1,
    +  vignette_color = "#464646",
    +  remove = FALSE
    +)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by the mapboxgl function or a proxy object.

    + + +
    density
    +

    A number between 0 and 1 controlling the rain particles density. Default is 0.5.

    + + +
    intensity
    +

    A number between 0 and 1 controlling the rain particles movement speed. Default is 1.

    + + +
    color
    +

    A string specifying the color of the rain droplets. Default is "#a8adbc".

    + + +
    opacity
    +

    A number between 0 and 1 controlling the rain particles opacity. Default is 0.7.

    + + +
    center_thinning
    +

    A number between 0 and 1 controlling the thinning factor of rain particles from center. Default is 0.57.

    + + +
    direction
    +

    A numeric vector of length 2 defining the azimuth and polar angles of the rain direction. Default is c(0, 80).

    + + +
    droplet_size
    +

    A numeric vector of length 2 controlling the rain droplet size (x - normal to direction, y - along direction). Default is c(2.6, 18.2).

    + + +
    distortion_strength
    +

    A number between 0 and 1 controlling the rain particles screen-space distortion strength. Default is 0.7.

    + + +
    vignette
    +

    A number between 0 and 1 controlling the screen-space vignette rain tinting effect intensity. Default is 1.0.

    + + +
    vignette_color
    +

    A string specifying the rain vignette screen-space corners tint color. Default is "#464646".

    + + +
    remove
    +

    A logical value indicating whether to remove the rain effect. Default is FALSE.

    + +
    +
    +

    Value

    +

    The updated map object.

    +
    + +
    +

    Examples

    +
    if (FALSE) { # \dontrun{
    +# Add rain effect with default values
    +mapboxgl(...) |> set_rain()
    +
    +# Add rain effect with custom values
    +mapboxgl(
    +  style = mapbox_style("standard"),
    +  center = c(24.951528, 60.169573),
    +  zoom = 16.8,
    +  pitch = 74,
    +  bearing = 12.8
    +) |>
    +  set_rain(
    +    density = 0.5,
    +    opacity = 0.7,
    +    color = "#a8adbc"
    +  )
    +  
    +# Remove rain effect (useful in Shiny)
    +map_proxy |> set_rain(remove = TRUE)
    +} # }
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/set_snow.html b/docs/reference/set_snow.html new file mode 100644 index 00000000..c59de1e3 --- /dev/null +++ b/docs/reference/set_snow.html @@ -0,0 +1,162 @@ + +Set snow effect on a Mapbox GL map — set_snow • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Set snow effect on a Mapbox GL map

    +
    + +
    +

    Usage

    +
    set_snow(
    +  map,
    +  density = 0.85,
    +  intensity = 1,
    +  color = "#ffffff",
    +  opacity = 1,
    +  center_thinning = 0.4,
    +  direction = c(0, 50),
    +  flake_size = 0.71,
    +  vignette = 0.3,
    +  vignette_color = "#ffffff",
    +  remove = FALSE
    +)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by the mapboxgl function or a proxy object.

    + + +
    density
    +

    A number between 0 and 1 controlling the snow particles density. Default is 0.85.

    + + +
    intensity
    +

    A number between 0 and 1 controlling the snow particles movement speed. Default is 1.0.

    + + +
    color
    +

    A string specifying the color of the snow particles. Default is "#ffffff".

    + + +
    opacity
    +

    A number between 0 and 1 controlling the snow particles opacity. Default is 1.0.

    + + +
    center_thinning
    +

    A number between 0 and 1 controlling the thinning factor of snow particles from center. Default is 0.4.

    + + +
    direction
    +

    A numeric vector of length 2 defining the azimuth and polar angles of the snow direction. Default is c(0, 50).

    + + +
    flake_size
    +

    A number between 0 and 5 controlling the snow flake particle size. Default is 0.71.

    + + +
    vignette
    +

    A number between 0 and 1 controlling the snow vignette screen-space effect. Default is 0.3.

    + + +
    vignette_color
    +

    A string specifying the snow vignette screen-space corners tint color. Default is "#ffffff".

    + + +
    remove
    +

    A logical value indicating whether to remove the snow effect. Default is FALSE.

    + +
    +
    +

    Value

    +

    The updated map object.

    +
    + +
    +

    Examples

    +
    if (FALSE) { # \dontrun{
    +# Add snow effect with default values
    +mapboxgl(...) |> set_snow()
    +
    +# Add snow effect with custom values
    +mapboxgl(
    +  style = mapbox_style("standard"),
    +  center = c(24.951528, 60.169573),
    +  zoom = 16.8,
    +  pitch = 74,
    +  bearing = 12.8
    +) |>
    +  set_snow(
    +    density = 0.85,
    +    flake_size = 0.71,
    +    color = "#ffffff"
    +  )
    +  
    +# Remove snow effect (useful in Shiny)
    +map_proxy |> set_snow(remove = TRUE)
    +} # }
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/reference/set_source.html b/docs/reference/set_source.html new file mode 100644 index 00000000..bb5aedac --- /dev/null +++ b/docs/reference/set_source.html @@ -0,0 +1,93 @@ + +Set source of a map layer — set_source • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Set source of a map layer

    +
    + +
    +

    Usage

    +
    set_source(map, layer, source)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by the mapboxgl or maplibre function, or a proxy object.

    + + +
    layer
    +

    The ID of the layer to update.

    + + +
    source
    +

    An sf object (which will be converted to a GeoJSON source).

    + +
    +
    +

    Value

    +

    The updated map object.

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/set_style.html b/docs/reference/set_style.html index 25df7dbb..2b4c77e8 100644 --- a/docs/reference/set_style.html +++ b/docs/reference/set_style.html @@ -1,5 +1,5 @@ -Update the style of a map — set_style • mapgl +Update the style of a map — set_style • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -44,7 +47,7 @@

    Usage

    -
    set_style(map, style, config = NULL, diff = TRUE)
    +
    set_style(map, style, config = NULL, diff = TRUE, preserve_layers = TRUE)
    @@ -66,6 +69,10 @@

    Argumentsdiff

    A boolean that attempts a diff-based update rather than re-drawing the full style. Not available for all styles.

    + +
    preserve_layers
    +

    A boolean that indicates whether to preserve user-added sources and layers when changing styles. Defaults to TRUE.

    +

    Value

    @@ -99,7 +106,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/set_terrain.html b/docs/reference/set_terrain.html index 6be1d94a..5f381900 100644 --- a/docs/reference/set_terrain.html +++ b/docs/reference/set_terrain.html @@ -1,5 +1,5 @@ -Set terrain properties on a map — set_terrain • mapgl +Set terrain properties on a map — set_terrain • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -102,7 +105,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/set_tooltip.html b/docs/reference/set_tooltip.html new file mode 100644 index 00000000..e1ad2f8c --- /dev/null +++ b/docs/reference/set_tooltip.html @@ -0,0 +1,93 @@ + +Set tooltip on a map layer — set_tooltip • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Set tooltip on a map layer

    +
    + +
    +

    Usage

    +
    set_tooltip(map, layer, tooltip)
    +
    + +
    +

    Arguments

    + + +
    map
    +

    A map object created by the mapboxgl or maplibre function, or a proxy object.

    + + +
    layer
    +

    The ID of the layer to update.

    + + +
    tooltip
    +

    The name of the tooltip to set.

    + +
    +
    +

    Value

    +

    The updated map object.

    +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/set_view.html b/docs/reference/set_view.html index fff9ce3e..e85c1dbf 100644 --- a/docs/reference/set_view.html +++ b/docs/reference/set_view.html @@ -1,5 +1,5 @@ -Set the map center and zoom level — set_view • mapgl +Set the map center and zoom level — set_view • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -77,7 +80,7 @@

    Value

    diff --git a/docs/reference/step_expr.html b/docs/reference/step_expr.html index 81fcdd5c..bc04a404 100644 --- a/docs/reference/step_expr.html +++ b/docs/reference/step_expr.html @@ -1,5 +1,5 @@ -Create a step expression — step_expr • mapgl +Create a step expression — step_expr • mapgl Skip to contents @@ -7,7 +7,7 @@ mapgl - 0.1.4 + 0.2.2.9000 - @@ -34,7 +37,7 @@
    @@ -131,7 +134,7 @@

    Examples -

    Site built with pkgdown 2.0.9.9000.

    +

    Site built with pkgdown 2.1.3.9000.

    diff --git a/docs/reference/story_leaflet.html b/docs/reference/story_leaflet.html new file mode 100644 index 00000000..55c704f1 --- /dev/null +++ b/docs/reference/story_leaflet.html @@ -0,0 +1,127 @@ + +Create a scrollytelling story map with Leaflet — story_leaflet • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Create a scrollytelling story map with Leaflet

    +
    + +
    +

    Usage

    +
    story_leaflet(
    +  map_id,
    +  sections,
    +  root_margin = "-20% 0px -20% 0px",
    +  threshold = 0,
    +  styles = NULL,
    +  bg_color = "rgba(255,255,255,0.9)",
    +  text_color = "#34495e",
    +  font_family = NULL
    +)
    +
    + +
    +

    Arguments

    + + +
    map_id
    +

    The ID of your mapboxgl, maplibre, or leaflet output +defined in the server, e.g. "map"

    + + +
    sections
    +

    A named list of story_section objects. +Names will correspond to map events defined within +the server using on_section().

    + + +
    root_margin
    +

    The margin around the viewport for triggering sections by +the intersection observer. Should be specified as a string, +e.g. "-20% 0px -20% 0px".

    + + +
    threshold
    +

    A number that indicates the visibility ratio for a story +' panel to be used to trigger a section; should be a number between +0 and 1. Defaults to 0, meaning that the section is triggered as soon +as the first pixel is visible.

    + + +
    styles
    +

    Optional custom CSS styles. Should be specified as a +character string within shiny::tags$style().

    + + +
    bg_color
    +

    Default background color for all sections

    + + +
    text_color
    +

    Default text color for all sections

    + + +
    font_family
    +

    Default font family for all sections

    + +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/story_map.html b/docs/reference/story_map.html new file mode 100644 index 00000000..fb6c00e1 --- /dev/null +++ b/docs/reference/story_map.html @@ -0,0 +1,135 @@ + +Create a scrollytelling story map — story_map • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Create a scrollytelling story map

    +
    + +
    +

    Usage

    +
    story_map(
    +  map_id,
    +  sections,
    +  map_type = c("mapboxgl", "maplibre", "leaflet"),
    +  root_margin = "-20% 0px -20% 0px",
    +  threshold = 0,
    +  styles = NULL,
    +  bg_color = "rgba(255,255,255,0.9)",
    +  text_color = "#34495e",
    +  font_family = NULL
    +)
    +
    + +
    +

    Arguments

    + + +
    map_id
    +

    The ID of your mapboxgl, maplibre, or leaflet output +defined in the server, e.g. "map"

    + + +
    sections
    +

    A named list of story_section objects. +Names will correspond to map events defined within +the server using on_section().

    + + +
    map_type
    +

    One of "mapboxgl", "maplibre", or "leaflet". +This will use either mapboxglOutput(), maplibreOutput(), +or leafletOutput() respectively, and must +correspond to the appropriate render*() function used in the server.

    + + +
    root_margin
    +

    The margin around the viewport for triggering sections by +the intersection observer. Should be specified as a string, +e.g. "-20% 0px -20% 0px".

    + + +
    threshold
    +

    A number that indicates the visibility ratio for a story +' panel to be used to trigger a section; should be a number between +0 and 1. Defaults to 0, meaning that the section is triggered as soon +as the first pixel is visible.

    + + +
    styles
    +

    Optional custom CSS styles. Should be specified as a +character string within shiny::tags$style().

    + + +
    bg_color
    +

    Default background color for all sections

    + + +
    text_color
    +

    Default text color for all sections

    + + +
    font_family
    +

    Default font family for all sections

    + +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/story_maplibre.html b/docs/reference/story_maplibre.html new file mode 100644 index 00000000..2f5c2368 --- /dev/null +++ b/docs/reference/story_maplibre.html @@ -0,0 +1,127 @@ + +Create a scrollytelling story map with MapLibre — story_maplibre • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Create a scrollytelling story map with MapLibre

    +
    + +
    +

    Usage

    +
    story_maplibre(
    +  map_id,
    +  sections,
    +  root_margin = "-20% 0px -20% 0px",
    +  threshold = 0,
    +  styles = NULL,
    +  bg_color = "rgba(255,255,255,0.9)",
    +  text_color = "#34495e",
    +  font_family = NULL
    +)
    +
    + +
    +

    Arguments

    + + +
    map_id
    +

    The ID of your mapboxgl, maplibre, or leaflet output +defined in the server, e.g. "map"

    + + +
    sections
    +

    A named list of story_section objects. +Names will correspond to map events defined within +the server using on_section().

    + + +
    root_margin
    +

    The margin around the viewport for triggering sections by +the intersection observer. Should be specified as a string, +e.g. "-20% 0px -20% 0px".

    + + +
    threshold
    +

    A number that indicates the visibility ratio for a story +' panel to be used to trigger a section; should be a number between +0 and 1. Defaults to 0, meaning that the section is triggered as soon +as the first pixel is visible.

    + + +
    styles
    +

    Optional custom CSS styles. Should be specified as a +character string within shiny::tags$style().

    + + +
    bg_color
    +

    Default background color for all sections

    + + +
    text_color
    +

    Default text color for all sections

    + + +
    font_family
    +

    Default font family for all sections

    + +
    + +
    + + +
    + + + + + + + diff --git a/docs/reference/story_section.html b/docs/reference/story_section.html new file mode 100644 index 00000000..20bf9fa2 --- /dev/null +++ b/docs/reference/story_section.html @@ -0,0 +1,113 @@ + +Create a story section for story maps — story_section • mapgl + Skip to contents + + +
    +
    +
    + +
    +

    Create a story section for story maps

    +
    + +
    +

    Usage

    +
    story_section(
    +  title,
    +  content,
    +  position = c("left", "center", "right"),
    +  width = 400,
    +  bg_color = NULL,
    +  text_color = NULL,
    +  font_family = NULL
    +)
    +
    + +
    +

    Arguments

    + + +
    title
    +

    Section title

    + + +
    content
    +

    Section content - can be text, HTML, or Shiny outputs

    + + +
    position
    +

    Position of text block ("left", "center", "right")

    + + +
    width
    +

    Width of text block in pixels (default: 400)

    + + +
    bg_color
    +

    Background color (with alpha) for text block

    + + +
    text_color
    +

    Text color

    + + +
    font_family
    +

    Font family for the section

    + +
    + +
    + + +
    + + + + + + + diff --git a/docs/search.json b/docs/search.json index 4193915d..f155b026 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://walker-data.com/mapgl/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 Kyle Walker Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://walker-data.com/mapgl/articles/getting-started.html","id":"using-mapbox-gl-js","dir":"Articles","previous_headings":"","what":"Using Mapbox GL JS","title":"Getting started with mapgl","text":"gateway Mapbox GL JS v3 R mapboxgl() function. Run function arguments get interactive globe using Mapbox’s Standard style: use Mapbox maps, need Mapbox access token. user mapboxapi package installed Mapbox access token, mapboxgl() pick token . new R packages, ’ll want get token Mapbox account, run usethis::edit_r_environ(), set environment variable MAPBOX_PUBLIC_TOKEN=\"your_token_here\". ’s important know Mapbox GL JS commercial product charges map views; however, generous free tier. Mapbox’s default styles accessible mapbox_style() function, can passed style parameter change style map. Mapbox GL JS also supports modifying map projections; use projection = \"winkelTripel\" Winkel Tripel global projection. get local view map, can use center, zoom, pitch, bearing arguments. example shown , arguments incorporated “fly ” animation. mapgl supports several animated transitions. Mapbox GL JS v3, new Standard style includes custom-rendered buildings around world, American Airlines Center Dallas.","code":"library(mapgl) mapboxgl() mapboxgl( style = mapbox_style(\"satellite\"), projection = \"winkelTripel\") mapboxgl( center = c(-97.6, 25.4) ) |> fly_to( center = c(-96.810481, 32.790869), zoom = 18.4, pitch = 75, bearing = 136.8 )"},{"path":"https://walker-data.com/mapgl/articles/getting-started.html","id":"using-maplibre-gl-js","dir":"Articles","previous_headings":"","what":"Using Maplibre GL JS","title":"Getting started with mapgl","text":"Maplibre GL JS, fork permissively-licensed Mapbox GL JS 1.0, also available R users mapgl. core function initialize MapLibre map maplibre(). default tiles maplibre() CARTO’s Voyager tiles, usable without API key. MapTiler tiles also available via maptiler_style() function. styles work quite well MapLibre, require API key; set environment variable MAPTILER_API_KEY .Renviron file store key. example uses Bright MapTiler style, adds fullscreen control navigation control map. controls styles available mapboxgl() well; mapgl aims provide consistent API work either Mapbox MapLibre.","code":"library(mapgl) maplibre() maplibre( style = maptiler_style(\"bright\"), center = c(-43.23412, -22.91370), zoom = 14 ) |> add_fullscreen_control(position = \"top-left\") |> add_navigation_control()"},{"path":"https://walker-data.com/mapgl/articles/getting-started.html","id":"comparing-map-views","dir":"Articles","previous_headings":"","what":"Comparing map views","title":"Getting started with mapgl","text":"mapgl includes function compare() allows users create synced swipe maps can compare two styles. function works either Mapbox MapLibre maps. don’t working correctly rendered R Markdown / Quarto docs Shiny apps yet, ’m working !","code":"m1 <- mapboxgl() m2 <- mapboxgl(mapbox_style(\"satellite-streets\")) compare(m1, m2)"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"using-layers-an-overview","dir":"Articles","previous_headings":"","what":"Using layers: an overview","title":"Layers overview","text":"Mapbox GL JS MapLibre, datasets added maps sources styled layers. mapgl aims expose sources layers APIs R users ways honor deep customization available JavaScript libraries also accommodate R users’ typical workflows. Geospatial practitioners R typically work objects sf package. initial release mapgl natively supports sf objects, aim support geospatial formats (objects terra package) future. Objects class sf can specified sources map either add_source() function via source parameter one mapgl’s layer functions. add_fill_layer() function calls Mapbox GL JS addLayer() function internally fill type, enumerates available options styling layer function arguments. mapgl users often want use bounds argument initializing map, alternatively fit_bounds() function, fix map view given layer’s bounding box. overview available layers mapgl . Layers can used either mapboxgl() maplibre() maps.","code":"library(mapgl) library(sf) nc <- st_read(system.file(\"shape/nc.shp\", package=\"sf\")) ## Reading layer `nc' from data source ## `/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/sf/shape/nc.shp' ## using driver `ESRI Shapefile' ## Simple feature collection with 100 features and 14 fields ## Geometry type: MULTIPOLYGON ## Dimension: XY ## Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 ## Geodetic CRS: NAD27 mapboxgl(bounds = nc) |> add_fill_layer(id = \"nc_data\", source = nc, fill_color = \"blue\", fill_opacity = 0.5)"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"line-layers","dir":"Articles","previous_headings":"","what":"Line layers","title":"Layers overview","text":"","code":"library(mapgl) library(tigris) ## To enable caching of data, set `options(tigris_use_cache = TRUE)` ## in your R script or .Rprofile. options(tigris_use_cache = TRUE) loving_roads <- roads(\"TX\", \"Loving\") maplibre(style = maptiler_style(\"backdrop\"), bounds = loving_roads) |> add_line_layer( id = \"roads\", source = loving_roads, line_color = \"navy\", line_opacity = 0.7 )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"circle-layers","dir":"Articles","previous_headings":"","what":"Circle layers","title":"Layers overview","text":"Circle layers typically used represent point data map. Circle clustering implemented cluster_options argument, list generated cluster_options() function can passed.","code":"library(mapgl) library(sf) library(dplyr) # Set seed for reproducibility set.seed(1234) # Define the bounding box for Washington DC (approximately) bbox <- st_bbox(c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), crs = st_crs(4326)) # Generate 30 random points within the bounding box random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox[\"xmin\"], bbox[\"xmax\"]), lat = runif(30, bbox[\"ymin\"], bbox[\"ymax\"]) ), coords = c(\"lon\", \"lat\"), crs = 4326 ) # Assign random categories categories <- c('music', 'bar', 'theatre', 'bicycle') random_points <- random_points %>% mutate(category = sample(categories, n(), replace = TRUE)) # Map with circle layer mapboxgl(style = mapbox_style(\"dark\"), bounds = random_points) %>% add_circle_layer( id = \"poi-layer\", source = random_points, circle_color = match_expr( \"category\", values = c(\"music\", \"bar\", \"theatre\", \"bicycle\"), stops = c(\"#1f78b4\", \"#33a02c\", \"#e31a1c\", \"#ff7f00\") ), circle_radius = 8, circle_stroke_color = \"#ffffff\", circle_stroke_width = 2, circle_opacity = 0.8, tooltip = \"category\", hover_options = list(circle_radius = 12, circle_color = \"#ffff99\") ) %>% add_categorical_legend( legend_title = \"Points of Interest\", values = c(\"Music\", \"Bar\", \"Theatre\", \"Bicycle\"), colors = c(\"#1f78b4\", \"#33a02c\", \"#e31a1c\", \"#ff7f00\"), circular_patches = TRUE )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"symbol-layers","dir":"Articles","previous_headings":"","what":"Symbol layers","title":"Layers overview","text":"Symbol layers offer wide range arguments customizing icon label appearance; however arguments work icons. icon_image argument look string represents icon found map style’s sprite. Read sprites .","code":"mapboxgl(style = mapbox_style(\"light\"), bounds = random_points) |> add_symbol_layer( id = \"points-of-interest\", source = random_points, icon_image = get_column(\"category\"), icon_allow_overlap = TRUE, tooltip = \"category\" )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"heatmap-layers","dir":"Articles","previous_headings":"","what":"Heatmap layers","title":"Layers overview","text":"Heatmap layers take object geometry type POINT visualize density points visually attractive way. add_heatmap_layer() takes sf POINT objects; example shows read remote GeoJSON file source well.","code":"library(mapgl) mapboxgl(style = mapbox_style(\"dark\"), center = c(-120, 50), zoom = 2) |> add_heatmap_layer( id = \"earthquakes-heat\", source = list( type = \"geojson\", data = \"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\" ), heatmap_weight = interpolate( column = \"mag\", values = c(0, 6), stops = c(0, 1) ), heatmap_intensity = interpolate( property = \"zoom\", values = c(0, 9), stops = c(1, 3) ), heatmap_color = interpolate( property = \"heatmap-density\", values = seq(0, 1, 0.2), stops = c('rgba(33,102,172,0)', 'rgb(103,169,207)', 'rgb(209,229,240)', 'rgb(253,219,199)', 'rgb(239,138,98)', 'rgb(178,24,43)') ), heatmap_opacity = 0.7 )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"fill-extrusion-layers","dir":"Articles","previous_headings":"","what":"Fill-extrusion layers","title":"Layers overview","text":"","code":"library(mapgl) maplibre( style = maptiler_style(\"basic\"), center = c(-74.0066, 40.7135), zoom = 15.5, pitch = 45, bearing = -17.6 ) |> add_vector_source( id = \"openmaptiles\", url = paste0(\"https://api.maptiler.com/tiles/v3/tiles.json?key=\", Sys.getenv(\"MAPTILER_API_KEY\")) ) |> add_fill_extrusion_layer( id = \"3d-buildings\", source = 'openmaptiles', source_layer = 'building', fill_extrusion_color = interpolate( column = 'render_height', values = c(0, 200, 400), stops = c('lightgray', 'royalblue', 'lightblue') ), fill_extrusion_height = list( 'interpolate', list('linear'), list('zoom'), 15, 0, 16, list('get', 'render_height') ) )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"raster-layers","dir":"Articles","previous_headings":"","what":"Raster layers","title":"Layers overview","text":"mapgl supports rasters terra package passed data argument add_image_source() function, visualized add_raster_layer(). Remote raster sources (shown ) can also added add_image_source() remotely-hosted image files, add_raster_source() remotely-hosted raster tiles.","code":"mapboxgl(style = mapbox_style(\"dark\"), zoom = 5, center = c(-75.789, 41.874)) |> add_image_source( id = \"radar\", url = \"https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif\", coordinates = list( c(-80.425, 46.437), c(-71.516, 46.437), c(-71.516, 37.936), c(-80.425, 37.936) ) ) |> add_raster_layer( id = 'radar-layer', source = 'radar', raster_fade_duration = 0 )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"markers","dir":"Articles","previous_headings":"","what":"Markers","title":"Layers overview","text":"Markers represent unique visual component Mapbox GL JS MapLibre GL JS, highlight locations count map layers. mapgl, users can add markers using add_markers() function. single marker can added length-2 vector longitude latitude; list length-2 vectors sf POINT object add multiple markers.","code":"mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.006, 40.7128), zoom = 10 ) |> add_markers( c(-74.006, 40.7128), color = \"blue\", rotation = 45, popup = \"A marker\" )"},{"path":"https://walker-data.com/mapgl/articles/map-design.html","id":"continuous-styling","dir":"Articles","previous_headings":"","what":"Continuous styling","title":"Fundamentals of map design with mapgl","text":"Styling Mapbox GL JS Maplibre GL JS typically handled expressions. Expressions allow quite bit customization map-makers, can feel clunky R users. mapgl includes several functions help R users translate code expressions use data visualizations. interpolate() function create interpolate expression, smoothly transitions values series stops. means can natively create just color palette want map palette seamlessly data. , specify two values - 20 80 - map colors “lightblue” “darkblue” values. Mapbox GL JS smoothly interpolate colors light blue dark blue map data values found specified column. add_legend() function adds legend map. mapgl’s initial release, add_legend() automatically populate values style. gives users much flexibility format legend, though users also need take care ensure legend appropriately represents data. Future updates package may include functionality automated legends.","code":"fl_map |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = interpolate( column = \"estimate\", values = c(20, 80), stops = c(\"lightblue\", \"darkblue\"), na_color = \"lightgrey\" ), fill_opacity = 0.5 ) |> add_legend( \"Median age in Florida\", values = c(20, 80), colors = c(\"lightblue\", \"darkblue\") )"},{"path":"https://walker-data.com/mapgl/articles/map-design.html","id":"categorical-styling","dir":"Articles","previous_headings":"","what":"Categorical styling","title":"Fundamentals of map design with mapgl","text":"Cartographers may prefer binned method visualizing data rather continuous palette shown . Mapbox GL JS MapLibre, binned maps can created step expression. step_expr() function helps R users assemble expression. Step expressions may feel little unfamiliar R users, require base value followed series stops. example , generate five-color palette ColorBrewer. first color used base, four colors stops. values specify bin edges.","code":"brewer_pal <- RColorBrewer::brewer.pal(5, \"RdYlBu\") fl_map |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = step_expr( column = \"estimate\", base = brewer_pal[1], stops = brewer_pal[2:5], values = seq(25, 70, 15), na_color = \"white\" ), fill_opacity = 0.5 ) |> add_legend( \"Median age in Florida\", values = c( \"Under 25\", \"25-40\", \"40-55\", \"55-70\", \"Above 70\" ), colors = brewer_pal, type = \"categorical\" )"},{"path":"https://walker-data.com/mapgl/articles/map-design.html","id":"pop-ups-tooltips-and-highlighting","dir":"Articles","previous_headings":"","what":"Pop-ups, tooltips, and highlighting","title":"Fundamentals of map design with mapgl","text":"Mapmakers often want expose additional interactivity users form -click popups, hover tooltips, hover effects. native JavaScript, can tricky set requires knowledge events, queries, feature states libraries. mapgl wraps functionality make features accessible R users. popup tooltip arguments take string input representing name column display click hover. arguments accommodate HTML, best way set create column values display popup tooltip, use column adding layer. Hover effects can set hover_options argument. argument takes list key-value pairs keys arguments given layer type (case, fill layer) arguments desired values hover. example shown , tell Mapbox GL JS change Census tract’s fill yellow fill opacity 1 users hovers tract.","code":"fl_age$popup <- glue::glue( \"GEOID: <\/strong>{fl_age$GEOID}
    Median age: <\/strong>{fl_age$estimate}\" ) fl_map |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = interpolate( column = \"estimate\", values = c(20, 80), stops = c(\"lightblue\", \"darkblue\"), na_color = \"lightgrey\" ), fill_opacity = 0.5, popup = \"popup\", tooltip = \"estimate\", hover_options = list( fill_color = \"yellow\", fill_opacity = 1 ) ) |> add_legend( \"Median age in Florida\", values = c(20, 80), colors = c(\"lightblue\", \"darkblue\") )"},{"path":"https://walker-data.com/mapgl/articles/shiny.html","id":"map-inputs","dir":"Articles","previous_headings":"","what":"Map inputs","title":"Using mapgl with Shiny","text":"number map events built-working mapgl Shiny session exposed user inputs. include: input$MAPID_center: center coordinates map (named lng lat); input$MAPID_zoom: current zoom level map; input$MAPID_bbox: bounding box visible extent map, named xmin, xmax, ymin, ymax. input$MAPID_click: longitude latitude click, named lng lat, timestamp click, named time. Visible features map can also queried clicked. Clicking map Shiny returns input$MAPID_feature_click, gets layer ID, column values clicked feature (accessible properties), well coordinates time click. Try example see works:","code":"ui <- page_sidebar( title = \"mapgl with Shiny\", sidebar = sidebar( verbatimTextOutput(\"clicked_feature\") ), card( full_screen = TRUE, maplibreOutput(\"map\") ) ) server <- function(input, output, session) { output$map <- renderMaplibre({ maplibre(style = carto_style(\"positron\")) |> fit_bounds(nc, animate = FALSE) |> add_fill_layer(id = \"nc_data\", source = nc, fill_color = \"blue\", fill_opacity = 0.5) }) output$clicked_feature <- renderPrint({ req(input$map_feature_click) input$map_feature_click }) } shinyApp(ui, server)"},{"path":"https://walker-data.com/mapgl/articles/shiny.html","id":"shiny-specific-functions","dir":"Articles","previous_headings":"","what":"Shiny-specific functions","title":"Using mapgl with Shiny","text":"mapgl includes number functions help interact maps data Shiny session, likely add future. include: set_style(), modify underlying style (basemap) map; set_layout_property(), modify layout property map (whether layer displayed); set_paint_property(), modify styling layer; set_filter(), dynamically filters displayed data layer based input value. ’ll need build filter expressionto achieve ; using list() R translate square brackets JavaScript. plans make easier users future. ’ll use functions combination proxy object, familiar users coming Leaflet R mapping packages. map proxy preserves existing state map, allows edit components without re-drawing entire map app. ’ll use mapboxgl_proxy() Mapbox maps, maplibre_proxy() MapLibre maps. Try example uses color picker widget change color map, slider filter visible counties based expression.","code":"library(colourpicker) ui <- page_sidebar( title = \"mapgl with Shiny\", sidebar = sidebar( colourInput(\"color\", \"Select a color\", value = \"blue\"), sliderInput(\"slider\", \"Show BIR74 values above:\", value = 248, min = 248, max = 21588) ), card( full_screen = TRUE, maplibreOutput(\"map\") ) ) server <- function(input, output, session) { output$map <- renderMaplibre({ maplibre(style = carto_style(\"positron\")) |> fit_bounds(nc, animate = FALSE) |> add_fill_layer(id = \"nc_data\", source = nc, fill_color = \"blue\", fill_opacity = 0.5) }) observeEvent(input$color, { maplibre_proxy(\"map\") |> set_paint_property(\"nc_data\", \"fill-color\", input$color) }) observeEvent(input$slider, { maplibre_proxy(\"map\") |> set_filter(\"nc_data\", list(\">=\", get_column(\"BIR74\"), input$slider)) }) } shinyApp(ui, server)"},{"path":"https://walker-data.com/mapgl/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Kyle Walker. Author, maintainer.","code":""},{"path":"https://walker-data.com/mapgl/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Walker K (2024). mapgl: Interactive Maps 'Mapbox GL JS' 'MapLibre GL JS'. R package version 0.1.4, https://walker-data.com/mapgl/.","code":"@Manual{, title = {mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS'}, author = {Kyle Walker}, year = {2024}, note = {R package version 0.1.4}, url = {https://walker-data.com/mapgl/}, }"},{"path":"https://walker-data.com/mapgl/index.html","id":"mapgl-","dir":"","previous_headings":"","what":"mapgl: WebGL Maps in R with Mapbox and MapLibre","title":"mapgl: WebGL Maps in R with Mapbox and MapLibre","text":"mapgl R package makes latest versions Mapbox GL JS MapLibre GL JS available R users. package interface designed make powerful capabilities libraries available R mapping projects, also feel similar users coming R mapping packages. Install CRAN: , install development version GitHub: Read vignettes learn use package: Getting started mapgl Using layers: overview Fundamentals map design mapgl Using mapgl Shiny","code":"install.packages(\"mapgl\") remotes::install_github(\"walkerke/mapgl\")"},{"path":"https://walker-data.com/mapgl/index.html","id":"recommended-training-and-how-to-learn-more","dir":"","previous_headings":"","what":"Recommended training and how to learn more","title":"mapgl: WebGL Maps in R with Mapbox and MapLibre","text":"find project useful work like ensure continued development package, can provide support following ways: Purchase official mapgl workshop series, hosted mapgl’s author, Kyle Walker; Chip funds support package development via PayPal; Set consulting engagement workshop though Walker Data help implement mapgl project. Send note kyle@walker-data.com interested; File issue - even better, pull request - https://github.com/walkerke/mapgl/issues. stay top package updates / new features get information mapgl trainings, sure sign Walker Data mailing list .","code":""},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"function adds categorical legend Mapbox GL map. supports customizable colors, sizes, shapes legend items.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"","code":"add_categorical_legend( map, legend_title, values, colors, circular_patches = FALSE, position = \"top-left\", unique_id = NULL, sizes = NULL, add = FALSE, width = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"map map object created mapboxgl function. legend_title title legend. values vector categories values displayed legend. colors corresponding colors values. Can vector colors single color. circular_patches Logical, whether use circular patches legend. Default FALSE. position position legend map. One \"top-left\", \"bottom-left\", \"top-right\", \"bottom-right\". Default \"top-left\". unique_id unique ID legend container. NULL, random ID generated. sizes optional numeric vector sizes legend patches, single numeric value. provided vector, length values. circular_patches FALSE (square patches), sizes represent width height patch pixels. circular_patches TRUE, sizes represent radius circle. add Logical, whether add legend existing legends (TRUE) replace existing legends (FALSE). Default FALSE. width width legend. Can specified pixels (e.g., \"250px\") \"auto\". Default NULL, uses built-default.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"updated map object legend added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"","code":"if (FALSE) { # \\dontrun{ library(mapboxgl) map <- mapboxgl( center = c(-96, 37.8), zoom = 3 ) map %>% add_categorical_legend( legend_title = \"Population\", values = c(\"Low\", \"Medium\", \"High\"), colors = c(\"#FED976\", \"#FEB24C\", \"#FD8D3C\"), circular_patches = TRUE, sizes = c(10, 15, 20), width = \"300px\" ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a circle layer to a Mapbox GL map — add_circle_layer","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"Add circle layer Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"","code":"add_circle_layer( map, id, source, source_layer = NULL, circle_blur = NULL, circle_color = NULL, circle_opacity = NULL, circle_radius = NULL, circle_sort_key = NULL, circle_stroke_color = NULL, circle_stroke_opacity = NULL, circle_stroke_width = NULL, circle_translate = NULL, circle_translate_anchor = \"map\", visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL, cluster_options = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"map map object created mapboxgl function. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). circle_blur Amount blur circle. circle_color color circle. circle_opacity opacity circle drawn. circle_radius Circle radius. circle_sort_key Sorts features ascending order based value. circle_stroke_color color circle's stroke. circle_stroke_opacity opacity circle's stroke. circle_stroke_width width circle's stroke. circle_translate geometry's offset. Values c(x, y) negatives indicate left . circle_translate_anchor Controls frame reference circle-translate. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer. cluster_options list options clustering circles, created cluster_options() function.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"modified map object new circle layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(sf) library(dplyr) # Set seed for reproducibility set.seed(1234) # Define the bounding box for Washington DC (approximately) bbox <- st_bbox( c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), crs = st_crs(4326) ) # Generate 30 random points within the bounding box random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox[\"xmin\"], bbox[\"xmax\"]), lat = runif(30, bbox[\"ymin\"], bbox[\"ymax\"]) ), coords = c(\"lon\", \"lat\"), crs = 4326 ) # Assign random categories categories <- c(\"music\", \"bar\", \"theatre\", \"bicycle\") random_points <- random_points %>% mutate(category = sample(categories, n(), replace = TRUE)) # Map with circle layer mapboxgl(style = mapbox_style(\"light\")) %>% fit_bounds(random_points, animate = FALSE) %>% add_circle_layer( id = \"poi-layer\", source = random_points, circle_color = match_expr( \"category\", values = c( \"music\", \"bar\", \"theatre\", \"bicycle\" ), stops = c( \"#1f78b4\", \"#33a02c\", \"#e31a1c\", \"#ff7f00\" ) ), circle_radius = 8, circle_stroke_color = \"#ffffff\", circle_stroke_width = 2, circle_opacity = 0.8, tooltip = \"category\", hover_options = list( circle_radius = 12, circle_color = \"#ffff99\" ) ) %>% add_categorical_legend( legend_title = \"Points of Interest\", values = c(\"Music\", \"Bar\", \"Theatre\", \"Bicycle\"), colors = c(\"#1f78b4\", \"#33a02c\", \"#e31a1c\", \"#ff7f00\"), circular_patches = TRUE ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_continuous_legend.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a continuous legend — add_continuous_legend","title":"Add a continuous legend — add_continuous_legend","text":"Add continuous legend","code":""},{"path":"https://walker-data.com/mapgl/reference/add_continuous_legend.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a continuous legend — add_continuous_legend","text":"","code":"add_continuous_legend( map, legend_title, values, colors, position = \"top-left\", unique_id = NULL, add = FALSE, width = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_continuous_legend.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a continuous legend — add_continuous_legend","text":"map map object created mapboxgl function. legend_title title legend. values values represented map (vector stops). colors colors used generate color ramp. position position legend map (one \"top-left\", \"bottom-left\", \"top-right\", \"bottom-right\"). unique_id unique ID legend container. Defaults NULL. add Logical, whether add legend existing legends (TRUE) replace existing legends (FALSE). Default FALSE. width width legend. Can specified pixels (e.g., \"250px\") \"auto\". Default NULL, uses built-default.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_continuous_legend.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a continuous legend — add_continuous_legend","text":"updated map object legend added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a draw control to a map — add_draw_control","title":"Add a draw control to a map — add_draw_control","text":"Add draw control map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a draw control to a map — add_draw_control","text":"","code":"add_draw_control( map, position = \"top-left\", freehand = FALSE, simplify_freehand = FALSE, orientation = \"vertical\", ... )"},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a draw control to a map — add_draw_control","text":"map map object created mapboxgl maplibre functions. position string specifying position draw control. One \"top-right\", \"top-left\", \"bottom-right\", \"bottom-left\". freehand Logical, whether enable freehand drawing mode. Default FALSE. simplify_freehand Logical, whether apply simplification freehand drawings. Default FALSE. orientation string specifying orientation draw control. Either \"vertical\" (default) \"horizontal\". ... Additional named arguments. See https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md#options list options.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a draw control to a map — add_draw_control","text":"modified map object draw control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a draw control to a map — add_draw_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.50, 40), zoom = 9 ) |> add_draw_control() } # }"},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"Add fill-extrusion layer Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"","code":"add_fill_extrusion_layer( map, id, source, source_layer = NULL, fill_extrusion_base = NULL, fill_extrusion_color = NULL, fill_extrusion_height = NULL, fill_extrusion_opacity = NULL, fill_extrusion_pattern = NULL, fill_extrusion_translate = NULL, fill_extrusion_translate_anchor = \"map\", visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"map map object created mapboxgl function. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). fill_extrusion_base base height fill extrusion. fill_extrusion_color color fill extrusion. fill_extrusion_height height fill extrusion. fill_extrusion_opacity opacity fill extrusion. fill_extrusion_pattern Name image sprite use drawing image fills. fill_extrusion_translate geometry's offset. Values c(x, y) negatives indicate left . fill_extrusion_translate_anchor Controls frame reference fill-extrusion-translate. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"modified map object new fill-extrusion layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) maplibre( style = maptiler_style(\"basic\"), center = c(-74.0066, 40.7135), zoom = 15.5, pitch = 45, bearing = -17.6 ) |> add_vector_source( id = \"openmaptiles\", url = paste0( \"https://api.maptiler.com/tiles/v3/tiles.json?key=\", Sys.getenv(\"MAPTILER_API_KEY\") ) ) |> add_fill_extrusion_layer( id = \"3d-buildings\", source = \"openmaptiles\", source_layer = \"building\", fill_extrusion_color = interpolate( column = \"render_height\", values = c(0, 200, 400), stops = c(\"lightgray\", \"royalblue\", \"lightblue\") ), fill_extrusion_height = list( \"interpolate\", list(\"linear\"), list(\"zoom\"), 15, 0, 16, list(\"get\", \"render_height\") ) ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a fill layer to a map — add_fill_layer","title":"Add a fill layer to a map — add_fill_layer","text":"Add fill layer map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a fill layer to a map — add_fill_layer","text":"","code":"add_fill_layer( map, id, source, source_layer = NULL, fill_antialias = TRUE, fill_color = NULL, fill_emissive_strength = NULL, fill_opacity = NULL, fill_outline_color = NULL, fill_pattern = NULL, fill_sort_key = NULL, fill_translate = NULL, fill_translate_anchor = \"map\", fill_z_offset = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a fill layer to a map — add_fill_layer","text":"map map object created mapboxgl maplibre functions. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). fill_antialias Whether fill antialiased. fill_color color filled part layer. fill_emissive_strength Controls intensity light emitted source features. fill_opacity opacity entire fill layer. fill_outline_color outline color fill. fill_pattern Name image sprite use drawing image fills. fill_sort_key Sorts features ascending order based value. fill_translate geometry's offset. Values c(x, y) negatives indicate left . fill_translate_anchor Controls frame reference fill-translate. fill_z_offset Specifies uniform elevation meters. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a fill layer to a map — add_fill_layer","text":"modified map object new fill layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a fill layer to a map — add_fill_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(tidycensus) fl_age <- get_acs( geography = \"tract\", variables = \"B01002_001\", state = \"FL\", year = 2022, geometry = TRUE ) mapboxgl() |> fit_bounds(fl_age, animate = FALSE) |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = interpolate( column = \"estimate\", values = c(20, 80), stops = c(\"lightblue\", \"darkblue\"), na_color = \"lightgrey\" ), fill_opacity = 0.5 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a fullscreen control to a map — add_fullscreen_control","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"Add fullscreen control map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"","code":"add_fullscreen_control(map, position = \"top-right\")"},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"map map object created mapboxgl maplibre functions. position string specifying position fullscreen control. One \"top-right\", \"top-left\", \"bottom-right\", \"bottom-left\".","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"modified map object fullscreen control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) maplibre( style = maptiler_style(\"streets\"), center = c(11.255, 43.77), zoom = 13 ) |> add_fullscreen_control(position = \"top-right\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a geocoder control to a map — add_geocoder_control","title":"Add a geocoder control to a map — add_geocoder_control","text":"function adds Geocoder search bar Mapbox GL MapLibre GL map. default, marker added selected location map fly location. results geocode accessible Shiny session input$MAPID_geocoder$result, MAPID name map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a geocoder control to a map — add_geocoder_control","text":"","code":"add_geocoder_control( map, position = \"top-right\", placeholder = \"Search\", collapsed = FALSE, ... )"},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a geocoder control to a map — add_geocoder_control","text":"map map object created mapboxgl maplibre function. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"top-right\". placeholder string use placeholder text search bar. Default \"Search\". collapsed Whether control collapsed hovered clicked. Default FALSE. ... Additional parameters pass Geocoder.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a geocoder control to a map — add_geocoder_control","text":"modified map object geocoder control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a geocoder control to a map — add_geocoder_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_geocoder_control(position = \"top-left\", placeholder = \"Enter an address\") maplibre() |> add_geocoder_control(position = \"top-right\", placeholder = \"Search location\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a geolocate control to a map — add_geolocate_control","title":"Add a geolocate control to a map — add_geolocate_control","text":"function adds Geolocate control Mapbox GL MapLibre GL map. geolocate control allows users track current location map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a geolocate control to a map — add_geolocate_control","text":"","code":"add_geolocate_control( map, position = \"top-right\", track_user = FALSE, show_accuracy_circle = TRUE, show_user_location = TRUE, show_user_heading = FALSE, fit_bounds_options = list(maxZoom = 15), position_options = list(enableHighAccuracy = FALSE, timeout = 6000) )"},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a geolocate control to a map — add_geolocate_control","text":"map map object created mapboxgl maplibre functions. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"top-right\". track_user Whether actively track user's location. TRUE, map continuously update user moves. Default FALSE. show_accuracy_circle Whether show circle indicating accuracy location. Default TRUE. show_user_location Whether show dot user's location. Default TRUE. show_user_heading Whether show arrow indicating device's heading tracking location. works track_user TRUE. Default FALSE. fit_bounds_options list options fitting bounds panning user's location. Default maxZoom 15. position_options list Geolocation API position options. Default enableHighAccuracy=FALSE timeout=6000.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a geolocate control to a map — add_geolocate_control","text":"modified map object geolocate control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a geolocate control to a map — add_geolocate_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_geolocate_control( position = \"top-right\", track_user = TRUE, show_user_heading = TRUE ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a Globe Minimap to a map — add_globe_minimap","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"function adds globe minimap control Mapbox GL Maplibre map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"","code":"add_globe_minimap( map, position = \"bottom-right\", globe_size = 82, land_color = \"white\", water_color = \"rgba(30 40 70/60%)\", marker_color = \"#ff2233\", marker_size = 1 )"},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"map mapboxgl maplibre object. position string specifying position minimap. globe_size Number pixels diameter globe. Default 82. land_color HTML color use land areas globe. Default 'white'. water_color HTML color use water areas globe. Default 'rgba(30 40 70/60%)'. marker_color HTML color use center point marker. Default '#ff2233'. marker_size Scale ratio center point marker. Default 1.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"modified map object globe minimap added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) m <- mapboxgl() %>% add_globe_minimap() m <- maplibre() %>% add_globe_minimap() } # }"},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"Add heatmap layer Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"","code":"add_heatmap_layer( map, id, source, source_layer = NULL, heatmap_color = NULL, heatmap_intensity = NULL, heatmap_opacity = NULL, heatmap_radius = NULL, heatmap_weight = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"map map object created mapboxgl function. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). heatmap_color color heatmap points. heatmap_intensity intensity heatmap points. heatmap_opacity opacity heatmap layer. heatmap_radius radius influence individual heatmap point. heatmap_weight weight individual heatmap point. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"modified map object new heatmap layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl( style = mapbox_style(\"dark\"), center = c(-120, 50), zoom = 2 ) |> add_heatmap_layer( id = \"earthquakes-heat\", source = list( type = \"geojson\", data = \"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\" ), heatmap_weight = interpolate( column = \"mag\", values = c(0, 6), stops = c(0, 1) ), heatmap_intensity = interpolate( property = \"zoom\", values = c(0, 9), stops = c(1, 3) ), heatmap_color = interpolate( property = \"heatmap-density\", values = seq(0, 1, 0.2), stops = c( \"rgba(33,102,172,0)\", \"rgb(103,169,207)\", \"rgb(209,229,240)\", \"rgb(253,219,199)\", \"rgb(239,138,98)\", \"rgb(178,24,43)\" ) ), heatmap_opacity = 0.7 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":null,"dir":"Reference","previous_headings":"","what":"Add an image to the map — add_image","title":"Add an image to the map — add_image","text":"function adds image map's style. image can used icon-image, background-pattern, fill-pattern, line-pattern.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add an image to the map — add_image","text":"","code":"add_image( map, id, url, content = NULL, pixel_ratio = 1, sdf = FALSE, stretch_x = NULL, stretch_y = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add an image to the map — add_image","text":"map map object created mapboxgl maplibre functions. id string specifying ID image. url string specifying URL image loaded path local image file. Must PNG JPEG format. content vector four numbers c(x1, y1, x2, y2) defining part image can covered content text-field icon-text-fit used. pixel_ratio number specifying ratio pixels image physical pixels screen. sdf logical value indicating whether image interpreted SDF image. stretch_x list number pairs defining part(s) image can stretched horizontally. stretch_y list number pairs defining part(s) image can stretched vertically.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add an image to the map — add_image","text":"modified map object image added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add an image to the map — add_image","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) # Path to your local image file OR a URL to a remote image file # that is not blocked by CORS restrictions image_path <- \"/path/to/your/image.png\" pts <- tigris::landmarks(\"DE\")[1:100, ] maplibre(bounds = pts) |> add_image(\"local_icon\", image_path) |> add_symbol_layer( id = \"local_icons\", source = pts, icon_image = \"local_icon\", icon_size = 0.5, icon_allow_overlap = TRUE ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_image_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","title":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","text":"Add image source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","text":"","code":"add_image_source( map, id, url = NULL, data = NULL, coordinates = NULL, colors = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_image_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing image source. data SpatRaster object terra package RasterLayer object. coordinates list coordinates specifying image corners clockwise order: top left, top right, bottom right, bottom left. SpatRaster RasterLayer objects, extracted . colors vector colors use raster image.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a layer to a map from a source — add_layer","title":"Add a layer to a map from a source — add_layer","text":"many cases, use add_layer() internal layer-specific functions mapgl. Advanced users want use add_layer() fine-grained control appearance layers.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a layer to a map from a source — add_layer","text":"","code":"add_layer( map, id, type = \"fill\", source, source_layer = NULL, paint = list(), layout = list(), slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a layer to a map from a source — add_layer","text":"map map object created mapboxgl() maplibre() functions. id unique ID layer. type type layer (e.g., \"fill\", \"line\", \"circle\"). source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). paint list paint properties layer. layout list layout properties layer. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a layer to a map from a source — add_layer","text":"modified map object new layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a layer to a map from a source — add_layer","text":"","code":"if (FALSE) { # \\dontrun{ # Load necessary libraries library(mapgl) library(tigris) # Load geojson data for North Carolina tracts nc_tracts <- tracts(state = \"NC\", cb = TRUE) # Create a Mapbox GL map map <- mapboxgl( style = mapbox_style(\"light\"), center = c(-79.0193, 35.7596), zoom = 7 ) # Add a source and fill layer for North Carolina tracts map %>% add_source( id = \"nc-tracts\", data = nc_tracts ) %>% add_layer( id = \"nc-layer\", type = \"fill\", source = \"nc-tracts\", paint = list( \"fill-color\" = \"#888888\", \"fill-opacity\" = 0.4 ) ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a layers control to the map — add_layers_control","title":"Add a layers control to the map — add_layers_control","text":"Add layers control map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a layers control to the map — add_layers_control","text":"","code":"add_layers_control( map, position = \"top-left\", layers = NULL, collapsible = FALSE )"},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a layers control to the map — add_layers_control","text":"map map object. position position control map (one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\"). layers vector layer IDs included control. NULL, layers included. collapsible Whether control collapsible.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a layers control to the map — add_layers_control","text":"modified map object layers control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a layers control to the map — add_layers_control","text":"","code":"if (FALSE) { # \\dontrun{ library(tigris) options(tigris_use_cache = TRUE) rds <- roads(\"TX\", \"Tarrant\") tr <- tracts(\"TX\", \"Tarrant\", cb = TRUE) maplibre() |> fit_bounds(rds) |> add_fill_layer( id = \"Census tracts\", source = tr, fill_color = \"purple\", fill_opacity = 0.6 ) |> add_line_layer( \"Local roads\", source = rds, line_color = \"pink\" ) |> add_layers_control(collapsible = TRUE) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_legend.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a legend to a Mapbox GL map — add_legend","title":"Add a legend to a Mapbox GL map — add_legend","text":"Add legend Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_legend.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a legend to a Mapbox GL map — add_legend","text":"","code":"add_legend( map, legend_title, values, colors, type = c(\"continuous\", \"categorical\"), circular_patches = FALSE, position = \"top-left\", sizes = NULL, add = FALSE, width = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_legend.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a legend to a Mapbox GL map — add_legend","text":"map map object created mapboxgl function. legend_title title legend. values values represented map (either vector categories vector stops). colors corresponding colors values (either vector colors, single color, interpolate function). type One \"continuous\" \"categorical\". circular_patches Logical, whether use circular patches legend (categorical legends). position position legend map (one \"top-left\", \"bottom-left\", \"top-right\", \"bottom-right\"). sizes optional numeric vector sizes legend patches, single numeric value (categorical legends). add Logical, whether add legend existing legends (TRUE) replace existing legends (FALSE). Default FALSE. width width legend. Can specified pixels (e.g., \"250px\") \"auto\". Default NULL, uses built-default.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_legend.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a legend to a Mapbox GL map — add_legend","text":"updated map object legend added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a line layer to a map — add_line_layer","title":"Add a line layer to a map — add_line_layer","text":"Add line layer map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a line layer to a map — add_line_layer","text":"","code":"add_line_layer( map, id, source, source_layer = NULL, line_blur = NULL, line_cap = NULL, line_color = NULL, line_dasharray = NULL, line_emissive_strength = NULL, line_gap_width = NULL, line_gradient = NULL, line_join = NULL, line_miter_limit = NULL, line_occlusion_opacity = NULL, line_offset = NULL, line_opacity = NULL, line_pattern = NULL, line_round_limit = NULL, line_sort_key = NULL, line_translate = NULL, line_translate_anchor = \"map\", line_trim_color = NULL, line_trim_fade_range = NULL, line_trim_offset = NULL, line_width = NULL, line_z_offset = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a line layer to a map — add_line_layer","text":"map map object created mapboxgl maplibre functions. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). line_blur Amount blur line, pixels. line_cap display line endings. One \"butt\", \"round\", \"square\". line_color color line drawn. line_dasharray Specifies lengths alternating dashes gaps form dash pattern. line_emissive_strength Controls intensity light emitted source features. line_gap_width Draws line casing outside line's actual path. Value indicates width inner gap. line_gradient gradient used color line feature various distances along length. line_join display lines joining. line_miter_limit Used automatically convert miter joins bevel joins sharp angles. line_occlusion_opacity Opacity multiplier line part occluded 3D objects. line_offset line's offset. line_opacity opacity line drawn. line_pattern Name image sprite use drawing image lines. line_round_limit Used automatically convert round joins miter joins shallow angles. line_sort_key Sorts features ascending order based value. line_translate geometry's offset. Values c(x, y) negatives indicate left , respectively. line_translate_anchor Controls frame reference line-translate. line_trim_color color used rendering trimmed line section. line_trim_fade_range fade range trim-start trim-end points. line_trim_offset line part c(trim_start, trim_end) painted using line_trim_color. line_width Stroke thickness. line_z_offset Vertical offset ground, meters. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels) filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a line layer to a map — add_line_layer","text":"modified map object new line layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a line layer to a map — add_line_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(tigris) loving_roads <- roads(\"TX\", \"Loving\") maplibre(style = maptiler_style(\"backdrop\")) |> fit_bounds(loving_roads) |> add_line_layer( id = \"tracks\", source = loving_roads, line_color = \"navy\", line_opacity = 0.7 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":null,"dir":"Reference","previous_headings":"","what":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"Add markers Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"","code":"add_markers( map, data, color = \"red\", rotation = 0, popup = NULL, marker_id = NULL, draggable = FALSE, ... )"},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"map map object created mapboxgl maplibre functions. data length-2 numeric vector coordinates, list length-2 numeric vectors, sf POINT object. color color marker (default \"red\"). rotation rotation marker (default 0). popup column name popups (data sf object) string single popup (data numeric vector list vectors). marker_id unique ID marker. lists, names inherited list names. sf objects, column name. draggable boolean indicating marker draggable (default FALSE). ... Additional options passed marker.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"modified map object markers added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(sf) # Create a map object map <- mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.006, 40.7128), zoom = 10 ) # Add a single draggable marker with an ID map <- add_markers( map, c(-74.006, 40.7128), color = \"blue\", rotation = 45, popup = \"A marker\", draggable = TRUE, marker_id = \"marker1\" ) # Add multiple markers from a named list of coordinates coords_list <- list(marker2 = c(-74.006, 40.7128), marker3 = c(-73.935242, 40.730610)) map <- add_markers( map, coords_list, color = \"green\", popup = \"Multiple markers\", draggable = TRUE ) # Create an sf POINT object points_sf <- st_as_sf(data.frame( id = c(\"marker4\", \"marker5\"), lon = c(-74.006, -73.935242), lat = c(40.7128, 40.730610) ), coords = c(\"lon\", \"lat\"), crs = 4326) points_sf$popup <- c(\"Point 1\", \"Point 2\") # Add multiple markers from an sf object with IDs from a column map <- add_markers( map, points_sf, color = \"red\", popup = \"popup\", draggable = TRUE, marker_id = \"id\" ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a navigation control to a map — add_navigation_control","title":"Add a navigation control to a map — add_navigation_control","text":"Add navigation control map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a navigation control to a map — add_navigation_control","text":"","code":"add_navigation_control( map, show_compass = TRUE, show_zoom = TRUE, visualize_pitch = FALSE, position = \"top-right\", orientation = \"vertical\" )"},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a navigation control to a map — add_navigation_control","text":"map map object created mapboxgl maplibre functions. show_compass Whether show compass button. show_zoom Whether show zoom-zoom-buttons. visualize_pitch Whether visualize pitch rotating X-axis compass. position position map control added. Possible values \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". orientation orientation navigation control. Can \"vertical\" (default) \"horizontal\".","code":""},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a navigation control to a map — add_navigation_control","text":"updated map object navigation control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a navigation control to a map — add_navigation_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_navigation_control(visualize_pitch = TRUE) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_raster_dem_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","title":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","text":"Add raster DEM source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_dem_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","text":"","code":"add_raster_dem_source(map, id, url, tileSize = 512, maxzoom = NULL)"},{"path":"https://walker-data.com/mapgl/reference/add_raster_dem_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing raster DEM source. tileSize size raster tiles. maxzoom maximum zoom level raster tiles.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_dem_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a raster layer to a Mapbox GL map — add_raster_layer","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"Add raster layer Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"","code":"add_raster_layer( map, id, source, source_layer = NULL, raster_brightness_max = NULL, raster_brightness_min = NULL, raster_contrast = NULL, raster_fade_duration = NULL, raster_hue_rotate = NULL, raster_opacity = NULL, raster_resampling = NULL, raster_saturation = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, before_id = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"map map object created mapboxgl function. id unique ID layer. source ID source. source_layer source layer (vector sources). raster_brightness_max maximum brightness image. raster_brightness_min minimum brightness image. raster_contrast Increase reduce brightness image. raster_fade_duration duration fade-/fade-effect. raster_hue_rotate Rotates hues around color wheel. raster_opacity opacity raster drawn. raster_resampling resampling/interpolation method use overscaling. raster_saturation Increase reduce saturation image. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels).","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"modified map object new raster layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"","code":"if (FALSE) { # \\dontrun{ mapboxgl( style = mapbox_style(\"dark\"), zoom = 5, center = c(-75.789, 41.874) ) |> add_image_source( id = \"radar\", url = \"https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif\", coordinates = list( c(-80.425, 46.437), c(-71.516, 46.437), c(-71.516, 37.936), c(-80.425, 37.936) ) ) |> add_raster_layer( id = \"radar-layer\", source = \"radar\", raster_fade_duration = 0 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_raster_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","title":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","text":"Add raster tile source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","text":"","code":"add_raster_source( map, id, url = NULL, tiles = NULL, tileSize = 256, maxzoom = 22 )"},{"path":"https://walker-data.com/mapgl/reference/add_raster_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing raster tile source. (optional) tiles vector tile URLs raster source. (optional) tileSize size raster tiles. maxzoom maximum zoom level raster tiles.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a reset control to a map — add_reset_control","title":"Add a reset control to a map — add_reset_control","text":"function adds reset control Mapbox GL MapLibre GL map. reset control allows users return original zoom level center.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a reset control to a map — add_reset_control","text":"","code":"add_reset_control(map, position = \"top-right\", animate = TRUE, duration = NULL)"},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a reset control to a map — add_reset_control","text":"map map object created mapboxgl maplibre functions. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"top-right\". animate Whether animate transition original map view; defaults TRUE. FALSE, view \"jump\" original view transition. duration length transition current view original view, specified milliseconds. argument works animate TRUE.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a reset control to a map — add_reset_control","text":"modified map object reset control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a reset control to a map — add_reset_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_reset_control(position = \"top-left\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a scale control to a map — add_scale_control","title":"Add a scale control to a map — add_scale_control","text":"function adds scale control Mapbox GL Maplibre GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a scale control to a map — add_scale_control","text":"","code":"add_scale_control( map, position = \"bottom-left\", unit = \"metric\", max_width = 100 )"},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a scale control to a map — add_scale_control","text":"map map object created mapboxgl maplibre functions. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"bottom-left\". unit unit scale. Can either \"imperial\", \"metric\", \"nautical\". Default \"metric\". max_width maximum length scale control pixels. Default 100.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a scale control to a map — add_scale_control","text":"modified map object scale control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a scale control to a map — add_scale_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_scale_control(position = \"bottom-right\", unit = \"imperial\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","title":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","text":"Add GeoJSON sf source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","text":"","code":"add_source(map, id, data, ...)"},{"path":"https://walker-data.com/mapgl/reference/add_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","text":"map map object created mapboxgl maplibre function. id unique ID source. data sf object URL pointing remote GeoJSON file. ... Additional arguments passed JavaScript addSource method.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a symbol layer to a map — add_symbol_layer","title":"Add a symbol layer to a map — add_symbol_layer","text":"Add symbol layer map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a symbol layer to a map — add_symbol_layer","text":"","code":"add_symbol_layer( map, id, source, source_layer = NULL, icon_allow_overlap = NULL, icon_anchor = NULL, icon_color = NULL, icon_color_brightness_max = NULL, icon_color_brightness_min = NULL, icon_color_contrast = NULL, icon_color_saturation = NULL, icon_emissive_strength = NULL, icon_halo_blur = NULL, icon_halo_color = NULL, icon_halo_width = NULL, icon_ignore_placement = NULL, icon_image = NULL, icon_image_cross_fade = NULL, icon_keep_upright = NULL, icon_offset = NULL, icon_opacity = NULL, icon_optional = NULL, icon_padding = NULL, icon_pitch_alignment = NULL, icon_rotate = NULL, icon_rotation_alignment = NULL, icon_size = NULL, icon_text_fit = NULL, icon_text_fit_padding = NULL, icon_translate = NULL, icon_translate_anchor = NULL, symbol_avoid_edges = NULL, symbol_placement = NULL, symbol_sort_key = NULL, symbol_spacing = NULL, symbol_z_elevate = NULL, symbol_z_order = NULL, text_allow_overlap = NULL, text_anchor = NULL, text_color = \"black\", text_emissive_strength = NULL, text_field = NULL, text_font = NULL, text_halo_blur = NULL, text_halo_color = NULL, text_halo_width = NULL, text_ignore_placement = NULL, text_justify = NULL, text_keep_upright = NULL, text_letter_spacing = NULL, text_line_height = NULL, text_max_angle = NULL, text_max_width = NULL, text_offset = NULL, text_opacity = NULL, text_optional = NULL, text_padding = NULL, text_pitch_alignment = NULL, text_radial_offset = NULL, text_rotate = NULL, text_rotation_alignment = NULL, text_size = NULL, text_transform = NULL, text_translate = NULL, text_translate_anchor = NULL, text_variable_anchor = NULL, text_writing_mode = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL, cluster_options = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a symbol layer to a map — add_symbol_layer","text":"map map object created mapboxgl maplibre functions. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). icon_allow_overlap TRUE, icon visible even collides previously drawn symbols. icon_anchor Part icon placed closest anchor. icon_color color icon. supported many Mapbox icons; read https://docs.mapbox.com/help/troubleshooting/using-recolorable-images--mapbox-maps/. icon_color_brightness_max maximum brightness icon color. icon_color_brightness_min minimum brightness icon color. icon_color_contrast contrast icon color. icon_color_saturation saturation icon color. icon_emissive_strength strength icon's emissive color. icon_halo_blur blur applied icon's halo. icon_halo_color color icon's halo. icon_halo_width width icon's halo. icon_ignore_placement TRUE, icon visible even collides symbols. icon_image Name image sprite use drawing image background. use values column input dataset, use get_column('YOUR_ICON_COLUMN_NAME'). Images can also loaded add_image() function precede add_symbol_layer() function. icon_image_cross_fade cross-fade parameter icon image. icon_keep_upright TRUE, icon kept upright. icon_offset Offset distance icon. icon_opacity opacity icon drawn. icon_optional TRUE, icon optional. icon_padding Padding around icon. icon_pitch_alignment Alignment icon respect pitch map. icon_rotate Rotates icon clockwise. icon_rotation_alignment Alignment icon respect map. icon_size size icon, specified relative original size image. example, value 5 make icon 5 times larger original size, whereas value 0.5 make icon half size original. icon_text_fit Scales text fit icon. icon_text_fit_padding Padding text fitting icon. icon_translate offset distance icon. icon_translate_anchor Controls frame reference icon-translate. symbol_avoid_edges TRUE, symbol avoided near edges. symbol_placement Placement symbol map. symbol_sort_key Sorts features ascending order based value. symbol_spacing Spacing symbols. symbol_z_elevate Elevates symbol z-axis. symbol_z_order Orders symbol z-axis. text_allow_overlap TRUE, text visible even collides previously drawn symbols. text_anchor Part text placed closest anchor. text_color color text. text_emissive_strength strength text's emissive color. text_field Value use text label. text_font Font stack use displaying text. text_halo_blur blur applied text's halo. text_halo_color color text's halo. text_halo_width width text's halo. text_ignore_placement TRUE, text visible even collides symbols. text_justify justification text. text_keep_upright TRUE, text kept upright. text_letter_spacing Spacing text letters. text_line_height Height text lines. text_max_angle Maximum angle text. text_max_width Maximum width text. text_offset Offset distance text. text_opacity opacity text drawn. text_optional TRUE, text optional. text_padding Padding around text. text_pitch_alignment Alignment text respect pitch map. text_radial_offset Radial offset text. text_rotate Rotates text clockwise. text_rotation_alignment Alignment text respect map. text_size size text. text_transform Transform applied text. text_translate offset distance text. text_translate_anchor Controls frame reference text-translate. text_variable_anchor Variable anchor text. text_writing_mode Writing mode text. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. elements SVG icons can styled. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer. cluster_options list options clustering symbols, created cluster_options() function.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a symbol layer to a map — add_symbol_layer","text":"modified map object new symbol layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a symbol layer to a map — add_symbol_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(sf) library(dplyr) # Set seed for reproducibility set.seed(1234) # Define the bounding box for Washington DC (approximately) bbox <- st_bbox( c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), crs = st_crs(4326) ) # Generate 30 random points within the bounding box random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox[\"xmin\"], bbox[\"xmax\"]), lat = runif(30, bbox[\"ymin\"], bbox[\"ymax\"]) ), coords = c(\"lon\", \"lat\"), crs = 4326 ) # Assign random icons icons <- c(\"music\", \"bar\", \"theatre\", \"bicycle\") random_points <- random_points |> mutate(icon = sample(icons, n(), replace = TRUE)) # Map with icons mapboxgl(style = mapbox_style(\"light\")) |> fit_bounds(random_points, animate = FALSE) |> add_symbol_layer( id = \"points-of-interest\", source = random_points, icon_image = c(\"get\", \"icon\"), icon_allow_overlap = TRUE, tooltip = \"icon\" ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_vector_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","title":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","text":"Add vector tile source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_vector_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","text":"","code":"add_vector_source(map, id, url)"},{"path":"https://walker-data.com/mapgl/reference/add_vector_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing vector tile source.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_vector_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_video_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","title":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","text":"Add video source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_video_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","text":"","code":"add_video_source(map, id, urls, coordinates)"},{"path":"https://walker-data.com/mapgl/reference/add_video_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","text":"map map object created mapboxgl maplibre function. id unique ID source. urls vector URLs pointing video sources. coordinates list coordinates specifying video corners clockwise order: top left, top right, bottom right, bottom left.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_video_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/carto_style.html","id":null,"dir":"Reference","previous_headings":"","what":"Get CARTO Style URL — carto_style","title":"Get CARTO Style URL — carto_style","text":"Get CARTO Style URL","code":""},{"path":"https://walker-data.com/mapgl/reference/carto_style.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get CARTO Style URL — carto_style","text":"","code":"carto_style(style_name)"},{"path":"https://walker-data.com/mapgl/reference/carto_style.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get CARTO Style URL — carto_style","text":"style_name name style (e.g., \"voyager\", \"positron\", \"dark-matter\").","code":""},{"path":"https://walker-data.com/mapgl/reference/carto_style.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get CARTO Style URL — carto_style","text":"style URL corresponding given style name.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_controls.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","title":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","text":"Clear controls Mapbox GL Maplibre GL map Shiny app","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_controls.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","text":"","code":"clear_controls(map)"},{"path":"https://walker-data.com/mapgl/reference/clear_controls.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","text":"map map object created mapboxgl maplibre function.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_controls.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","text":"modified map object controls removed.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear a layer from a map using a proxy — clear_layer","title":"Clear a layer from a map using a proxy — clear_layer","text":"function allows layer removed existing Mapbox GL map using proxy object.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear a layer from a map using a proxy — clear_layer","text":"","code":"clear_layer(proxy, layer_id)"},{"path":"https://walker-data.com/mapgl/reference/clear_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear a layer from a map using a proxy — clear_layer","text":"proxy proxy object created mapboxgl_proxy maplibre_proxy. layer_id ID layer removed.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear a layer from a map using a proxy — clear_layer","text":"updated proxy object.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_legend.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear legend from a map in a proxy session — clear_legend","title":"Clear legend from a map in a proxy session — clear_legend","text":"Clear legend map proxy session","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_legend.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear legend from a map in a proxy session — clear_legend","text":"","code":"clear_legend(map)"},{"path":"https://walker-data.com/mapgl/reference/clear_legend.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear legend from a map in a proxy session — clear_legend","text":"map map object created mapboxgl_proxy maplibre_proxy function.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_legend.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear legend from a map in a proxy session — clear_legend","text":"updated map object legend cleared.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_markers.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear markers from a map in a Shiny session — clear_markers","title":"Clear markers from a map in a Shiny session — clear_markers","text":"Clear markers map Shiny session","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_markers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear markers from a map in a Shiny session — clear_markers","text":"","code":"clear_markers(map)"},{"path":"https://walker-data.com/mapgl/reference/clear_markers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear markers from a map in a Shiny session — clear_markers","text":"map map object created mapboxgl_proxy maplibre_proxy function.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_markers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear markers from a map in a Shiny session — clear_markers","text":"modified map object markers cleared.","code":""},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare cluster options for circle layers — cluster_options","title":"Prepare cluster options for circle layers — cluster_options","text":"function creates list options clustering circle layers.","code":""},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare cluster options for circle layers — cluster_options","text":"","code":"cluster_options( max_zoom = 14, cluster_radius = 50, color_stops = c(\"#51bbd6\", \"#f1f075\", \"#f28cb1\"), radius_stops = c(20, 30, 40), count_stops = c(0, 100, 750), circle_blur = NULL, circle_opacity = NULL, circle_stroke_color = NULL, circle_stroke_opacity = NULL, circle_stroke_width = NULL, text_color = \"black\" )"},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare cluster options for circle layers — cluster_options","text":"max_zoom maximum zoom level cluster points. cluster_radius radius cluster clustering points. color_stops vector colors circle color step expression. radius_stops vector radii circle radius step expression. count_stops vector point counts color radius step expressions. circle_blur Amount blur circle. circle_opacity opacity circle. circle_stroke_color color circle's stroke. circle_stroke_opacity opacity circle's stroke. circle_stroke_width width circle's stroke. text_color color use labels cluster circles.","code":""},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare cluster options for circle layers — cluster_options","text":"list cluster options.","code":""},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare cluster options for circle layers — cluster_options","text":"","code":"cluster_options( max_zoom = 14, cluster_radius = 50, color_stops = c(\"#51bbd6\", \"#f1f075\", \"#f28cb1\"), radius_stops = c(20, 30, 40), count_stops = c(0, 100, 750), circle_blur = 1, circle_opacity = 0.8, circle_stroke_color = \"#ffffff\", circle_stroke_width = 2 ) #> $max_zoom #> [1] 14 #> #> $cluster_radius #> [1] 50 #> #> $color_stops #> [1] \"#51bbd6\" \"#f1f075\" \"#f28cb1\" #> #> $radius_stops #> [1] 20 30 40 #> #> $count_stops #> [1] 0 100 750 #> #> $circle_blur #> [1] 1 #> #> $circle_opacity #> [1] 0.8 #> #> $circle_stroke_color #> [1] \"#ffffff\" #> #> $circle_stroke_opacity #> NULL #> #> $circle_stroke_width #> [1] 2 #> #> $text_color #> [1] \"black\" #>"},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Compare slider widget — compare","title":"Create a Compare slider widget — compare","text":"function creates comparison view two Mapbox GL Maplibre GL maps, allowing users swipe two maps compare different styles data layers.","code":""},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Compare slider widget — compare","text":"","code":"compare( map1, map2, width = \"100%\", height = NULL, elementId = NULL, mousemove = FALSE, orientation = \"vertical\" )"},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Compare slider widget — compare","text":"map1 mapboxgl maplibre object representing first map. map2 mapboxgl maplibre object representing second map. width Width map container. height Height map container. elementId optional string specifying ID container comparison. NULL, unique ID generated. mousemove logical value indicating whether enable swiping cursor movement (rather clicked). orientation string specifying orientation swiper, either \"horizontal\" \"vertical\".","code":""},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Compare slider widget — compare","text":"comparison widget.","code":""},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a Compare slider widget — compare","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(mapgl) m1 <- mapboxgl(style = mapbox_style(\"light\")) m2 <- mapboxgl(style = mapbox_style(\"dark\")) compare(m1, m2) } # }"},{"path":"https://walker-data.com/mapgl/reference/ease_to.html","id":null,"dir":"Reference","previous_headings":"","what":"Ease to a given view — ease_to","title":"Ease to a given view — ease_to","text":"Ease given view","code":""},{"path":"https://walker-data.com/mapgl/reference/ease_to.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ease to a given view — ease_to","text":"","code":"ease_to(map, center, zoom = NULL, ...)"},{"path":"https://walker-data.com/mapgl/reference/ease_to.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Ease to a given view — ease_to","text":"map map object created mapboxgl maplibre function proxy object. center numeric vector length 2 specifying target center map (longitude, latitude). zoom target zoom level. ... Additional named arguments easing view.","code":""},{"path":"https://walker-data.com/mapgl/reference/ease_to.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Ease to a given view — ease_to","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/fit_bounds.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit the map to a bounding box — fit_bounds","title":"Fit the map to a bounding box — fit_bounds","text":"Fit map bounding box","code":""},{"path":"https://walker-data.com/mapgl/reference/fit_bounds.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit the map to a bounding box — fit_bounds","text":"","code":"fit_bounds(map, bbox, animate = FALSE, ...)"},{"path":"https://walker-data.com/mapgl/reference/fit_bounds.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit the map to a bounding box — fit_bounds","text":"map map object created mapboxgl maplibre function proxy object. bbox bounding box specified numeric vector length 4 (minLng, minLat, maxLng, maxLat), sf object bounding box calculated. animate logical value indicating whether animate transition new bounds. Defaults FALSE. ... Additional named arguments fitting bounds.","code":""},{"path":"https://walker-data.com/mapgl/reference/fit_bounds.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit the map to a bounding box — fit_bounds","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/fly_to.html","id":null,"dir":"Reference","previous_headings":"","what":"Fly to a given view — fly_to","title":"Fly to a given view — fly_to","text":"Fly given view","code":""},{"path":"https://walker-data.com/mapgl/reference/fly_to.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fly to a given view — fly_to","text":"","code":"fly_to(map, center, zoom = NULL, ...)"},{"path":"https://walker-data.com/mapgl/reference/fly_to.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fly to a given view — fly_to","text":"map map object created mapboxgl maplibre function proxy object. center numeric vector length 2 specifying target center map (longitude, latitude). zoom target zoom level. ... Additional named arguments flying view.","code":""},{"path":"https://walker-data.com/mapgl/reference/fly_to.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fly to a given view — fly_to","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_column.html","id":null,"dir":"Reference","previous_headings":"","what":"Get column or property for use in mapping — get_column","title":"Get column or property for use in mapping — get_column","text":"function returns expression get specified column dataset (property layer).","code":""},{"path":"https://walker-data.com/mapgl/reference/get_column.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get column or property for use in mapping — get_column","text":"","code":"get_column(column)"},{"path":"https://walker-data.com/mapgl/reference/get_column.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get column or property for use in mapping — get_column","text":"column name column property get.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_column.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get column or property for use in mapping — get_column","text":"list representing expression get column.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":null,"dir":"Reference","previous_headings":"","what":"Get drawn features from the map — get_drawn_features","title":"Get drawn features from the map — get_drawn_features","text":"Get drawn features map","code":""},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get drawn features from the map — get_drawn_features","text":"","code":"get_drawn_features(map)"},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get drawn features from the map — get_drawn_features","text":"map map object created mapboxgl function, mapboxgl proxy.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get drawn features from the map — get_drawn_features","text":"sf object containing drawn features.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get drawn features from the map — get_drawn_features","text":"","code":"if (FALSE) { # \\dontrun{ # In a Shiny application library(shiny) library(mapgl) ui <- fluidPage( mapboxglOutput(\"map\"), actionButton(\"get_features\", \"Get Drawn Features\"), verbatimTextOutput(\"feature_output\") ) server <- function(input, output, session) { output$map <- renderMapboxgl({ mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.50, 40), zoom = 9 ) |> add_draw_control() }) observeEvent(input$get_features, { drawn_features <- get_drawn_features(mapboxgl_proxy(\"map\")) output$feature_output <- renderPrint({ print(drawn_features) }) }) } shinyApp(ui, server) } # }"},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an interpolation expression — interpolate","title":"Create an interpolation expression — interpolate","text":"function generates interpolation expression can used style data.","code":""},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an interpolation expression — interpolate","text":"","code":"interpolate( column = NULL, property = NULL, type = \"linear\", values, stops, na_color = NULL )"},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an interpolation expression — interpolate","text":"column name column use interpolation. specified, property NULL. property name property use interpolation. specified, column NULL. type interpolation type. Can one \"linear\", list(\"exponential\", base) base specifies rate output increases, list(\"cubic-bezier\", x1, y1, x2, y2) define cubic bezier curve control points. values numeric vector values stops occur. stops vector corresponding stops (colors, sizes, etc.) interpolation. na_color color use missing values. Mapbox GL JS defaults black supplied.","code":""},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an interpolation expression — interpolate","text":"list representing interpolation expression.","code":""},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an interpolation expression — interpolate","text":"","code":"interpolate( column = \"estimate\", type = \"linear\", values = c(1000, 200000), stops = c(\"#eff3ff\", \"#08519c\") ) #> [[1]] #> [1] \"interpolate\" #> #> [[2]] #> [[2]][[1]] #> [1] \"linear\" #> #> #> [[3]] #> [[3]][[1]] #> [1] \"get\" #> #> [[3]][[2]] #> [1] \"estimate\" #> #> #> [[4]] #> [1] 1000 #> #> [[5]] #> [1] \"#eff3ff\" #> #> [[6]] #> [1] 2e+05 #> #> [[7]] #> [1] \"#08519c\" #>"},{"path":"https://walker-data.com/mapgl/reference/jump_to.html","id":null,"dir":"Reference","previous_headings":"","what":"Jump to a given view — jump_to","title":"Jump to a given view — jump_to","text":"Jump given view","code":""},{"path":"https://walker-data.com/mapgl/reference/jump_to.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Jump to a given view — jump_to","text":"","code":"jump_to(map, center, zoom = NULL, ...)"},{"path":"https://walker-data.com/mapgl/reference/jump_to.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Jump to a given view — jump_to","text":"map map object created mapboxgl maplibre function proxy object. center numeric vector length 2 specifying target center map (longitude, latitude). zoom target zoom level. ... Additional named arguments jumping view.","code":""},{"path":"https://walker-data.com/mapgl/reference/jump_to.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Jump to a given view — jump_to","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapbox_style.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Mapbox Style URL — mapbox_style","title":"Get Mapbox Style URL — mapbox_style","text":"Get Mapbox Style URL","code":""},{"path":"https://walker-data.com/mapgl/reference/mapbox_style.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Mapbox Style URL — mapbox_style","text":"","code":"mapbox_style(style_name)"},{"path":"https://walker-data.com/mapgl/reference/mapbox_style.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Mapbox Style URL — mapbox_style","text":"style_name name style (e.g., \"standard\", \"streets\", \"outdoors\", etc.).","code":""},{"path":"https://walker-data.com/mapgl/reference/mapbox_style.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Mapbox Style URL — mapbox_style","text":"style URL corresponding given style name.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize a Mapbox GL Map — mapboxgl","title":"Initialize a Mapbox GL Map — mapboxgl","text":"Initialize Mapbox GL Map","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize a Mapbox GL Map — mapboxgl","text":"","code":"mapboxgl( style = NULL, center = c(0, 0), zoom = 0, bearing = 0, pitch = 0, projection = \"globe\", parallels = NULL, access_token = NULL, bounds = NULL, width = \"100%\", height = NULL, ... )"},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Initialize a Mapbox GL Map — mapboxgl","text":"style Mapbox style use. center numeric vector length 2 specifying initial center map. zoom initial zoom level map. bearing initial bearing (rotation) map, degrees. pitch initial pitch (tilt) map, degrees. projection map projection use (e.g., \"mercator\", \"globe\"). parallels vector two numbers representing standard parellels projection. available projection \"albers\" \"lambertConformalConic\". access_token Mapbox access token. bounds sf object bounding box fit map . width width output htmlwidget. height height output htmlwidget. ... Additional named parameters passed Mapbox GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize a Mapbox GL Map — mapboxgl","text":"HTML widget Mapbox map.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Initialize a Mapbox GL Map — mapboxgl","text":"","code":"if (FALSE) { # \\dontrun{ mapboxgl(projection = \"globe\") } # }"},{"path":"https://walker-data.com/mapgl/reference/mapboxglOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Mapbox GL output element for Shiny — mapboxglOutput","title":"Create a Mapbox GL output element for Shiny — mapboxglOutput","text":"Create Mapbox GL output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxglOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Mapbox GL output element for Shiny — mapboxglOutput","text":"","code":"mapboxglOutput(outputId, width = \"100%\", height = \"400px\")"},{"path":"https://walker-data.com/mapgl/reference/mapboxglOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Mapbox GL output element for Shiny — mapboxglOutput","text":"outputId output variable read width width element height height element","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxglOutput.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Mapbox GL output element for Shiny — mapboxglOutput","text":"Mapbox GL output element use Shiny UI","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_proxy.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","title":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","text":"function allows updates sent existing Mapbox GL map Shiny application without redrawing entire map.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_proxy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","text":"","code":"mapboxgl_proxy(mapId, session = shiny::getDefaultReactiveDomain())"},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_proxy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","text":"mapId ID map output element. session Shiny session object.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_proxy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","text":"proxy object Mapbox GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapgl-package.html","id":null,"dir":"Reference","previous_headings":"","what":"mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' — mapgl-package","title":"mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' — mapgl-package","text":"Provides interface 'Mapbox GL JS' (https://docs.mapbox.com/mapbox-gl-js/guides) 'MapLibre GL JS' (https://maplibre.org/maplibre-gl-js/docs/) interactive mapping libraries help users create custom interactive maps R. Users can create interactive globe visualizations; layer 'sf' objects create filled maps, circle maps, 'heatmaps', three-dimensional graphics; customize map styles views. package also includes utilities use 'Mapbox' 'MapLibre' maps 'Shiny' web applications.","code":""},{"path":[]},{"path":"https://walker-data.com/mapgl/reference/mapgl-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' — mapgl-package","text":"Maintainer: Kyle Walker kyle@walker-data.com","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize a Maplibre GL Map — maplibre","title":"Initialize a Maplibre GL Map — maplibre","text":"Initialize Maplibre GL Map","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize a Maplibre GL Map — maplibre","text":"","code":"maplibre( style = carto_style(\"voyager\"), center = c(0, 0), zoom = 0, bearing = 0, pitch = 0, bounds = NULL, width = \"100%\", height = NULL, ... )"},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Initialize a Maplibre GL Map — maplibre","text":"style style JSON use. center numeric vector length 2 specifying initial center map. zoom initial zoom level map. bearing initial bearing (rotation) map, degrees. pitch initial pitch (tilt) map, degrees. bounds sf object bounding box fit map . width width output htmlwidget. height height output htmlwidget. ... Additional named parameters passed Mapbox GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize a Maplibre GL Map — maplibre","text":"HTML widget Mapbox map.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Initialize a Maplibre GL Map — maplibre","text":"","code":"if (FALSE) { # \\dontrun{ maplibre() } # }"},{"path":"https://walker-data.com/mapgl/reference/maplibreOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Maplibre GL output element for Shiny — maplibreOutput","title":"Create a Maplibre GL output element for Shiny — maplibreOutput","text":"Create Maplibre GL output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibreOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Maplibre GL output element for Shiny — maplibreOutput","text":"","code":"maplibreOutput(outputId, width = \"100%\", height = \"400px\")"},{"path":"https://walker-data.com/mapgl/reference/maplibreOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Maplibre GL output element for Shiny — maplibreOutput","text":"outputId output variable read width width element height height element","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibreOutput.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Maplibre GL output element for Shiny — maplibreOutput","text":"Maplibre GL output element use Shiny UI","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_proxy.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","title":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","text":"function allows updates sent existing Maplibre GL map Shiny application without redrawing entire map.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_proxy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","text":"","code":"maplibre_proxy(mapId, session = shiny::getDefaultReactiveDomain())"},{"path":"https://walker-data.com/mapgl/reference/maplibre_proxy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","text":"mapId ID map output element. session Shiny session object.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_proxy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","text":"proxy object Maplibre GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/maptiler_style.html","id":null,"dir":"Reference","previous_headings":"","what":"Get MapTiler Style URL — maptiler_style","title":"Get MapTiler Style URL — maptiler_style","text":"Get MapTiler Style URL","code":""},{"path":"https://walker-data.com/mapgl/reference/maptiler_style.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get MapTiler Style URL — maptiler_style","text":"","code":"maptiler_style(style_name, api_key = NULL)"},{"path":"https://walker-data.com/mapgl/reference/maptiler_style.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get MapTiler Style URL — maptiler_style","text":"style_name name style (e.g., \"basic\", \"streets\", \"toner\", etc.). api_key MapTiler API key (required)","code":""},{"path":"https://walker-data.com/mapgl/reference/maptiler_style.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get MapTiler Style URL — maptiler_style","text":"style URL corresponding given style name.","code":""},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a match expression — match_expr","title":"Create a match expression — match_expr","text":"function generates match expression can used style data.","code":""},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a match expression — match_expr","text":"","code":"match_expr(column = NULL, property = NULL, values, stops, default = \"#cccccc\")"},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a match expression — match_expr","text":"column name column use match expression. specified, property NULL. property name property use match expression. specified, column NULL. values vector values match . stops vector corresponding stops (colors, etc.) matched values. default default value use matches found.","code":""},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a match expression — match_expr","text":"list representing match expression.","code":""},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a match expression — match_expr","text":"","code":"match_expr( column = \"category\", values = c(\"A\", \"B\", \"C\"), stops = c(\"#ff0000\", \"#00ff00\", \"#0000ff\"), default = \"#cccccc\" ) #> [[1]] #> [1] \"match\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"category\" #> #> #> [[3]] #> [1] \"A\" #> #> [[4]] #> [1] \"#ff0000\" #> #> [[5]] #> [1] \"B\" #> #> [[6]] #> [1] \"#00ff00\" #> #> [[7]] #> [1] \"C\" #> #> [[8]] #> [1] \"#0000ff\" #> #> [[9]] #> [1] \"#cccccc\" #>"},{"path":"https://walker-data.com/mapgl/reference/move_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Move a layer to a different z-position — move_layer","title":"Move a layer to a different z-position — move_layer","text":"function allows layer moved different z-position existing Mapbox GL Maplibre GL map using proxy object.","code":""},{"path":"https://walker-data.com/mapgl/reference/move_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Move a layer to a different z-position — move_layer","text":"","code":"move_layer(proxy, layer_id, before_id = NULL)"},{"path":"https://walker-data.com/mapgl/reference/move_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Move a layer to a different z-position — move_layer","text":"proxy proxy object created mapboxgl_proxy maplibre_proxy. layer_id ID layer move. before_id ID existing layer insert new layer . Important: means layer appear immediately behind layer defined before_id. omitted, layer appended end layers array appear layers.","code":""},{"path":"https://walker-data.com/mapgl/reference/move_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Move a layer to a different z-position — move_layer","text":"updated proxy object.","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxgl.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a Mapbox GL output element in Shiny — renderMapboxgl","title":"Render a Mapbox GL output element in Shiny — renderMapboxgl","text":"Render Mapbox GL output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxgl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a Mapbox GL output element in Shiny — renderMapboxgl","text":"","code":"renderMapboxgl(expr, env = parent.frame(), quoted = FALSE)"},{"path":"https://walker-data.com/mapgl/reference/renderMapboxgl.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a Mapbox GL output element in Shiny — renderMapboxgl","text":"expr expression generates Mapbox GL map env environment evaluate expr quoted expr quoted expression","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxgl.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a Mapbox GL output element in Shiny — renderMapboxgl","text":"rendered Mapbox GL map use Shiny server","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibre.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a Maplibre GL output element in Shiny — renderMaplibre","title":"Render a Maplibre GL output element in Shiny — renderMaplibre","text":"Render Maplibre GL output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibre.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a Maplibre GL output element in Shiny — renderMaplibre","text":"","code":"renderMaplibre(expr, env = parent.frame(), quoted = FALSE)"},{"path":"https://walker-data.com/mapgl/reference/renderMaplibre.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a Maplibre GL output element in Shiny — renderMaplibre","text":"expr expression generates Maplibre GL map env environment evaluate expr quoted expr quoted expression","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibre.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a Maplibre GL output element in Shiny — renderMaplibre","text":"rendered Maplibre GL map use Shiny server","code":""},{"path":"https://walker-data.com/mapgl/reference/set_config_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a configuration property for a Mapbox GL map — set_config_property","title":"Set a configuration property for a Mapbox GL map — set_config_property","text":"Set configuration property Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_config_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a configuration property for a Mapbox GL map — set_config_property","text":"","code":"set_config_property(map, import_id, config_name, value)"},{"path":"https://walker-data.com/mapgl/reference/set_config_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a configuration property for a Mapbox GL map — set_config_property","text":"map map object created mapboxgl function proxy object defined mapboxgl_proxy(). import_id name imported style set config (e.g., 'basemap'). config_name name configuration property style. value value set configuration property.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_config_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a configuration property for a Mapbox GL map — set_config_property","text":"updated map object configuration property set.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_filter.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a filter on a map layer — set_filter","title":"Set a filter on a map layer — set_filter","text":"function sets filter map layer, working regular map objects proxy objects.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_filter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a filter on a map layer — set_filter","text":"","code":"set_filter(map, layer_id, filter)"},{"path":"https://walker-data.com/mapgl/reference/set_filter.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a filter on a map layer — set_filter","text":"map map object created mapboxgl maplibre function, proxy object. layer_id ID layer filter applied. filter filter expression apply.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_filter.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a filter on a map layer — set_filter","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_fog.html","id":null,"dir":"Reference","previous_headings":"","what":"Set fog on a Mapbox GL map — set_fog","title":"Set fog on a Mapbox GL map — set_fog","text":"Set fog Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_fog.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set fog on a Mapbox GL map — set_fog","text":"","code":"set_fog( map, range = NULL, color = NULL, horizon_blend = NULL, high_color = NULL, space_color = NULL, star_intensity = NULL )"},{"path":"https://walker-data.com/mapgl/reference/set_fog.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set fog on a Mapbox GL map — set_fog","text":"map map object created mapboxgl function proxy object. range numeric vector length 2 defining minimum maximum range fog. color string specifying color fog. horizon_blend number 0 1 controlling blending fog horizon. high_color string specifying color fog higher elevations. space_color string specifying color fog space. star_intensity number 0 1 controlling intensity stars fog.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_fog.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set fog on a Mapbox GL map — set_fog","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_layout_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a layout property on a map layer — set_layout_property","title":"Set a layout property on a map layer — set_layout_property","text":"Set layout property map layer","code":""},{"path":"https://walker-data.com/mapgl/reference/set_layout_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a layout property on a map layer — set_layout_property","text":"","code":"set_layout_property(map, layer, name, value)"},{"path":"https://walker-data.com/mapgl/reference/set_layout_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a layout property on a map layer — set_layout_property","text":"map map object created mapboxgl maplibre function, proxy object. layer ID layer update. name name layout property set. value value set property .","code":""},{"path":"https://walker-data.com/mapgl/reference/set_layout_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a layout property on a map layer — set_layout_property","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_paint_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a paint property on a map layer — set_paint_property","title":"Set a paint property on a map layer — set_paint_property","text":"Set paint property map layer","code":""},{"path":"https://walker-data.com/mapgl/reference/set_paint_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a paint property on a map layer — set_paint_property","text":"","code":"set_paint_property(map, layer, name, value)"},{"path":"https://walker-data.com/mapgl/reference/set_paint_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a paint property on a map layer — set_paint_property","text":"map map object created mapboxgl maplibre function, proxy object. layer ID layer update. name name paint property set. value value set property .","code":""},{"path":"https://walker-data.com/mapgl/reference/set_paint_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a paint property on a map layer — set_paint_property","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":null,"dir":"Reference","previous_headings":"","what":"Update the style of a map — set_style","title":"Update the style of a map — set_style","text":"Update style map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Update the style of a map — set_style","text":"","code":"set_style(map, style, config = NULL, diff = TRUE)"},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Update the style of a map — set_style","text":"map map object created mapboxgl maplibre function, proxy object. style new style URL applied map. config named list options passed style config. diff boolean attempts diff-based update rather re-drawing full style. available styles.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Update the style of a map — set_style","text":"modified map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Update the style of a map — set_style","text":"","code":"if (FALSE) { # \\dontrun{ map <- mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.006, 40.7128), zoom = 10, access_token = \"your_mapbox_access_token\" ) # Update the map style in a Shiny app observeEvent(input$change_style, { mapboxgl_proxy(\"map\", session) %>% set_style(mapbox_style(\"dark\"), config = list(showLabels = FALSE), diff = TRUE) }) } # }"},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":null,"dir":"Reference","previous_headings":"","what":"Set terrain properties on a map — set_terrain","title":"Set terrain properties on a map — set_terrain","text":"Set terrain properties map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set terrain properties on a map — set_terrain","text":"","code":"set_terrain(map, source, exaggeration = 1)"},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set terrain properties on a map — set_terrain","text":"map map object created mapboxgl maplibre functions. source ID raster DEM source. exaggeration terrain exaggeration factor.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set terrain properties on a map — set_terrain","text":"modified map object terrain settings applied.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set terrain properties on a map — set_terrain","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl( style = mapbox_style(\"standard-satellite\"), center = c(-114.26608, 32.7213), zoom = 14, pitch = 80, bearing = 41 ) |> add_raster_dem_source( id = \"mapbox-dem\", url = \"mapbox://mapbox.mapbox-terrain-dem-v1\", tileSize = 512, maxzoom = 14 ) |> set_terrain( source = \"mapbox-dem\", exaggeration = 1.5 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/set_view.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the map center and zoom level — set_view","title":"Set the map center and zoom level — set_view","text":"Set map center zoom level","code":""},{"path":"https://walker-data.com/mapgl/reference/set_view.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the map center and zoom level — set_view","text":"","code":"set_view(map, center, zoom)"},{"path":"https://walker-data.com/mapgl/reference/set_view.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the map center and zoom level — set_view","text":"map map object created mapboxgl maplibre function proxy object. center numeric vector length 2 specifying center map (longitude, latitude). zoom zoom level.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_view.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the map center and zoom level — set_view","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a step expression — step_expr","title":"Create a step expression — step_expr","text":"function generates step expression can used styles.","code":""},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a step expression — step_expr","text":"","code":"step_expr(column = NULL, property = NULL, base, values, stops, na_color = NULL)"},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a step expression — step_expr","text":"column name column use step expression. specified, property NULL. property name property use step expression. specified, column NULL. base base value use step expression. values numeric vector values steps occur. stops vector corresponding stops (colors, sizes, etc.) steps. na_color color use missing values. Mapbox GL JS defaults black supplied.","code":""},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a step expression — step_expr","text":"list representing step expression.","code":""},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a step expression — step_expr","text":"","code":"step_expr( column = \"value\", base = \"#ffffff\", values = c(1000, 5000, 10000), stops = c(\"#ff0000\", \"#00ff00\", \"#0000ff\") ) #> [[1]] #> [1] \"step\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"value\" #> #> #> [[3]] #> [1] \"#ffffff\" #> #> [[4]] #> [1] 1000 #> #> [[5]] #> [1] \"#ff0000\" #> #> [[6]] #> [1] 5000 #> #> [[7]] #> [1] \"#00ff00\" #> #> [[8]] #> [1] 10000 #> #> [[9]] #> [1] \"#0000ff\" #>"},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-014","dir":"Changelog","previous_headings":"","what":"mapgl 0.1.4","title":"mapgl 0.1.4","text":"CRAN release: 2024-11-01 add_image() allows add image map’s sprite use icon / symbol layer add_geolocate_control() adds Geolocate control map add_globe_minimap() adds mini globe overview map tracks map moves around globe Support multiple legends argument add = TRUE move_layer() function gives fine-grained control layer ordering Shiny session Various bug fixes performance improvements.","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-013","dir":"Changelog","previous_headings":"","what":"mapgl 0.1.3","title":"mapgl 0.1.3","text":"CRAN release: 2024-09-04 Geocoding support Mapbox MapLibre maps added add_geocoder_control() Freehand draw support draw toolbar add_draw_control(freehand = TRUE) “reset view” control available add_reset_control() Circle clustering streamlined cluster_options() function, used cluster_options argument add_circle_layer() add_symbol_layer() Various bug fixes performance improvements.","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-010","dir":"Changelog","previous_headings":"","what":"mapgl 0.1.0","title":"mapgl 0.1.0","text":"Initial release.","code":""}] +[{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":null,"dir":"","previous_headings":"","what":"CLAUDE.md","title":"CLAUDE.md","text":"file provides guidance Claude Code (claude.ai/code) working code repository.","code":""},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"CLAUDE.md","text":"mapgl R package provides interface Mapbox GL JS MapLibre GL JS creating interactive maps R. designed feel familiar R users making powerful capabilities mapping libraries available.","code":""},{"path":[]},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"package-building-and-installation","dir":"","previous_headings":"Common Development Commands","what":"Package Building and Installation","title":"CLAUDE.md","text":"","code":"# Build and install the package locally devtools::install() # Check the package for issues devtools::check() # Generate documentation from roxygen2 comments devtools::document() # Run tests devtools::test() # Build the package devtools::build()"},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"vignette-and-documentation","dir":"","previous_headings":"Common Development Commands","what":"Vignette and Documentation","title":"CLAUDE.md","text":"","code":"# Build all vignettes devtools::build_vignettes() # Build a specific vignette knitr::knit(\"vignettes/getting-started.Rmd\") # Build pkgdown site pkgdown::build_site()"},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"shiny-development","dir":"","previous_headings":"Common Development Commands","what":"Shiny Development","title":"CLAUDE.md","text":"","code":"# When developing Shiny apps with mapgl, use: shiny::runApp(\"app.R\", reload = TRUE)"},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"testing-individual-functions","dir":"","previous_headings":"Common Development Commands","what":"Testing Individual Functions","title":"CLAUDE.md","text":"","code":"# Load the development version devtools::load_all() # Test individual functions library(mapgl) map <- maplibre() |> add_circle_layer(data = sf_object, ...)"},{"path":[]},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"htmlwidgets-architecture","dir":"","previous_headings":"Architecture and Code Structure","what":"HTMLWidgets Architecture","title":"CLAUDE.md","text":"package uses htmlwidgets framework bridge R JavaScript: mapboxgl.R / maplibre.R: Main widget creation functions layers.R: Functions adding map layers (circles, fills, lines, etc.) sources.R: Functions adding data sources controls.R: Functions adding UI controls shiny.R: Shiny integration proxy functions plugins.R: Integration JS plugins (globe minimap, geocoder, etc.) mapboxgl.js / maplibregl.js: Main JS widget bindings mapboxgl_compare.js / maplibregl_compare.js: Compare view implementations YAML files define dependencies widget MapLibre GL JS (vendored) Mapbox GL JS (loaded CDN) Various plugins (globe-minimap, draw, geocoder, etc.)","code":""},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"widget-communication-pattern","dir":"","previous_headings":"Architecture and Code Structure","what":"Widget Communication Pattern","title":"CLAUDE.md","text":"R functions create list structures map instructions serialized JSON sent JavaScript JavaScript interprets instructions updates map Shiny proxy functions send messages existing maps","code":""},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"key-design-patterns","dir":"","previous_headings":"Architecture and Code Structure","what":"Key Design Patterns","title":"CLAUDE.md","text":"Layer Management: layer requires source. package automatically creates sources needed: Proxy Pattern: Shiny apps, proxy functions allow updating existing maps: Expression System: package supports Mapbox GL expressions: Control Positioning: Controls can positioned 8 locations: - “top-left”, “top-center”, “top-right” - “bottom-left”, “bottom-center”, “bottom-right” - “middle-left”, “middle-right”","code":"# This creates both a source and a layer add_circle_layer(map, id = \"circles\", source = \"data\", data = sf_object) maplibre_proxy(\"map_id\") |> set_filter(\"layer_id\", list(\"==\", \"property\", \"value\")) interpolate( column = \"value\", values = c(0, 100), colors = c(\"blue\", \"red\") )"},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"dependencies-and-versions","dir":"","previous_headings":"Architecture and Code Structure","what":"Dependencies and Versions","title":"CLAUDE.md","text":"MapLibre GL JS: v5.3.0 (vendored) Mapbox GL JS: v3.12.0 (CDN) R dependencies: htmlwidgets, sf, geojsonsf, shiny, etc.","code":""},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"working-with-styles","dir":"","previous_headings":"Architecture and Code Structure","what":"Working with Styles","title":"CLAUDE.md","text":"package supports multiple style sources: - mapbox_style(): Official Mapbox styles (requires token) - maptiler_style(): MapTiler styles (requires API key) - carto_style(): CARTO styles (free) - Custom style URLs JSON objects","code":""},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"testing-changes","dir":"","previous_headings":"Architecture and Code Structure","what":"Testing Changes","title":"CLAUDE.md","text":"Test JavaScript changes modifying files inst/htmlwidgets/ Test R changes running devtools::load_all() testing interactively Use examples vignettes/ test cases Test Shiny functionality apps vignettes/ create minimal examples","code":""},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"current-issues-and-edge-cases","dir":"","previous_headings":"Architecture and Code Structure","what":"Current Issues and Edge Cases","title":"CLAUDE.md","text":"Globe minimap positioning MapLibre “bottom-right” position CSS issues Compare views require special handling synchronized map updates Mapbox-specific features may work MapLibre vice versa","code":""},{"path":"https://walker-data.com/mapgl/CLAUDE.html","id":"specific-instructions","dir":"","previous_headings":"Architecture and Code Structure","what":"Specific instructions","title":"CLAUDE.md","text":"create examples folder create R script files files within folder getting explicit approval Code style follow Posit’s Air formatter Code style prefers snake case (words separated underscores) rather camel case.","code":""},{"path":"https://walker-data.com/mapgl/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 Kyle Walker Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://walker-data.com/mapgl/articles/getting-started.html","id":"using-mapbox-gl-js","dir":"Articles","previous_headings":"","what":"Using Mapbox GL JS","title":"Getting started with mapgl","text":"gateway Mapbox GL JS v3 R mapboxgl() function. Run function arguments get interactive globe using Mapbox’s Standard style: use Mapbox maps, need Mapbox access token. user mapboxapi package installed Mapbox access token, mapboxgl() pick token . new R packages, ’ll want get token Mapbox account, run usethis::edit_r_environ(), set environment variable MAPBOX_PUBLIC_TOKEN=\"your_token_here\". ’s important know Mapbox GL JS commercial product charges map views; however, generous free tier. Mapbox’s default styles accessible mapbox_style() function, can passed style parameter change style map. Mapbox GL JS also supports modifying map projections; use projection = \"winkelTripel\" Winkel Tripel global projection. get local view map, can use center, zoom, pitch, bearing arguments. example shown , arguments incorporated “fly ” animation. mapgl supports several animated transitions. Mapbox GL JS v3, new Standard style includes custom-rendered buildings around world, American Airlines Center Dallas.","code":"library(mapgl) mapboxgl() mapboxgl( style = mapbox_style(\"satellite\"), projection = \"winkelTripel\") mapboxgl( center = c(-97.6, 25.4) ) |> fly_to( center = c(-96.810481, 32.790869), zoom = 18.4, pitch = 75, bearing = 136.8 )"},{"path":"https://walker-data.com/mapgl/articles/getting-started.html","id":"using-maplibre-gl-js","dir":"Articles","previous_headings":"","what":"Using Maplibre GL JS","title":"Getting started with mapgl","text":"Maplibre GL JS, fork permissively-licensed Mapbox GL JS 1.0, also available R users mapgl. core function initialize MapLibre map maplibre(). default tiles maplibre() CARTO’s Voyager tiles, usable without API key. MapTiler tiles also available via maptiler_style() function. styles work quite well MapLibre, require API key; set environment variable MAPTILER_API_KEY .Renviron file store key. example uses Bright MapTiler style, adds fullscreen control navigation control map. controls styles available mapboxgl() well; mapgl aims provide consistent API work either Mapbox MapLibre.","code":"library(mapgl) maplibre() maplibre( style = maptiler_style(\"bright\"), center = c(-43.23412, -22.91370), zoom = 14 ) |> add_fullscreen_control(position = \"top-left\") |> add_navigation_control()"},{"path":"https://walker-data.com/mapgl/articles/getting-started.html","id":"comparing-map-views","dir":"Articles","previous_headings":"","what":"Comparing map views","title":"Getting started with mapgl","text":"mapgl includes function compare() allows users create synced swipe maps can compare two styles. function works either Mapbox MapLibre maps.","code":"m1 <- mapboxgl() m2 <- mapboxgl(mapbox_style(\"satellite-streets\")) compare(m1, m2)"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"using-layers-an-overview","dir":"Articles","previous_headings":"","what":"Using layers: an overview","title":"Layers overview","text":"Mapbox GL JS MapLibre, datasets added maps sources styled layers. mapgl aims expose sources layers APIs R users ways honor deep customization available JavaScript libraries also accommodate R users’ typical workflows. Geospatial practitioners R typically work objects sf package. initial release mapgl natively supports sf objects, aim support geospatial formats (objects terra package) future. Objects class sf can specified sources map either add_source() function via source parameter one mapgl’s layer functions. add_fill_layer() function calls Mapbox GL JS addLayer() function internally fill type, enumerates available options styling layer function arguments. mapgl users often want use bounds argument initializing map, alternatively fit_bounds() function, fix map view given layer’s bounding box. overview available layers mapgl . Layers can used either mapboxgl() maplibre() maps.","code":"library(mapgl) library(sf) nc <- st_read(system.file(\"shape/nc.shp\", package=\"sf\")) ## Reading layer `nc' from data source ## `/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/sf/shape/nc.shp' ## using driver `ESRI Shapefile' ## Simple feature collection with 100 features and 14 fields ## Geometry type: MULTIPOLYGON ## Dimension: XY ## Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 ## Geodetic CRS: NAD27 mapboxgl(bounds = nc) |> add_fill_layer(id = \"nc_data\", source = nc, fill_color = \"blue\", fill_opacity = 0.5)"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"line-layers","dir":"Articles","previous_headings":"","what":"Line layers","title":"Layers overview","text":"","code":"library(mapgl) library(tigris) ## To enable caching of data, set `options(tigris_use_cache = TRUE)` ## in your R script or .Rprofile. options(tigris_use_cache = TRUE) loving_roads <- roads(\"TX\", \"Loving\") maplibre(style = maptiler_style(\"backdrop\"), bounds = loving_roads) |> add_line_layer( id = \"roads\", source = loving_roads, line_color = \"navy\", line_opacity = 0.7 )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"circle-layers","dir":"Articles","previous_headings":"","what":"Circle layers","title":"Layers overview","text":"Circle layers typically used represent point data map. Circle clustering implemented cluster_options argument, list generated cluster_options() function can passed.","code":"library(mapgl) library(sf) library(dplyr) # Set seed for reproducibility set.seed(1234) # Define the bounding box for Washington DC (approximately) bbox <- st_bbox(c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), crs = st_crs(4326)) # Generate 30 random points within the bounding box random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox[\"xmin\"], bbox[\"xmax\"]), lat = runif(30, bbox[\"ymin\"], bbox[\"ymax\"]) ), coords = c(\"lon\", \"lat\"), crs = 4326 ) # Assign random categories categories <- c('music', 'bar', 'theatre', 'bicycle') random_points <- random_points %>% mutate(category = sample(categories, n(), replace = TRUE)) # Map with circle layer mapboxgl(style = mapbox_style(\"dark\"), bounds = random_points) %>% add_circle_layer( id = \"poi-layer\", source = random_points, circle_color = match_expr( \"category\", values = c(\"music\", \"bar\", \"theatre\", \"bicycle\"), stops = c(\"#1f78b4\", \"#33a02c\", \"#e31a1c\", \"#ff7f00\") ), circle_radius = 8, circle_stroke_color = \"#ffffff\", circle_stroke_width = 2, circle_opacity = 0.8, tooltip = \"category\", hover_options = list(circle_radius = 12, circle_color = \"#ffff99\") ) %>% add_categorical_legend( legend_title = \"Points of Interest\", values = c(\"Music\", \"Bar\", \"Theatre\", \"Bicycle\"), colors = c(\"#1f78b4\", \"#33a02c\", \"#e31a1c\", \"#ff7f00\"), circular_patches = TRUE )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"symbol-layers","dir":"Articles","previous_headings":"","what":"Symbol layers","title":"Layers overview","text":"Symbol layers offer wide range arguments customizing icon label appearance; however arguments work icons. icon_image argument look string represents icon found map style’s sprite. Read sprites .","code":"mapboxgl(style = mapbox_style(\"light\"), bounds = random_points) |> add_symbol_layer( id = \"points-of-interest\", source = random_points, icon_image = get_column(\"category\"), icon_allow_overlap = TRUE, tooltip = \"category\" )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"heatmap-layers","dir":"Articles","previous_headings":"","what":"Heatmap layers","title":"Layers overview","text":"Heatmap layers take object geometry type POINT visualize density points visually attractive way. add_heatmap_layer() takes sf POINT objects; example shows read remote GeoJSON file source well.","code":"library(mapgl) mapboxgl(style = mapbox_style(\"dark\"), center = c(-120, 50), zoom = 2) |> add_heatmap_layer( id = \"earthquakes-heat\", source = list( type = \"geojson\", data = \"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\" ), heatmap_weight = interpolate( column = \"mag\", values = c(0, 6), stops = c(0, 1) ), heatmap_intensity = interpolate( property = \"zoom\", values = c(0, 9), stops = c(1, 3) ), heatmap_color = interpolate( property = \"heatmap-density\", values = seq(0, 1, 0.2), stops = c('rgba(33,102,172,0)', 'rgb(103,169,207)', 'rgb(209,229,240)', 'rgb(253,219,199)', 'rgb(239,138,98)', 'rgb(178,24,43)') ), heatmap_opacity = 0.7 )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"fill-extrusion-layers","dir":"Articles","previous_headings":"","what":"Fill-extrusion layers","title":"Layers overview","text":"","code":"library(mapgl) maplibre( style = maptiler_style(\"basic\"), center = c(-74.0066, 40.7135), zoom = 15.5, pitch = 45, bearing = -17.6 ) |> add_vector_source( id = \"openmaptiles\", url = paste0(\"https://api.maptiler.com/tiles/v3/tiles.json?key=\", Sys.getenv(\"MAPTILER_API_KEY\")) ) |> add_fill_extrusion_layer( id = \"3d-buildings\", source = 'openmaptiles', source_layer = 'building', fill_extrusion_color = interpolate( column = 'render_height', values = c(0, 200, 400), stops = c('lightgray', 'royalblue', 'lightblue') ), fill_extrusion_height = list( 'interpolate', list('linear'), list('zoom'), 15, 0, 16, list('get', 'render_height') ) )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"raster-layers","dir":"Articles","previous_headings":"","what":"Raster layers","title":"Layers overview","text":"mapgl supports rasters terra package passed data argument add_image_source() function, visualized add_raster_layer(). Remote raster sources (shown ) can also added add_image_source() remotely-hosted image files, add_raster_source() remotely-hosted raster tiles.","code":"mapboxgl(style = mapbox_style(\"dark\"), zoom = 5, center = c(-75.789, 41.874)) |> add_image_source( id = \"radar\", url = \"https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif\", coordinates = list( c(-80.425, 46.437), c(-71.516, 46.437), c(-71.516, 37.936), c(-80.425, 37.936) ) ) |> add_raster_layer( id = 'radar-layer', source = 'radar', raster_fade_duration = 0 )"},{"path":"https://walker-data.com/mapgl/articles/layers-overview.html","id":"markers","dir":"Articles","previous_headings":"","what":"Markers","title":"Layers overview","text":"Markers represent unique visual component Mapbox GL JS MapLibre GL JS, highlight locations count map layers. mapgl, users can add markers using add_markers() function. single marker can added length-2 vector longitude latitude; list length-2 vectors sf POINT object add multiple markers.","code":"mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.006, 40.7128), zoom = 10 ) |> add_markers( c(-74.006, 40.7128), color = \"blue\", rotation = 45, popup = \"A marker\" )"},{"path":"https://walker-data.com/mapgl/articles/map-design.html","id":"continuous-styling","dir":"Articles","previous_headings":"","what":"Continuous styling","title":"Fundamentals of map design with mapgl","text":"Styling Mapbox GL JS Maplibre GL JS typically handled expressions. Expressions allow quite bit customization map-makers, can feel clunky R users. mapgl includes several functions help R users translate code expressions use data visualizations. interpolate() function create interpolate expression, smoothly transitions values series stops. means can natively create just color palette want map palette seamlessly data. , specify two values - 20 80 - map colors “lightblue” “darkblue” values. Mapbox GL JS smoothly interpolate colors light blue dark blue map data values found specified column. add_legend() function adds legend map. mapgl’s initial release, add_legend() automatically populate values style. gives users much flexibility format legend, though users also need take care ensure legend appropriately represents data. Future updates package may include functionality automated legends.","code":"fl_map |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = interpolate( column = \"estimate\", values = c(20, 80), stops = c(\"lightblue\", \"darkblue\"), na_color = \"lightgrey\" ), fill_opacity = 0.5 ) |> add_legend( \"Median age in Florida\", values = c(20, 80), colors = c(\"lightblue\", \"darkblue\") )"},{"path":"https://walker-data.com/mapgl/articles/map-design.html","id":"categorical-styling","dir":"Articles","previous_headings":"","what":"Categorical styling","title":"Fundamentals of map design with mapgl","text":"Cartographers may prefer binned method visualizing data rather continuous palette shown . Mapbox GL JS MapLibre, binned maps can created step expression. step_expr() function helps R users assemble expression. Step expressions may feel little unfamiliar R users, require base value followed series stops. example , generate five-color palette ColorBrewer. first color used base, four colors stops. values specify bin edges.","code":"brewer_pal <- RColorBrewer::brewer.pal(5, \"RdYlBu\") fl_map |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = step_expr( column = \"estimate\", base = brewer_pal[1], stops = brewer_pal[2:5], values = seq(25, 70, 15), na_color = \"white\" ), fill_opacity = 0.5 ) |> add_legend( \"Median age in Florida\", values = c( \"Under 25\", \"25-40\", \"40-55\", \"55-70\", \"Above 70\" ), colors = brewer_pal, type = \"categorical\" )"},{"path":"https://walker-data.com/mapgl/articles/map-design.html","id":"pop-ups-tooltips-and-highlighting","dir":"Articles","previous_headings":"","what":"Pop-ups, tooltips, and highlighting","title":"Fundamentals of map design with mapgl","text":"Mapmakers often want expose additional interactivity users form -click popups, hover tooltips, hover effects. native JavaScript, can tricky set requires knowledge events, queries, feature states libraries. mapgl wraps functionality make features accessible R users. popup tooltip arguments take string input representing name column display click hover. arguments accommodate HTML, best way set create column values display popup tooltip, use column adding layer. Hover effects can set hover_options argument. argument takes list key-value pairs keys arguments given layer type (case, fill layer) arguments desired values hover. example shown , tell Mapbox GL JS change Census tract’s fill yellow fill opacity 1 users hovers tract.","code":"fl_age$popup <- glue::glue( \"GEOID: <\/strong>{fl_age$GEOID}
    Median age: <\/strong>{fl_age$estimate}\" ) fl_map |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = interpolate( column = \"estimate\", values = c(20, 80), stops = c(\"lightblue\", \"darkblue\"), na_color = \"lightgrey\" ), fill_opacity = 0.5, popup = \"popup\", tooltip = \"estimate\", hover_options = list( fill_color = \"yellow\", fill_opacity = 1 ) ) |> add_legend( \"Median age in Florida\", values = c(20, 80), colors = c(\"lightblue\", \"darkblue\") )"},{"path":"https://walker-data.com/mapgl/articles/shiny.html","id":"map-inputs","dir":"Articles","previous_headings":"","what":"Map inputs","title":"Using mapgl with Shiny","text":"number map events built-working mapgl Shiny session exposed user inputs. include: input$MAPID_center: center coordinates map (named lng lat); input$MAPID_zoom: current zoom level map; input$MAPID_bbox: bounding box visible extent map, named xmin, xmax, ymin, ymax. input$MAPID_click: longitude latitude click, named lng lat, timestamp click, named time. Visible features map can also queried clicked. Clicking map Shiny returns input$MAPID_feature_click, gets layer ID, column values clicked feature (accessible properties), well coordinates time click. Try example see works:","code":"ui <- page_sidebar( title = \"mapgl with Shiny\", sidebar = sidebar( verbatimTextOutput(\"clicked_feature\") ), card( full_screen = TRUE, maplibreOutput(\"map\") ) ) server <- function(input, output, session) { output$map <- renderMaplibre({ maplibre(style = carto_style(\"positron\")) |> fit_bounds(nc, animate = FALSE) |> add_fill_layer(id = \"nc_data\", source = nc, fill_color = \"blue\", fill_opacity = 0.5) }) output$clicked_feature <- renderPrint({ req(input$map_feature_click) input$map_feature_click }) } shinyApp(ui, server)"},{"path":"https://walker-data.com/mapgl/articles/shiny.html","id":"shiny-specific-functions","dir":"Articles","previous_headings":"","what":"Shiny-specific functions","title":"Using mapgl with Shiny","text":"mapgl includes number functions help interact maps data Shiny session, likely add future. include: set_style(), modify underlying style (basemap) map; set_layout_property(), modify layout property map (whether layer displayed); set_paint_property(), modify styling layer; set_filter(), dynamically filters displayed data layer based input value. ’ll need build filter expressionto achieve ; using list() R translate square brackets JavaScript. plans make easier users future. ’ll use functions combination proxy object, familiar users coming Leaflet R mapping packages. map proxy preserves existing state map, allows edit components without re-drawing entire map app. ’ll use mapboxgl_proxy() Mapbox maps, maplibre_proxy() MapLibre maps. Try example uses color picker widget change color map, slider filter visible counties based expression.","code":"library(colourpicker) ui <- page_sidebar( title = \"mapgl with Shiny\", sidebar = sidebar( colourInput(\"color\", \"Select a color\", value = \"blue\"), sliderInput(\"slider\", \"Show BIR74 values above:\", value = 248, min = 248, max = 21588) ), card( full_screen = TRUE, maplibreOutput(\"map\") ) ) server <- function(input, output, session) { output$map <- renderMaplibre({ maplibre(style = carto_style(\"positron\")) |> fit_bounds(nc, animate = FALSE) |> add_fill_layer(id = \"nc_data\", source = nc, fill_color = \"blue\", fill_opacity = 0.5) }) observeEvent(input$color, { maplibre_proxy(\"map\") |> set_paint_property(\"nc_data\", \"fill-color\", input$color) }) observeEvent(input$slider, { maplibre_proxy(\"map\") |> set_filter(\"nc_data\", list(\">=\", get_column(\"BIR74\"), input$slider)) }) } shinyApp(ui, server)"},{"path":"https://walker-data.com/mapgl/articles/shiny.html","id":"comparison-maps-in-shiny","dir":"Articles","previous_headings":"","what":"Comparison maps in Shiny","title":"Using mapgl with Shiny","text":"way side--side maps generated compare() function work mapgl, comparison maps require rendering functions. Mapbox maps, can use mapboxglCompareOutput(), renderMapboxglCompare(); mapboxgl_compare_proxy(); MapLibre, use maplibreCompareOutput(); renderMaplibreCompare(); maplibre_compare_proxy(). compare proxies, can target side map want modify argument map_side = \"\" (left top) map_side = \"\" (right bottom).","code":""},{"path":"https://walker-data.com/mapgl/articles/story-maps.html","id":"moving-the-map-on-scroll","dir":"Articles","previous_headings":"","what":"Moving the map on scroll","title":"Building story maps with mapgl","text":"Let’s take look works basic example. ’ll build story map two sections: introductory section, second section map “flies ” location user scrolls. get started, let’s build basic user interface without map actions. ui, set story_map() inside fluid page two sections. server, ’ll create Mapbox globe mapboxgl() renderMapboxgl(). cases ’ll want set option scrollZoom = FALSE initialize map map scrolling behavior doesn’t interfere story scrolling. ’ll note scrolling transition story sections, can still interact map clicking panning. However, haven’t set actions server, nothing else happens scroll sections. can change using on_section() function. on_section(), ’ll specify map ID (case, \"map\") section ID link action; section ID name corresponding list element defined list passed sections UI. ’ll define expression, much like observeEvent() Shiny, executed given section appears. map zooms Colosseum Rome user scroll. scroll back top, however, ’ll notice view return original globe. can remedied tying on_section() event introductory section. map transitions, addition fly_to(), might consider using ease_to() jump_to() depending use case. Map transition functions support camera options animation options keyword arguments applicable.","code":"library(shiny) library(mapgl) ui <- fluidPage( story_map( map_id = \"map\", sections = list( \"intro\" = story_section( \"Introduction\", \"This is a story map.\" ), \"location\" = story_section( \"Location\", \"Check out this interesting location.\" ) ) ) ) server <- function(input, output, session) { output$map <- renderMapboxgl({ mapboxgl(scrollZoom = FALSE) }) } shinyApp(ui, server) library(shiny) library(mapgl) ui <- fluidPage( story_map( map_id = \"map\", sections = list( \"intro\" = story_section( \"Introduction\", \"This is a story map.\" ), \"location\" = story_section( \"Location\", \"Check out this interesting location.\" ) ) ) ) server <- function(input, output, session) { output$map <- renderMapboxgl({ mapboxgl(scrollZoom = FALSE) }) on_section(\"map\", \"location\", { mapboxgl_proxy(\"map\") |> fly_to(center = c(12.49257, 41.890233), zoom = 17.5, pitch = 49, bearing = 12.8) }) } shinyApp(ui, server) library(shiny) library(mapgl) ui <- fluidPage( story_map( map_id = \"map\", sections = list( \"intro\" = story_section( \"Introduction\", \"This is a story map.\" ), \"location\" = story_section( \"Location\", \"Check out this interesting location.\" ) ) ) ) server <- function(input, output, session) { output$map <- renderMapboxgl({ mapboxgl(scrollZoom = FALSE) }) on_section(\"map\", \"intro\", { mapboxgl_proxy(\"map\") |> fly_to(center = c(0, 0), zoom = 0, pitch = 0, bearing = 0) }) on_section(\"map\", \"location\", { mapboxgl_proxy(\"map\") |> fly_to(center = c(12.49257, 41.890233), zoom = 17.5, pitch = 49, bearing = 12.8) }) } shinyApp(ui, server)"},{"path":"https://walker-data.com/mapgl/articles/story-maps.html","id":"adding-data-and-modifying-story-appearance","dir":"Articles","previous_headings":"","what":"Adding data and modifying story appearance","title":"Building story maps with mapgl","text":"many cases, ’ll want use story maps visualize data ’ll add Mapbox / MapLibre basemap. Let’s build example real estate firm might use story map market property. Let’s break key elements story map. ’re loading Google font, “Poppins”, Shiny app tags$link(). allows us use Poppins font globally story_map() passing argument font_family. appearance panels can also modified section--section prefer. story section panel, passing list HTML items content. introductory section shows include local image (www folder local app); can also reference remotely-hosted images include HTML elements supported Shiny. Also note position = \"center\" argument position introductory panel center screen; \"left\" default, \"right\" also supported without need additional CSS customization. first example, story actions defined calls on_section() operate Mapbox GL proxy object, \"map\". example, use add_markers() add marker location, add_fill_layer() add 20-minute drivetime isochrone created Mapbox API. Transitions views handled fly_to() fit_bounds(), clear_layer() clear_markers() calls used control data layers visible user goes forward backward story.","code":"library(shiny) library(mapgl) library(mapboxapi) property <- c(-97.71326, 30.402550) isochrone <- mb_isochrone(property, profile = \"driving\", time = 20) ui <- fluidPage( tags$link(href = \"https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap\", rel=\"stylesheet\"), story_map( map_id = \"map\", font_family = \"Poppins\", sections = list( \"intro\" = story_section( title = \"MULTIFAMILY INVESTMENT OPPORTUNITY\", content = list( p(\"New Class A Apartments in Austin, Texas\"), img(src = \"apartment.png\", width = \"300px\") ), position = \"center\" ), \"marker\" = story_section( title = \"PROPERTY LOCATION\", content = list( p(\"The property will be located in the thriving Domain district of north Austin, home to some of the city's best shopping, dining, and entertainment.\") ) ), \"isochrone\" = story_section( title = \"AUSTIN AT YOUR FINGERTIPS\", content = list( p(\"The property is within a 20-minute drive of downtown Austin, the University of Texas, and the city's major employers.\") ) ) ) ) ) server <- function(input, output, session) { output$map <- renderMapboxgl({ mapboxgl(scrollZoom = FALSE, center = c(-97.7301093, 30.288647), zoom = 12) }) on_section(\"map\", \"intro\", { mapboxgl_proxy(\"map\") |> clear_markers() |> fly_to(center = c(-97.7301093, 30.288647), zoom = 12, pitch = 0, bearing = 0) }) on_section(\"map\", \"marker\", { mapboxgl_proxy(\"map\") |> clear_layer(\"isochrone\") |> add_markers(data = property, color = \"#CC5500\") |> fly_to(center = property, zoom = 16, pitch = 45, bearing = -90) }) on_section(\"map\", \"isochrone\", { mapboxgl_proxy(\"map\") |> add_fill_layer( id = \"isochrone\", source = isochrone, fill_color = \"#CC5500\", fill_opacity = 0.5 ) |> fit_bounds( isochrone, animate = TRUE, duration = 8000, pitch = 75 ) }) } shinyApp(ui, server)"},{"path":"https://walker-data.com/mapgl/articles/story-maps.html","id":"integrating-shiny-inputs-and-outputs","dir":"Articles","previous_headings":"","what":"Integrating Shiny inputs and outputs","title":"Building story maps with mapgl","text":"story map feature mapgl built unique way accommodate map-based scrollytelling, still creating R Shiny app. means Shiny’s functionality interactivity available build story maps. list items pass content given story section panel can include Shiny inputs well Shiny outputs can correspond content visible story maps. Let’s set scenario adds interactivity data displayed Fundamentals map design mapgl vignette. ’ll make map median age Florida, display introductory story panel. user selects county display; scroll, story zoom selected county show histogram values Census tracts county. Let’s walk works. UI code familiar, though now using MapLibre backend story_maplibre(). main difference inclusion Shiny selectInput() first story panel two Shiny outputs second story panel. ’ve set , users can select county beginning story, get different output scroll . reactive object sel_county() used get county-specific values second story panel, help us determine map’s extent want zoom selected county. said, don’t use sel_county() directly map. Instead, use mapgl’s set_filter() function, performant filtering data clearing layer re-adding . allows us invoke underlying setFilter() JavaScript method (see documentation) operate directly map layer . Setting filter NULL clears filter gives us back entire state Florida. note content second panel entirely Shiny outputs: h2 header corresponds selected county, histogram median age values Census tracts county drawn ggplot2.","code":"library(shiny) library(mapgl) library(tidycensus) library(tidyverse) library(sf) fl_age <- get_acs( geography = \"tract\", variables = \"B01002_001\", state = \"FL\", year = 2023, geometry = TRUE ) |> separate_wider_delim(NAME, delim = \"; \", names = c(\"tract\", \"county\", \"state\")) %>% st_sf() ui <- fluidPage( story_maplibre( map_id = \"map\", sections = list( \"intro\" = story_section( \"Median Age in Florida\", content = list( selectInput( \"county\", \"Select a county\", choices = sort(unique(fl_age$county)) ), p(\"Scroll down to view the median age distribution in the selected county.\") ) ), \"county\" = story_section( title = NULL, content = list( uiOutput(\"county_text\"), plotOutput(\"county_plot\") ) ) ) ) ) server <- function(input, output, session) { sel_county <- reactive({ filter(fl_age, county == input$county) }) output$map <- renderMaplibre({ maplibre( carto_style(\"positron\"), bounds = fl_age, scrollZoom = FALSE ) |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = interpolate( column = \"estimate\", values = c(20, 80), stops = c(\"lightblue\", \"darkblue\"), na_color = \"lightgrey\" ), fill_opacity = 0.5 ) |> add_legend( \"Median age in Florida\", values = c(20, 80), colors = c(\"lightblue\", \"darkblue\"), position = \"bottom-right\" ) }) output$county_text <- renderUI({ h2(toupper(input$county)) }) output$county_plot <- renderPlot({ ggplot(sel_county(), aes(x = estimate)) + geom_histogram(fill = \"lightblue\", color = \"black\", bins = 10) + theme_minimal() + labs(x = \"Median Age\", y = \"\") }) on_section(\"map\", \"intro\", { maplibre_proxy(\"map\") |> set_filter(\"fl_tracts\", NULL) |> fit_bounds(fl_age, animate = TRUE) }) on_section(\"map\", \"county\", { maplibre_proxy(\"map\") |> set_filter(\"fl_tracts\", filter = list(\"==\", \"county\", input$county)) |> fit_bounds(sel_county(), animate = TRUE) }) } shinyApp(ui, server)"},{"path":"https://walker-data.com/mapgl/articles/story-maps.html","id":"sharing-your-stories-next-steps","dir":"Articles","previous_headings":"","what":"Sharing your stories / next steps","title":"Building story maps with mapgl","text":"story map Shiny app, ’ll need publish Shiny server share . Posit’s ShinyApps.io Connect Cloud products nice options don’t want set Shiny server. building story maps mapgl, please let know ! ’m also planning trainings / workshops feature, please reach interested.","code":""},{"path":"https://walker-data.com/mapgl/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Kyle Walker. Author, maintainer.","code":""},{"path":"https://walker-data.com/mapgl/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Walker K (2025). mapgl: Interactive Maps 'Mapbox GL JS' 'MapLibre GL JS'. R package version 0.2.2.9000, https://walker-data.com/mapgl/.","code":"@Manual{, title = {mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS'}, author = {Kyle Walker}, year = {2025}, note = {R package version 0.2.2.9000}, url = {https://walker-data.com/mapgl/}, }"},{"path":"https://walker-data.com/mapgl/index.html","id":"mapgl-","dir":"","previous_headings":"","what":"mapgl: WebGL Maps in R with Mapbox and MapLibre","title":"mapgl: WebGL Maps in R with Mapbox and MapLibre","text":"mapgl R package makes latest versions Mapbox GL JS MapLibre GL JS available R users. package interface designed make powerful capabilities libraries available R mapping projects, also feel similar users coming R mapping packages. Install CRAN: , install development version GitHub: Read vignettes learn use package: Getting started mapgl Using layers: overview Fundamentals map design mapgl Using mapgl Shiny Building story maps mapgl","code":"install.packages(\"mapgl\") remotes::install_github(\"walkerke/mapgl\")"},{"path":"https://walker-data.com/mapgl/index.html","id":"recommended-training-and-how-to-learn-more","dir":"","previous_headings":"","what":"Recommended training and how to learn more","title":"mapgl: WebGL Maps in R with Mapbox and MapLibre","text":"find project useful work like ensure continued development package, can provide support following ways: Purchase official mapgl workshop series, hosted mapgl’s author, Kyle Walker; Chip funds support package development via PayPal; Set consulting engagement workshop though Walker Data help implement mapgl project. Send note kyle@walker-data.com interested; File issue - even better, pull request - https://github.com/walkerke/mapgl/issues. stay top package updates / new features get information mapgl trainings, sure sign Walker Data mailing list .","code":""},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"function adds categorical legend Mapbox GL map. supports customizable colors, sizes, shapes legend items.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"","code":"add_categorical_legend( map, legend_title, values, colors, circular_patches = FALSE, position = \"top-left\", unique_id = NULL, sizes = NULL, add = FALSE, width = NULL, layer_id = NULL, margin_top = NULL, margin_right = NULL, margin_bottom = NULL, margin_left = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"map map object created mapboxgl function. legend_title title legend. values vector categories values displayed legend. colors corresponding colors values. Can vector colors single color. circular_patches Logical, whether use circular patches legend. Default FALSE. position position legend map. One \"top-left\", \"bottom-left\", \"top-right\", \"bottom-right\". Default \"top-left\". unique_id unique ID legend container. NULL, random ID generated. sizes optional numeric vector sizes legend patches, single numeric value. provided vector, length values. circular_patches FALSE (square patches), sizes represent width height patch pixels. circular_patches TRUE, sizes represent radius circle. add Logical, whether add legend existing legends (TRUE) replace existing legends (FALSE). Default FALSE. width width legend. Can specified pixels (e.g., \"250px\") \"auto\". Default NULL, uses built-default. layer_id ID layer legend associated . provided, legend shown/hidden layer visibility toggled. margin_top Custom top margin pixels, allowing fine control legend positioning. Default NULL (uses standard positioning). margin_right Custom right margin pixels. Default NULL. margin_bottom Custom bottom margin pixels. Default NULL. margin_left Custom left margin pixels. Default NULL.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"updated map object legend added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_categorical_legend.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a categorical legend to a Mapbox GL map — add_categorical_legend","text":"","code":"if (FALSE) { # \\dontrun{ library(mapboxgl) map <- mapboxgl( center = c(-96, 37.8), zoom = 3 ) map %>% add_categorical_legend( legend_title = \"Population\", values = c(\"Low\", \"Medium\", \"High\"), colors = c(\"#FED976\", \"#FEB24C\", \"#FD8D3C\"), circular_patches = TRUE, sizes = c(10, 15, 20), width = \"300px\" ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a circle layer to a Mapbox GL map — add_circle_layer","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"Add circle layer Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"","code":"add_circle_layer( map, id, source, source_layer = NULL, circle_blur = NULL, circle_color = NULL, circle_opacity = NULL, circle_radius = NULL, circle_sort_key = NULL, circle_stroke_color = NULL, circle_stroke_opacity = NULL, circle_stroke_width = NULL, circle_translate = NULL, circle_translate_anchor = \"map\", visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL, cluster_options = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"map map object created mapboxgl function. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). circle_blur Amount blur circle. circle_color color circle. circle_opacity opacity circle drawn. circle_radius Circle radius. circle_sort_key Sorts features ascending order based value. circle_stroke_color color circle's stroke. circle_stroke_opacity opacity circle's stroke. circle_stroke_width width circle's stroke. circle_translate geometry's offset. Values c(x, y) negatives indicate left . circle_translate_anchor Controls frame reference circle-translate. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer. cluster_options list options clustering circles, created cluster_options() function.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"modified map object new circle layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_circle_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a circle layer to a Mapbox GL map — add_circle_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(sf) library(dplyr) # Set seed for reproducibility set.seed(1234) # Define the bounding box for Washington DC (approximately) bbox <- st_bbox( c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), crs = st_crs(4326) ) # Generate 30 random points within the bounding box random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox[\"xmin\"], bbox[\"xmax\"]), lat = runif(30, bbox[\"ymin\"], bbox[\"ymax\"]) ), coords = c(\"lon\", \"lat\"), crs = 4326 ) # Assign random categories categories <- c(\"music\", \"bar\", \"theatre\", \"bicycle\") random_points <- random_points %>% mutate(category = sample(categories, n(), replace = TRUE)) # Map with circle layer mapboxgl(style = mapbox_style(\"light\")) %>% fit_bounds(random_points, animate = FALSE) %>% add_circle_layer( id = \"poi-layer\", source = random_points, circle_color = match_expr( \"category\", values = c( \"music\", \"bar\", \"theatre\", \"bicycle\" ), stops = c( \"#1f78b4\", \"#33a02c\", \"#e31a1c\", \"#ff7f00\" ) ), circle_radius = 8, circle_stroke_color = \"#ffffff\", circle_stroke_width = 2, circle_opacity = 0.8, tooltip = \"category\", hover_options = list( circle_radius = 12, circle_color = \"#ffff99\" ) ) %>% add_categorical_legend( legend_title = \"Points of Interest\", values = c(\"Music\", \"Bar\", \"Theatre\", \"Bicycle\"), colors = c(\"#1f78b4\", \"#33a02c\", \"#e31a1c\", \"#ff7f00\"), circular_patches = TRUE ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_continuous_legend.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a continuous legend — add_continuous_legend","title":"Add a continuous legend — add_continuous_legend","text":"Add continuous legend","code":""},{"path":"https://walker-data.com/mapgl/reference/add_continuous_legend.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a continuous legend — add_continuous_legend","text":"","code":"add_continuous_legend( map, legend_title, values, colors, position = \"top-left\", unique_id = NULL, add = FALSE, width = NULL, layer_id = NULL, margin_top = NULL, margin_right = NULL, margin_bottom = NULL, margin_left = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_continuous_legend.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a continuous legend — add_continuous_legend","text":"map map object created mapboxgl function. legend_title title legend. values values represented map (vector stops). colors colors used generate color ramp. position position legend map (one \"top-left\", \"bottom-left\", \"top-right\", \"bottom-right\"). unique_id unique ID legend container. Defaults NULL. add Logical, whether add legend existing legends (TRUE) replace existing legends (FALSE). Default FALSE. width width legend. Can specified pixels (e.g., \"250px\") \"auto\". Default NULL, uses built-default. layer_id ID layer legend associated . provided, legend shown/hidden layer visibility toggled. margin_top Custom top margin pixels, allowing fine control legend positioning. Default NULL (uses standard positioning). margin_right Custom right margin pixels. Default NULL. margin_bottom Custom bottom margin pixels. Default NULL. margin_left Custom left margin pixels. Default NULL.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_continuous_legend.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a continuous legend — add_continuous_legend","text":"updated map object legend added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a custom control to a map — add_control","title":"Add a custom control to a map — add_control","text":"function adds custom control Mapbox GL MapLibre GL map. allows create custom HTML element controls add map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a custom control to a map — add_control","text":"","code":"add_control(map, html, position = \"top-right\", className = NULL, ...)"},{"path":"https://walker-data.com/mapgl/reference/add_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a custom control to a map — add_control","text":"map map object created mapboxgl maplibre functions. html Character string containing HTML content control. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"top-right\". className Optional CSS class name control container. ... Additional arguments passed JavaScript side.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a custom control to a map — add_control","text":"modified map object custom control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a custom control to a map — add_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) maplibre() |> add_control( html = \"

    Custom HTML<\/p> image <\/div>\", position = \"top-left\" ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a draw control to a map — add_draw_control","title":"Add a draw control to a map — add_draw_control","text":"Add draw control map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a draw control to a map — add_draw_control","text":"","code":"add_draw_control( map, position = \"top-left\", freehand = FALSE, simplify_freehand = FALSE, orientation = \"vertical\", source = NULL, point_color = \"#3bb2d0\", line_color = \"#3bb2d0\", fill_color = \"#3bb2d0\", fill_opacity = 0.1, active_color = \"#fbb03b\", vertex_radius = 5, line_width = 2, ... )"},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a draw control to a map — add_draw_control","text":"map map object created mapboxgl maplibre functions. position string specifying position draw control. One \"top-right\", \"top-left\", \"bottom-right\", \"bottom-left\". freehand Logical, whether enable freehand drawing mode. Default FALSE. simplify_freehand Logical, whether apply simplification freehand drawings. Default FALSE. orientation string specifying orientation draw control. Either \"vertical\" (default) \"horizontal\". source character string specifying source ID add draw control. Default NULL. point_color Color point features. Default \"#3bb2d0\" (light blue). line_color Color line features. Default \"#3bb2d0\" (light blue). fill_color Fill color polygon features. Default \"#3bb2d0\" (light blue). fill_opacity Fill opacity polygon features. Default 0.1. active_color Color active (selected) features. Default \"#fbb03b\" (orange). vertex_radius Radius vertex points pixels. Default 5. line_width Width lines pixels. Default 2. ... Additional named arguments. See https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md#options list options.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a draw control to a map — add_draw_control","text":"modified map object draw control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_draw_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a draw control to a map — add_draw_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.50, 40), zoom = 9 ) |> add_draw_control() # With initial features from a source library(tigris) tx <- counties(state = \"TX\", cb = TRUE) mapboxgl(bounds = tx) |> add_source(id = \"tx\", data = tx) |> add_draw_control(source = \"tx\") # With custom styling mapboxgl() |> add_draw_control( point_color = \"#ff0000\", line_color = \"#00ff00\", fill_color = \"#0000ff\", fill_opacity = 0.3, active_color = \"#ff00ff\", vertex_radius = 7, line_width = 3 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_features_to_draw.html","id":null,"dir":"Reference","previous_headings":"","what":"Add features to an existing draw control — add_features_to_draw","title":"Add features to an existing draw control — add_features_to_draw","text":"function adds features existing source draw control map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_features_to_draw.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add features to an existing draw control — add_features_to_draw","text":"","code":"add_features_to_draw(map, source, clear_existing = FALSE)"},{"path":"https://walker-data.com/mapgl/reference/add_features_to_draw.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add features to an existing draw control — add_features_to_draw","text":"map map object draw control already added source Character string specifying source ID get features clear_existing Logical, whether clear existing drawn features adding new ones. Default FALSE.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_features_to_draw.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add features to an existing draw control — add_features_to_draw","text":"modified map object","code":""},{"path":"https://walker-data.com/mapgl/reference/add_features_to_draw.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add features to an existing draw control — add_features_to_draw","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(tigris) # Add features from an existing source tx <- counties(state = \"TX\", cb = TRUE) mapboxgl(bounds = tx) |> add_source(id = \"tx\", data = tx) |> add_draw_control() |> add_features_to_draw(source = \"tx\") # In a Shiny app observeEvent(input$load_data, { mapboxgl_proxy(\"map\") |> add_features_to_draw( source = \"dynamic_data\", clear_existing = TRUE ) }) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"Add fill-extrusion layer Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"","code":"add_fill_extrusion_layer( map, id, source, source_layer = NULL, fill_extrusion_base = NULL, fill_extrusion_color = NULL, fill_extrusion_height = NULL, fill_extrusion_opacity = NULL, fill_extrusion_pattern = NULL, fill_extrusion_translate = NULL, fill_extrusion_translate_anchor = \"map\", visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"map map object created mapboxgl function. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). fill_extrusion_base base height fill extrusion. fill_extrusion_color color fill extrusion. fill_extrusion_height height fill extrusion. fill_extrusion_opacity opacity fill extrusion. fill_extrusion_pattern Name image sprite use drawing image fills. fill_extrusion_translate geometry's offset. Values c(x, y) negatives indicate left . fill_extrusion_translate_anchor Controls frame reference fill-extrusion-translate. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"modified map object new fill-extrusion layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a fill-extrusion layer to a Mapbox GL map — add_fill_extrusion_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) maplibre( style = maptiler_style(\"basic\"), center = c(-74.0066, 40.7135), zoom = 15.5, pitch = 45, bearing = -17.6 ) |> add_vector_source( id = \"openmaptiles\", url = paste0( \"https://api.maptiler.com/tiles/v3/tiles.json?key=\", Sys.getenv(\"MAPTILER_API_KEY\") ) ) |> add_fill_extrusion_layer( id = \"3d-buildings\", source = \"openmaptiles\", source_layer = \"building\", fill_extrusion_color = interpolate( column = \"render_height\", values = c(0, 200, 400), stops = c(\"lightgray\", \"royalblue\", \"lightblue\") ), fill_extrusion_height = list( \"interpolate\", list(\"linear\"), list(\"zoom\"), 15, 0, 16, list(\"get\", \"render_height\") ) ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a fill layer to a map — add_fill_layer","title":"Add a fill layer to a map — add_fill_layer","text":"Add fill layer map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a fill layer to a map — add_fill_layer","text":"","code":"add_fill_layer( map, id, source, source_layer = NULL, fill_antialias = TRUE, fill_color = NULL, fill_emissive_strength = NULL, fill_opacity = NULL, fill_outline_color = NULL, fill_pattern = NULL, fill_sort_key = NULL, fill_translate = NULL, fill_translate_anchor = \"map\", fill_z_offset = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a fill layer to a map — add_fill_layer","text":"map map object created mapboxgl maplibre functions. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). fill_antialias Whether fill antialiased. fill_color color filled part layer. fill_emissive_strength Controls intensity light emitted source features. fill_opacity opacity entire fill layer. fill_outline_color outline color fill. fill_pattern Name image sprite use drawing image fills. fill_sort_key Sorts features ascending order based value. fill_translate geometry's offset. Values c(x, y) negatives indicate left . fill_translate_anchor Controls frame reference fill-translate. fill_z_offset Specifies uniform elevation meters. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a fill layer to a map — add_fill_layer","text":"modified map object new fill layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fill_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a fill layer to a map — add_fill_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(tidycensus) fl_age <- get_acs( geography = \"tract\", variables = \"B01002_001\", state = \"FL\", year = 2022, geometry = TRUE ) mapboxgl() |> fit_bounds(fl_age, animate = FALSE) |> add_fill_layer( id = \"fl_tracts\", source = fl_age, fill_color = interpolate( column = \"estimate\", values = c(20, 80), stops = c(\"lightblue\", \"darkblue\"), na_color = \"lightgrey\" ), fill_opacity = 0.5 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a fullscreen control to a map — add_fullscreen_control","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"Add fullscreen control map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"","code":"add_fullscreen_control(map, position = \"top-right\")"},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"map map object created mapboxgl maplibre functions. position string specifying position fullscreen control. One \"top-right\", \"top-left\", \"bottom-right\", \"bottom-left\".","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"modified map object fullscreen control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_fullscreen_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a fullscreen control to a map — add_fullscreen_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) maplibre( style = maptiler_style(\"streets\"), center = c(11.255, 43.77), zoom = 13 ) |> add_fullscreen_control(position = \"top-right\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a geocoder control to a map — add_geocoder_control","title":"Add a geocoder control to a map — add_geocoder_control","text":"function adds Geocoder search bar Mapbox GL MapLibre GL map. default, marker added selected location map fly location. results geocode accessible Shiny session input$MAPID_geocoder$result, MAPID name map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a geocoder control to a map — add_geocoder_control","text":"","code":"add_geocoder_control( map, position = \"top-right\", placeholder = \"Search\", collapsed = FALSE, ... )"},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a geocoder control to a map — add_geocoder_control","text":"map map object created mapboxgl maplibre function. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"top-right\". placeholder string use placeholder text search bar. Default \"Search\". collapsed Whether control collapsed hovered clicked. Default FALSE. ... Additional parameters pass Geocoder.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a geocoder control to a map — add_geocoder_control","text":"modified map object geocoder control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geocoder_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a geocoder control to a map — add_geocoder_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_geocoder_control(position = \"top-left\", placeholder = \"Enter an address\") maplibre() |> add_geocoder_control(position = \"top-right\", placeholder = \"Search location\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a geolocate control to a map — add_geolocate_control","title":"Add a geolocate control to a map — add_geolocate_control","text":"function adds Geolocate control Mapbox GL MapLibre GL map. geolocate control allows users track current location map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a geolocate control to a map — add_geolocate_control","text":"","code":"add_geolocate_control( map, position = \"top-right\", track_user = FALSE, show_accuracy_circle = TRUE, show_user_location = TRUE, show_user_heading = FALSE, fit_bounds_options = list(maxZoom = 15), position_options = list(enableHighAccuracy = FALSE, timeout = 6000) )"},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a geolocate control to a map — add_geolocate_control","text":"map map object created mapboxgl maplibre functions. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"top-right\". track_user Whether actively track user's location. TRUE, map continuously update user moves. Default FALSE. show_accuracy_circle Whether show circle indicating accuracy location. Default TRUE. show_user_location Whether show dot user's location. Default TRUE. show_user_heading Whether show arrow indicating device's heading tracking location. works track_user TRUE. Default FALSE. fit_bounds_options list options fitting bounds panning user's location. Default maxZoom 15. position_options list Geolocation API position options. Default enableHighAccuracy=FALSE timeout=6000.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a geolocate control to a map — add_geolocate_control","text":"modified map object geolocate control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_geolocate_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a geolocate control to a map — add_geolocate_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_geolocate_control( position = \"top-right\", track_user = TRUE, show_user_heading = TRUE ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_globe_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a globe control to a map — add_globe_control","title":"Add a globe control to a map — add_globe_control","text":"function adds globe control MapLibre GL map allows toggling \"mercator\" \"globe\" projections single click.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a globe control to a map — add_globe_control","text":"","code":"add_globe_control(map, position = \"top-right\")"},{"path":"https://walker-data.com/mapgl/reference/add_globe_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a globe control to a map — add_globe_control","text":"map map object created maplibre function. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"top-right\".","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a globe control to a map — add_globe_control","text":"modified map object globe control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a globe control to a map — add_globe_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) maplibre() |> add_globe_control(position = \"top-right\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a Globe Minimap to a map — add_globe_minimap","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"function adds globe minimap control Mapbox GL Maplibre map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"","code":"add_globe_minimap( map, position = \"bottom-right\", globe_size = 82, land_color = \"white\", water_color = \"rgba(30 40 70/60%)\", marker_color = \"#ff2233\", marker_size = 1 )"},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"map mapboxgl maplibre object. position string specifying position minimap. globe_size Number pixels diameter globe. Default 82. land_color HTML color use land areas globe. Default 'white'. water_color HTML color use water areas globe. Default 'rgba(30 40 70/60%)'. marker_color HTML color use center point marker. Default '#ff2233'. marker_size Scale ratio center point marker. Default 1.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"modified map object globe minimap added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_globe_minimap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a Globe Minimap to a map — add_globe_minimap","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) m <- mapboxgl() %>% add_globe_minimap() m <- maplibre() %>% add_globe_minimap() } # }"},{"path":"https://walker-data.com/mapgl/reference/add_h3j_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a hexagon source from the H3 geospatial indexing system. — add_h3j_source","title":"Add a hexagon source from the H3 geospatial indexing system. — add_h3j_source","text":"Add hexagon source H3 geospatial indexing system.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_h3j_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a hexagon source from the H3 geospatial indexing system. — add_h3j_source","text":"","code":"add_h3j_source(map, id, url)"},{"path":"https://walker-data.com/mapgl/reference/add_h3j_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a hexagon source from the H3 geospatial indexing system. — add_h3j_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing vector tile source.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_h3j_source.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Add a hexagon source from the H3 geospatial indexing system. — add_h3j_source","text":"https://h3geo.org, https://github.com/INSPIDE/h3j-h3t","code":""},{"path":"https://walker-data.com/mapgl/reference/add_h3j_source.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a hexagon source from the H3 geospatial indexing system. — add_h3j_source","text":"","code":"if (FALSE) { # interactive() url = \"https://inspide.github.io/h3j-h3t/examples/h3j/sample.h3j\" maplibre(center=c(-3.704, 40.417), zoom=15, pitch=30) |> add_h3j_source(\"h3j_testsource\", url = url ) |> add_fill_extrusion_layer( id = \"h3j_testlayer\", source = \"h3j_testsource\", fill_extrusion_color = interpolate( column = \"value\", values = c(0, 21.864), stops = c(\"#430254\", \"#f83c70\") ), fill_extrusion_height = list( \"interpolate\", list(\"linear\"), list(\"zoom\"), 14, 0, 15.05, list(\"*\", 10, list(\"get\", \"value\")) ), fill_extrusion_opacity = 0.7 ) }"},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"Add heatmap layer Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"","code":"add_heatmap_layer( map, id, source, source_layer = NULL, heatmap_color = NULL, heatmap_intensity = NULL, heatmap_opacity = NULL, heatmap_radius = NULL, heatmap_weight = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"map map object created mapboxgl function. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). heatmap_color color heatmap points. heatmap_intensity intensity heatmap points. heatmap_opacity opacity heatmap layer. heatmap_radius radius influence individual heatmap point. heatmap_weight weight individual heatmap point. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"modified map object new heatmap layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_heatmap_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a heatmap layer to a Mapbox GL map — add_heatmap_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl( style = mapbox_style(\"dark\"), center = c(-120, 50), zoom = 2 ) |> add_heatmap_layer( id = \"earthquakes-heat\", source = list( type = \"geojson\", data = \"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\" ), heatmap_weight = interpolate( column = \"mag\", values = c(0, 6), stops = c(0, 1) ), heatmap_intensity = interpolate( property = \"zoom\", values = c(0, 9), stops = c(1, 3) ), heatmap_color = interpolate( property = \"heatmap-density\", values = seq(0, 1, 0.2), stops = c( \"rgba(33,102,172,0)\", \"rgb(103,169,207)\", \"rgb(209,229,240)\", \"rgb(253,219,199)\", \"rgb(239,138,98)\", \"rgb(178,24,43)\" ) ), heatmap_opacity = 0.7 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":null,"dir":"Reference","previous_headings":"","what":"Add an image to the map — add_image","title":"Add an image to the map — add_image","text":"function adds image map's style. image can used icon-image, background-pattern, fill-pattern, line-pattern.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add an image to the map — add_image","text":"","code":"add_image( map, id, url, content = NULL, pixel_ratio = 1, sdf = FALSE, stretch_x = NULL, stretch_y = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add an image to the map — add_image","text":"map map object created mapboxgl maplibre functions. id string specifying ID image. url string specifying URL image loaded path local image file. Must PNG JPEG format. content vector four numbers c(x1, y1, x2, y2) defining part image can covered content text-field icon-text-fit used. pixel_ratio number specifying ratio pixels image physical pixels screen. sdf logical value indicating whether image interpreted SDF image. stretch_x list number pairs defining part(s) image can stretched horizontally. stretch_y list number pairs defining part(s) image can stretched vertically.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add an image to the map — add_image","text":"modified map object image added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add an image to the map — add_image","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) # Path to your local image file OR a URL to a remote image file # that is not blocked by CORS restrictions image_path <- \"/path/to/your/image.png\" pts <- tigris::landmarks(\"DE\")[1:100, ] maplibre(bounds = pts) |> add_image(\"local_icon\", image_path) |> add_symbol_layer( id = \"local_icons\", source = pts, icon_image = \"local_icon\", icon_size = 0.5, icon_allow_overlap = TRUE ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_image_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","title":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","text":"Add image source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","text":"","code":"add_image_source( map, id, url = NULL, data = NULL, coordinates = NULL, colors = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_image_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing image source. data SpatRaster object terra package RasterLayer object. coordinates list coordinates specifying image corners clockwise order: top left, top right, bottom right, bottom left. SpatRaster RasterLayer objects, extracted . colors vector colors use raster image.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_image_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add an image source to a Mapbox GL or Maplibre GL map — add_image_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a layer to a map from a source — add_layer","title":"Add a layer to a map from a source — add_layer","text":"many cases, use add_layer() internal layer-specific functions mapgl. Advanced users want use add_layer() fine-grained control appearance layers.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a layer to a map from a source — add_layer","text":"","code":"add_layer( map, id, type = \"fill\", source, source_layer = NULL, paint = list(), layout = list(), slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a layer to a map from a source — add_layer","text":"map map object created mapboxgl() maplibre() functions. id unique ID layer. type type layer (e.g., \"fill\", \"line\", \"circle\"). source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). paint list paint properties layer. layout list layout properties layer. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a layer to a map from a source — add_layer","text":"modified map object new layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a layer to a map from a source — add_layer","text":"","code":"if (FALSE) { # \\dontrun{ # Load necessary libraries library(mapgl) library(tigris) # Load geojson data for North Carolina tracts nc_tracts <- tracts(state = \"NC\", cb = TRUE) # Create a Mapbox GL map map <- mapboxgl( style = mapbox_style(\"light\"), center = c(-79.0193, 35.7596), zoom = 7 ) # Add a source and fill layer for North Carolina tracts map %>% add_source( id = \"nc-tracts\", data = nc_tracts ) %>% add_layer( id = \"nc-layer\", type = \"fill\", source = \"nc-tracts\", paint = list( \"fill-color\" = \"#888888\", \"fill-opacity\" = 0.4 ) ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a layers control to the map — add_layers_control","title":"Add a layers control to the map — add_layers_control","text":"Add layers control map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a layers control to the map — add_layers_control","text":"","code":"add_layers_control( map, position = \"top-left\", layers = NULL, collapsible = TRUE, use_icon = TRUE, background_color = NULL, active_color = NULL, hover_color = NULL, active_text_color = NULL, inactive_text_color = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a layers control to the map — add_layers_control","text":"map map object. position position control map (one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\"). layers vector layer IDs included control. NULL, layers included. collapsible Whether control collapsible. use_icon Whether use stacked layers icon instead \"Layers\" text collapsed. applies collapsible = TRUE. background_color background color layers control; color used inactive layer items. active_color background color active layer items. hover_color background color layer items hovered. active_text_color text color active layer items. inactive_text_color text color inactive layer items.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a layers control to the map — add_layers_control","text":"modified map object layers control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_layers_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a layers control to the map — add_layers_control","text":"","code":"if (FALSE) { # \\dontrun{ library(tigris) options(tigris_use_cache = TRUE) rds <- roads(\"TX\", \"Tarrant\") tr <- tracts(\"TX\", \"Tarrant\", cb = TRUE) maplibre() |> fit_bounds(rds) |> add_fill_layer( id = \"Census tracts\", source = tr, fill_color = \"purple\", fill_opacity = 0.6 ) |> add_line_layer( \"Local roads\", source = rds, line_color = \"pink\" ) |> add_layers_control( position = \"top-left\", background_color = \"#ffffff\", active_color = \"#4a90e2\" ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_legend.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a legend to a Mapbox GL map — add_legend","title":"Add a legend to a Mapbox GL map — add_legend","text":"Add legend Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_legend.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a legend to a Mapbox GL map — add_legend","text":"","code":"add_legend( map, legend_title, values, colors, type = c(\"continuous\", \"categorical\"), circular_patches = FALSE, position = \"top-left\", sizes = NULL, add = FALSE, unique_id = NULL, width = NULL, layer_id = NULL, margin_top = NULL, margin_right = NULL, margin_bottom = NULL, margin_left = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_legend.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a legend to a Mapbox GL map — add_legend","text":"map map object created mapboxgl function. legend_title title legend. values values represented map (either vector categories vector stops). colors corresponding colors values (either vector colors, single color, interpolate function). type One \"continuous\" \"categorical\". circular_patches Logical, whether use circular patches legend (categorical legends). position position legend map (one \"top-left\", \"bottom-left\", \"top-right\", \"bottom-right\"). sizes optional numeric vector sizes legend patches, single numeric value (categorical legends). add Logical, whether add legend existing legends (TRUE) replace existing legends (FALSE). Default FALSE. unique_id Optional. unique identifier legend. provided, random ID generated. width width legend. Can specified pixels (e.g., \"250px\") \"auto\". Default NULL, uses built-default. layer_id ID layer legend associated . provided, legend shown/hidden layer visibility toggled. margin_top Custom top margin pixels, allowing fine control legend positioning. Default NULL (uses standard positioning). margin_right Custom right margin pixels. Default NULL. margin_bottom Custom bottom margin pixels. Default NULL. margin_left Custom left margin pixels. Default NULL.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_legend.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a legend to a Mapbox GL map — add_legend","text":"updated map object legend added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a line layer to a map — add_line_layer","title":"Add a line layer to a map — add_line_layer","text":"Add line layer map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a line layer to a map — add_line_layer","text":"","code":"add_line_layer( map, id, source, source_layer = NULL, line_blur = NULL, line_cap = NULL, line_color = NULL, line_dasharray = NULL, line_emissive_strength = NULL, line_gap_width = NULL, line_gradient = NULL, line_join = NULL, line_miter_limit = NULL, line_occlusion_opacity = NULL, line_offset = NULL, line_opacity = NULL, line_pattern = NULL, line_round_limit = NULL, line_sort_key = NULL, line_translate = NULL, line_translate_anchor = \"map\", line_trim_color = NULL, line_trim_fade_range = NULL, line_trim_offset = NULL, line_width = NULL, line_z_offset = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a line layer to a map — add_line_layer","text":"map map object created mapboxgl maplibre functions. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). line_blur Amount blur line, pixels. line_cap display line endings. One \"butt\", \"round\", \"square\". line_color color line drawn. line_dasharray Specifies lengths alternating dashes gaps form dash pattern. line_emissive_strength Controls intensity light emitted source features. line_gap_width Draws line casing outside line's actual path. Value indicates width inner gap. line_gradient gradient used color line feature various distances along length. line_join display lines joining. line_miter_limit Used automatically convert miter joins bevel joins sharp angles. line_occlusion_opacity Opacity multiplier line part occluded 3D objects. line_offset line's offset. line_opacity opacity line drawn. line_pattern Name image sprite use drawing image lines. line_round_limit Used automatically convert round joins miter joins shallow angles. line_sort_key Sorts features ascending order based value. line_translate geometry's offset. Values c(x, y) negatives indicate left , respectively. line_translate_anchor Controls frame reference line-translate. line_trim_color color used rendering trimmed line section. line_trim_fade_range fade range trim-start trim-end points. line_trim_offset line part c(trim_start, trim_end) painted using line_trim_color. line_width Stroke thickness. line_z_offset Vertical offset ground, meters. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels) filter optional filter expression subset features layer.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a line layer to a map — add_line_layer","text":"modified map object new line layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_line_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a line layer to a map — add_line_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(tigris) loving_roads <- roads(\"TX\", \"Loving\") maplibre(style = maptiler_style(\"backdrop\")) |> fit_bounds(loving_roads) |> add_line_layer( id = \"tracks\", source = loving_roads, line_color = \"navy\", line_opacity = 0.7 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":null,"dir":"Reference","previous_headings":"","what":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"Add markers Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"","code":"add_markers( map, data, color = \"red\", rotation = 0, popup = NULL, marker_id = NULL, draggable = FALSE, ... )"},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"map map object created mapboxgl maplibre functions. data length-2 numeric vector coordinates, list length-2 numeric vectors, sf POINT object. color color marker (default \"red\"). rotation rotation marker (default 0). popup column name popups (data sf object) string single popup (data numeric vector list vectors). marker_id unique ID marker. lists, names inherited list names. sf objects, column name. draggable boolean indicating marker draggable (default FALSE). ... Additional options passed marker.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"modified map object markers added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_markers.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add markers to a Mapbox GL or Maplibre GL map — add_markers","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(sf) # Create a map object map <- mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.006, 40.7128), zoom = 10 ) # Add a single draggable marker with an ID map <- add_markers( map, c(-74.006, 40.7128), color = \"blue\", rotation = 45, popup = \"A marker\", draggable = TRUE, marker_id = \"marker1\" ) # Add multiple markers from a named list of coordinates coords_list <- list(marker2 = c(-74.006, 40.7128), marker3 = c(-73.935242, 40.730610)) map <- add_markers( map, coords_list, color = \"green\", popup = \"Multiple markers\", draggable = TRUE ) # Create an sf POINT object points_sf <- st_as_sf(data.frame( id = c(\"marker4\", \"marker5\"), lon = c(-74.006, -73.935242), lat = c(40.7128, 40.730610) ), coords = c(\"lon\", \"lat\"), crs = 4326) points_sf$popup <- c(\"Point 1\", \"Point 2\") # Add multiple markers from an sf object with IDs from a column map <- add_markers( map, points_sf, color = \"red\", popup = \"popup\", draggable = TRUE, marker_id = \"id\" ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a navigation control to a map — add_navigation_control","title":"Add a navigation control to a map — add_navigation_control","text":"Add navigation control map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a navigation control to a map — add_navigation_control","text":"","code":"add_navigation_control( map, show_compass = TRUE, show_zoom = TRUE, visualize_pitch = FALSE, position = \"top-right\", orientation = \"vertical\" )"},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a navigation control to a map — add_navigation_control","text":"map map object created mapboxgl maplibre functions. show_compass Whether show compass button. show_zoom Whether show zoom-zoom-buttons. visualize_pitch Whether visualize pitch rotating X-axis compass. position position map control added. Possible values \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". orientation orientation navigation control. Can \"vertical\" (default) \"horizontal\".","code":""},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a navigation control to a map — add_navigation_control","text":"updated map object navigation control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_navigation_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a navigation control to a map — add_navigation_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_navigation_control(visualize_pitch = TRUE) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_raster_dem_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","title":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","text":"Add raster DEM source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_dem_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","text":"","code":"add_raster_dem_source(map, id, url, tileSize = 512, maxzoom = NULL)"},{"path":"https://walker-data.com/mapgl/reference/add_raster_dem_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing raster DEM source. tileSize size raster tiles. maxzoom maximum zoom level raster tiles.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_dem_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a raster DEM source to a Mapbox GL or Maplibre GL map — add_raster_dem_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a raster layer to a Mapbox GL map — add_raster_layer","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"Add raster layer Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"","code":"add_raster_layer( map, id, source, source_layer = NULL, raster_brightness_max = NULL, raster_brightness_min = NULL, raster_contrast = NULL, raster_fade_duration = NULL, raster_hue_rotate = NULL, raster_opacity = NULL, raster_resampling = NULL, raster_saturation = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, before_id = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"map map object created mapboxgl function. id unique ID layer. source ID source. source_layer source layer (vector sources). raster_brightness_max maximum brightness image. raster_brightness_min minimum brightness image. raster_contrast Increase reduce brightness image. raster_fade_duration duration fade-/fade-effect. raster_hue_rotate Rotates hues around color wheel. raster_opacity opacity raster drawn. raster_resampling resampling/interpolation method use overscaling. raster_saturation Increase reduce saturation image. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels).","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"modified map object new raster layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a raster layer to a Mapbox GL map — add_raster_layer","text":"","code":"if (FALSE) { # \\dontrun{ mapboxgl( style = mapbox_style(\"dark\"), zoom = 5, center = c(-75.789, 41.874) ) |> add_image_source( id = \"radar\", url = \"https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif\", coordinates = list( c(-80.425, 46.437), c(-71.516, 46.437), c(-71.516, 37.936), c(-80.425, 37.936) ) ) |> add_raster_layer( id = \"radar-layer\", source = \"radar\", raster_fade_duration = 0 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_raster_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","title":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","text":"Add raster tile source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","text":"","code":"add_raster_source( map, id, url = NULL, tiles = NULL, tileSize = 256, maxzoom = 22 )"},{"path":"https://walker-data.com/mapgl/reference/add_raster_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing raster tile source. (optional) tiles vector tile URLs raster source. (optional) tileSize size raster tiles. maxzoom maximum zoom level raster tiles.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_raster_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a raster tile source to a Mapbox GL or Maplibre GL map — add_raster_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a reset control to a map — add_reset_control","title":"Add a reset control to a map — add_reset_control","text":"function adds reset control Mapbox GL MapLibre GL map. reset control allows users return original zoom level center.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a reset control to a map — add_reset_control","text":"","code":"add_reset_control(map, position = \"top-right\", animate = TRUE, duration = NULL)"},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a reset control to a map — add_reset_control","text":"map map object created mapboxgl maplibre functions. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"top-right\". animate Whether animate transition original map view; defaults TRUE. FALSE, view \"jump\" original view transition. duration length transition current view original view, specified milliseconds. argument works animate TRUE.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a reset control to a map — add_reset_control","text":"modified map object reset control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_reset_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a reset control to a map — add_reset_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_reset_control(position = \"top-left\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a scale control to a map — add_scale_control","title":"Add a scale control to a map — add_scale_control","text":"function adds scale control Mapbox GL Maplibre GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a scale control to a map — add_scale_control","text":"","code":"add_scale_control( map, position = \"bottom-left\", unit = \"metric\", max_width = 100 )"},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a scale control to a map — add_scale_control","text":"map map object created mapboxgl maplibre functions. position position control. Can one \"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\". Default \"bottom-left\". unit unit scale. Can either \"imperial\", \"metric\", \"nautical\". Default \"metric\". max_width maximum length scale control pixels. Default 100.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a scale control to a map — add_scale_control","text":"modified map object scale control added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_scale_control.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a scale control to a map — add_scale_control","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl() |> add_scale_control(position = \"bottom-right\", unit = \"imperial\") } # }"},{"path":"https://walker-data.com/mapgl/reference/add_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","title":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","text":"Add GeoJSON sf source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","text":"","code":"add_source(map, id, data, ...)"},{"path":"https://walker-data.com/mapgl/reference/add_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","text":"map map object created mapboxgl maplibre function. id unique ID source. data sf object URL pointing remote GeoJSON file. ... Additional arguments passed JavaScript addSource method.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a GeoJSON or sf source to a Mapbox GL or Maplibre GL map — add_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a symbol layer to a map — add_symbol_layer","title":"Add a symbol layer to a map — add_symbol_layer","text":"Add symbol layer map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a symbol layer to a map — add_symbol_layer","text":"","code":"add_symbol_layer( map, id, source, source_layer = NULL, icon_allow_overlap = NULL, icon_anchor = NULL, icon_color = NULL, icon_color_brightness_max = NULL, icon_color_brightness_min = NULL, icon_color_contrast = NULL, icon_color_saturation = NULL, icon_emissive_strength = NULL, icon_halo_blur = NULL, icon_halo_color = NULL, icon_halo_width = NULL, icon_ignore_placement = NULL, icon_image = NULL, icon_image_cross_fade = NULL, icon_keep_upright = NULL, icon_offset = NULL, icon_opacity = NULL, icon_optional = NULL, icon_padding = NULL, icon_pitch_alignment = NULL, icon_rotate = NULL, icon_rotation_alignment = NULL, icon_size = NULL, icon_text_fit = NULL, icon_text_fit_padding = NULL, icon_translate = NULL, icon_translate_anchor = NULL, symbol_avoid_edges = NULL, symbol_placement = NULL, symbol_sort_key = NULL, symbol_spacing = NULL, symbol_z_elevate = NULL, symbol_z_offset = NULL, symbol_z_order = NULL, text_allow_overlap = NULL, text_anchor = NULL, text_color = \"black\", text_emissive_strength = NULL, text_field = NULL, text_font = NULL, text_halo_blur = NULL, text_halo_color = NULL, text_halo_width = NULL, text_ignore_placement = NULL, text_justify = NULL, text_keep_upright = NULL, text_letter_spacing = NULL, text_line_height = NULL, text_max_angle = NULL, text_max_width = NULL, text_offset = NULL, text_opacity = NULL, text_optional = NULL, text_padding = NULL, text_pitch_alignment = NULL, text_radial_offset = NULL, text_rotate = NULL, text_rotation_alignment = NULL, text_size = NULL, text_transform = NULL, text_translate = NULL, text_translate_anchor = NULL, text_variable_anchor = NULL, text_writing_mode = NULL, visibility = \"visible\", slot = NULL, min_zoom = NULL, max_zoom = NULL, popup = NULL, tooltip = NULL, hover_options = NULL, before_id = NULL, filter = NULL, cluster_options = NULL )"},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a symbol layer to a map — add_symbol_layer","text":"map map object created mapboxgl maplibre functions. id unique ID layer. source ID source, alternatively sf object (converted GeoJSON source) named list specifies type url remote source. source_layer source layer (vector sources). icon_allow_overlap TRUE, icon visible even collides previously drawn symbols. icon_anchor Part icon placed closest anchor. icon_color color icon. supported many Mapbox icons; read https://docs.mapbox.com/help/troubleshooting/using-recolorable-images--mapbox-maps/. icon_color_brightness_max maximum brightness icon color. icon_color_brightness_min minimum brightness icon color. icon_color_contrast contrast icon color. icon_color_saturation saturation icon color. icon_emissive_strength strength icon's emissive color. icon_halo_blur blur applied icon's halo. icon_halo_color color icon's halo. icon_halo_width width icon's halo. icon_ignore_placement TRUE, icon visible even collides symbols. icon_image Name image sprite use drawing image background. use values column input dataset, use get_column('YOUR_ICON_COLUMN_NAME'). Images can also loaded add_image() function precede add_symbol_layer() function. icon_image_cross_fade cross-fade parameter icon image. icon_keep_upright TRUE, icon kept upright. icon_offset Offset distance icon. icon_opacity opacity icon drawn. icon_optional TRUE, icon optional. icon_padding Padding around icon. icon_pitch_alignment Alignment icon respect pitch map. icon_rotate Rotates icon clockwise. icon_rotation_alignment Alignment icon respect map. icon_size size icon, specified relative original size image. example, value 5 make icon 5 times larger original size, whereas value 0.5 make icon half size original. icon_text_fit Scales text fit icon. icon_text_fit_padding Padding text fitting icon. icon_translate offset distance icon. icon_translate_anchor Controls frame reference icon-translate. symbol_avoid_edges TRUE, symbol avoided near edges. symbol_placement Placement symbol map. symbol_sort_key Sorts features ascending order based value. symbol_spacing Spacing symbols. symbol_z_elevate TRUE, positions symbol top fill-extrusion layer. Requires symbol_placement set \"point\" symbol-z-order set \"auto\". symbol_z_offset elevation symbol, meters. Use get_column() get elevations column dataset. symbol_z_order Orders symbol z-axis. text_allow_overlap TRUE, text visible even collides previously drawn symbols. text_anchor Part text placed closest anchor. text_color color text. text_emissive_strength strength text's emissive color. text_field Value use text label. text_font Font stack use displaying text. text_halo_blur blur applied text's halo. text_halo_color color text's halo. text_halo_width width text's halo. text_ignore_placement TRUE, text visible even collides symbols. text_justify justification text. text_keep_upright TRUE, text kept upright. text_letter_spacing Spacing text letters. text_line_height Height text lines. text_max_angle Maximum angle text. text_max_width Maximum width text. text_offset Offset distance text. text_opacity opacity text drawn. text_optional TRUE, text optional. text_padding Padding around text. text_pitch_alignment Alignment text respect pitch map. text_radial_offset Radial offset text. text_rotate Rotates text clockwise. text_rotation_alignment Alignment text respect map. text_size size text. text_transform Transform applied text. text_translate offset distance text. text_translate_anchor Controls frame reference text-translate. text_variable_anchor Variable anchor text. text_writing_mode Writing mode text. visibility Whether layer displayed. slot optional slot layer order. min_zoom minimum zoom level layer. max_zoom maximum zoom level layer. popup column name containing information display popup click. Columns containing HTML parsed. tooltip column name containing information display tooltip hover. Columns containing HTML parsed. hover_options named list options highlighting features layer hover. elements SVG icons can styled. before_id name layer layer appears \"\", allowing insert layers layers basemap (e.g. labels). filter optional filter expression subset features layer. cluster_options list options clustering symbols, created cluster_options() function.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a symbol layer to a map — add_symbol_layer","text":"modified map object new symbol layer added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_symbol_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a symbol layer to a map — add_symbol_layer","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) library(sf) library(dplyr) # Set seed for reproducibility set.seed(1234) # Define the bounding box for Washington DC (approximately) bbox <- st_bbox( c( xmin = -77.119759, ymin = 38.791645, xmax = -76.909393, ymax = 38.995548 ), crs = st_crs(4326) ) # Generate 30 random points within the bounding box random_points <- st_as_sf( data.frame( id = 1:30, lon = runif(30, bbox[\"xmin\"], bbox[\"xmax\"]), lat = runif(30, bbox[\"ymin\"], bbox[\"ymax\"]) ), coords = c(\"lon\", \"lat\"), crs = 4326 ) # Assign random icons icons <- c(\"music\", \"bar\", \"theatre\", \"bicycle\") random_points <- random_points |> mutate(icon = sample(icons, n(), replace = TRUE)) # Map with icons mapboxgl(style = mapbox_style(\"light\")) |> fit_bounds(random_points, animate = FALSE) |> add_symbol_layer( id = \"points-of-interest\", source = random_points, icon_image = c(\"get\", \"icon\"), icon_allow_overlap = TRUE, tooltip = \"icon\" ) } # }"},{"path":"https://walker-data.com/mapgl/reference/add_vector_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","title":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","text":"Add vector tile source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_vector_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","text":"","code":"add_vector_source(map, id, url)"},{"path":"https://walker-data.com/mapgl/reference/add_vector_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","text":"map map object created mapboxgl maplibre function. id unique ID source. url URL pointing vector tile source.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_vector_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a vector tile source to a Mapbox GL or Maplibre GL map — add_vector_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_video_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","title":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","text":"Add video source Mapbox GL Maplibre GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/add_video_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","text":"","code":"add_video_source(map, id, urls, coordinates)"},{"path":"https://walker-data.com/mapgl/reference/add_video_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","text":"map map object created mapboxgl maplibre function. id unique ID source. urls vector URLs pointing video sources. coordinates list coordinates specifying video corners clockwise order: top left, top right, bottom right, bottom left.","code":""},{"path":"https://walker-data.com/mapgl/reference/add_video_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a video source to a Mapbox GL or Maplibre GL map — add_video_source","text":"modified map object new source added.","code":""},{"path":"https://walker-data.com/mapgl/reference/carto_style.html","id":null,"dir":"Reference","previous_headings":"","what":"Get CARTO Style URL — carto_style","title":"Get CARTO Style URL — carto_style","text":"Get CARTO Style URL","code":""},{"path":"https://walker-data.com/mapgl/reference/carto_style.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get CARTO Style URL — carto_style","text":"","code":"carto_style(style_name)"},{"path":"https://walker-data.com/mapgl/reference/carto_style.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get CARTO Style URL — carto_style","text":"style_name name style (e.g., \"voyager\", \"positron\", \"dark-matter\").","code":""},{"path":"https://walker-data.com/mapgl/reference/carto_style.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get CARTO Style URL — carto_style","text":"style URL corresponding given style name.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_controls.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","title":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","text":"Clear controls Mapbox GL Maplibre GL map Shiny app","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_controls.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","text":"","code":"clear_controls(map)"},{"path":"https://walker-data.com/mapgl/reference/clear_controls.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","text":"map map object created mapboxgl maplibre function.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_controls.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear all controls from a Mapbox GL or Maplibre GL map in a Shiny app — clear_controls","text":"modified map object controls removed.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear a layer from a map using a proxy — clear_layer","title":"Clear a layer from a map using a proxy — clear_layer","text":"function allows layer removed existing Mapbox GL map using proxy object.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear a layer from a map using a proxy — clear_layer","text":"","code":"clear_layer(proxy, layer_id)"},{"path":"https://walker-data.com/mapgl/reference/clear_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear a layer from a map using a proxy — clear_layer","text":"proxy proxy object created mapboxgl_proxy maplibre_proxy. layer_id ID layer removed.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear a layer from a map using a proxy — clear_layer","text":"updated proxy object.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_legend.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear legend(s) from a map in a proxy session — clear_legend","title":"Clear legend(s) from a map in a proxy session — clear_legend","text":"Clear legend(s) map proxy session","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_legend.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear legend(s) from a map in a proxy session — clear_legend","text":"","code":"clear_legend(map, legend_ids = NULL)"},{"path":"https://walker-data.com/mapgl/reference/clear_legend.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear legend(s) from a map in a proxy session — clear_legend","text":"map map object created mapboxgl_proxy maplibre_proxy function. legend_ids Optional. character vector legend IDs clear. provided, legends cleared.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_legend.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear legend(s) from a map in a proxy session — clear_legend","text":"updated map object specified legend(s) cleared.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_markers.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear markers from a map in a Shiny session — clear_markers","title":"Clear markers from a map in a Shiny session — clear_markers","text":"Clear markers map Shiny session","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_markers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear markers from a map in a Shiny session — clear_markers","text":"","code":"clear_markers(map)"},{"path":"https://walker-data.com/mapgl/reference/clear_markers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear markers from a map in a Shiny session — clear_markers","text":"map map object created mapboxgl_proxy maplibre_proxy function.","code":""},{"path":"https://walker-data.com/mapgl/reference/clear_markers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear markers from a map in a Shiny session — clear_markers","text":"modified map object markers cleared.","code":""},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare cluster options for circle layers — cluster_options","title":"Prepare cluster options for circle layers — cluster_options","text":"function creates list options clustering circle layers.","code":""},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare cluster options for circle layers — cluster_options","text":"","code":"cluster_options( max_zoom = 14, cluster_radius = 50, color_stops = c(\"#51bbd6\", \"#f1f075\", \"#f28cb1\"), radius_stops = c(20, 30, 40), count_stops = c(0, 100, 750), circle_blur = NULL, circle_opacity = NULL, circle_stroke_color = NULL, circle_stroke_opacity = NULL, circle_stroke_width = NULL, text_color = \"black\" )"},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare cluster options for circle layers — cluster_options","text":"max_zoom maximum zoom level cluster points. cluster_radius radius cluster clustering points. color_stops vector colors circle color step expression. radius_stops vector radii circle radius step expression. count_stops vector point counts color radius step expressions. circle_blur Amount blur circle. circle_opacity opacity circle. circle_stroke_color color circle's stroke. circle_stroke_opacity opacity circle's stroke. circle_stroke_width width circle's stroke. text_color color use labels cluster circles.","code":""},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare cluster options for circle layers — cluster_options","text":"list cluster options.","code":""},{"path":"https://walker-data.com/mapgl/reference/cluster_options.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare cluster options for circle layers — cluster_options","text":"","code":"cluster_options( max_zoom = 14, cluster_radius = 50, color_stops = c(\"#51bbd6\", \"#f1f075\", \"#f28cb1\"), radius_stops = c(20, 30, 40), count_stops = c(0, 100, 750), circle_blur = 1, circle_opacity = 0.8, circle_stroke_color = \"#ffffff\", circle_stroke_width = 2 ) #> $max_zoom #> [1] 14 #> #> $cluster_radius #> [1] 50 #> #> $color_stops #> [1] \"#51bbd6\" \"#f1f075\" \"#f28cb1\" #> #> $radius_stops #> [1] 20 30 40 #> #> $count_stops #> [1] 0 100 750 #> #> $circle_blur #> [1] 1 #> #> $circle_opacity #> [1] 0.8 #> #> $circle_stroke_color #> [1] \"#ffffff\" #> #> $circle_stroke_opacity #> NULL #> #> $circle_stroke_width #> [1] 2 #> #> $text_color #> [1] \"black\" #>"},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Compare widget — compare","title":"Create a Compare widget — compare","text":"function creates comparison view two Mapbox GL Maplibre GL maps, allowing users either swipe two maps view side--side synchronized navigation.","code":""},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Compare widget — compare","text":"","code":"compare( map1, map2, width = \"100%\", height = NULL, elementId = NULL, mousemove = FALSE, orientation = \"vertical\", mode = \"swipe\", swiper_color = NULL )"},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Compare widget — compare","text":"map1 mapboxgl maplibre object representing first map. map2 mapboxgl maplibre object representing second map. width Width map container. height Height map container. elementId optional string specifying ID container comparison. NULL, unique ID generated. mousemove logical value indicating whether enable swiping cursor movement (rather clicked). applicable mode=\"swipe\". orientation string specifying orientation swiper side--side layout, either \"horizontal\" \"vertical\". mode string specifying comparison mode: \"swipe\" (default) swipeable comparison slider, \"sync\" synchronized maps displayed next . swiper_color optional CSS color value (e.g., \"#000000\", \"rgb(0,0,0)\", \"black\") customize color swiper handle. applicable mode=\"swipe\".","code":""},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Compare widget — compare","text":"comparison widget.","code":""},{"path":[]},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"comparison-modes","dir":"Reference","previous_headings":"","what":"Comparison modes","title":"Create a Compare widget — compare","text":"compare() function supports two modes: mode=\"swipe\" (default) - Creates swipeable interface slider reveal portions map mode=\"sync\" - Places maps next synchronized navigation modes, navigation (panning, zooming, rotating, tilting) synchronized maps.","code":""},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"using-the-compare-widget-in-shiny","dir":"Reference","previous_headings":"","what":"Using the compare widget in Shiny","title":"Create a Compare widget — compare","text":"compare widget can used Shiny applications following functions: mapboxglCompareOutput() / renderMapboxglCompare() - Mapbox GL comparisons maplibreCompareOutput() / renderMaplibreCompare() - Maplibre GL comparisons mapboxgl_compare_proxy() / maplibre_compare_proxy() - updating maps compare widget creating compare widget Shiny app, can use proxy functions update either \"\" (left/top) \"\" (right/bottom) map. proxy objects work regular map update functions like set_style(), set_paint_property(), etc. get proxy targets specific map comparison: compare widget also provides Shiny input values view state clicks. compare widget ID \"mycompare\", : input$mycompare_before_view - View state (center, zoom, bearing, pitch) left/top map input$mycompare_after_view - View state right/bottom map input$mycompare_before_click - Click events left/top map input$mycompare_after_click - Click events right/bottom map","code":"# Access the left/top map left_proxy <- maplibre_compare_proxy(\"compare_id\", map_side = \"before\") # Access the right/bottom map right_proxy <- maplibre_compare_proxy(\"compare_id\", map_side = \"after\")"},{"path":"https://walker-data.com/mapgl/reference/compare.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a Compare widget — compare","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) m1 <- mapboxgl(style = mapbox_style(\"light\")) m2 <- mapboxgl(style = mapbox_style(\"dark\")) # Default swipe mode compare(m1, m2) # Synchronized side-by-side mode compare(m1, m2, mode = \"sync\") # Custom swiper color compare(m1, m2, swiper_color = \"#FF0000\") # Red swiper # Shiny example library(shiny) ui <- fluidPage( maplibreCompareOutput(\"comparison\") ) server <- function(input, output, session) { output$comparison <- renderMaplibreCompare({ compare( maplibre(style = carto_style(\"positron\")), maplibre(style = carto_style(\"dark-matter\")), mode = \"sync\" ) }) # Update the right map observe({ right_proxy <- maplibre_compare_proxy(\"comparison\", map_side = \"after\") set_style(right_proxy, carto_style(\"voyager\")) }) # Example with custom swiper color output$comparison2 <- renderMaplibreCompare({ compare( maplibre(style = carto_style(\"positron\")), maplibre(style = carto_style(\"dark-matter\")), swiper_color = \"#3498db\" # Blue swiper ) }) } } # }"},{"path":"https://walker-data.com/mapgl/reference/concat.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a concatenation expression — concat","title":"Create a concatenation expression — concat","text":"function creates concatenation expression combines multiple values expressions single string. Useful creating dynamic tooltips labels.","code":""},{"path":"https://walker-data.com/mapgl/reference/concat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a concatenation expression — concat","text":"","code":"concat(...)"},{"path":"https://walker-data.com/mapgl/reference/concat.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a concatenation expression — concat","text":"... Values expressions concatenate. Can strings, numbers, expressions like get_column().","code":""},{"path":"https://walker-data.com/mapgl/reference/concat.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a concatenation expression — concat","text":"list representing concatenation expression.","code":""},{"path":"https://walker-data.com/mapgl/reference/concat.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a concatenation expression — concat","text":"","code":"# Create a dynamic tooltip concat(\"Name:<\/strong> \", get_column(\"name\"), \"
    Value: \", get_column(\"value\")) #> [[1]] #> [1] \"concat\" #> #> [[2]] #> [1] \"Name:<\/strong> \" #> #> [[3]] #> [[3]][[1]] #> [1] \"get\" #> #> [[3]][[2]] #> [1] \"name\" #> #> #> [[4]] #> [1] \"
    Value: \" #> #> [[5]] #> [[5]][[1]] #> [1] \"get\" #> #> [[5]][[2]] #> [1] \"value\" #> #>"},{"path":"https://walker-data.com/mapgl/reference/ease_to.html","id":null,"dir":"Reference","previous_headings":"","what":"Ease to a given view — ease_to","title":"Ease to a given view — ease_to","text":"Ease given view","code":""},{"path":"https://walker-data.com/mapgl/reference/ease_to.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ease to a given view — ease_to","text":"","code":"ease_to(map, center, zoom = NULL, ...)"},{"path":"https://walker-data.com/mapgl/reference/ease_to.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Ease to a given view — ease_to","text":"map map object created mapboxgl maplibre function proxy object. center numeric vector length 2 specifying target center map (longitude, latitude). zoom target zoom level. ... Additional named arguments easing view.","code":""},{"path":"https://walker-data.com/mapgl/reference/ease_to.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Ease to a given view — ease_to","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/fit_bounds.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit the map to a bounding box — fit_bounds","title":"Fit the map to a bounding box — fit_bounds","text":"Fit map bounding box","code":""},{"path":"https://walker-data.com/mapgl/reference/fit_bounds.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit the map to a bounding box — fit_bounds","text":"","code":"fit_bounds(map, bbox, animate = FALSE, ...)"},{"path":"https://walker-data.com/mapgl/reference/fit_bounds.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit the map to a bounding box — fit_bounds","text":"map map object created mapboxgl maplibre function proxy object. bbox bounding box specified numeric vector length 4 (minLng, minLat, maxLng, maxLat), sf object bounding box calculated. animate logical value indicating whether animate transition new bounds. Defaults FALSE. ... Additional named arguments fitting bounds.","code":""},{"path":"https://walker-data.com/mapgl/reference/fit_bounds.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit the map to a bounding box — fit_bounds","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/fly_to.html","id":null,"dir":"Reference","previous_headings":"","what":"Fly to a given view — fly_to","title":"Fly to a given view — fly_to","text":"Fly given view","code":""},{"path":"https://walker-data.com/mapgl/reference/fly_to.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fly to a given view — fly_to","text":"","code":"fly_to(map, center, zoom = NULL, ...)"},{"path":"https://walker-data.com/mapgl/reference/fly_to.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fly to a given view — fly_to","text":"map map object created mapboxgl maplibre function proxy object. center numeric vector length 2 specifying target center map (longitude, latitude). zoom target zoom level. ... Additional named arguments flying view.","code":""},{"path":"https://walker-data.com/mapgl/reference/fly_to.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fly to a given view — fly_to","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_column.html","id":null,"dir":"Reference","previous_headings":"","what":"Get column or property for use in mapping — get_column","title":"Get column or property for use in mapping — get_column","text":"function returns expression get specified column dataset (property layer).","code":""},{"path":"https://walker-data.com/mapgl/reference/get_column.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get column or property for use in mapping — get_column","text":"","code":"get_column(column)"},{"path":"https://walker-data.com/mapgl/reference/get_column.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get column or property for use in mapping — get_column","text":"column name column property get.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_column.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get column or property for use in mapping — get_column","text":"list representing expression get column.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":null,"dir":"Reference","previous_headings":"","what":"Get drawn features from the map — get_drawn_features","title":"Get drawn features from the map — get_drawn_features","text":"Get drawn features map","code":""},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get drawn features from the map — get_drawn_features","text":"","code":"get_drawn_features(map)"},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get drawn features from the map — get_drawn_features","text":"map map object created mapboxgl function, mapboxgl proxy.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get drawn features from the map — get_drawn_features","text":"sf object containing drawn features.","code":""},{"path":"https://walker-data.com/mapgl/reference/get_drawn_features.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get drawn features from the map — get_drawn_features","text":"","code":"if (FALSE) { # \\dontrun{ # In a Shiny application library(shiny) library(mapgl) ui <- fluidPage( mapboxglOutput(\"map\"), actionButton(\"get_features\", \"Get Drawn Features\"), verbatimTextOutput(\"feature_output\") ) server <- function(input, output, session) { output$map <- renderMapboxgl({ mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.50, 40), zoom = 9 ) |> add_draw_control() }) observeEvent(input$get_features, { drawn_features <- get_drawn_features(mapboxgl_proxy(\"map\")) output$feature_output <- renderPrint({ print(drawn_features) }) }) } shinyApp(ui, server) } # }"},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an interpolation expression — interpolate","title":"Create an interpolation expression — interpolate","text":"function generates interpolation expression can used style data.","code":""},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an interpolation expression — interpolate","text":"","code":"interpolate( column = NULL, property = NULL, type = \"linear\", values, stops, na_color = NULL )"},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an interpolation expression — interpolate","text":"column name column use interpolation. specified, property NULL. property name property use interpolation. specified, column NULL. type interpolation type. Can one \"linear\", list(\"exponential\", base) base specifies rate output increases, list(\"cubic-bezier\", x1, y1, x2, y2) define cubic bezier curve control points. values numeric vector values stops occur. stops vector corresponding stops (colors, sizes, etc.) interpolation. na_color color use missing values. Mapbox GL JS defaults black supplied.","code":""},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an interpolation expression — interpolate","text":"list representing interpolation expression.","code":""},{"path":"https://walker-data.com/mapgl/reference/interpolate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an interpolation expression — interpolate","text":"","code":"interpolate( column = \"estimate\", type = \"linear\", values = c(1000, 200000), stops = c(\"#eff3ff\", \"#08519c\") ) #> [[1]] #> [1] \"interpolate\" #> #> [[2]] #> [[2]][[1]] #> [1] \"linear\" #> #> #> [[3]] #> [[3]][[1]] #> [1] \"get\" #> #> [[3]][[2]] #> [1] \"estimate\" #> #> #> [[4]] #> [1] 1000 #> #> [[5]] #> [1] \"#eff3ff\" #> #> [[6]] #> [1] 2e+05 #> #> [[7]] #> [1] \"#08519c\" #>"},{"path":"https://walker-data.com/mapgl/reference/jump_to.html","id":null,"dir":"Reference","previous_headings":"","what":"Jump to a given view — jump_to","title":"Jump to a given view — jump_to","text":"Jump given view","code":""},{"path":"https://walker-data.com/mapgl/reference/jump_to.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Jump to a given view — jump_to","text":"","code":"jump_to(map, center, zoom = NULL, ...)"},{"path":"https://walker-data.com/mapgl/reference/jump_to.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Jump to a given view — jump_to","text":"map map object created mapboxgl maplibre function proxy object. center numeric vector length 2 specifying target center map (longitude, latitude). zoom target zoom level. ... Additional named arguments jumping view.","code":""},{"path":"https://walker-data.com/mapgl/reference/jump_to.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Jump to a given view — jump_to","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapbox_style.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Mapbox Style URL — mapbox_style","title":"Get Mapbox Style URL — mapbox_style","text":"Get Mapbox Style URL","code":""},{"path":"https://walker-data.com/mapgl/reference/mapbox_style.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Mapbox Style URL — mapbox_style","text":"","code":"mapbox_style(style_name)"},{"path":"https://walker-data.com/mapgl/reference/mapbox_style.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Mapbox Style URL — mapbox_style","text":"style_name name style (e.g., \"standard\", \"streets\", \"outdoors\", etc.).","code":""},{"path":"https://walker-data.com/mapgl/reference/mapbox_style.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Mapbox Style URL — mapbox_style","text":"style URL corresponding given style name.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize a Mapbox GL Map — mapboxgl","title":"Initialize a Mapbox GL Map — mapboxgl","text":"Initialize Mapbox GL Map","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize a Mapbox GL Map — mapboxgl","text":"","code":"mapboxgl( style = NULL, center = c(0, 0), zoom = 0, bearing = 0, pitch = 0, projection = \"globe\", parallels = NULL, access_token = NULL, bounds = NULL, width = \"100%\", height = NULL, ... )"},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Initialize a Mapbox GL Map — mapboxgl","text":"style Mapbox style use. center numeric vector length 2 specifying initial center map. zoom initial zoom level map. bearing initial bearing (rotation) map, degrees. pitch initial pitch (tilt) map, degrees. projection map projection use (e.g., \"mercator\", \"globe\"). parallels vector two numbers representing standard parallels projection. available projection \"albers\" \"lambertConformalConic\". access_token Mapbox access token. bounds sf object bounding box fit map . width width output htmlwidget. height height output htmlwidget. ... Additional named parameters passed Mapbox GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize a Mapbox GL Map — mapboxgl","text":"HTML widget Mapbox map.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Initialize a Mapbox GL Map — mapboxgl","text":"","code":"if (FALSE) { # \\dontrun{ mapboxgl(projection = \"globe\") } # }"},{"path":"https://walker-data.com/mapgl/reference/mapboxglCompareOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Mapbox GL Compare output element for Shiny — mapboxglCompareOutput","title":"Create a Mapbox GL Compare output element for Shiny — mapboxglCompareOutput","text":"Create Mapbox GL Compare output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxglCompareOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Mapbox GL Compare output element for Shiny — mapboxglCompareOutput","text":"","code":"mapboxglCompareOutput(outputId, width = \"100%\", height = \"400px\")"},{"path":"https://walker-data.com/mapgl/reference/mapboxglCompareOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Mapbox GL Compare output element for Shiny — mapboxglCompareOutput","text":"outputId output variable read width width element height height element","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxglCompareOutput.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Mapbox GL Compare output element for Shiny — mapboxglCompareOutput","text":"Mapbox GL Compare output element use Shiny UI","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxglOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Mapbox GL output element for Shiny — mapboxglOutput","title":"Create a Mapbox GL output element for Shiny — mapboxglOutput","text":"Create Mapbox GL output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxglOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Mapbox GL output element for Shiny — mapboxglOutput","text":"","code":"mapboxglOutput(outputId, width = \"100%\", height = \"400px\")"},{"path":"https://walker-data.com/mapgl/reference/mapboxglOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Mapbox GL output element for Shiny — mapboxglOutput","text":"outputId output variable read width width element height height element","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxglOutput.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Mapbox GL output element for Shiny — mapboxglOutput","text":"Mapbox GL output element use Shiny UI","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_compare_proxy.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a proxy object for a Mapbox GL Compare widget in Shiny — mapboxgl_compare_proxy","title":"Create a proxy object for a Mapbox GL Compare widget in Shiny — mapboxgl_compare_proxy","text":"function allows updates sent existing Mapbox GL Compare widget Shiny application.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_compare_proxy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a proxy object for a Mapbox GL Compare widget in Shiny — mapboxgl_compare_proxy","text":"","code":"mapboxgl_compare_proxy( compareId, session = shiny::getDefaultReactiveDomain(), map_side = \"before\" )"},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_compare_proxy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a proxy object for a Mapbox GL Compare widget in Shiny — mapboxgl_compare_proxy","text":"compareId ID compare output element. session Shiny session object. map_side map side target compare widget, either \"\" \"\".","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_compare_proxy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a proxy object for a Mapbox GL Compare widget in Shiny — mapboxgl_compare_proxy","text":"proxy object Mapbox GL Compare widget.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_proxy.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","title":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","text":"function allows updates sent existing Mapbox GL map Shiny application without redrawing entire map.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_proxy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","text":"","code":"mapboxgl_proxy(mapId, session = shiny::getDefaultReactiveDomain())"},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_proxy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","text":"mapId ID map output element. session Shiny session object.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_proxy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a proxy object for a Mapbox GL map in Shiny — mapboxgl_proxy","text":"proxy object Mapbox GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_view.html","id":null,"dir":"Reference","previous_headings":"","what":"Quick visualization of geometries with Mapbox GL — mapboxgl_view","title":"Quick visualization of geometries with Mapbox GL — mapboxgl_view","text":"function provides quick way visualize sf geometries using Mapbox GL JS. automatically detects geometry type applies appropriate styling.","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_view.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Quick visualization of geometries with Mapbox GL — mapboxgl_view","text":"","code":"mapboxgl_view( data, column = NULL, n = NULL, style = mapbox_style(\"light\"), ... )"},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_view.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Quick visualization of geometries with Mapbox GL — mapboxgl_view","text":"data sf object visualize column name column visualize. NULL (default), geometries shown default styling. n Number quantile breaks numeric columns. specified, uses step_expr() instead interpolate(). style Mapbox style use. Defaults mapbox_style(\"light\"). ... Additional arguments passed mapboxgl()","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_view.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Quick visualization of geometries with Mapbox GL — mapboxgl_view","text":"Mapbox GL map object","code":""},{"path":"https://walker-data.com/mapgl/reference/mapboxgl_view.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Quick visualization of geometries with Mapbox GL — mapboxgl_view","text":"","code":"if (FALSE) { # \\dontrun{ library(sf) nc <- st_read(system.file(\"shape/nc.shp\", package = \"sf\")) # Basic view mapboxgl_view(nc) # View with column visualization mapboxgl_view(nc, column = \"AREA\") # View with quantile breaks mapboxgl_view(nc, column = \"AREA\", n = 5) } # }"},{"path":"https://walker-data.com/mapgl/reference/mapgl-package.html","id":null,"dir":"Reference","previous_headings":"","what":"mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' — mapgl-package","title":"mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' — mapgl-package","text":"Provides interface 'Mapbox GL JS' (https://docs.mapbox.com/mapbox-gl-js/guides) 'MapLibre GL JS' (https://maplibre.org/maplibre-gl-js/docs/) interactive mapping libraries help users create custom interactive maps R. Users can create interactive globe visualizations; layer 'sf' objects create filled maps, circle maps, 'heatmaps', three-dimensional graphics; customize map styles views. package also includes utilities use 'Mapbox' 'MapLibre' maps 'Shiny' web applications.","code":""},{"path":[]},{"path":"https://walker-data.com/mapgl/reference/mapgl-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"mapgl: Interactive Maps with 'Mapbox GL JS' and 'MapLibre GL JS' — mapgl-package","text":"Maintainer: Kyle Walker kyle@walker-data.com","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize a Maplibre GL Map — maplibre","title":"Initialize a Maplibre GL Map — maplibre","text":"Initialize Maplibre GL Map","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize a Maplibre GL Map — maplibre","text":"","code":"maplibre( style = carto_style(\"voyager\"), center = c(0, 0), zoom = 0, bearing = 0, pitch = 0, bounds = NULL, width = \"100%\", height = NULL, ... )"},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Initialize a Maplibre GL Map — maplibre","text":"style style JSON use. center numeric vector length 2 specifying initial center map. zoom initial zoom level map. bearing initial bearing (rotation) map, degrees. pitch initial pitch (tilt) map, degrees. bounds sf object bounding box fit map . width width output htmlwidget. height height output htmlwidget. ... Additional named parameters passed Mapbox GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize a Maplibre GL Map — maplibre","text":"HTML widget Mapbox map.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Initialize a Maplibre GL Map — maplibre","text":"","code":"if (FALSE) { # \\dontrun{ maplibre() } # }"},{"path":"https://walker-data.com/mapgl/reference/maplibreCompareOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Maplibre GL Compare output element for Shiny — maplibreCompareOutput","title":"Create a Maplibre GL Compare output element for Shiny — maplibreCompareOutput","text":"Create Maplibre GL Compare output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibreCompareOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Maplibre GL Compare output element for Shiny — maplibreCompareOutput","text":"","code":"maplibreCompareOutput(outputId, width = \"100%\", height = \"400px\")"},{"path":"https://walker-data.com/mapgl/reference/maplibreCompareOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Maplibre GL Compare output element for Shiny — maplibreCompareOutput","text":"outputId output variable read width width element height height element","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibreCompareOutput.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Maplibre GL Compare output element for Shiny — maplibreCompareOutput","text":"Maplibre GL Compare output element use Shiny UI","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibreOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Maplibre GL output element for Shiny — maplibreOutput","title":"Create a Maplibre GL output element for Shiny — maplibreOutput","text":"Create Maplibre GL output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibreOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Maplibre GL output element for Shiny — maplibreOutput","text":"","code":"maplibreOutput(outputId, width = \"100%\", height = \"400px\")"},{"path":"https://walker-data.com/mapgl/reference/maplibreOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Maplibre GL output element for Shiny — maplibreOutput","text":"outputId output variable read width width element height height element","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibreOutput.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Maplibre GL output element for Shiny — maplibreOutput","text":"Maplibre GL output element use Shiny UI","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_compare_proxy.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a proxy object for a Maplibre GL Compare widget in Shiny — maplibre_compare_proxy","title":"Create a proxy object for a Maplibre GL Compare widget in Shiny — maplibre_compare_proxy","text":"function allows updates sent existing Maplibre GL Compare widget Shiny application.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_compare_proxy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a proxy object for a Maplibre GL Compare widget in Shiny — maplibre_compare_proxy","text":"","code":"maplibre_compare_proxy( compareId, session = shiny::getDefaultReactiveDomain(), map_side = \"before\" )"},{"path":"https://walker-data.com/mapgl/reference/maplibre_compare_proxy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a proxy object for a Maplibre GL Compare widget in Shiny — maplibre_compare_proxy","text":"compareId ID compare output element. session Shiny session object. map_side map side target compare widget, either \"\" \"\".","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_compare_proxy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a proxy object for a Maplibre GL Compare widget in Shiny — maplibre_compare_proxy","text":"proxy object Maplibre GL Compare widget.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_proxy.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","title":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","text":"function allows updates sent existing Maplibre GL map Shiny application without redrawing entire map.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_proxy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","text":"","code":"maplibre_proxy(mapId, session = shiny::getDefaultReactiveDomain())"},{"path":"https://walker-data.com/mapgl/reference/maplibre_proxy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","text":"mapId ID map output element. session Shiny session object.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_proxy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a proxy object for a Maplibre GL map in Shiny — maplibre_proxy","text":"proxy object Maplibre GL map.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_view.html","id":null,"dir":"Reference","previous_headings":"","what":"Quick visualization of geometries with MapLibre GL — maplibre_view","title":"Quick visualization of geometries with MapLibre GL — maplibre_view","text":"function provides quick way visualize sf geometries using MapLibre GL JS. automatically detects geometry type applies appropriate styling.","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_view.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Quick visualization of geometries with MapLibre GL — maplibre_view","text":"","code":"maplibre_view( data, column = NULL, n = NULL, style = carto_style(\"positron\"), ... )"},{"path":"https://walker-data.com/mapgl/reference/maplibre_view.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Quick visualization of geometries with MapLibre GL — maplibre_view","text":"data sf object visualize column name column visualize. NULL (default), geometries shown default styling. n Number quantile breaks numeric columns. specified, uses step_expr() instead interpolate(). style MapLibre style use. Defaults carto_style(\"positron\"). ... Additional arguments passed maplibre()","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_view.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Quick visualization of geometries with MapLibre GL — maplibre_view","text":"MapLibre GL map object","code":""},{"path":"https://walker-data.com/mapgl/reference/maplibre_view.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Quick visualization of geometries with MapLibre GL — maplibre_view","text":"","code":"if (FALSE) { # \\dontrun{ library(sf) nc <- st_read(system.file(\"shape/nc.shp\", package = \"sf\")) # Basic view maplibre_view(nc) # View with column visualization maplibre_view(nc, column = \"AREA\") # View with quantile breaks maplibre_view(nc, column = \"AREA\", n = 5) } # }"},{"path":"https://walker-data.com/mapgl/reference/maptiler_style.html","id":null,"dir":"Reference","previous_headings":"","what":"Get MapTiler Style URL — maptiler_style","title":"Get MapTiler Style URL — maptiler_style","text":"Get MapTiler Style URL","code":""},{"path":"https://walker-data.com/mapgl/reference/maptiler_style.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get MapTiler Style URL — maptiler_style","text":"","code":"maptiler_style(style_name, api_key = NULL)"},{"path":"https://walker-data.com/mapgl/reference/maptiler_style.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get MapTiler Style URL — maptiler_style","text":"style_name name style (e.g., \"basic\", \"streets\", \"toner\", etc.). api_key MapTiler API key (required)","code":""},{"path":"https://walker-data.com/mapgl/reference/maptiler_style.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get MapTiler Style URL — maptiler_style","text":"style URL corresponding given style name.","code":""},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a match expression — match_expr","title":"Create a match expression — match_expr","text":"function generates match expression can used style data.","code":""},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a match expression — match_expr","text":"","code":"match_expr(column = NULL, property = NULL, values, stops, default = \"#cccccc\")"},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a match expression — match_expr","text":"column name column use match expression. specified, property NULL. property name property use match expression. specified, column NULL. values vector values match . stops vector corresponding stops (colors, etc.) matched values. default default value use matches found.","code":""},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a match expression — match_expr","text":"list representing match expression.","code":""},{"path":"https://walker-data.com/mapgl/reference/match_expr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a match expression — match_expr","text":"","code":"match_expr( column = \"category\", values = c(\"A\", \"B\", \"C\"), stops = c(\"#ff0000\", \"#00ff00\", \"#0000ff\"), default = \"#cccccc\" ) #> [[1]] #> [1] \"match\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"category\" #> #> #> [[3]] #> [1] \"A\" #> #> [[4]] #> [1] \"#ff0000\" #> #> [[5]] #> [1] \"B\" #> #> [[6]] #> [1] \"#00ff00\" #> #> [[7]] #> [1] \"C\" #> #> [[8]] #> [1] \"#0000ff\" #> #> [[9]] #> [1] \"#cccccc\" #>"},{"path":"https://walker-data.com/mapgl/reference/move_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Move a layer to a different z-position — move_layer","title":"Move a layer to a different z-position — move_layer","text":"function allows layer moved different z-position existing Mapbox GL Maplibre GL map using proxy object.","code":""},{"path":"https://walker-data.com/mapgl/reference/move_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Move a layer to a different z-position — move_layer","text":"","code":"move_layer(proxy, layer_id, before_id = NULL)"},{"path":"https://walker-data.com/mapgl/reference/move_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Move a layer to a different z-position — move_layer","text":"proxy proxy object created mapboxgl_proxy maplibre_proxy. layer_id ID layer move. before_id ID existing layer insert new layer . Important: means layer appear immediately behind layer defined before_id. omitted, layer appended end layers array appear layers.","code":""},{"path":"https://walker-data.com/mapgl/reference/move_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Move a layer to a different z-position — move_layer","text":"updated proxy object.","code":""},{"path":"https://walker-data.com/mapgl/reference/number_format.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a number formatting expression — number_format","title":"Create a number formatting expression — number_format","text":"function creates number formatting expression formats numeric values according locale-specific conventions. can used tooltips, popups, text fields symbol layers.","code":""},{"path":"https://walker-data.com/mapgl/reference/number_format.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a number formatting expression — number_format","text":"","code":"number_format( column, locale = \"en-US\", style = \"decimal\", currency = NULL, unit = NULL, minimum_fraction_digits = NULL, maximum_fraction_digits = NULL, minimum_integer_digits = NULL, use_grouping = NULL, notation = NULL, compact_display = NULL )"},{"path":"https://walker-data.com/mapgl/reference/number_format.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a number formatting expression — number_format","text":"column name column containing numeric value format. Can also expression evaluates number. locale string specifying locale use formatting (e.g., \"en-US\", \"de-DE\", \"fr-FR\"). Defaults \"en-US\". style formatting style use. Options include: \"decimal\" (default): Plain number formatting \"currency\": Currency formatting (requires currency parameter) \"percent\": Percentage formatting (multiplies 100 adds %) \"unit\": Unit formatting (requires unit parameter) currency style = \"currency\", ISO 4217 currency code (e.g., \"USD\", \"EUR\", \"GBP\"). unit style = \"unit\", unit use (e.g., \"kilometer\", \"mile\", \"liter\"). minimum_fraction_digits minimum number fraction digits display. maximum_fraction_digits maximum number fraction digits display. minimum_integer_digits minimum number integer digits display. use_grouping Whether use grouping separators (e.g., thousands separators). Defaults TRUE. notation formatting notation. Options include: \"standard\" (default): Regular notation \"scientific\": Scientific notation \"engineering\": Engineering notation \"compact\": Compact notation (e.g., \"1.2K\", \"3.4M\") compact_display notation = \"compact\", whether use \"short\" (default) \"long\" form.","code":""},{"path":"https://walker-data.com/mapgl/reference/number_format.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a number formatting expression — number_format","text":"list representing number-format expression.","code":""},{"path":"https://walker-data.com/mapgl/reference/number_format.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a number formatting expression — number_format","text":"","code":"# Basic number formatting with thousands separators number_format(\"population\") #> [[1]] #> [1] \"number-format\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"population\" #> #> #> [[3]] #> [[3]]$locale #> [1] \"en-US\" #> #> [[3]]$style #> [1] \"decimal\" #> #> # Currency formatting number_format(\"income\", style = \"currency\", currency = \"USD\") #> [[1]] #> [1] \"number-format\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"income\" #> #> #> [[3]] #> [[3]]$locale #> [1] \"en-US\" #> #> [[3]]$style #> [1] \"currency\" #> #> [[3]]$currency #> [1] \"USD\" #> #> # Percentage with 1 decimal place number_format(\"rate\", style = \"percent\", maximum_fraction_digits = 1) #> [[1]] #> [1] \"number-format\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"rate\" #> #> #> [[3]] #> [[3]]$locale #> [1] \"en-US\" #> #> [[3]]$style #> [1] \"percent\" #> #> [[3]]$`max-fraction-digits` #> [1] 1 #> #> # Compact notation for large numbers number_format(\"population\", notation = \"compact\") #> [[1]] #> [1] \"number-format\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"population\" #> #> #> [[3]] #> [[3]]$locale #> [1] \"en-US\" #> #> [[3]]$style #> [1] \"decimal\" #> #> [[3]]$notation #> [1] \"compact\" #> #> # Using within a tooltip concat(\"Population: \", number_format(\"population\", notation = \"compact\")) #> [[1]] #> [1] \"concat\" #> #> [[2]] #> [1] \"Population: \" #> #> [[3]] #> [[3]][[1]] #> [1] \"number-format\" #> #> [[3]][[2]] #> [[3]][[2]][[1]] #> [1] \"get\" #> #> [[3]][[2]][[2]] #> [1] \"population\" #> #> #> [[3]][[3]] #> [[3]][[3]]$locale #> [1] \"en-US\" #> #> [[3]][[3]]$style #> [1] \"decimal\" #> #> [[3]][[3]]$notation #> [1] \"compact\" #> #> #> # Using with get_column() number_format(get_column(\"value\"), style = \"currency\", currency = \"EUR\") #> [[1]] #> [1] \"number-format\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"value\" #> #> #> [[3]] #> [[3]]$locale #> [1] \"en-US\" #> #> [[3]]$style #> [1] \"currency\" #> #> [[3]]$currency #> [1] \"EUR\" #> #>"},{"path":"https://walker-data.com/mapgl/reference/on_section.html","id":null,"dir":"Reference","previous_headings":"","what":"Observe events on story map section transitions — on_section","title":"Observe events on story map section transitions — on_section","text":"given story_section(), may want trigger event section becomes visible. function wraps shiny::observeEvent() allow modify state map invoke Shiny actions user scroll.","code":""},{"path":"https://walker-data.com/mapgl/reference/on_section.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Observe events on story map section transitions — on_section","text":"","code":"on_section(map_id, section_id, handler)"},{"path":"https://walker-data.com/mapgl/reference/on_section.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Observe events on story map section transitions — on_section","text":"map_id ID map output section_id ID section trigger , defined story_section() handler Expression execute section becomes visible.","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxgl.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a Mapbox GL output element in Shiny — renderMapboxgl","title":"Render a Mapbox GL output element in Shiny — renderMapboxgl","text":"Render Mapbox GL output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxgl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a Mapbox GL output element in Shiny — renderMapboxgl","text":"","code":"renderMapboxgl(expr, env = parent.frame(), quoted = FALSE)"},{"path":"https://walker-data.com/mapgl/reference/renderMapboxgl.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a Mapbox GL output element in Shiny — renderMapboxgl","text":"expr expression generates Mapbox GL map env environment evaluate expr quoted expr quoted expression","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxgl.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a Mapbox GL output element in Shiny — renderMapboxgl","text":"rendered Mapbox GL map use Shiny server","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxglCompare.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a Mapbox GL Compare output element in Shiny — renderMapboxglCompare","title":"Render a Mapbox GL Compare output element in Shiny — renderMapboxglCompare","text":"Render Mapbox GL Compare output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxglCompare.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a Mapbox GL Compare output element in Shiny — renderMapboxglCompare","text":"","code":"renderMapboxglCompare(expr, env = parent.frame(), quoted = FALSE)"},{"path":"https://walker-data.com/mapgl/reference/renderMapboxglCompare.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a Mapbox GL Compare output element in Shiny — renderMapboxglCompare","text":"expr expression generates Mapbox GL Compare map env environment evaluate expr quoted expr quoted expression","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMapboxglCompare.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a Mapbox GL Compare output element in Shiny — renderMapboxglCompare","text":"rendered Mapbox GL Compare map use Shiny server","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibre.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a Maplibre GL output element in Shiny — renderMaplibre","title":"Render a Maplibre GL output element in Shiny — renderMaplibre","text":"Render Maplibre GL output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibre.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a Maplibre GL output element in Shiny — renderMaplibre","text":"","code":"renderMaplibre(expr, env = parent.frame(), quoted = FALSE)"},{"path":"https://walker-data.com/mapgl/reference/renderMaplibre.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a Maplibre GL output element in Shiny — renderMaplibre","text":"expr expression generates Maplibre GL map env environment evaluate expr quoted expr quoted expression","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibre.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a Maplibre GL output element in Shiny — renderMaplibre","text":"rendered Maplibre GL map use Shiny server","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibreCompare.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a Maplibre GL Compare output element in Shiny — renderMaplibreCompare","title":"Render a Maplibre GL Compare output element in Shiny — renderMaplibreCompare","text":"Render Maplibre GL Compare output element Shiny","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibreCompare.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a Maplibre GL Compare output element in Shiny — renderMaplibreCompare","text":"","code":"renderMaplibreCompare(expr, env = parent.frame(), quoted = FALSE)"},{"path":"https://walker-data.com/mapgl/reference/renderMaplibreCompare.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a Maplibre GL Compare output element in Shiny — renderMaplibreCompare","text":"expr expression generates Maplibre GL Compare map env environment evaluate expr quoted expr quoted expression","code":""},{"path":"https://walker-data.com/mapgl/reference/renderMaplibreCompare.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Render a Maplibre GL Compare output element in Shiny — renderMaplibreCompare","text":"rendered Maplibre GL Compare map use Shiny server","code":""},{"path":"https://walker-data.com/mapgl/reference/set_config_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a configuration property for a Mapbox GL map — set_config_property","title":"Set a configuration property for a Mapbox GL map — set_config_property","text":"Set configuration property Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_config_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a configuration property for a Mapbox GL map — set_config_property","text":"","code":"set_config_property(map, import_id, config_name, value)"},{"path":"https://walker-data.com/mapgl/reference/set_config_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a configuration property for a Mapbox GL map — set_config_property","text":"map map object created mapboxgl function proxy object defined mapboxgl_proxy(). import_id name imported style set config (e.g., 'basemap'). config_name name configuration property style. value value set configuration property.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_config_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a configuration property for a Mapbox GL map — set_config_property","text":"updated map object configuration property set.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_filter.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a filter on a map layer — set_filter","title":"Set a filter on a map layer — set_filter","text":"function sets filter map layer, working regular map objects proxy objects.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_filter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a filter on a map layer — set_filter","text":"","code":"set_filter(map, layer_id, filter)"},{"path":"https://walker-data.com/mapgl/reference/set_filter.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a filter on a map layer — set_filter","text":"map map object created mapboxgl maplibre function, proxy object. layer_id ID layer filter applied. filter filter expression apply.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_filter.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a filter on a map layer — set_filter","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_fog.html","id":null,"dir":"Reference","previous_headings":"","what":"Set fog on a Mapbox GL map — set_fog","title":"Set fog on a Mapbox GL map — set_fog","text":"Set fog Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_fog.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set fog on a Mapbox GL map — set_fog","text":"","code":"set_fog( map, range = NULL, color = NULL, horizon_blend = NULL, high_color = NULL, space_color = NULL, star_intensity = NULL )"},{"path":"https://walker-data.com/mapgl/reference/set_fog.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set fog on a Mapbox GL map — set_fog","text":"map map object created mapboxgl function proxy object. range numeric vector length 2 defining minimum maximum range fog. color string specifying color fog. horizon_blend number 0 1 controlling blending fog horizon. high_color string specifying color fog higher elevations. space_color string specifying color fog space. star_intensity number 0 1 controlling intensity stars fog.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_fog.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set fog on a Mapbox GL map — set_fog","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_layout_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a layout property on a map layer — set_layout_property","title":"Set a layout property on a map layer — set_layout_property","text":"Set layout property map layer","code":""},{"path":"https://walker-data.com/mapgl/reference/set_layout_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a layout property on a map layer — set_layout_property","text":"","code":"set_layout_property(map, layer, name, value)"},{"path":"https://walker-data.com/mapgl/reference/set_layout_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a layout property on a map layer — set_layout_property","text":"map map object created mapboxgl maplibre function, proxy object. layer ID layer update. name name layout property set. value value set property .","code":""},{"path":"https://walker-data.com/mapgl/reference/set_layout_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a layout property on a map layer — set_layout_property","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_paint_property.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a paint property on a map layer — set_paint_property","title":"Set a paint property on a map layer — set_paint_property","text":"Set paint property map layer","code":""},{"path":"https://walker-data.com/mapgl/reference/set_paint_property.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a paint property on a map layer — set_paint_property","text":"","code":"set_paint_property(map, layer, name, value)"},{"path":"https://walker-data.com/mapgl/reference/set_paint_property.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a paint property on a map layer — set_paint_property","text":"map map object created mapboxgl maplibre function, proxy object. layer ID layer update. name name paint property set. value value set property .","code":""},{"path":"https://walker-data.com/mapgl/reference/set_paint_property.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a paint property on a map layer — set_paint_property","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_popup.html","id":null,"dir":"Reference","previous_headings":"","what":"Set popup on a map layer — set_popup","title":"Set popup on a map layer — set_popup","text":"Set popup map layer","code":""},{"path":"https://walker-data.com/mapgl/reference/set_popup.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set popup on a map layer — set_popup","text":"","code":"set_popup(map, layer, popup)"},{"path":"https://walker-data.com/mapgl/reference/set_popup.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set popup on a map layer — set_popup","text":"map map object created mapboxgl maplibre function, proxy object. layer ID layer update. popup name popup property expression set.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_popup.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set popup on a map layer — set_popup","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_projection.html","id":null,"dir":"Reference","previous_headings":"","what":"Set Projection for a Mapbox/Maplibre Map — set_projection","title":"Set Projection for a Mapbox/Maplibre Map — set_projection","text":"function sets projection dynamically map initialization.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_projection.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set Projection for a Mapbox/Maplibre Map — set_projection","text":"","code":"set_projection(map, projection)"},{"path":"https://walker-data.com/mapgl/reference/set_projection.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set Projection for a Mapbox/Maplibre Map — set_projection","text":"map map object created mapboxgl() maplibre() functions, respective proxy objects projection string representing projection name (e.g., \"mercator\", \"globe\", \"albers\", \"equalEarth\", etc.)","code":""},{"path":"https://walker-data.com/mapgl/reference/set_projection.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set Projection for a Mapbox/Maplibre Map — set_projection","text":"modified map object","code":""},{"path":"https://walker-data.com/mapgl/reference/set_rain.html","id":null,"dir":"Reference","previous_headings":"","what":"Set rain effect on a Mapbox GL map — set_rain","title":"Set rain effect on a Mapbox GL map — set_rain","text":"Set rain effect Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_rain.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set rain effect on a Mapbox GL map — set_rain","text":"","code":"set_rain( map, density = 0.5, intensity = 1, color = \"#a8adbc\", opacity = 0.7, center_thinning = 0.57, direction = c(0, 80), droplet_size = c(2.6, 18.2), distortion_strength = 0.7, vignette = 1, vignette_color = \"#464646\", remove = FALSE )"},{"path":"https://walker-data.com/mapgl/reference/set_rain.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set rain effect on a Mapbox GL map — set_rain","text":"map map object created mapboxgl function proxy object. density number 0 1 controlling rain particles density. Default 0.5. intensity number 0 1 controlling rain particles movement speed. Default 1. color string specifying color rain droplets. Default \"#a8adbc\". opacity number 0 1 controlling rain particles opacity. Default 0.7. center_thinning number 0 1 controlling thinning factor rain particles center. Default 0.57. direction numeric vector length 2 defining azimuth polar angles rain direction. Default c(0, 80). droplet_size numeric vector length 2 controlling rain droplet size (x - normal direction, y - along direction). Default c(2.6, 18.2). distortion_strength number 0 1 controlling rain particles screen-space distortion strength. Default 0.7. vignette number 0 1 controlling screen-space vignette rain tinting effect intensity. Default 1.0. vignette_color string specifying rain vignette screen-space corners tint color. Default \"#464646\". remove logical value indicating whether remove rain effect. Default FALSE.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_rain.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set rain effect on a Mapbox GL map — set_rain","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_rain.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set rain effect on a Mapbox GL map — set_rain","text":"","code":"if (FALSE) { # \\dontrun{ # Add rain effect with default values mapboxgl(...) |> set_rain() # Add rain effect with custom values mapboxgl( style = mapbox_style(\"standard\"), center = c(24.951528, 60.169573), zoom = 16.8, pitch = 74, bearing = 12.8 ) |> set_rain( density = 0.5, opacity = 0.7, color = \"#a8adbc\" ) # Remove rain effect (useful in Shiny) map_proxy |> set_rain(remove = TRUE) } # }"},{"path":"https://walker-data.com/mapgl/reference/set_snow.html","id":null,"dir":"Reference","previous_headings":"","what":"Set snow effect on a Mapbox GL map — set_snow","title":"Set snow effect on a Mapbox GL map — set_snow","text":"Set snow effect Mapbox GL map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_snow.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set snow effect on a Mapbox GL map — set_snow","text":"","code":"set_snow( map, density = 0.85, intensity = 1, color = \"#ffffff\", opacity = 1, center_thinning = 0.4, direction = c(0, 50), flake_size = 0.71, vignette = 0.3, vignette_color = \"#ffffff\", remove = FALSE )"},{"path":"https://walker-data.com/mapgl/reference/set_snow.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set snow effect on a Mapbox GL map — set_snow","text":"map map object created mapboxgl function proxy object. density number 0 1 controlling snow particles density. Default 0.85. intensity number 0 1 controlling snow particles movement speed. Default 1.0. color string specifying color snow particles. Default \"#ffffff\". opacity number 0 1 controlling snow particles opacity. Default 1.0. center_thinning number 0 1 controlling thinning factor snow particles center. Default 0.4. direction numeric vector length 2 defining azimuth polar angles snow direction. Default c(0, 50). flake_size number 0 5 controlling snow flake particle size. Default 0.71. vignette number 0 1 controlling snow vignette screen-space effect. Default 0.3. vignette_color string specifying snow vignette screen-space corners tint color. Default \"#ffffff\". remove logical value indicating whether remove snow effect. Default FALSE.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_snow.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set snow effect on a Mapbox GL map — set_snow","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_snow.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set snow effect on a Mapbox GL map — set_snow","text":"","code":"if (FALSE) { # \\dontrun{ # Add snow effect with default values mapboxgl(...) |> set_snow() # Add snow effect with custom values mapboxgl( style = mapbox_style(\"standard\"), center = c(24.951528, 60.169573), zoom = 16.8, pitch = 74, bearing = 12.8 ) |> set_snow( density = 0.85, flake_size = 0.71, color = \"#ffffff\" ) # Remove snow effect (useful in Shiny) map_proxy |> set_snow(remove = TRUE) } # }"},{"path":"https://walker-data.com/mapgl/reference/set_source.html","id":null,"dir":"Reference","previous_headings":"","what":"Set source of a map layer — set_source","title":"Set source of a map layer — set_source","text":"Set source map layer","code":""},{"path":"https://walker-data.com/mapgl/reference/set_source.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set source of a map layer — set_source","text":"","code":"set_source(map, layer, source)"},{"path":"https://walker-data.com/mapgl/reference/set_source.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set source of a map layer — set_source","text":"map map object created mapboxgl maplibre function, proxy object. layer ID layer update. source sf object (converted GeoJSON source).","code":""},{"path":"https://walker-data.com/mapgl/reference/set_source.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set source of a map layer — set_source","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":null,"dir":"Reference","previous_headings":"","what":"Update the style of a map — set_style","title":"Update the style of a map — set_style","text":"Update style map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Update the style of a map — set_style","text":"","code":"set_style(map, style, config = NULL, diff = TRUE, preserve_layers = TRUE)"},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Update the style of a map — set_style","text":"map map object created mapboxgl maplibre function, proxy object. style new style URL applied map. config named list options passed style config. diff boolean attempts diff-based update rather re-drawing full style. available styles. preserve_layers boolean indicates whether preserve user-added sources layers changing styles. Defaults TRUE.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Update the style of a map — set_style","text":"modified map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_style.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Update the style of a map — set_style","text":"","code":"if (FALSE) { # \\dontrun{ map <- mapboxgl( style = mapbox_style(\"streets\"), center = c(-74.006, 40.7128), zoom = 10, access_token = \"your_mapbox_access_token\" ) # Update the map style in a Shiny app observeEvent(input$change_style, { mapboxgl_proxy(\"map\", session) %>% set_style(mapbox_style(\"dark\"), config = list(showLabels = FALSE), diff = TRUE) }) } # }"},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":null,"dir":"Reference","previous_headings":"","what":"Set terrain properties on a map — set_terrain","title":"Set terrain properties on a map — set_terrain","text":"Set terrain properties map","code":""},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set terrain properties on a map — set_terrain","text":"","code":"set_terrain(map, source, exaggeration = 1)"},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set terrain properties on a map — set_terrain","text":"map map object created mapboxgl maplibre functions. source ID raster DEM source. exaggeration terrain exaggeration factor.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set terrain properties on a map — set_terrain","text":"modified map object terrain settings applied.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_terrain.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set terrain properties on a map — set_terrain","text":"","code":"if (FALSE) { # \\dontrun{ library(mapgl) mapboxgl( style = mapbox_style(\"standard-satellite\"), center = c(-114.26608, 32.7213), zoom = 14, pitch = 80, bearing = 41 ) |> add_raster_dem_source( id = \"mapbox-dem\", url = \"mapbox://mapbox.mapbox-terrain-dem-v1\", tileSize = 512, maxzoom = 14 ) |> set_terrain( source = \"mapbox-dem\", exaggeration = 1.5 ) } # }"},{"path":"https://walker-data.com/mapgl/reference/set_tooltip.html","id":null,"dir":"Reference","previous_headings":"","what":"Set tooltip on a map layer — set_tooltip","title":"Set tooltip on a map layer — set_tooltip","text":"Set tooltip map layer","code":""},{"path":"https://walker-data.com/mapgl/reference/set_tooltip.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set tooltip on a map layer — set_tooltip","text":"","code":"set_tooltip(map, layer, tooltip)"},{"path":"https://walker-data.com/mapgl/reference/set_tooltip.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set tooltip on a map layer — set_tooltip","text":"map map object created mapboxgl maplibre function, proxy object. layer ID layer update. tooltip name tooltip set.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_tooltip.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set tooltip on a map layer — set_tooltip","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_view.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the map center and zoom level — set_view","title":"Set the map center and zoom level — set_view","text":"Set map center zoom level","code":""},{"path":"https://walker-data.com/mapgl/reference/set_view.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the map center and zoom level — set_view","text":"","code":"set_view(map, center, zoom)"},{"path":"https://walker-data.com/mapgl/reference/set_view.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the map center and zoom level — set_view","text":"map map object created mapboxgl maplibre function proxy object. center numeric vector length 2 specifying center map (longitude, latitude). zoom zoom level.","code":""},{"path":"https://walker-data.com/mapgl/reference/set_view.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the map center and zoom level — set_view","text":"updated map object.","code":""},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a step expression — step_expr","title":"Create a step expression — step_expr","text":"function generates step expression can used styles.","code":""},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a step expression — step_expr","text":"","code":"step_expr(column = NULL, property = NULL, base, values, stops, na_color = NULL)"},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a step expression — step_expr","text":"column name column use step expression. specified, property NULL. property name property use step expression. specified, column NULL. base base value use step expression. values numeric vector values steps occur. stops vector corresponding stops (colors, sizes, etc.) steps. na_color color use missing values. Mapbox GL JS defaults black supplied.","code":""},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a step expression — step_expr","text":"list representing step expression.","code":""},{"path":"https://walker-data.com/mapgl/reference/step_expr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a step expression — step_expr","text":"","code":"step_expr( column = \"value\", base = \"#ffffff\", values = c(1000, 5000, 10000), stops = c(\"#ff0000\", \"#00ff00\", \"#0000ff\") ) #> [[1]] #> [1] \"step\" #> #> [[2]] #> [[2]][[1]] #> [1] \"get\" #> #> [[2]][[2]] #> [1] \"value\" #> #> #> [[3]] #> [1] \"#ffffff\" #> #> [[4]] #> [1] 1000 #> #> [[5]] #> [1] \"#ff0000\" #> #> [[6]] #> [1] 5000 #> #> [[7]] #> [1] \"#00ff00\" #> #> [[8]] #> [1] 10000 #> #> [[9]] #> [1] \"#0000ff\" #>"},{"path":"https://walker-data.com/mapgl/reference/story_leaflet.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a scrollytelling story map with Leaflet — story_leaflet","title":"Create a scrollytelling story map with Leaflet — story_leaflet","text":"Create scrollytelling story map Leaflet","code":""},{"path":"https://walker-data.com/mapgl/reference/story_leaflet.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a scrollytelling story map with Leaflet — story_leaflet","text":"","code":"story_leaflet( map_id, sections, root_margin = \"-20% 0px -20% 0px\", threshold = 0, styles = NULL, bg_color = \"rgba(255,255,255,0.9)\", text_color = \"#34495e\", font_family = NULL )"},{"path":"https://walker-data.com/mapgl/reference/story_leaflet.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a scrollytelling story map with Leaflet — story_leaflet","text":"map_id ID mapboxgl, maplibre, leaflet output defined server, e.g. \"map\" sections named list story_section objects. Names correspond map events defined within server using on_section(). root_margin margin around viewport triggering sections intersection observer. specified string, e.g. \"-20% 0px -20% 0px\". threshold number indicates visibility ratio story ' panel used trigger section; number 0 1. Defaults 0, meaning section triggered soon first pixel visible. styles Optional custom CSS styles. specified character string within shiny::tags$style(). bg_color Default background color sections text_color Default text color sections font_family Default font family sections","code":""},{"path":"https://walker-data.com/mapgl/reference/story_map.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a scrollytelling story map — story_map","title":"Create a scrollytelling story map — story_map","text":"Create scrollytelling story map","code":""},{"path":"https://walker-data.com/mapgl/reference/story_map.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a scrollytelling story map — story_map","text":"","code":"story_map( map_id, sections, map_type = c(\"mapboxgl\", \"maplibre\", \"leaflet\"), root_margin = \"-20% 0px -20% 0px\", threshold = 0, styles = NULL, bg_color = \"rgba(255,255,255,0.9)\", text_color = \"#34495e\", font_family = NULL )"},{"path":"https://walker-data.com/mapgl/reference/story_map.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a scrollytelling story map — story_map","text":"map_id ID mapboxgl, maplibre, leaflet output defined server, e.g. \"map\" sections named list story_section objects. Names correspond map events defined within server using on_section(). map_type One \"mapboxgl\", \"maplibre\", \"leaflet\". use either mapboxglOutput(), maplibreOutput(), leafletOutput() respectively, must correspond appropriate render*() function used server. root_margin margin around viewport triggering sections intersection observer. specified string, e.g. \"-20% 0px -20% 0px\". threshold number indicates visibility ratio story ' panel used trigger section; number 0 1. Defaults 0, meaning section triggered soon first pixel visible. styles Optional custom CSS styles. specified character string within shiny::tags$style(). bg_color Default background color sections text_color Default text color sections font_family Default font family sections","code":""},{"path":"https://walker-data.com/mapgl/reference/story_maplibre.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a scrollytelling story map with MapLibre — story_maplibre","title":"Create a scrollytelling story map with MapLibre — story_maplibre","text":"Create scrollytelling story map MapLibre","code":""},{"path":"https://walker-data.com/mapgl/reference/story_maplibre.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a scrollytelling story map with MapLibre — story_maplibre","text":"","code":"story_maplibre( map_id, sections, root_margin = \"-20% 0px -20% 0px\", threshold = 0, styles = NULL, bg_color = \"rgba(255,255,255,0.9)\", text_color = \"#34495e\", font_family = NULL )"},{"path":"https://walker-data.com/mapgl/reference/story_maplibre.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a scrollytelling story map with MapLibre — story_maplibre","text":"map_id ID mapboxgl, maplibre, leaflet output defined server, e.g. \"map\" sections named list story_section objects. Names correspond map events defined within server using on_section(). root_margin margin around viewport triggering sections intersection observer. specified string, e.g. \"-20% 0px -20% 0px\". threshold number indicates visibility ratio story ' panel used trigger section; number 0 1. Defaults 0, meaning section triggered soon first pixel visible. styles Optional custom CSS styles. specified character string within shiny::tags$style(). bg_color Default background color sections text_color Default text color sections font_family Default font family sections","code":""},{"path":"https://walker-data.com/mapgl/reference/story_section.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a story section for story maps — story_section","title":"Create a story section for story maps — story_section","text":"Create story section story maps","code":""},{"path":"https://walker-data.com/mapgl/reference/story_section.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a story section for story maps — story_section","text":"","code":"story_section( title, content, position = c(\"left\", \"center\", \"right\"), width = 400, bg_color = NULL, text_color = NULL, font_family = NULL )"},{"path":"https://walker-data.com/mapgl/reference/story_section.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a story section for story maps — story_section","text":"title Section title content Section content - can text, HTML, Shiny outputs position Position text block (\"left\", \"center\", \"right\") width Width text block pixels (default: 400) bg_color Background color (alpha) text block text_color Text color font_family Font family section","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-development-version","dir":"Changelog","previous_headings":"","what":"mapgl (development version)","title":"mapgl (development version)","text":"Added ability load existing features map sources draw control editing either initializing draw control via add_features_to_draw() Fixed vertex styling properly highlight selected vertices editing Extended draw control support compare views, enabling feature editing side--side map comparisons Improved compatibility Mapbox GL JS MapLibre GL JS Added proper source layer handling vector tiles using hover effects Now works correctly PMTiles vector tile sources include feature IDs Note: Vector tiles must include feature IDs hover effects work. GeoJSON sources automatically generate IDs. Tooltips can now use expressions dynamic content generation Use get_column() reference feature properties tooltips Added concat() helper function combining strings expressions Example: tooltip = concat(\"Name:<\/strong> \", get_column(\"name\"), \"
    Value: \", get_column(\"value\")) Works regular tooltips set_tooltip() Shiny applications","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-022","dir":"Changelog","previous_headings":"","what":"mapgl 0.2.2","title":"mapgl 0.2.2","text":"CRAN release: 2025-05-23 Added mapboxgl_view() maplibre_view() functions quick visualization sf objects automatic geometry detection column-based styling (#102). Added support rain snow effects Mapbox GL maps set_rain() set_snow() functions. Added add_globe_control() MapLibre maps, allowing users toggle “mercator” “globe” projections. Fixed issue set_style() Shiny applications Mapbox MapLibre maps (#99). Fixed namespacing issue get_drawn_features() Shiny modules (#95). Improved compare functionality better control support swiper color customization.","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-021","dir":"Changelog","previous_headings":"","what":"mapgl 0.2.1","title":"mapgl 0.2.1","text":"CRAN release: 2025-03-18 Improved styling positioning behavior layers control. Users can now customize appearance layers control, layers control collapsed default cleaner appearance. Added ability link legends specific layers new layer_id parameter add_legend(). layer toggled layers control, associated legend automatically show hide. Added support custom legend positioning new margin parameters (margin_top, margin_right, margin_bottom, margin_left) allow fine-grained control legend placement. Fixed layers control toggle button state correctly reflect initial visibility layers, resolving issue layers set visibility = \"none\" showing active control. Support compare() plugin Shiny applications, new rendering proxy functions comparison apps Mapbox MapLibre. New mode parameter compare() allowing users choose \"swipe\" mode comparison slider, \"sync\" mode displays synchronized maps side--side. Updates throughout codebase allow features used comparison maps via Shiny proxy sessions.","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-020","dir":"Changelog","previous_headings":"","what":"mapgl 0.2.0","title":"mapgl 0.2.0","text":"CRAN release: 2025-01-13 new “story map” feature allows users build interactive story maps. View story mapping vignette information. Various bug fixes performance improvements; visit package GitHub page details.","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-014","dir":"Changelog","previous_headings":"","what":"mapgl 0.1.4","title":"mapgl 0.1.4","text":"CRAN release: 2024-11-01 add_image() allows add image map’s sprite use icon / symbol layer add_geolocate_control() adds Geolocate control map add_globe_minimap() adds mini globe overview map tracks map moves around globe Support multiple legends argument add = TRUE move_layer() function gives fine-grained control layer ordering Shiny session Various bug fixes performance improvements.","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-013","dir":"Changelog","previous_headings":"","what":"mapgl 0.1.3","title":"mapgl 0.1.3","text":"CRAN release: 2024-09-04 Geocoding support Mapbox MapLibre maps added add_geocoder_control() Freehand draw support draw toolbar add_draw_control(freehand = TRUE) “reset view” control available add_reset_control() Circle clustering streamlined cluster_options() function, used cluster_options argument add_circle_layer() add_symbol_layer() Various bug fixes performance improvements.","code":""},{"path":"https://walker-data.com/mapgl/news/index.html","id":"mapgl-010","dir":"Changelog","previous_headings":"","what":"mapgl 0.1.0","title":"mapgl 0.1.0","text":"Initial release.","code":""}] diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 3f3795a7..2bc3e792 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -1,5 +1,6 @@ https://walker-data.com/mapgl/404.html +https://walker-data.com/mapgl/CLAUDE.html https://walker-data.com/mapgl/LICENSE-text.html https://walker-data.com/mapgl/LICENSE.html https://walker-data.com/mapgl/articles/getting-started.html @@ -7,19 +8,24 @@ https://walker-data.com/mapgl/articles/layers-overview.html https://walker-data.com/mapgl/articles/map-design.html https://walker-data.com/mapgl/articles/shiny.html +https://walker-data.com/mapgl/articles/story-maps.html https://walker-data.com/mapgl/authors.html https://walker-data.com/mapgl/index.html https://walker-data.com/mapgl/news/index.html https://walker-data.com/mapgl/reference/add_categorical_legend.html https://walker-data.com/mapgl/reference/add_circle_layer.html https://walker-data.com/mapgl/reference/add_continuous_legend.html +https://walker-data.com/mapgl/reference/add_control.html https://walker-data.com/mapgl/reference/add_draw_control.html +https://walker-data.com/mapgl/reference/add_features_to_draw.html https://walker-data.com/mapgl/reference/add_fill_extrusion_layer.html https://walker-data.com/mapgl/reference/add_fill_layer.html https://walker-data.com/mapgl/reference/add_fullscreen_control.html https://walker-data.com/mapgl/reference/add_geocoder_control.html https://walker-data.com/mapgl/reference/add_geolocate_control.html +https://walker-data.com/mapgl/reference/add_globe_control.html https://walker-data.com/mapgl/reference/add_globe_minimap.html +https://walker-data.com/mapgl/reference/add_h3j_source.html https://walker-data.com/mapgl/reference/add_heatmap_layer.html https://walker-data.com/mapgl/reference/add_image.html https://walker-data.com/mapgl/reference/add_image_source.html @@ -45,6 +51,7 @@ https://walker-data.com/mapgl/reference/clear_markers.html https://walker-data.com/mapgl/reference/cluster_options.html https://walker-data.com/mapgl/reference/compare.html +https://walker-data.com/mapgl/reference/concat.html https://walker-data.com/mapgl/reference/ease_to.html https://walker-data.com/mapgl/reference/fit_bounds.html https://walker-data.com/mapgl/reference/fly_to.html @@ -55,25 +62,45 @@ https://walker-data.com/mapgl/reference/jump_to.html https://walker-data.com/mapgl/reference/mapbox_style.html https://walker-data.com/mapgl/reference/mapboxgl.html +https://walker-data.com/mapgl/reference/mapboxglCompareOutput.html https://walker-data.com/mapgl/reference/mapboxglOutput.html +https://walker-data.com/mapgl/reference/mapboxgl_compare_proxy.html https://walker-data.com/mapgl/reference/mapboxgl_proxy.html +https://walker-data.com/mapgl/reference/mapboxgl_view.html https://walker-data.com/mapgl/reference/mapgl-package.html https://walker-data.com/mapgl/reference/maplibre.html +https://walker-data.com/mapgl/reference/maplibreCompareOutput.html https://walker-data.com/mapgl/reference/maplibreOutput.html +https://walker-data.com/mapgl/reference/maplibre_compare_proxy.html https://walker-data.com/mapgl/reference/maplibre_proxy.html +https://walker-data.com/mapgl/reference/maplibre_view.html https://walker-data.com/mapgl/reference/maptiler_style.html https://walker-data.com/mapgl/reference/match_expr.html https://walker-data.com/mapgl/reference/move_layer.html +https://walker-data.com/mapgl/reference/number_format.html +https://walker-data.com/mapgl/reference/on_section.html https://walker-data.com/mapgl/reference/renderMapboxgl.html +https://walker-data.com/mapgl/reference/renderMapboxglCompare.html https://walker-data.com/mapgl/reference/renderMaplibre.html +https://walker-data.com/mapgl/reference/renderMaplibreCompare.html https://walker-data.com/mapgl/reference/set_config_property.html https://walker-data.com/mapgl/reference/set_filter.html https://walker-data.com/mapgl/reference/set_fog.html https://walker-data.com/mapgl/reference/set_layout_property.html https://walker-data.com/mapgl/reference/set_paint_property.html +https://walker-data.com/mapgl/reference/set_popup.html +https://walker-data.com/mapgl/reference/set_projection.html +https://walker-data.com/mapgl/reference/set_rain.html +https://walker-data.com/mapgl/reference/set_snow.html +https://walker-data.com/mapgl/reference/set_source.html https://walker-data.com/mapgl/reference/set_style.html https://walker-data.com/mapgl/reference/set_terrain.html +https://walker-data.com/mapgl/reference/set_tooltip.html https://walker-data.com/mapgl/reference/set_view.html https://walker-data.com/mapgl/reference/step_expr.html +https://walker-data.com/mapgl/reference/story_leaflet.html +https://walker-data.com/mapgl/reference/story_map.html +https://walker-data.com/mapgl/reference/story_maplibre.html +https://walker-data.com/mapgl/reference/story_section.html diff --git a/inst/htmlwidgets/lib/h3j-h3t/h3j_h3t.js b/inst/htmlwidgets/lib/h3j-h3t/h3j_h3t.js new file mode 100644 index 00000000..16631aa5 --- /dev/null +++ b/inst/htmlwidgets/lib/h3j-h3t/h3j_h3t.js @@ -0,0 +1,3 @@ +!function(A){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=A();else if("function"==typeof define&&define.amd)define([],A);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).h3j_h3t=A()}}((function(){return function A(e,r,t){function i(o,a){if(!r[o]){if(!e[o]){var f="function"==typeof require&&require;if(!a&&f)return f(o,!0);if(n)return n(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var u=r[o]={exports:{}};e[o][0].call(u.exports,(function(A){return i(e[o][1][A]||A)}),u,u.exports,A,e,r,t)}return r[o].exports}for(var n="function"==typeof require&&require,o=0;o>3}if(n--,1===i||2===i)o+=A.readSVarint(),a+=A.readSVarint(),1===i&&(e&&f.push(e),e=[]),e.push(new t(o,a));else{if(7!==i)throw new Error("unknown command "+i);e&&e.push(e[0].clone())}}return e&&f.push(e),f},i.prototype.bbox=function(){var A=this._pbf;A.pos=this._geometry;for(var e=A.readVarint()+A.pos,r=1,t=0,i=0,n=0,o=1/0,a=-1/0,f=1/0,s=-1/0;A.pos>3}if(t--,1===r||2===r)(i+=A.readSVarint())a&&(a=i),(n+=A.readSVarint())s&&(s=n);else if(7!==r)throw new Error("unknown command "+r)}return[o,f,a,s]},i.prototype.toGeoJSON=function(A,e,r){var t,n,a=this.extent*Math.pow(2,r),f=this.extent*A,s=this.extent*e,u=this.loadGeometry(),l=i.types[this.type];function h(A){for(var e=0;e>3;e=1===t?A.readString():2===t?A.readFloat():3===t?A.readDouble():4===t?A.readVarint64():5===t?A.readVarint():6===t?A.readSVarint():7===t?A.readBoolean():null}return e}(r))}e.exports=i,i.prototype.feature=function(A){if(A<0||A>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[A];var e=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,e,this.extent,this._keys,this._values)}},{"./vectortilefeature.js":4}],6:[function(A,e,r){!function(A,t){"object"==typeof r&&void 0!==e?e.exports=t():A.geojsonvt=t()}(this,(function(){"use strict";function A(r,t,i,n){for(var o,a=n,f=i-t>>1,s=i-t,u=r[t],l=r[t+1],h=r[i],c=r[i+1],d=t+3;da)o=d,a=g;else if(g===a){var w=Math.abs(d-f);wn&&(o-t>3&&A(r,t,o,n),r[o+2]=a,i-o>3&&A(r,o,i,n))}function e(A,e,r,t,i,n){var o=i-r,a=n-t;if(0!==o||0!==a){var f=((A-r)*o+(e-t)*a)/(o*o+a*a);f>1?(r=i,t=n):f>0&&(r+=o*f,t+=a*f)}return(o=A-r)*o+(a=e-t)*a}function r(A,e,r,i){var n={id:void 0===A?null:A,type:e,geometry:r,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(A){var e=A.geometry,r=A.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)t(A,e);else if("Polygon"===r||"MultiLineString"===r)for(var i=0;i0&&(a+=i?(n*h-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(h-o,2))),n=l,o=h}var c=r.length-3;r[2]=1,A(r,0,c,t),r[c+2]=1,r.size=Math.abs(a),r.start=0,r.end=r.size}function a(A,e,r,t){for(var i=0;i1?1:r}function u(A,e,t,i,n,o,a,f){if(i/=e,o>=(t/=e)&&a=i)return null;for(var s=[],u=0;u=t&&B=i)){var b=[];if("Point"===w||"MultiPoint"===w)l(g,b,t,i,n);else if("LineString"===w)h(g,b,t,i,n,!1,f.lineMetrics);else if("MultiLineString"===w)d(g,b,t,i,n,!1);else if("Polygon"===w)d(g,b,t,i,n,!0);else if("MultiPolygon"===w)for(var v=0;v=r&&o<=t&&(e.push(A[n]),e.push(A[n+1]),e.push(A[n+2]))}}function h(A,e,r,t,i,n,o){for(var a,f,s=c(A),u=0===i?w:p,l=A.start,h=0;hr&&(f=u(s,d,B,v,m,r),o&&(s.start=l+a*f)):k>t?M=r&&(f=u(s,d,B,v,m,r),Q=!0),M>t&&k<=t&&(f=u(s,d,B,v,m,t),Q=!0),!n&&Q&&(o&&(s.end=l+a*f),e.push(s),s=c(A)),o&&(l+=a)}var y=A.length-3;d=A[y],B=A[y+1],b=A[y+2],(k=0===i?d:B)>=r&&k<=t&&g(s,d,B,b),y=s.length-3,n&&y>=3&&(s[y]!==s[0]||s[y+1]!==s[1])&&g(s,s[0],s[1],s[2]),s.length&&e.push(s)}function c(A){var e=[];return e.size=A.size,e.start=A.start,e.end=A.end,e}function d(A,e,r,t,i,n){for(var o=0;oo.maxX&&(o.maxX=u),l>o.maxY&&(o.maxY=l)}return o}function M(A,e,r,t){var i=e.geometry,n=e.type,o=[];if("Point"===n||"MultiPoint"===n)for(var a=0;a0&&e.size<(i?o:t))r.numPoints+=e.length/3;else{for(var a=[],f=0;fo)&&(r.numSimplified++,a.push(e[f]),a.push(e[f+1])),r.numPoints++;i&&function(A,e){for(var r=0,t=0,i=A.length,n=i-2;t0===e)for(t=0,i=A.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var t=function(A,e){var r=[];if("FeatureCollection"===A.type)for(var t=0;t1&&console.time("creation"),c=this.tiles[h]=k(A,e,r,t,f),this.tileCoords.push({z:e,x:r,y:t}),s)){s>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,t,c.numFeatures,c.numPoints,c.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(c.source=A,i){if(e===f.maxZoom||e===i)continue;var g=1<1&&console.time("clipping");var w,p,B,b,v,m,M=.5*f.buffer/f.extent,Q=.5-M,y=.5+M,x=1+M;w=p=B=b=null,v=u(A,l,r-M,r+y,0,c.minX,c.maxX,f),m=u(A,l,r+Q,r+x,0,c.minX,c.maxX,f),A=null,v&&(w=u(v,l,t-M,t+y,1,c.minY,c.maxY,f),p=u(v,l,t+Q,t+x,1,c.minY,c.maxY,f),v=null),m&&(B=u(m,l,t-M,t+y,1,c.minY,c.maxY,f),b=u(m,l,t+Q,t+x,1,c.minY,c.maxY,f),m=null),s>1&&console.timeEnd("clipping"),a.push(w||[],e+1,2*r,2*t),a.push(p||[],e+1,2*r,2*t+1),a.push(B||[],e+1,2*r+1,2*t),a.push(b||[],e+1,2*r+1,2*t+1)}}},y.prototype.getTile=function(A,e,r){var t=this.options,i=t.extent,n=t.debug;if(A<0||A>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",A,e,r);for(var f,s=A,u=e,l=r;!f&&s>0;)s--,u=Math.floor(u/2),l=Math.floor(l/2),f=this.tiles[E(s,u,l)];return f&&f.source?(n>1&&console.log("found parent tile z%d-%d-%d",s,u,l),n>1&&console.time("drilling down"),this.splitTile(f.source,s,u,l,A,e,r),n>1&&console.timeEnd("drilling down"),this.tiles[a]?v(this.tiles[a],i):null):null},function(A,e){return new y(A,e)}}))},{}],7:[function(A,e,r){var t=function(A){var e,r=void 0!==(A=A||{})?A:{},t={};for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);var i,n=[],o="";document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",i=function(A,e,r){var t=new XMLHttpRequest;t.open("GET",A,!0),t.responseType="arraybuffer",t.onload=function(){if(200==t.status||0==t.status&&t.response)e(t.response);else{var i=J(A);i?e(i.buffer):r()}},t.onerror=r,t.send(null)};var a=r.print||console.log.bind(console),f=r.printErr||console.warn.bind(console);for(e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);t=null,r.arguments&&(n=r.arguments);var s=0,u=function(){return s};var l=!1;function h(A){var e,t=r["_"+A];return e="Cannot call unknown function "+A+", make sure it is exported",t||fA("Assertion failed: "+e),t}function c(A,e,r,t,i){var n={string:function(A){var e=0;if(null!=A&&0!==A){var r=1+(A.length<<2);(function(A,e,r){(function(A,e,r,t){if(!(t>0))return 0;for(var i=r,n=r+t-1,o=0;o=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&A.charCodeAt(++o);if(a<=127){if(r>=n)break;e[r++]=a}else if(a<=2047){if(r+1>=n)break;e[r++]=192|a>>6,e[r++]=128|63&a}else if(a<=65535){if(r+2>=n)break;e[r++]=224|a>>12,e[r++]=128|a>>6&63,e[r++]=128|63&a}else{if(r+3>=n)break;e[r++]=240|a>>18,e[r++]=128|a>>12&63,e[r++]=128|a>>6&63,e[r++]=128|63&a}}e[r]=0})(A,B,e,r)})(A,e=AA(r),r)}return e},array:function(A){var e=AA(A.length);return function(A,e){p.set(A,e)}(A,e),e}};var o=h(A),a=[],f=0;if(t)for(var s=0;s=t);)++i;if(i-e>16&&A.subarray&&d)return d.decode(A.subarray(e,i));for(var n="";e>10,56320|1023&s)}}else n+=String.fromCharCode((31&o)<<6|a)}else n+=String.fromCharCode(o)}return n}(B,A,e):""}var w,p,B,b,v,m,k;"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");function M(A,e){return A%e>0&&(A+=e-A%e),A}function Q(A){w=A,r.HEAP8=p=new Int8Array(A),r.HEAP16=b=new Int16Array(A),r.HEAP32=v=new Int32Array(A),r.HEAPU8=B=new Uint8Array(A),r.HEAPU16=new Uint16Array(A),r.HEAPU32=new Uint32Array(A),r.HEAPF32=m=new Float32Array(A),r.HEAPF64=k=new Float64Array(A)}var y=r.TOTAL_MEMORY||33554432;function E(A){for(;A.length>0;){var e=A.shift();if("function"!=typeof e){var t=e.func;"number"==typeof t?void 0===e.arg?r.dynCall_v(t):r.dynCall_vi(t,e.arg):t(void 0===e.arg?null:e.arg)}else e()}}y=(w=r.buffer?r.buffer:new ArrayBuffer(y)).byteLength,Q(w),v[6004]=5266928;var x=[],D=[],_=[],I=[];var F=Math.abs,C=Math.ceil,P=Math.floor,U=Math.min,G=0,S=null,T=null;r.preloadedImages={},r.preloadedAudios={};var V,H,R=null,L="data:application/octet-stream;base64,";function z(A){return String.prototype.startsWith?A.startsWith(L):0===A.indexOf(L)}R="data:application/octet-stream;base64,AAAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAABAAAAAMAAAAGAAAABQAAAAIAAAAAAAAAAgAAAAMAAAABAAAABAAAAAYAAAAAAAAABQAAAAMAAAAGAAAABAAAAAUAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAABAAAABQAAAAIAAAAAAAAAAQAAAAMAAAAGAAAABAAAAAYAAAAAAAAABQAAAAIAAAABAAAABAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAgAAAAMAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAABgAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAABgAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAAAAAACAAAAAwAAAAQAAAAFAAAABgAAAAAAAAABAAAAAwAAAAQAAAAFAAAABgAAAAAAAAABAAAAAgAAAAQAAAAFAAAABgAAAAAAAAABAAAAAgAAAAMAAAAFAAAABgAAAAAAAAABAAAAAgAAAAMAAAAEAAAABgAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAAAAAAABgAAAAAAAAADAAAAAgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAUAAAAEAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAEAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAUAAAACAAAABAAAAAMAAAAIAAAAAQAAAAcAAAAGAAAACQAAAAAAAAADAAAAAgAAAAIAAAAGAAAACgAAAAsAAAAAAAAAAQAAAAUAAAADAAAADQAAAAEAAAAHAAAABAAAAAwAAAAAAAAABAAAAH8AAAAPAAAACAAAAAMAAAAAAAAADAAAAAUAAAACAAAAEgAAAAoAAAAIAAAAAAAAABAAAAAGAAAADgAAAAsAAAARAAAAAQAAAAkAAAACAAAABwAAABUAAAAJAAAAEwAAAAMAAAANAAAAAQAAAAgAAAAFAAAAFgAAABAAAAAEAAAAAAAAAA8AAAAJAAAAEwAAAA4AAAAUAAAAAQAAAAcAAAAGAAAACgAAAAsAAAAYAAAAFwAAAAUAAAACAAAAEgAAAAsAAAARAAAAFwAAABkAAAACAAAABgAAAAoAAAAMAAAAHAAAAA0AAAAaAAAABAAAAA8AAAADAAAADQAAABoAAAAVAAAAHQAAAAMAAAAMAAAABwAAAA4AAAB/AAAAEQAAABsAAAAJAAAAFAAAAAYAAAAPAAAAFgAAABwAAAAfAAAABAAAAAgAAAAMAAAAEAAAABIAAAAhAAAAHgAAAAgAAAAFAAAAFgAAABEAAAALAAAADgAAAAYAAAAjAAAAGQAAABsAAAASAAAAGAAAAB4AAAAgAAAABQAAAAoAAAAQAAAAEwAAACIAAAAUAAAAJAAAAAcAAAAVAAAACQAAABQAAAAOAAAAEwAAAAkAAAAoAAAAGwAAACQAAAAVAAAAJgAAABMAAAAiAAAADQAAAB0AAAAHAAAAFgAAABAAAAApAAAAIQAAAA8AAAAIAAAAHwAAABcAAAAYAAAACwAAAAoAAAAnAAAAJQAAABkAAAAYAAAAfwAAACAAAAAlAAAACgAAABcAAAASAAAAGQAAABcAAAARAAAACwAAAC0AAAAnAAAAIwAAABoAAAAqAAAAHQAAACsAAAAMAAAAHAAAAA0AAAAbAAAAKAAAACMAAAAuAAAADgAAABQAAAARAAAAHAAAAB8AAAAqAAAALAAAAAwAAAAPAAAAGgAAAB0AAAArAAAAJgAAAC8AAAANAAAAGgAAABUAAAAeAAAAIAAAADAAAAAyAAAAEAAAABIAAAAhAAAAHwAAACkAAAAsAAAANQAAAA8AAAAWAAAAHAAAACAAAAAeAAAAGAAAABIAAAA0AAAAMgAAACUAAAAhAAAAHgAAADEAAAAwAAAAFgAAABAAAAApAAAAIgAAABMAAAAmAAAAFQAAADYAAAAkAAAAMwAAACMAAAAuAAAALQAAADgAAAARAAAAGwAAABkAAAAkAAAAFAAAACIAAAATAAAANwAAACgAAAA2AAAAJQAAACcAAAA0AAAAOQAAABgAAAAXAAAAIAAAACYAAAB/AAAAIgAAADMAAAAdAAAALwAAABUAAAAnAAAAJQAAABkAAAAXAAAAOwAAADkAAAAtAAAAKAAAABsAAAAkAAAAFAAAADwAAAAuAAAANwAAACkAAAAxAAAANQAAAD0AAAAWAAAAIQAAAB8AAAAqAAAAOgAAACsAAAA+AAAAHAAAACwAAAAaAAAAKwAAAD4AAAAvAAAAQAAAABoAAAAqAAAAHQAAACwAAAA1AAAAOgAAAEEAAAAcAAAAHwAAACoAAAAtAAAAJwAAACMAAAAZAAAAPwAAADsAAAA4AAAALgAAADwAAAA4AAAARAAAABsAAAAoAAAAIwAAAC8AAAAmAAAAKwAAAB0AAABFAAAAMwAAAEAAAAAwAAAAMQAAAB4AAAAhAAAAQwAAAEIAAAAyAAAAMQAAAH8AAAA9AAAAQgAAACEAAAAwAAAAKQAAADIAAAAwAAAAIAAAAB4AAABGAAAAQwAAADQAAAAzAAAARQAAADYAAABHAAAAJgAAAC8AAAAiAAAANAAAADkAAABGAAAASgAAACAAAAAlAAAAMgAAADUAAAA9AAAAQQAAAEsAAAAfAAAAKQAAACwAAAA2AAAARwAAADcAAABJAAAAIgAAADMAAAAkAAAANwAAACgAAAA2AAAAJAAAAEgAAAA8AAAASQAAADgAAABEAAAAPwAAAE0AAAAjAAAALgAAAC0AAAA5AAAAOwAAAEoAAABOAAAAJQAAACcAAAA0AAAAOgAAAH8AAAA+AAAATAAAACwAAABBAAAAKgAAADsAAAA/AAAATgAAAE8AAAAnAAAALQAAADkAAAA8AAAASAAAAEQAAABQAAAAKAAAADcAAAAuAAAAPQAAADUAAAAxAAAAKQAAAFEAAABLAAAAQgAAAD4AAAArAAAAOgAAACoAAABSAAAAQAAAAEwAAAA/AAAAfwAAADgAAAAtAAAATwAAADsAAABNAAAAQAAAAC8AAAA+AAAAKwAAAFQAAABFAAAAUgAAAEEAAAA6AAAANQAAACwAAABWAAAATAAAAEsAAABCAAAAQwAAAFEAAABVAAAAMQAAADAAAAA9AAAAQwAAAEIAAAAyAAAAMAAAAFcAAABVAAAARgAAAEQAAAA4AAAAPAAAAC4AAABaAAAATQAAAFAAAABFAAAAMwAAAEAAAAAvAAAAWQAAAEcAAABUAAAARgAAAEMAAAA0AAAAMgAAAFMAAABXAAAASgAAAEcAAABZAAAASQAAAFsAAAAzAAAARQAAADYAAABIAAAAfwAAAEkAAAA3AAAAUAAAADwAAABYAAAASQAAAFsAAABIAAAAWAAAADYAAABHAAAANwAAAEoAAABOAAAAUwAAAFwAAAA0AAAAOQAAAEYAAABLAAAAQQAAAD0AAAA1AAAAXgAAAFYAAABRAAAATAAAAFYAAABSAAAAYAAAADoAAABBAAAAPgAAAE0AAAA/AAAARAAAADgAAABdAAAATwAAAFoAAABOAAAASgAAADsAAAA5AAAAXwAAAFwAAABPAAAATwAAAE4AAAA/AAAAOwAAAF0AAABfAAAATQAAAFAAAABEAAAASAAAADwAAABjAAAAWgAAAFgAAABRAAAAVQAAAF4AAABlAAAAPQAAAEIAAABLAAAAUgAAAGAAAABUAAAAYgAAAD4AAABMAAAAQAAAAFMAAAB/AAAASgAAAEYAAABkAAAAVwAAAFwAAABUAAAARQAAAFIAAABAAAAAYQAAAFkAAABiAAAAVQAAAFcAAABlAAAAZgAAAEIAAABDAAAAUQAAAFYAAABMAAAASwAAAEEAAABoAAAAYAAAAF4AAABXAAAAUwAAAGYAAABkAAAAQwAAAEYAAABVAAAAWAAAAEgAAABbAAAASQAAAGMAAABQAAAAaQAAAFkAAABhAAAAWwAAAGcAAABFAAAAVAAAAEcAAABaAAAATQAAAFAAAABEAAAAagAAAF0AAABjAAAAWwAAAEkAAABZAAAARwAAAGkAAABYAAAAZwAAAFwAAABTAAAATgAAAEoAAABsAAAAZAAAAF8AAABdAAAATwAAAFoAAABNAAAAbQAAAF8AAABqAAAAXgAAAFYAAABRAAAASwAAAGsAAABoAAAAZQAAAF8AAABcAAAATwAAAE4AAABtAAAAbAAAAF0AAABgAAAAaAAAAGIAAABuAAAATAAAAFYAAABSAAAAYQAAAH8AAABiAAAAVAAAAGcAAABZAAAAbwAAAGIAAABuAAAAYQAAAG8AAABSAAAAYAAAAFQAAABjAAAAUAAAAGkAAABYAAAAagAAAFoAAABxAAAAZAAAAGYAAABTAAAAVwAAAGwAAAByAAAAXAAAAGUAAABmAAAAawAAAHAAAABRAAAAVQAAAF4AAABmAAAAZQAAAFcAAABVAAAAcgAAAHAAAABkAAAAZwAAAFsAAABhAAAAWQAAAHQAAABpAAAAbwAAAGgAAABrAAAAbgAAAHMAAABWAAAAXgAAAGAAAABpAAAAWAAAAGcAAABbAAAAcQAAAGMAAAB0AAAAagAAAF0AAABjAAAAWgAAAHUAAABtAAAAcQAAAGsAAAB/AAAAZQAAAF4AAABzAAAAaAAAAHAAAABsAAAAZAAAAF8AAABcAAAAdgAAAHIAAABtAAAAbQAAAGwAAABdAAAAXwAAAHUAAAB2AAAAagAAAG4AAABiAAAAaAAAAGAAAAB3AAAAbwAAAHMAAABvAAAAYQAAAG4AAABiAAAAdAAAAGcAAAB3AAAAcAAAAGsAAABmAAAAZQAAAHgAAABzAAAAcgAAAHEAAABjAAAAdAAAAGkAAAB1AAAAagAAAHkAAAByAAAAcAAAAGQAAABmAAAAdgAAAHgAAABsAAAAcwAAAG4AAABrAAAAaAAAAHgAAAB3AAAAcAAAAHQAAABnAAAAdwAAAG8AAABxAAAAaQAAAHkAAAB1AAAAfwAAAG0AAAB2AAAAcQAAAHkAAABqAAAAdgAAAHgAAABsAAAAcgAAAHUAAAB5AAAAbQAAAHcAAABvAAAAcwAAAG4AAAB5AAAAdAAAAHgAAAB4AAAAcwAAAHIAAABwAAAAeQAAAHcAAAB2AAAAeQAAAHQAAAB4AAAAdwAAAHUAAABxAAAAdgAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAEAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAQAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAADAAAABQAAAAEAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAgAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAABQAAAAUAAAAAAAAAAAAAAP////8BAAAAAAAAAAMAAAAEAAAAAgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAQAAAP//////////AQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAIAAAAAAAAAAAAAAAEAAAACAAAABgAAAAQAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAoAAAACAAAAAAAAAAAAAAABAAAAAQAAAAUAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAAAAAAAAAAAAAEAAAADAAAABwAAAAYAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAHAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAAAAAAAAAAAAQAAAAAAAAAJAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAAAAAAAAAAAAQAAAAQAAAAIAAAACgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAAAAAAAAAAABAAAACwAAAA8AAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA4AAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAgAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAAAAAAAAAAABAAAADAAAABAAAAAMAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAEAAAAKAAAAEwAAAAgAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAJAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAgAAAAAAAAAAAAAAAQAAAA0AAAARAAAADQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABMAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAAAAAAAAAAAAAEAAAAOAAAAEgAAAA8AAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAAAAAABAAAA//////////8TAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABIAAAAAAAAAGAAAAAAAAAAhAAAAAAAAAB4AAAAAAAAAIAAAAAMAAAAxAAAAAQAAADAAAAADAAAAMgAAAAMAAAAIAAAAAAAAAAUAAAAFAAAACgAAAAUAAAAWAAAAAAAAABAAAAAAAAAAEgAAAAAAAAApAAAAAQAAACEAAAAAAAAAHgAAAAAAAAAEAAAAAAAAAAAAAAAFAAAAAgAAAAUAAAAPAAAAAQAAAAgAAAAAAAAABQAAAAUAAAAfAAAAAQAAABYAAAAAAAAAEAAAAAAAAAACAAAAAAAAAAYAAAAAAAAADgAAAAAAAAAKAAAAAAAAAAsAAAAAAAAAEQAAAAMAAAAYAAAAAQAAABcAAAADAAAAGQAAAAMAAAAAAAAAAAAAAAEAAAAFAAAACQAAAAUAAAAFAAAAAAAAAAIAAAAAAAAABgAAAAAAAAASAAAAAQAAAAoAAAAAAAAACwAAAAAAAAAEAAAAAQAAAAMAAAAFAAAABwAAAAUAAAAIAAAAAQAAAAAAAAAAAAAAAQAAAAUAAAAQAAAAAQAAAAUAAAAAAAAAAgAAAAAAAAAHAAAAAAAAABUAAAAAAAAAJgAAAAAAAAAJAAAAAAAAABMAAAAAAAAAIgAAAAMAAAAOAAAAAQAAABQAAAADAAAAJAAAAAMAAAADAAAAAAAAAA0AAAAFAAAAHQAAAAUAAAABAAAAAAAAAAcAAAAAAAAAFQAAAAAAAAAGAAAAAQAAAAkAAAAAAAAAEwAAAAAAAAAEAAAAAgAAAAwAAAAFAAAAGgAAAAUAAAAAAAAAAQAAAAMAAAAAAAAADQAAAAUAAAACAAAAAQAAAAEAAAAAAAAABwAAAAAAAAAaAAAAAAAAACoAAAAAAAAAOgAAAAAAAAAdAAAAAAAAACsAAAAAAAAAPgAAAAMAAAAmAAAAAQAAAC8AAAADAAAAQAAAAAMAAAAMAAAAAAAAABwAAAAFAAAALAAAAAUAAAANAAAAAAAAABoAAAAAAAAAKgAAAAAAAAAVAAAAAQAAAB0AAAAAAAAAKwAAAAAAAAAEAAAAAwAAAA8AAAAFAAAAHwAAAAUAAAADAAAAAQAAAAwAAAAAAAAAHAAAAAUAAAAHAAAAAQAAAA0AAAAAAAAAGgAAAAAAAAAfAAAAAAAAACkAAAAAAAAAMQAAAAAAAAAsAAAAAAAAADUAAAAAAAAAPQAAAAMAAAA6AAAAAQAAAEEAAAADAAAASwAAAAMAAAAPAAAAAAAAABYAAAAFAAAAIQAAAAUAAAAcAAAAAAAAAB8AAAAAAAAAKQAAAAAAAAAqAAAAAQAAACwAAAAAAAAANQAAAAAAAAAEAAAABAAAAAgAAAAFAAAAEAAAAAUAAAAMAAAAAQAAAA8AAAAAAAAAFgAAAAUAAAAaAAAAAQAAABwAAAAAAAAAHwAAAAAAAAAyAAAAAAAAADAAAAAAAAAAMQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAIQAAAAMAAAAYAAAAAwAAABIAAAADAAAAEAAAAAMAAABGAAAAAAAAAEMAAAAAAAAAQgAAAAMAAAA0AAAAAwAAADIAAAAAAAAAMAAAAAAAAAAlAAAAAwAAACAAAAAAAAAAHgAAAAMAAABTAAAAAAAAAFcAAAADAAAAVQAAAAMAAABKAAAAAwAAAEYAAAAAAAAAQwAAAAAAAAA5AAAAAQAAADQAAAADAAAAMgAAAAAAAAAZAAAAAAAAABcAAAAAAAAAGAAAAAMAAAARAAAAAAAAAAsAAAADAAAACgAAAAMAAAAOAAAAAwAAAAYAAAADAAAAAgAAAAMAAAAtAAAAAAAAACcAAAAAAAAAJQAAAAMAAAAjAAAAAwAAABkAAAAAAAAAFwAAAAAAAAAbAAAAAwAAABEAAAAAAAAACwAAAAMAAAA/AAAAAAAAADsAAAADAAAAOQAAAAMAAAA4AAAAAwAAAC0AAAAAAAAAJwAAAAAAAAAuAAAAAwAAACMAAAADAAAAGQAAAAAAAAAkAAAAAAAAABQAAAAAAAAADgAAAAMAAAAiAAAAAAAAABMAAAADAAAACQAAAAMAAAAmAAAAAwAAABUAAAADAAAABwAAAAMAAAA3AAAAAAAAACgAAAAAAAAAGwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAFAAAAAAAAAAzAAAAAwAAACIAAAAAAAAAEwAAAAMAAABIAAAAAAAAADwAAAADAAAALgAAAAMAAABJAAAAAwAAADcAAAAAAAAAKAAAAAAAAABHAAAAAwAAADYAAAADAAAAJAAAAAAAAABAAAAAAAAAAC8AAAAAAAAAJgAAAAMAAAA+AAAAAAAAACsAAAADAAAAHQAAAAMAAAA6AAAAAwAAACoAAAADAAAAGgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAMwAAAAMAAABSAAAAAwAAAEAAAAAAAAAALwAAAAAAAABMAAAAAwAAAD4AAAAAAAAAKwAAAAMAAABhAAAAAAAAAFkAAAADAAAARwAAAAMAAABiAAAAAwAAAFQAAAAAAAAARQAAAAAAAABgAAAAAwAAAFIAAAADAAAAQAAAAAAAAABLAAAAAAAAAEEAAAAAAAAAOgAAAAMAAAA9AAAAAAAAADUAAAADAAAALAAAAAMAAAAxAAAAAwAAACkAAAADAAAAHwAAAAMAAABeAAAAAAAAAFYAAAAAAAAATAAAAAMAAABRAAAAAwAAAEsAAAAAAAAAQQAAAAAAAABCAAAAAwAAAD0AAAAAAAAANQAAAAMAAABrAAAAAAAAAGgAAAADAAAAYAAAAAMAAABlAAAAAwAAAF4AAAAAAAAAVgAAAAAAAABVAAAAAwAAAFEAAAADAAAASwAAAAAAAAA5AAAAAAAAADsAAAAAAAAAPwAAAAMAAABKAAAAAAAAAE4AAAADAAAATwAAAAMAAABTAAAAAwAAAFwAAAADAAAAXwAAAAMAAAAlAAAAAAAAACcAAAADAAAALQAAAAMAAAA0AAAAAAAAADkAAAAAAAAAOwAAAAAAAABGAAAAAwAAAEoAAAAAAAAATgAAAAMAAAAYAAAAAAAAABcAAAADAAAAGQAAAAMAAAAgAAAAAwAAACUAAAAAAAAAJwAAAAMAAAAyAAAAAwAAADQAAAAAAAAAOQAAAAAAAAAuAAAAAAAAADwAAAAAAAAASAAAAAMAAAA4AAAAAAAAAEQAAAADAAAAUAAAAAMAAAA/AAAAAwAAAE0AAAADAAAAWgAAAAMAAAAbAAAAAAAAACgAAAADAAAANwAAAAMAAAAjAAAAAAAAAC4AAAAAAAAAPAAAAAAAAAAtAAAAAwAAADgAAAAAAAAARAAAAAMAAAAOAAAAAAAAABQAAAADAAAAJAAAAAMAAAARAAAAAwAAABsAAAAAAAAAKAAAAAMAAAAZAAAAAwAAACMAAAAAAAAALgAAAAAAAABHAAAAAAAAAFkAAAAAAAAAYQAAAAMAAABJAAAAAAAAAFsAAAADAAAAZwAAAAMAAABIAAAAAwAAAFgAAAADAAAAaQAAAAMAAAAzAAAAAAAAAEUAAAADAAAAVAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAWQAAAAAAAAA3AAAAAwAAAEkAAAAAAAAAWwAAAAMAAAAmAAAAAAAAAC8AAAADAAAAQAAAAAMAAAAiAAAAAwAAADMAAAAAAAAARQAAAAMAAAAkAAAAAwAAADYAAAAAAAAARwAAAAAAAABgAAAAAAAAAGgAAAAAAAAAawAAAAMAAABiAAAAAAAAAG4AAAADAAAAcwAAAAMAAABhAAAAAwAAAG8AAAADAAAAdwAAAAMAAABMAAAAAAAAAFYAAAADAAAAXgAAAAMAAABSAAAAAAAAAGAAAAAAAAAAaAAAAAAAAABUAAAAAwAAAGIAAAAAAAAAbgAAAAMAAAA6AAAAAAAAAEEAAAADAAAASwAAAAMAAAA+AAAAAwAAAEwAAAAAAAAAVgAAAAMAAABAAAAAAwAAAFIAAAAAAAAAYAAAAAAAAABVAAAAAAAAAFcAAAAAAAAAUwAAAAMAAABlAAAAAAAAAGYAAAADAAAAZAAAAAMAAABrAAAAAwAAAHAAAAADAAAAcgAAAAMAAABCAAAAAAAAAEMAAAADAAAARgAAAAMAAABRAAAAAAAAAFUAAAAAAAAAVwAAAAAAAABeAAAAAwAAAGUAAAAAAAAAZgAAAAMAAAAxAAAAAAAAADAAAAADAAAAMgAAAAMAAAA9AAAAAwAAAEIAAAAAAAAAQwAAAAMAAABLAAAAAwAAAFEAAAAAAAAAVQAAAAAAAABfAAAAAAAAAFwAAAAAAAAAUwAAAAAAAABPAAAAAAAAAE4AAAAAAAAASgAAAAMAAAA/AAAAAQAAADsAAAADAAAAOQAAAAMAAABtAAAAAAAAAGwAAAAAAAAAZAAAAAUAAABdAAAAAQAAAF8AAAAAAAAAXAAAAAAAAABNAAAAAQAAAE8AAAAAAAAATgAAAAAAAAB1AAAABAAAAHYAAAAFAAAAcgAAAAUAAABqAAAAAQAAAG0AAAAAAAAAbAAAAAAAAABaAAAAAQAAAF0AAAABAAAAXwAAAAAAAABaAAAAAAAAAE0AAAAAAAAAPwAAAAAAAABQAAAAAAAAAEQAAAAAAAAAOAAAAAMAAABIAAAAAQAAADwAAAADAAAALgAAAAMAAABqAAAAAAAAAF0AAAAAAAAATwAAAAUAAABjAAAAAQAAAFoAAAAAAAAATQAAAAAAAABYAAAAAQAAAFAAAAAAAAAARAAAAAAAAAB1AAAAAwAAAG0AAAAFAAAAXwAAAAUAAABxAAAAAQAAAGoAAAAAAAAAXQAAAAAAAABpAAAAAQAAAGMAAAABAAAAWgAAAAAAAABpAAAAAAAAAFgAAAAAAAAASAAAAAAAAABnAAAAAAAAAFsAAAAAAAAASQAAAAMAAABhAAAAAQAAAFkAAAADAAAARwAAAAMAAABxAAAAAAAAAGMAAAAAAAAAUAAAAAUAAAB0AAAAAQAAAGkAAAAAAAAAWAAAAAAAAABvAAAAAQAAAGcAAAAAAAAAWwAAAAAAAAB1AAAAAgAAAGoAAAAFAAAAWgAAAAUAAAB5AAAAAQAAAHEAAAAAAAAAYwAAAAAAAAB3AAAAAQAAAHQAAAABAAAAaQAAAAAAAAB3AAAAAAAAAG8AAAAAAAAAYQAAAAAAAABzAAAAAAAAAG4AAAAAAAAAYgAAAAMAAABrAAAAAQAAAGgAAAADAAAAYAAAAAMAAAB5AAAAAAAAAHQAAAAAAAAAZwAAAAUAAAB4AAAAAQAAAHcAAAAAAAAAbwAAAAAAAABwAAAAAQAAAHMAAAAAAAAAbgAAAAAAAAB1AAAAAQAAAHEAAAAFAAAAaQAAAAUAAAB2AAAAAQAAAHkAAAAAAAAAdAAAAAAAAAByAAAAAQAAAHgAAAABAAAAdwAAAAAAAAByAAAAAAAAAHAAAAAAAAAAawAAAAAAAABkAAAAAAAAAGYAAAAAAAAAZQAAAAMAAABTAAAAAQAAAFcAAAADAAAAVQAAAAMAAAB2AAAAAAAAAHgAAAAAAAAAcwAAAAUAAABsAAAAAQAAAHIAAAAAAAAAcAAAAAAAAABcAAAAAQAAAGQAAAAAAAAAZgAAAAAAAAB1AAAAAAAAAHkAAAAFAAAAdwAAAAUAAABtAAAAAQAAAHYAAAAAAAAAeAAAAAAAAABfAAAAAQAAAGwAAAABAAAAcgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAB+ogX28rbpPxqumpJv+fM/165tC4ns9D+XaEnTqUsEQFrOtNlC4PA/3U+0XG6P9b9TdUUBxTTjP4PUp8ex1ty/B1rD/EN43z+lcDi6LLrZP/a45NWEHMY/oJ5ijLDZ+j/xw3rjxWPjP2B8A46ioQdAotff3wla2z+FMSpA1jj+v6b5Y1mtPbS/cIu8K0F457/2esiyJpDNv98k5Ts2NeA/pvljWa09tD88ClUJ60MDQPZ6yLImkM0/4ONKxa0UBcD2uOTVhBzGv5G7JRxGave/8cN648Vj47+HCwtkjAXIv6LX398JWtu/qyheaCAL9D9TdUUBxTTjv4gyTxslhwVAB1rD/EN4378EH/28teoFwH6iBfbytum/F6ztFYdK/r/Xrm0Liez0vwcS6wNGWeO/Ws602ULg8L9TCtRLiLT8P8pi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAMuhRbbsNlBBYqHW9OmHIkF9XBuqnS31QAK37uYhNMhAOSo3UUupm0DC+6pc6JxvQHV9eseEEEJAzURsCyqlFEB8BQ4NMJjnPyy3tBoS97o/xawXQznRjj89J2K2CZxhP6vX43RIIDQ/S8isgygEBz+LvFHQkmzaPjFFFO7wMq4+AADMLkTtjkIAAOgkJqxhQgAAU7B0MjRCAADwpBcVB0IAAACYP2HaQQAAAIn/Ja5BzczM4Eg6gUHNzMxMU7BTQTMzMzNfgCZBAAAAAEi3+UAAAAAAwGPNQDMzMzMzy6BAmpmZmZkxc0AzMzMzM/NFQDMzMzMzMxlAzczMzMzM7D+ygXSx2U6RQKimJOvQKnpA23hmONTHY0A/AGcxyudNQNb3K647mzZA+S56rrwWIUAm4kUQ+9UJQKre9hGzh/M/BLvoy9WG3T+LmqMf8VHGP2m3nYNV37A/gbFHcyeCmT+cBPWBckiDP61tZACjKW0/q2RbYVUYVj8uDypVyLNAP6jGS5cA5zBBwcqhBdCNGUEGEhQ/JVEDQT6WPnRbNO1AB/AWSJgT1kDfUWNCNLDAQNk+5C33OqlAchWL34QSk0DKvtDIrNV8QNF0G3kFzGVASSeWhBl6UED+/0mNGuk4QGjA/dm/1CJALPLPMql6DEDSHoDrwpP1P2jouzWST+A/egAAAAAAAABKAwAAAAAAAPoWAAAAAAAAyqAAAAAAAAB6ZQQAAAAAAErGHgAAAAAA+mvXAAAAAADK8+MFAAAAAHqqOykAAAAASqmhIAEAAAD6oGvkBwAAAMpm8T43AAAAes+ZuIIBAABKrDQMkwoAAPq1cFUFSgAAyvkUViUGAgAAAAAAAwAAAAYAAAACAAAABQAAAAEAAAAEAAAAAAAAAAAAAAAFAAAAAwAAAAEAAAAGAAAABAAAAAIAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAA/////wAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAP////8AAAAAAAAAAAEAAAABAAAAAAAAAAAAAAD/////AAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAAAAAAABAAEAAAEBAAAAAAABAAAAAQAAAAEAAQAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAAYWxnb3MuYwBfcG9seWZpbGxJbnRlcm5hbABhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0dlb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9HZW9Cb3VuZGFyeQBwb2x5Z29uLT5uZXh0ID09IE5VTEwAbGlua2VkR2VvLmMAYWRkTmV3TGlua2VkUG9seWdvbgBuZXh0ICE9IE5VTEwAbG9vcCAhPSBOVUxMAGFkZE5ld0xpbmtlZExvb3AAcG9seWdvbi0+Zmlyc3QgPT0gTlVMTABhZGRMaW5rZWRMb29wAGNvb3JkICE9IE5VTEwAYWRkTGlua2VkQ29vcmQAbG9vcC0+Zmlyc3QgPT0gTlVMTABpbm5lckxvb3BzICE9IE5VTEwAbm9ybWFsaXplTXVsdGlQb2x5Z29uAGJib3hlcyAhPSBOVUxMAGNhbmRpZGF0ZXMgIT0gTlVMTABmaW5kUG9seWdvbkZvckhvbGUAY2FuZGlkYXRlQkJveGVzICE9IE5VTEwAcmV2RGlyICE9IElOVkFMSURfRElHSVQAbG9jYWxpai5jAGgzVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAcGVudGFnb25Sb3RhdGlvbnMgPj0gMABkaXJlY3Rpb25Sb3RhdGlvbnMgPj0gMABiYXNlQ2VsbCA9PSBvcmlnaW5CYXNlQ2VsbABiYXNlQ2VsbCAhPSBJTlZBTElEX0JBU0VfQ0VMTABsb2NhbElqa1RvSDMAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAd2l0aGluUGVudGFnb25Sb3RhdGlvbnMgPj0gMABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";function Y(A){return A}function O(A){return A.replace(/\b__Z[\w\d_]+/g,(function(A){return A===A?A:A+" ["+A+"]"}))}function j(){var A=new Error;if(!A.stack){try{throw new Error(0)}catch(e){A=e}if(!A.stack)return"(no stack trace available)"}return A.stack.toString()}function N(){return p.length}function Z(A){try{var e=new ArrayBuffer(A);if(e.byteLength!=A)return;return new Int8Array(e).set(p),$(e),Q(e),1}catch(A){}}var W="function"==typeof atob?atob:function(A){var e,r,t,i,n,o,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="",s=0;A=A.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{e=a.indexOf(A.charAt(s++))<<2|(i=a.indexOf(A.charAt(s++)))>>4,r=(15&i)<<4|(n=a.indexOf(A.charAt(s++)))>>2,t=(3&n)<<6|(o=a.indexOf(A.charAt(s++))),f+=String.fromCharCode(e),64!==n&&(f+=String.fromCharCode(r)),64!==o&&(f+=String.fromCharCode(t))}while(s>2]=A,i[a+4>>2]=e,(a=0!=(0|n))&&(i[n>>2]=0),0|UA(A,e))return I=o,0|(d=1);i[d>>2]=0;A:do{if((0|r)>=1)if(a)for(l=0,h=1,c=1,f=0,a=A;;){if(!(f|l)){if(0==(0|(a=0|U(a,e,4,d)))&0==(0|(e=0|M()))){a=2;break A}if(0|UA(a,e)){a=1;break A}}if(0==(0|(a=0|U(a,e,0|i[16+(l<<2)>>2],d)))&0==(0|(e=0|M()))){a=2;break A}if(i[(A=t+(c<<3)|0)>>2]=a,i[A+4>>2]=e,i[n+(c<<2)>>2]=h,A=(0|(f=f+1|0))==(0|h),u=6==(0|(s=l+1|0)),0|UA(a,e)){a=1;break A}if((0|(h=h+(u&A&1)|0))>(0|r)){a=0;break}l=A?u?0:s:l,c=c+1|0,f=A?0:f}else for(l=0,h=1,c=1,f=0,a=A;;){if(!(f|l)){if(0==(0|(a=0|U(a,e,4,d)))&0==(0|(e=0|M()))){a=2;break A}if(0|UA(a,e)){a=1;break A}}if(0==(0|(a=0|U(a,e,0|i[16+(l<<2)>>2],d)))&0==(0|(e=0|M()))){a=2;break A}if(i[(A=t+(c<<3)|0)>>2]=a,i[A+4>>2]=e,A=(0|(f=f+1|0))==(0|h),u=6==(0|(s=l+1|0)),0|UA(a,e)){a=1;break A}if((0|(h=h+(u&A&1)|0))>(0|r)){a=0;break}l=A?u?0:s:l,c=c+1|0,f=A?0:f}else a=0}while(0);return I=o,0|(d=a)}function P(A,e,r,t,n,o,a){r|=0,t|=0,n|=0,o|=0,a|=0;var f,s,u=0,l=0,h=0,c=0,d=0;if(s=I,I=I+16|0,f=s,0==(0|(A|=0))&0==(0|(e|=0)))I=s;else{if(u=0|Me(0|A,0|e,0|o,((0|o)<0)<<31>>31|0),M(),!(0==(0|(d=0|i[(c=l=t+(u<<3)|0)>>2]))&0==(0|(c=0|i[c+4>>2]))|(h=(0|d)==(0|A)&(0|c)==(0|e))))do{h=(0|(c=0|i[(d=l=t+((u=(u+1|0)%(0|o)|0)<<3)|0)>>2]))==(0|A)&(0|(d=0|i[d+4>>2]))==(0|e)}while(!(0==(0|c)&0==(0|d)|h));u=n+(u<<2)|0,h&&(0|i[u>>2])<=(0|a)||(i[(d=l)>>2]=A,i[d+4>>2]=e,i[u>>2]=a,(0|a)>=(0|r)||(d=a+1|0,i[f>>2]=0,P(c=0|U(A,e,2,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,3,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,1,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,5,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,4,f),0|M(),r,t,n,o,d),i[f>>2]=0,P(c=0|U(A,e,6,f),0|M(),r,t,n,o,d))),I=s}}function U(A,e,r,t){A|=0,e|=0,r|=0;var n,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0;if((0|i[(t|=0)>>2])>0){a=0;do{r=0|fA(r),a=a+1|0}while((0|a)<(0|i[t>>2]))}n=0|Qe(0|A,0|e,45),M(),o=127&n,f=0|GA(A,e),a=0|Qe(0|A,0|e,52),M(),a&=15;A:do{if(a)for(;;){if(h=0|Qe(0|A,0|e,0|(l=3*(15-a|0)|0)),M(),h&=7,c=0==(0|RA(a)),a=a+-1|0,u=0|ye(7,0,0|l),e&=~(0|M()),A=(l=0|ye(0|i[(c?464:48)+(28*h|0)+(r<<2)>>2],0,0|l))|A&~u,e|=0|M(),!(r=0|i[(c?672:256)+(28*h|0)+(r<<2)>>2])){r=0;break A}if(!a){s=6;break}}else s=6}while(0);6==(0|s)&&(A|=h=0|ye(0|(c=0|i[880+(28*o|0)+(r<<2)>>2]),0,45),e=0|M()|-1040385&e,r=0|i[4304+(28*o|0)+(r<<2)>>2],127==(127&c|0)&&(c=0|ye(0|i[880+(28*o|0)+20>>2],0,45),e=0|M()|-1040385&e,r=0|i[4304+(28*o|0)+20>>2],A=0|TA(c|A,e),e=0|M(),i[t>>2]=1+(0|i[t>>2]))),s=0|Qe(0|A,0|e,45),M(),s&=127;A:do{if(0|S(s)){e:do{if(1==(0|GA(A,e))){if((0|o)!=(0|s)){if(0|R(s,0|i[7728+(28*o|0)>>2])){A=0|HA(A,e),f=1,e=0|M();break}A=0|TA(A,e),f=1,e=0|M();break}switch(0|f){case 5:A=0|HA(A,e),e=0|M(),i[t>>2]=5+(0|i[t>>2]),f=0;break e;case 3:A=0|TA(A,e),e=0|M(),i[t>>2]=1+(0|i[t>>2]),f=0;break e;default:return c=0,k(0|(h=0)),0|c}}else f=0}while(0);if((0|r)>0){a=0;do{A=0|SA(A,e),e=0|M(),a=a+1|0}while((0|a)!=(0|r))}if((0|o)!=(0|s)){if(!(0|T(s))){if(0!=(0|f)|5!=(0|GA(A,e)))break;i[t>>2]=1+(0|i[t>>2]);break}switch(127&n){case 8:case 118:break A}3!=(0|GA(A,e))&&(i[t>>2]=1+(0|i[t>>2]))}}else if((0|r)>0){a=0;do{A=0|TA(A,e),e=0|M(),a=a+1|0}while((0|a)!=(0|r))}}while(0);return i[t>>2]=((0|i[t>>2])+r|0)%6|0,c=A,k(0|(h=e)),0|c}function G(A,e,r,t,o,a){e|=0,r|=0,t|=0,o|=0,a|=0;var f,s,u,l,h,c,d,g,w,p=0,B=0,b=0,v=0,m=0,k=0,Q=0,y=0,E=0,x=0,D=0,_=0,F=0,C=0;if(w=I,I=I+48|0,c=w+32|0,d=w+16|0,g=w,(0|(p=0|i[(A|=0)>>2]))<=0)return I=w,0|(_=0);f=A+4|0,s=c+8|0,u=d+8|0,l=g+8|0,h=((0|e)<0)<<31>>31,D=0;A:for(;;){E=(B=0|i[f>>2])+(D<<4)|0,i[c>>2]=i[E>>2],i[c+4>>2]=i[E+4>>2],i[c+8>>2]=i[E+8>>2],i[c+12>>2]=i[E+12>>2],(0|D)==(p+-1|0)?(i[d>>2]=i[B>>2],i[d+4>>2]=i[B+4>>2],i[d+8>>2]=i[B+8>>2],i[d+12>>2]=i[B+12>>2]):(E=B+(D+1<<4)|0,i[d>>2]=i[E>>2],i[d+4>>2]=i[E+4>>2],i[d+8>>2]=i[E+8>>2],i[d+12>>2]=i[E+12>>2]),E=0|N(c,d,r);e:do{if((0|E)>0){x=+(0|E),y=0;r:for(;;){C=+(E-y|0),F=+(0|y),n[g>>3]=+n[c>>3]*C/x+ +n[d>>3]*F/x,n[l>>3]=+n[s>>3]*C/x+ +n[u>>3]*F/x,B=0|Me(0|(k=0|LA(g,r)),0|(Q=0|M()),0|e,0|h),M(),v=0|i[(b=p=a+(B<<3)|0)>>2],b=0|i[b+4>>2];t:do{if(0==(0|v)&0==(0|b))_=14;else for(m=0;;){if((0|m)>(0|e)){p=1;break t}if((0|v)==(0|k)&(0|b)==(0|Q)){p=7;break t}if(0==(0|(v=0|i[(b=p=a+((B=(B+1|0)%(0|e)|0)<<3)|0)>>2]))&0==(0|(b=0|i[b+4>>2]))){_=14;break}m=m+1|0}}while(0);switch(14==(0|_)&&(_=0,0==(0|k)&0==(0|Q)?p=7:(i[p>>2]=k,i[p+4>>2]=Q,p=0|i[t>>2],i[(m=o+(p<<3)|0)>>2]=k,i[m+4>>2]=Q,i[t>>2]=p+1,p=0)),7&p){case 7:case 0:break;default:break r}if((0|E)<=(0|(y=y+1|0))){_=8;break e}}if(0|p){p=-1,_=20;break A}}else _=8}while(0);if(8==(0|_)&&(_=0),(0|(D=D+1|0))>=(0|(p=0|i[A>>2]))){p=0,_=20;break}}return 20==(0|_)?(I=w,0|p):0}function S(A){return 0|i[7728+(28*(A|=0)|0)+16>>2]}function T(A){return 4==(0|(A|=0))|117==(0|A)|0}function V(A){return 0|i[11152+(216*(0|i[(A|=0)>>2])|0)+(72*(0|i[A+4>>2])|0)+(24*(0|i[A+8>>2])|0)+(i[A+12>>2]<<3)>>2]}function H(A){return 0|i[11152+(216*(0|i[(A|=0)>>2])|0)+(72*(0|i[A+4>>2])|0)+(24*(0|i[A+8>>2])|0)+(i[A+12>>2]<<3)+4>>2]}function R(A,e){return e|=0,(0|i[7728+(28*(A|=0)|0)+20>>2])==(0|e)?0|(e=1):0|(e=(0|i[7728+(28*A|0)+24>>2])==(0|e))}function L(A,e){return 0|i[880+(28*(A|=0)|0)+((e|=0)<<2)>>2]}function z(A,e){return e|=0,(0|i[880+(28*(A|=0)|0)>>2])==(0|e)?0|(e=0):(0|i[880+(28*A|0)+4>>2])==(0|e)?0|(e=1):(0|i[880+(28*A|0)+8>>2])==(0|e)?0|(e=2):(0|i[880+(28*A|0)+12>>2])==(0|e)?0|(e=3):(0|i[880+(28*A|0)+16>>2])==(0|e)?0|(e=4):(0|i[880+(28*A|0)+20>>2])==(0|e)?0|(e=5):0|((0|i[880+(28*A|0)+24>>2])==(0|e)?6:7)}function Y(A){return+n[(A|=0)+16>>3]<+n[A+24>>3]|0}function O(A,e){A|=0;var r,t,i=0;return(i=+n[(e|=0)>>3])>=+n[A+8>>3]&&i<=+n[A>>3]?(r=+n[A+16>>3],i=+n[A+24>>3],e=(t=+n[e+8>>3])>=i,A=t<=r&1,r>2]=0,l=l+4|0}while((0|l)<(0|h));return NA(e,o),OA(h=0|i[(l=o)>>2],l=0|i[l+4>>2],r),jA(h,l,t),s=+DA(r,t+8|0),n[r>>3]=+n[A>>3],n[(l=r+8|0)>>3]=+n[A+16>>3],n[t>>3]=+n[A+8>>3],n[(h=t+8|0)>>3]=+n[A+24>>3],u=+DA(r,t),h=~~+B(+u*u/+Ee(+ +f(+(+n[l>>3]-+n[h>>3])/(+n[r>>3]-+n[t>>3])),3)/(s*(2.59807621135*s)*.8)),I=a,0|(0==(0|h)?1:h)}function N(A,e,r){A|=0,e|=0,r|=0;var t,n,o,a,f,s=0,u=0;a=I,I=I+288|0,t=a+264|0,n=a+96|0,u=(s=o=a)+96|0;do{i[s>>2]=0,s=s+4|0}while((0|s)<(0|u));return NA(r,o),OA(s=0|i[(u=o)>>2],u=0|i[u+4>>2],t),jA(s,u,n),f=+DA(t,n+8|0),u=~~+B(+ +DA(A,e)/(2*f)),I=a,0|(0==(0|u)?1:u)}function Z(A,e,r,t){e|=0,r|=0,t|=0,i[(A|=0)>>2]=e,i[A+4>>2]=r,i[A+8>>2]=t}function W(A,e){A|=0;var r,t,o,a,s=0,u=0,l=0,h=0,c=0,d=0,g=0;i[(a=(e|=0)+8|0)>>2]=0,t=+n[A>>3],h=+f(+t),o=+n[A+8>>3],h+=.5*(c=+f(+o)/.8660254037844386),h-=+(0|(s=~~h)),c-=+(0|(A=~~c));do{if(h<.5){if(h<.3333333333333333){if(i[e>>2]=s,c<.5*(h+1)){i[e+4>>2]=A;break}A=A+1|0,i[e+4>>2]=A;break}if(A=(1&!(c<(g=1-h)))+A|0,i[e+4>>2]=A,g<=c&c<2*h){s=s+1|0,i[e>>2]=s;break}i[e>>2]=s;break}if(!(h<.6666666666666666)){if(s=s+1|0,i[e>>2]=s,c<.5*h){i[e+4>>2]=A;break}A=A+1|0,i[e+4>>2]=A;break}if(c<1-h){if(i[e+4>>2]=A,2*h-1>2]=s;break}}else A=A+1|0,i[e+4>>2]=A;s=s+1|0,i[e>>2]=s}while(0);do{if(t<0){if(1&A){s=~~(+(0|s)-(2*(+((d=0|ve(0|s,((0|s)<0)<<31>>31|0,0|(d=(A+1|0)/2|0),((0|d)<0)<<31>>31|0))>>>0)+4294967296*+(0|M()))+1)),i[e>>2]=s;break}s=~~(+(0|s)-2*(+((d=0|ve(0|s,((0|s)<0)<<31>>31|0,0|(d=(0|A)/2|0),((0|d)<0)<<31>>31|0))>>>0)+4294967296*+(0|M()))),i[e>>2]=s;break}}while(0);d=e+4|0,o<0&&(s=s-((1|A<<1)/2|0)|0,i[e>>2]=s,A=0-A|0,i[d>>2]=A),u=A-s|0,(0|s)<0?(l=0-s|0,i[d>>2]=u,i[a>>2]=l,i[e>>2]=0,A=u,s=0):l=0,(0|A)<0&&(s=s-A|0,i[e>>2]=s,l=l-A|0,i[a>>2]=l,i[d>>2]=0,A=0),r=s-l|0,u=A-l|0,(0|l)<0&&(i[e>>2]=r,i[d>>2]=u,i[a>>2]=0,A=u,s=r,l=0),(0|(u=(0|l)<(0|(u=(0|A)<(0|s)?A:s))?l:u))<=0||(i[e>>2]=s-u,i[d>>2]=A-u,i[a>>2]=l-u)}function J(A){var e,r=0,t=0,n=0,o=0,a=0;r=0|i[(A|=0)>>2],t=0|i[(e=A+4|0)>>2],(0|r)<0&&(t=t-r|0,i[e>>2]=t,i[(a=A+8|0)>>2]=(0|i[a>>2])-r,i[A>>2]=0,r=0),(0|t)<0?(r=r-t|0,i[A>>2]=r,o=(0|i[(a=A+8|0)>>2])-t|0,i[a>>2]=o,i[e>>2]=0,t=0):(a=o=A+8|0,o=0|i[o>>2]),(0|o)<0&&(r=r-o|0,i[A>>2]=r,t=t-o|0,i[e>>2]=t,i[a>>2]=0,o=0),(0|(n=(0|o)<(0|(n=(0|t)<(0|r)?t:r))?o:n))<=0||(i[A>>2]=r-n,i[e>>2]=t-n,i[a>>2]=o-n)}function K(A,e){e|=0;var r,t;t=0|i[(A|=0)+8>>2],r=+((0|i[A+4>>2])-t|0),n[e>>3]=+((0|i[A>>2])-t|0)-.5*r,n[e+8>>3]=.8660254037844386*r}function X(A,e,r){A|=0,e|=0,i[(r|=0)>>2]=(0|i[e>>2])+(0|i[A>>2]),i[r+4>>2]=(0|i[e+4>>2])+(0|i[A+4>>2]),i[r+8>>2]=(0|i[e+8>>2])+(0|i[A+8>>2])}function q(A,e,r){A|=0,e|=0,i[(r|=0)>>2]=(0|i[A>>2])-(0|i[e>>2]),i[r+4>>2]=(0|i[A+4>>2])-(0|i[e+4>>2]),i[r+8>>2]=(0|i[A+8>>2])-(0|i[e+8>>2])}function $(A,e){e|=0;var r,t=0;t=0|b(0|i[(A|=0)>>2],e),i[A>>2]=t,r=0|b(0|i[(t=A+4|0)>>2],e),i[t>>2]=r,e=0|b(0|i[(A=A+8|0)>>2],e),i[A>>2]=e}function AA(A){var e,r,t=0,n=0,o=0,a=0,f=0;f=(0|(r=0|i[(A|=0)>>2]))<0,A=(A=(n=(0|(a=((e=(0|(o=(0|i[A+4>>2])-(f?r:0)|0))<0)?0-o|0:0)+((0|i[A+8>>2])-(f?r:0))|0))<0)?0:a)-((o=(0|(n=(0|A)<(0|(n=(0|(t=(e?0:o)-(n?a:0)|0))<(0|(a=(f?0:r)-(e?o:0)-(n?a:0)|0))?t:a))?A:n))>0)?n:0)|0,t=t-(o?n:0)|0;A:do{switch(a-(o?n:0)|0){case 0:switch(0|t){case 0:return 0|(f=0==(0|A)?0:1==(0|A)?1:7);case 1:return 0|(f=0==(0|A)?2:1==(0|A)?3:7);default:break A}case 1:switch(0|t){case 0:return 0|(f=0==(0|A)?4:1==(0|A)?5:7);case 1:if(A)break A;return 0|(A=6);default:break A}}}while(0);return 0|(f=7)}function eA(A){var e,r,t=0,n=0,o=0,a=0,f=0;n=0|i[(e=(A|=0)+8|0)>>2],o=0|we(+((3*(t=(0|i[A>>2])-n|0)|0)-(n=(0|i[(r=A+4|0)>>2])-n|0)|0)/7),i[A>>2]=o,t=0|we(+((n<<1)+t|0)/7),i[r>>2]=t,i[e>>2]=0,n=t-o|0,(0|o)<0?(f=0-o|0,i[r>>2]=n,i[e>>2]=f,i[A>>2]=0,t=n,o=0,n=f):n=0,(0|t)<0&&(o=o-t|0,i[A>>2]=o,n=n-t|0,i[e>>2]=n,i[r>>2]=0,t=0),f=o-n|0,a=t-n|0,(0|n)<0?(i[A>>2]=f,i[r>>2]=a,i[e>>2]=0,t=a,a=f,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|t)<(0|a)?t:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=t-o,i[e>>2]=n-o)}function rA(A){var e,r,t=0,n=0,o=0,a=0,f=0;n=0|i[(e=(A|=0)+8|0)>>2],o=0|we(+(((t=(0|i[A>>2])-n|0)<<1)+(n=(0|i[(r=A+4|0)>>2])-n|0)|0)/7),i[A>>2]=o,t=0|we(+((3*n|0)-t|0)/7),i[r>>2]=t,i[e>>2]=0,n=t-o|0,(0|o)<0?(f=0-o|0,i[r>>2]=n,i[e>>2]=f,i[A>>2]=0,t=n,o=0,n=f):n=0,(0|t)<0&&(o=o-t|0,i[A>>2]=o,n=n-t|0,i[e>>2]=n,i[r>>2]=0,t=0),f=o-n|0,a=t-n|0,(0|n)<0?(i[A>>2]=f,i[r>>2]=a,i[e>>2]=0,t=a,a=f,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|t)<(0|a)?t:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=t-o,i[e>>2]=n-o)}function tA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],o=0|i[(r=A+4|0)>>2],a=0|i[(t=A+8|0)>>2],f=o+(3*n|0)|0,i[A>>2]=f,o=a+(3*o|0)|0,i[r>>2]=o,n=(3*a|0)+n|0,i[t>>2]=n,a=o-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=a,i[t>>2]=n,i[A>>2]=0,o=a,a=0):a=f,(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function iA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=(3*(n=0|i[(r=A+4|0)>>2])|0)+f|0,f=(o=0|i[(t=A+8|0)>>2])+(3*f|0)|0,i[A>>2]=f,i[r>>2]=a,n=(3*o|0)+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,f=0):o=a,(0|o)<0&&(f=f-o|0,i[A>>2]=f,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=f-n|0,a=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=a,i[t>>2]=0,f=e,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|a)<(0|f)?a:f))?n:o))<=0||(i[A>>2]=f-o,i[r>>2]=a-o,i[t>>2]=n-o)}function nA(A,e){A|=0;var r,t,n,o=0,a=0,f=0;((e|=0)+-1|0)>>>0>=6||(f=(0|i[15472+(12*e|0)>>2])+(0|i[A>>2])|0,i[A>>2]=f,n=A+4|0,a=(0|i[15472+(12*e|0)+4>>2])+(0|i[n>>2])|0,i[n>>2]=a,t=A+8|0,e=(0|i[15472+(12*e|0)+8>>2])+(0|i[t>>2])|0,i[t>>2]=e,o=a-f|0,(0|f)<0?(e=e-f|0,i[n>>2]=o,i[t>>2]=e,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,e=e-o|0,i[t>>2]=e,i[n>>2]=0,o=0),r=a-e|0,f=o-e|0,(0|e)<0?(i[A>>2]=r,i[n>>2]=f,i[t>>2]=0,a=r,e=0):f=o,(0|(o=(0|e)<(0|(o=(0|f)<(0|a)?f:a))?e:o))<=0||(i[A>>2]=a-o,i[n>>2]=f-o,i[t>>2]=e-o))}function oA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=(n=0|i[(r=A+4|0)>>2])+f|0,f=(o=0|i[(t=A+8|0)>>2])+f|0,i[A>>2]=f,i[r>>2]=a,n=o+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function aA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],a=0|i[(r=A+4|0)>>2],o=0|i[(t=A+8|0)>>2],f=a+n|0,i[A>>2]=f,a=o+a|0,i[r>>2]=a,n=o+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,a=0):(o=a,a=f),(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function fA(A){switch(0|(A|=0)){case 1:A=5;break;case 5:A=4;break;case 4:A=6;break;case 6:A=2;break;case 2:A=3;break;case 3:A=1}return 0|A}function sA(A){switch(0|(A|=0)){case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5;break;case 5:A=1}return 0|A}function uA(A){var e,r,t,n=0,o=0,a=0,f=0;n=0|i[(A|=0)>>2],o=0|i[(r=A+4|0)>>2],a=0|i[(t=A+8|0)>>2],f=o+(n<<1)|0,i[A>>2]=f,o=a+(o<<1)|0,i[r>>2]=o,n=(a<<1)+n|0,i[t>>2]=n,a=o-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=a,i[t>>2]=n,i[A>>2]=0,o=a,a=0):a=f,(0|o)<0&&(a=a-o|0,i[A>>2]=a,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=a-n|0,f=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=f,i[t>>2]=0,a=e,n=0):f=o,(0|(o=(0|n)<(0|(o=(0|f)<(0|a)?f:a))?n:o))<=0||(i[A>>2]=a-o,i[r>>2]=f-o,i[t>>2]=n-o)}function lA(A){var e,r,t,n=0,o=0,a=0,f=0;f=0|i[(A|=0)>>2],a=((n=0|i[(r=A+4|0)>>2])<<1)+f|0,f=(o=0|i[(t=A+8|0)>>2])+(f<<1)|0,i[A>>2]=f,i[r>>2]=a,n=(o<<1)+n|0,i[t>>2]=n,o=a-f|0,(0|f)<0?(n=n-f|0,i[r>>2]=o,i[t>>2]=n,i[A>>2]=0,f=0):o=a,(0|o)<0&&(f=f-o|0,i[A>>2]=f,n=n-o|0,i[t>>2]=n,i[r>>2]=0,o=0),e=f-n|0,a=o-n|0,(0|n)<0?(i[A>>2]=e,i[r>>2]=a,i[t>>2]=0,f=e,n=0):a=o,(0|(o=(0|n)<(0|(o=(0|a)<(0|f)?a:f))?n:o))<=0||(i[A>>2]=f-o,i[r>>2]=a-o,i[t>>2]=n-o)}function hA(A,e){e|=0;var r,t,n,o=0,a=0,f=0;return n=(0|(t=(0|i[(A|=0)>>2])-(0|i[e>>2])|0))<0,r=(0|(a=(0|i[A+4>>2])-(0|i[e+4>>2])-(n?t:0)|0))<0,e=(e=(A=(0|(f=(n?0-t|0:0)+(0|i[A+8>>2])-(0|i[e+8>>2])+(r?0-a|0:0)|0))<0)?0:f)-((a=(0|(A=(0|e)<(0|(A=(0|(o=(r?0:a)-(A?f:0)|0))<(0|(f=(n?0:t)-(r?a:0)-(A?f:0)|0))?o:f))?e:A))>0)?A:0)|0,o=o-(a?A:0)|0,0|((0|(A=(0|(A=f-(a?A:0)|0))>-1?A:0-A|0))>(0|(e=(0|(o=(0|o)>-1?o:0-o|0))>(0|(e=(0|e)>-1?e:0-e|0))?o:e))?A:e)}function cA(A,e){e|=0;var r;r=0|i[(A|=0)+8>>2],i[e>>2]=(0|i[A>>2])-r,i[e+4>>2]=(0|i[A+4>>2])-r}function dA(A,e){e|=0;var r,t,n,o=0,a=0,f=0;a=0|i[(A|=0)>>2],i[e>>2]=a,A=0|i[A+4>>2],i[(t=e+4|0)>>2]=A,i[(n=e+8|0)>>2]=0,o=A-a|0,(0|a)<0?(A=0-a|0,i[t>>2]=o,i[n>>2]=A,i[e>>2]=0,a=0):(o=A,A=0),(0|o)<0&&(a=a-o|0,i[e>>2]=a,A=A-o|0,i[n>>2]=A,i[t>>2]=0,o=0),r=a-A|0,f=o-A|0,(0|A)<0?(i[e>>2]=r,i[t>>2]=f,i[n>>2]=0,o=f,f=r,A=0):f=a,(0|(a=(0|A)<(0|(a=(0|o)<(0|f)?o:f))?A:a))<=0||(i[e>>2]=f-a,i[t>>2]=o-a,i[n>>2]=A-a)}function gA(A){var e,r,t,n;r=(n=0|i[(e=(A|=0)+8|0)>>2])-(0|i[A>>2])|0,i[A>>2]=r,A=(0|i[(t=A+4|0)>>2])-n|0,i[t>>2]=A,i[e>>2]=0-(A+r)}function wA(A){var e,r,t=0,n=0,o=0,a=0,f=0;t=0-(n=0|i[(A|=0)>>2])|0,i[A>>2]=t,i[(e=A+8|0)>>2]=0,a=(o=0|i[(r=A+4|0)>>2])+n|0,(0|n)>0?(i[r>>2]=a,i[e>>2]=n,i[A>>2]=0,t=0,o=a):n=0,(0|o)<0?(f=t-o|0,i[A>>2]=f,n=n-o|0,i[e>>2]=n,i[r>>2]=0,a=f-n|0,t=0-n|0,(0|n)<0?(i[A>>2]=a,i[r>>2]=t,i[e>>2]=0,o=t,n=0):(o=0,a=f)):a=t,(0|(t=(0|n)<(0|(t=(0|o)<(0|a)?o:a))?n:t))<=0||(i[A>>2]=a-t,i[r>>2]=o-t,i[e>>2]=n-t)}function pA(A,e,r,t){e|=0,r|=0,t|=0;var o,a=0,f=0,s=0,u=0;if(o=I,I=I+32|0,function(A,e){e|=0;var r=0,t=0,i=0;r=+n[(A=A|0)>>3],t=+l(+r),r=+h(+r),n[e+16>>3]=r,r=+n[A+8>>3],i=t*+l(+r),n[e>>3]=i,r=t*+h(+r),n[e+8>>3]=r}(A|=0,f=o),i[r>>2]=0,a=+fe(15888,f),(s=+fe(15912,f))>2]=1,a=s),(s=+fe(15936,f))>2]=2,a=s),(s=+fe(15960,f))>2]=3,a=s),(s=+fe(15984,f))>2]=4,a=s),(s=+fe(16008,f))>2]=5,a=s),(s=+fe(16032,f))>2]=6,a=s),(s=+fe(16056,f))>2]=7,a=s),(s=+fe(16080,f))>2]=8,a=s),(s=+fe(16104,f))>2]=9,a=s),(s=+fe(16128,f))>2]=10,a=s),(s=+fe(16152,f))>2]=11,a=s),(s=+fe(16176,f))>2]=12,a=s),(s=+fe(16200,f))>2]=13,a=s),(s=+fe(16224,f))>2]=14,a=s),(s=+fe(16248,f))>2]=15,a=s),(s=+fe(16272,f))>2]=16,a=s),(s=+fe(16296,f))>2]=17,a=s),(s=+fe(16320,f))>2]=18,a=s),(s=+fe(16344,f))>2]=19,a=s),(s=+d(+(1-.5*a)))<1e-16)return i[t>>2]=0,i[t+4>>2]=0,i[t+8>>2]=0,i[t+12>>2]=0,void(I=o);if(r=0|i[r>>2],a=+EA((a=+n[16368+(24*r|0)>>3])-+EA(+function(A,e){A|=0;var r=0,t=0,i=0,o=0,a=0;return o=+n[(e=e|0)>>3],t=+l(+o),i=+n[e+8>>3]-+n[A+8>>3],a=t*+h(+i),r=+n[A>>3],+ +p(+a,+(+h(+o)*+l(+r)-+l(+i)*(t*+h(+r))))}(15568+(r<<4)|0,A))),u=0|RA(e)?+EA(a+-.3334731722518321):a,a=+c(+s)/.381966011250105,(0|e)>0){f=0;do{a*=2.6457513110645907,f=f+1|0}while((0|f)!=(0|e))}s=+l(+u)*a,n[t>>3]=s,u=+h(+u)*a,n[t+8>>3]=u,I=o}function BA(A,e,r,t,o){e|=0,r|=0,t|=0,o|=0;var a=0,u=0;if((a=+function(A){var e=0,r=0;return r=+n[(A=A|0)>>3],e=+n[A+8>>3],+ +s(+(r*r+e*e))}(A|=0))<1e-16)return e=15568+(e<<4)|0,i[o>>2]=i[e>>2],i[o+4>>2]=i[e+4>>2],i[o+8>>2]=i[e+8>>2],void(i[o+12>>2]=i[e+12>>2]);if(u=+p(+ +n[A+8>>3],+ +n[A>>3]),(0|r)>0){A=0;do{a/=2.6457513110645907,A=A+1|0}while((0|A)!=(0|r))}t?(a/=3,r=0==(0|RA(r)),a=+w(.381966011250105*(r?a:a/2.6457513110645907))):(a=+w(.381966011250105*a),0|RA(r)&&(u=+EA(u+.3334731722518321))),function(A,e,r,t){A|=0,e=+e,t|=0;var o=0,a=0,s=0,u=0;if((r=+r)<1e-16)return i[t>>2]=i[A>>2],i[t+4>>2]=i[A+4>>2],i[t+8>>2]=i[A+8>>2],void(i[t+12>>2]=i[A+12>>2]);a=e<0?e+6.283185307179586:e,a=e>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(o=+f(+(a+-3.141592653589793))<1e-16,e=+n[A>>3],o){e-=r,n[t>>3]=e,o=t;break}if(s=+l(+r),r=+h(+r),e=s*+h(+e)+ +l(+a)*(r*+l(+e)),e=+g(+((e=e>1?1:e)<-1?-1:e)),n[t>>3]=e,+f(+(e+-1.5707963267948966))<1e-16)return n[t>>3]=1.5707963267948966,void(n[t+8>>3]=0);if(+f(+(e+1.5707963267948966))<1e-16)return n[t>>3]=-1.5707963267948966,void(n[t+8>>3]=0);if(u=+l(+e),a=r*+h(+a)/u,r=+n[A>>3],e=(s-+h(+e)*+h(+r))/+l(+r)/u,s=a>1?1:a,e=e>1?1:e,(e=+n[A+8>>3]+ +p(+(s<-1?-1:s),+(e<-1?-1:e)))>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);return void(n[t+8>>3]=e)}e=+n[A>>3]+r,n[t>>3]=e,o=t}while(0);if(+f(+(e+-1.5707963267948966))<1e-16)return n[o>>3]=1.5707963267948966,void(n[t+8>>3]=0);if(+f(+(e+1.5707963267948966))<1e-16)return n[o>>3]=-1.5707963267948966,void(n[t+8>>3]=0);if((e=+n[A+8>>3])>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);n[t+8>>3]=e}(15568+(e<<4)|0,+EA(+n[16368+(24*e|0)>>3]-u),a,o)}function bA(A,e,r){e|=0,r|=0;var t,n;t=I,I=I+16|0,K((A|=0)+4|0,n=t),BA(n,0|i[A>>2],e,0,r),I=t}function vA(A,e,r,t,o){A|=0,e|=0,r|=0,t|=0,o|=0;var a,f,s,u,l,h,c,d,g,w,p,B,b,v,m,k,M,y,E,x,D,_,F=0,C=0,P=0,U=0,G=0,S=0;if(_=I,I=I+272|0,U=_+240|0,E=_,x=_+224|0,D=_+208|0,p=_+176|0,B=_+160|0,b=_+192|0,v=_+144|0,m=_+128|0,k=_+112|0,M=_+96|0,y=_+80|0,i[(F=_+256|0)>>2]=e,i[U>>2]=i[A>>2],i[U+4>>2]=i[A+4>>2],i[U+8>>2]=i[A+8>>2],i[U+12>>2]=i[A+12>>2],mA(U,F,E),i[o>>2]=0,(0|(U=t+r+(5==(0|t)&1)|0))<=(0|r))I=_;else{f=x+4|0,s=p+4|0,u=r+5|0,l=16848+((a=0|i[F>>2])<<2)|0,h=16928+(a<<2)|0,c=m+8|0,d=k+8|0,g=M+8|0,w=D+4|0,P=r;A:for(;;){C=E+(((0|P)%5|0)<<4)|0,i[D>>2]=i[C>>2],i[D+4>>2]=i[C+4>>2],i[D+8>>2]=i[C+8>>2],i[D+12>>2]=i[C+12>>2];do{}while(2==(0|kA(D,a,0,1)));if((0|P)>(0|r)&0!=(0|RA(e))){if(i[p>>2]=i[D>>2],i[p+4>>2]=i[D+4>>2],i[p+8>>2]=i[D+8>>2],i[p+12>>2]=i[D+12>>2],K(f,B),t=0|i[p>>2],F=0|i[17008+(80*t|0)+(i[x>>2]<<2)>>2],i[p>>2]=i[18608+(80*t|0)+(20*F|0)>>2],(0|(C=0|i[18608+(80*t|0)+(20*F|0)+16>>2]))>0){A=0;do{oA(s),A=A+1|0}while((0|A)<(0|C))}switch(C=18608+(80*t|0)+(20*F|0)+4|0,i[b>>2]=i[C>>2],i[b+4>>2]=i[C+4>>2],i[b+8>>2]=i[C+8>>2],$(b,3*(0|i[l>>2])|0),X(s,b,s),J(s),K(s,v),G=+(0|i[h>>2]),n[m>>3]=3*G,n[c>>3]=0,S=-1.5*G,n[k>>3]=S,n[d>>3]=2.598076211353316*G,n[M>>3]=S,n[g>>3]=-2.598076211353316*G,0|i[17008+(80*(0|i[p>>2])|0)+(i[D>>2]<<2)>>2]){case 1:A=k,t=m;break;case 3:A=M,t=k;break;case 2:A=m,t=M;break;default:A=12;break A}oe(B,v,t,A,y),BA(y,0|i[p>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])}if((0|P)<(0|u)&&(K(w,p),BA(p,0|i[D>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])),i[x>>2]=i[D>>2],i[x+4>>2]=i[D+4>>2],i[x+8>>2]=i[D+8>>2],i[x+12>>2]=i[D+12>>2],(0|(P=P+1|0))>=(0|U)){A=3;break}}3!=(0|A)?12==(0|A)&&Q(22474,22521,581,22531):I=_}}function mA(A,e,r){A|=0,e|=0,r|=0;var t,n=0,o=0,a=0,f=0,s=0;t=I,I=I+128|0,o=t,f=20208,s=(a=n=t+64|0)+60|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));f=20272,s=(a=o)+60|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));n=(s=0==(0|RA(0|i[e>>2])))?n:o,uA(o=A+4|0),lA(o),0|RA(0|i[e>>2])&&(iA(o),i[e>>2]=1+(0|i[e>>2])),i[r>>2]=i[A>>2],X(o,n,e=r+4|0),J(e),i[r+16>>2]=i[A>>2],X(o,n+12|0,e=r+20|0),J(e),i[r+32>>2]=i[A>>2],X(o,n+24|0,e=r+36|0),J(e),i[r+48>>2]=i[A>>2],X(o,n+36|0,e=r+52|0),J(e),i[r+64>>2]=i[A>>2],X(o,n+48|0,r=r+68|0),J(r),I=t}function kA(A,e,r,t){r|=0,t|=0;var n,o,a,f,s,u,l=0,h=0,c=0,d=0,g=0;if(u=I,I=I+32|0,s=u+12|0,o=u,g=(A|=0)+4|0,d=0|i[16928+((e|=0)<<2)>>2],d=(f=0!=(0|t))?3*d|0:d,l=0|i[g>>2],n=0|i[(a=A+8|0)>>2],f){if((0|(l=n+l+(t=0|i[(h=A+12|0)>>2])|0))==(0|d))return I=u,0|(g=1);c=h}else l=n+l+(t=0|i[(c=A+12|0)>>2])|0;if((0|l)<=(0|d))return I=u,0|(g=0);do{if((0|t)>0){if(t=0|i[A>>2],(0|n)>0){h=18608+(80*t|0)+60|0,t=A;break}t=18608+(80*t|0)+40|0,r?(Z(s,d,0,0),q(g,s,o),aA(o),X(o,s,g),h=t,t=A):(h=t,t=A)}else h=18608+(80*(0|i[A>>2])|0)+20|0,t=A}while(0);if(i[t>>2]=i[h>>2],(0|i[(l=h+16|0)>>2])>0){t=0;do{oA(g),t=t+1|0}while((0|t)<(0|i[l>>2]))}return A=h+4|0,i[s>>2]=i[A>>2],i[s+4>>2]=i[A+4>>2],i[s+8>>2]=i[A+8>>2],e=0|i[16848+(e<<2)>>2],$(s,f?3*e|0:e),X(g,s,g),J(g),t=f&&((0|i[a>>2])+(0|i[g>>2])+(0|i[c>>2])|0)==(0|d)?1:2,I=u,0|(g=t)}function MA(A,e){A|=0,e|=0;var r=0;do{r=0|kA(A,e,0,1)}while(2==(0|r));return 0|r}function QA(A,e,r,t,o){A|=0,e|=0,r|=0,t|=0,o|=0;var a,f,s,u,l,h,c,d,g,w,p,B,b,v,m,k,M,y,E=0,x=0,D=0,_=0,F=0;if(y=I,I=I+240|0,v=y+208|0,m=y,k=y+192|0,M=y+176|0,g=y+160|0,w=y+144|0,p=y+128|0,B=y+112|0,b=y+96|0,i[(E=y+224|0)>>2]=e,i[v>>2]=i[A>>2],i[v+4>>2]=i[A+4>>2],i[v+8>>2]=i[A+8>>2],i[v+12>>2]=i[A+12>>2],yA(v,E,m),i[o>>2]=0,(0|(d=t+r+(6==(0|t)&1)|0))<=(0|r))I=y;else{f=r+6|0,s=16928+((a=0|i[E>>2])<<2)|0,u=w+8|0,l=p+8|0,h=B+8|0,c=k+4|0,x=0,D=r,t=-1;A:for(;;){if(A=m+((E=(0|D)%6|0)<<4)|0,i[k>>2]=i[A>>2],i[k+4>>2]=i[A+4>>2],i[k+8>>2]=i[A+8>>2],i[k+12>>2]=i[A+12>>2],A=x,x=0|kA(k,a,0,1),(0|D)>(0|r)&0!=(0|RA(e))&&(1!=(0|A)&&(0|i[k>>2])!=(0|t))){switch(K(m+(((E+5|0)%6|0)<<4)+4|0,M),K(m+(E<<4)+4|0,g),_=+(0|i[s>>2]),n[w>>3]=3*_,n[u>>3]=0,F=-1.5*_,n[p>>3]=F,n[l>>3]=2.598076211353316*_,n[B>>3]=F,n[h>>3]=-2.598076211353316*_,E=0|i[v>>2],0|i[17008+(80*E|0)+(((0|t)==(0|E)?0|i[k>>2]:t)<<2)>>2]){case 1:A=p,t=w;break;case 3:A=B,t=p;break;case 2:A=w,t=B;break;default:A=8;break A}oe(M,g,t,A,b),0|ae(M,b)||0|ae(g,b)||(BA(b,0|i[v>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2]))}if((0|D)<(0|f)&&(K(c,M),BA(M,0|i[k>>2],a,1,o+8+(i[o>>2]<<4)|0),i[o>>2]=1+(0|i[o>>2])),(0|(D=D+1|0))>=(0|d)){A=3;break}t=0|i[k>>2]}3!=(0|A)?8==(0|A)&&Q(22557,22521,746,22602):I=y}}function yA(A,e,r){A|=0,e|=0,r|=0;var t,n=0,o=0,a=0,f=0,s=0;t=I,I=I+160|0,o=t,f=20336,s=(a=n=t+80|0)+72|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));f=20416,s=(a=o)+72|0;do{i[a>>2]=i[f>>2],a=a+4|0,f=f+4|0}while((0|a)<(0|s));n=(s=0==(0|RA(0|i[e>>2])))?n:o,uA(o=A+4|0),lA(o),0|RA(0|i[e>>2])&&(iA(o),i[e>>2]=1+(0|i[e>>2])),i[r>>2]=i[A>>2],X(o,n,e=r+4|0),J(e),i[r+16>>2]=i[A>>2],X(o,n+12|0,e=r+20|0),J(e),i[r+32>>2]=i[A>>2],X(o,n+24|0,e=r+36|0),J(e),i[r+48>>2]=i[A>>2],X(o,n+36|0,e=r+52|0),J(e),i[r+64>>2]=i[A>>2],X(o,n+48|0,e=r+68|0),J(e),i[r+80>>2]=i[A>>2],X(o,n+60|0,r=r+84|0),J(r),I=t}function EA(A){var e;return e=(A=+A)<0?A+6.283185307179586:A,+(A>=6.283185307179586?e+-6.283185307179586:e)}function xA(A,e){return e|=0,+f(+(+n[(A|=0)>>3]-+n[e>>3]))<17453292519943298e-27?0|(e=+f(+(+n[A+8>>3]-+n[e+8>>3]))<17453292519943298e-27):0|(e=0)}function DA(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))*6371.007180918475}function _A(A,e,r){A|=0,r|=0;var t,i,o,a,f=0,u=0,d=0,g=0,B=0,b=0;return b=+n[(e|=0)>>3],o=+n[A>>3],B=+h(.5*(b-o)),d=+n[e+8>>3],i=+n[A+8>>3],g=+h(.5*(d-i)),t=+l(+o),a=+l(+b),g=2*+p(+ +s(+(g=B*B+g*(a*t*g))),+ +s(+(1-g))),B=+n[r>>3],b=+h(.5*(B-b)),f=+n[r+8>>3],d=+h(.5*(f-d)),u=+l(+B),d=2*+p(+ +s(+(d=b*b+d*(a*u*d))),+ +s(+(1-d))),B=+h(.5*(o-B)),f=+h(.5*(i-f)),f=2*+p(+ +s(+(f=B*B+f*(t*u*f))),+ +s(+(1-f))),4*+w(+ +s(+ +c(.5*(u=.5*(g+d+f)))*+c(.5*(u-g))*+c(.5*(u-d))*+c(.5*(u-f))))}function IA(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),45),M(),127&e|0}function FA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0;if(!(!0&134217728==(-16777216&(e|=0)|0)))return 0|(e=0);if(o=0|Qe(0|(A|=0),0|e,45),M(),(o&=127)>>>0>121)return 0|(e=0);r=0|Qe(0|A,0|e,52),M(),r&=15;do{if(0|r){for(i=1,t=0;;){if(n=0|Qe(0|A,0|e,3*(15-i|0)|0),M(),0!=(0|(n&=7))&(1^t)){if(1==(0|n)&0!=(0|S(o))){a=0,t=13;break}t=1}if(7==(0|n)){a=0,t=13;break}if(!(i>>>0>>0)){t=9;break}i=i+1|0}if(9==(0|t)){if(15!=(0|r))break;return 0|(a=1)}if(13==(0|t))return 0|a}}while(0);for(;;){if(a=0|Qe(0|A,0|e,3*(14-r|0)|0),M(),!(7==(7&a|0)&!0)){a=0,t=13;break}if(!(r>>>0<14)){a=1,t=13;break}r=r+1|0}return 13==(0|t)?0|a:0}function CA(A,e,r){r|=0;var t=0,i=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|(t&=15))>=(0|r)){if((0|t)!=(0|r))if(r>>>0<=15){if(A|=i=0|ye(0|r,0,52),e=0|M()|-15728641&e,(0|t)>(0|r))do{i=0|ye(7,0,3*(14-r|0)|0),r=r+1|0,A|=i,e=0|M()|e}while((0|r)<(0|t))}else e=0,A=0}else e=0,A=0;return k(0|e),0|A}function PA(A,e,r,t){r|=0,t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(f&=15))<=(0|r)){if((0|f)==(0|r))return i[(r=t)>>2]=A,void(i[r+4>>2]=e);if(n=(0|(u=0|ee(7,r-f|0)))/7|0,s=0|Qe(0|A,0|e,45),M(),0|S(127&s)){A:do{if(f)for(a=1;;){if(o=0|Qe(0|A,0|e,3*(15-a|0)|0),M(),0|(o&=7))break A;if(!(a>>>0>>0)){o=0;break}a=a+1|0}else o=0}while(0);a=0==(0|o)}else a=0;if(l=0|ye(f+1|0,0,52),o=0|M()|-15728641&e,PA(e=(l|A)&~(e=0|ye(7,0,0|(s=3*(14-f|0)|0))),f=o&~(0|M()),r,t),o=t+(n<<3)|0,!a)return PA((l=0|ye(1,0,0|s))|e,0|M()|f,r,o),l=o+(n<<3)|0,PA((u=0|ye(2,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(3,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(4,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(5,0,0|s))|e,0|M()|f,r,l),void PA((u=0|ye(6,0,0|s))|e,0|M()|f,r,l+(n<<3)|0);a=o+(n<<3)|0,(0|u)>6&&(_e(0|o,0,(l=(a>>>0>(u=o+8|0)>>>0?a:u)+-1+(0-o)|0)+8&-8|0),o=u+(l>>>3<<3)|0),PA((l=0|ye(2,0,0|s))|e,0|M()|f,r,o),l=o+(n<<3)|0,PA((u=0|ye(3,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(4,0,0|s))|e,0|M()|f,r,l),l=l+(n<<3)|0,PA((u=0|ye(5,0,0|s))|e,0|M()|f,r,l),PA((u=0|ye(6,0,0|s))|e,0|M()|f,r,l+(n<<3)|0)}}function UA(A,e){var r=0,t=0,i=0;if(i=0|Qe(0|(A|=0),0|(e|=0),45),M(),!(0|S(127&i)))return 0|(i=0);i=0|Qe(0|A,0|e,52),M(),i&=15;A:do{if(i)for(t=1;;){if(r=0|Qe(0|A,0|e,3*(15-t|0)|0),M(),0|(r&=7))break A;if(!(t>>>0>>0)){r=0;break}t=t+1|0}else r=0}while(0);return 0|(i=0==(0|r)&1)}function GA(A,e){var r=0,t=0,i=0;if(i=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(i&=15))return 0|(i=0);for(t=1;;){if(r=0|Qe(0|A,0|e,3*(15-t|0)|0),M(),0|(r&=7)){t=5;break}if(!(t>>>0>>0)){r=0,t=5;break}t=t+1|0}return 5==(0|t)?0|r:0}function SA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0,f=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(f&=15))return f=A,k(0|(a=e)),0|f;for(a=1,r=0;;){t=0|ye(7,0,0|(n=3*(15-a|0)|0)),i=0|M(),o=0|Qe(0|A,0|e,0|n),M(),A=(n=0|ye(0|fA(7&o),0,0|n))|A&~t,e=(o=0|M())|e&~i;A:do{if(!r)if(0==(n&t|0)&0==(o&i|0))r=0;else if(t=0|Qe(0|A,0|e,52),M(),t&=15){r=1;e:for(;;){switch(o=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),7&o){case 1:break e;case 0:break;default:r=1;break A}if(!(r>>>0>>0)){r=1;break A}r=r+1|0}for(r=1;;){if(i=0|Qe(0|A,0|e,0|(o=3*(15-r|0)|0)),M(),n=0|ye(7,0,0|o),e&=~(0|M()),A=A&~n|(o=0|ye(0|fA(7&i),0,0|o)),e=0|e|M(),!(r>>>0>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return k(0|e),0|A}function TA(A,e){var r=0,t=0,i=0,n=0,o=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(t&=15))return t=A,k(0|(r=e)),0|t;for(r=1;o=0|Qe(0|A,0|e,0|(n=3*(15-r|0)|0)),M(),i=0|ye(7,0,0|n),e&=~(0|M()),A=(n=0|ye(0|fA(7&o),0,0|n))|A&~i,e=0|M()|e,r>>>0>>0;)r=r+1|0;return k(0|e),0|A}function VA(A,e){var r=0,t=0,i=0,n=0,o=0,a=0,f=0;if(f=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(f&=15))return f=A,k(0|(a=e)),0|f;for(a=1,r=0;;){t=0|ye(7,0,0|(n=3*(15-a|0)|0)),i=0|M(),o=0|Qe(0|A,0|e,0|n),M(),A=(n=0|ye(0|sA(7&o),0,0|n))|A&~t,e=(o=0|M())|e&~i;A:do{if(!r)if(0==(n&t|0)&0==(o&i|0))r=0;else if(t=0|Qe(0|A,0|e,52),M(),t&=15){r=1;e:for(;;){switch(o=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),7&o){case 1:break e;case 0:break;default:r=1;break A}if(!(r>>>0>>0)){r=1;break A}r=r+1|0}for(r=1;;){if(n=0|ye(7,0,0|(i=3*(15-r|0)|0)),o=e&~(0|M()),e=0|Qe(0|A,0|e,0|i),M(),A=A&~n|(e=0|ye(0|sA(7&e),0,0|i)),e=0|o|M(),!(r>>>0>>0)){r=1;break}r=r+1|0}}else r=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return k(0|e),0|A}function HA(A,e){var r=0,t=0,i=0,n=0,o=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),!(t&=15))return t=A,k(0|(r=e)),0|t;for(r=1;n=0|ye(7,0,0|(o=3*(15-r|0)|0)),i=e&~(0|M()),e=0|Qe(0|A,0|e,0|o),M(),A=(e=0|ye(0|sA(7&e),0,0|o))|A&~n,e=0|M()|i,r>>>0>>0;)r=r+1|0;return k(0|e),0|A}function RA(A){return 0|(0|(A|=0))%2}function LA(A,e){A|=0;var r,t;return t=I,I=I+16|0,r=t,(e|=0)>>>0<=15&&2146435072!=(2146435072&i[A+4>>2]|0)&&2146435072!=(2146435072&i[A+8+4>>2]|0)?(!function(A,e,r){var t,i;t=I,I=I+16|0,pA(A|=0,e|=0,r|=0,i=t),W(i,r+4|0),I=t}(A,e,r),e=0|function(A,e){A|=0;var r,t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0;if(r=I,I=I+64|0,s=r+40|0,n=r+24|0,o=r+12|0,a=r,ye(0|(e|=0),0,52),t=134225919|M(),!e)return(0|i[A+4>>2])>2||(0|i[A+8>>2])>2||(0|i[A+12>>2])>2?(s=0,k(0|(f=0)),I=r,0|s):(ye(0|V(A),0,45),f=0|M()|t,s=-1,k(0|f),I=r,0|s);if(i[s>>2]=i[A>>2],i[s+4>>2]=i[A+4>>2],i[s+8>>2]=i[A+8>>2],i[s+12>>2]=i[A+12>>2],f=s+4|0,(0|e)>0)for(A=-1;i[n>>2]=i[f>>2],i[n+4>>2]=i[f+4>>2],i[n+8>>2]=i[f+8>>2],1&e?(eA(f),i[o>>2]=i[f>>2],i[o+4>>2]=i[f+4>>2],i[o+8>>2]=i[f+8>>2],tA(o)):(rA(f),i[o>>2]=i[f>>2],i[o+4>>2]=i[f+4>>2],i[o+8>>2]=i[f+8>>2],iA(o)),q(n,o,a),J(a),u=0|ye(7,0,0|(l=3*(15-e|0)|0)),t&=~(0|M()),A=(l=0|ye(0|AA(a),0,0|l))|A&~u,t=0|M()|t,(0|e)>1;)e=e+-1|0;else A=-1;A:do{if((0|i[f>>2])<=2&&(0|i[s+8>>2])<=2&&(0|i[s+12>>2])<=2){if(e=0|ye(0|(n=0|V(s)),0,45),e|=A,A=0|M()|-1040385&t,a=0|H(s),!(0|S(n))){if((0|a)<=0)break;for(o=0;;){if(n=0|Qe(0|e,0|A,52),M(),n&=15)for(t=1;s=0|Qe(0|e,0|A,0|(l=3*(15-t|0)|0)),M(),u=0|ye(7,0,0|l),A&=~(0|M()),e=e&~u|(l=0|ye(0|fA(7&s),0,0|l)),A=0|A|M(),t>>>0>>0;)t=t+1|0;if((0|(o=o+1|0))==(0|a))break A}}o=0|Qe(0|e,0|A,52),M(),o&=15;e:do{if(o){t=1;r:for(;;){switch(l=0|Qe(0|e,0|A,3*(15-t|0)|0),M(),7&l){case 1:break r;case 0:break;default:break e}if(!(t>>>0>>0))break e;t=t+1|0}if(0|R(n,0|i[s>>2]))for(t=1;u=0|ye(7,0,0|(s=3*(15-t|0)|0)),l=A&~(0|M()),A=0|Qe(0|e,0|A,0|s),M(),e=e&~u|(A=0|ye(0|sA(7&A),0,0|s)),A=0|l|M(),t>>>0>>0;)t=t+1|0;else for(t=1;s=0|Qe(0|e,0|A,0|(l=3*(15-t|0)|0)),M(),u=0|ye(7,0,0|l),A&=~(0|M()),e=e&~u|(l=0|ye(0|fA(7&s),0,0|l)),A=0|A|M(),t>>>0>>0;)t=t+1|0}}while(0);if((0|a)>0){t=0;do{e=0|SA(e,A),A=0|M(),t=t+1|0}while((0|t)!=(0|a))}}else e=0,A=0}while(0);return l=e,k(0|(u=A)),I=r,0|l}(r,e),A=0|M()):(A=0,e=0),k(0|A),I=t,0|e}function zA(A,e,r){var t,n=0,o=0,a=0;if(t=(r|=0)+4|0,o=0|Qe(0|(A|=0),0|(e|=0),52),M(),o&=15,a=0|Qe(0|A,0|e,45),M(),n=0==(0|o),0|S(127&a)){if(n)return 0|(a=1);n=1}else{if(n)return 0|(a=0);n=0==(0|i[t>>2])&&0==(0|i[r+8>>2])?0!=(0|i[r+12>>2])&1:1}for(r=1;1&r?tA(t):iA(t),a=0|Qe(0|A,0|e,3*(15-r|0)|0),M(),nA(t,7&a),r>>>0>>0;)r=r+1|0;return 0|n}function YA(A,e,r){r|=0;var t,n,o=0,a=0,f=0,s=0,u=0,l=0;n=I,I=I+16|0,t=n,l=0|Qe(0|(A|=0),0|(e|=0),45),M(),l&=127;A:do{if(0!=(0|S(l))&&(f=0|Qe(0|A,0|e,52),M(),0!=(0|(f&=15)))){o=1;e:for(;;){switch(u=0|Qe(0|A,0|e,3*(15-o|0)|0),M(),7&u){case 5:break e;case 0:break;default:o=e;break A}if(!(o>>>0>>0)){o=e;break A}o=o+1|0}for(a=1,o=e;s=0|ye(7,0,0|(e=3*(15-a|0)|0)),u=o&~(0|M()),o=0|Qe(0|A,0|o,0|e),M(),A=A&~s|(o=0|ye(0|sA(7&o),0,0|e)),o=0|u|M(),a>>>0>>0;)a=a+1|0}else o=e}while(0);if(u=7728+(28*l|0)|0,i[r>>2]=i[u>>2],i[r+4>>2]=i[u+4>>2],i[r+8>>2]=i[u+8>>2],i[r+12>>2]=i[u+12>>2],0|zA(A,o,r)){if(s=r+4|0,i[t>>2]=i[s>>2],i[t+4>>2]=i[s+4>>2],i[t+8>>2]=i[s+8>>2],f=0|Qe(0|A,0|o,52),M(),u=15&f,1&f?(iA(s),f=u+1|0):f=u,0|S(l)){A:do{if(u)for(e=1;;){if(a=0|Qe(0|A,0|o,3*(15-e|0)|0),M(),0|(a&=7)){o=a;break A}if(!(e>>>0>>0)){o=0;break}e=e+1|0}else o=0}while(0);o=4==(0|o)&1}else o=0;if(0|kA(r,f,o,0)){if(0|S(l))do{}while(0!=(0|kA(r,f,0,0)));(0|f)!=(0|u)&&rA(s)}else(0|f)!=(0|u)&&(i[s>>2]=i[t>>2],i[s+4>>2]=i[t+4>>2],i[s+8>>2]=i[t+8>>2]);I=n}else I=n}function OA(A,e,r){r|=0;var t,i;t=I,I=I+16|0,YA(A|=0,e|=0,i=t),e=0|Qe(0|A,0|e,52),M(),bA(i,15&e,r),I=t}function jA(A,e,r){r|=0;var t,i,n=0,o=0;i=I,I=I+16|0,YA(A|=0,e|=0,t=i),n=0|Qe(0|A,0|e,45),M(),n=0==(0|S(127&n)),o=0|Qe(0|A,0|e,52),M(),o&=15;A:do{if(!n){if(0|o)for(n=1;;){if(!(0==((0|ye(7,0,3*(15-n|0)|0))&A|0)&0==((0|M())&e|0)))break A;if(!(n>>>0>>0))break;n=n+1|0}return vA(t,o,0,5,r),void(I=i)}}while(0);QA(t,o,0,6,r),I=i}function NA(A,e){e|=0;var r,t=0,n=0,o=0,a=0,f=0,s=0;if(ye(0|(A|=0),0,52),r=134225919|M(),(0|A)<1){n=0,t=0;do{0|S(n)&&(ye(0|n,0,45),f=0|r|M(),i[(A=e+(t<<3)|0)>>2]=-1,i[A+4>>2]=f,t=t+1|0),n=n+1|0}while(122!=(0|n))}else{f=0,t=0;do{if(0|S(f)){for(ye(0|f,0,45),n=1,o=-1,a=0|r|M();o&=~(s=0|ye(7,0,3*(15-n|0)|0)),a&=~(0|M()),(0|n)!=(0|A);)n=n+1|0;i[(s=e+(t<<3)|0)>>2]=o,i[s+4>>2]=a,t=t+1|0}f=f+1|0}while(122!=(0|f))}}function ZA(A,e,r,t){var n,o=0,a=0,f=0,s=0,u=0;if(n=I,I=I+64|0,f=n,(0|(A|=0))==(0|(r|=0))&(0|(e|=0))==(0|(t|=0))|!1|134217728!=(2013265920&e|0)|!1|134217728!=(2013265920&t|0))return I=n,0|(f=0);if(o=0|Qe(0|A,0|e,52),M(),o&=15,a=0|Qe(0|r,0|t,52),M(),(0|o)!=(15&a|0))return I=n,0|(f=0);if(a=o+-1|0,o>>>0>1&&(u=0|CA(A,e,a),s=0|M(),(0|u)==(0|(a=0|CA(r,t,a)))&(0|s)==(0|M()))){if(o=0|Qe(0|A,0|e,0|(a=3*(15^o)|0)),M(),o&=7,a=0|Qe(0|r,0|t,0|a),M(),0==(0|o)|0==(0|(a&=7)))return I=n,0|(u=1);if((0|i[21136+(o<<2)>>2])==(0|a))return I=n,0|(u=1);if((0|i[21168+(o<<2)>>2])==(0|a))return I=n,0|(u=1)}a=(o=f)+56|0;do{i[o>>2]=0,o=o+4|0}while((0|o)<(0|a));return F(A,e,1,f),o=(0|i[(u=f)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+8|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+16|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+24|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+32|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)||(0|i[(u=f+40|0)>>2])==(0|r)&&(0|i[u+4>>2])==(0|t)?1:1&((0|i[(o=f+48|0)>>2])==(0|r)?(0|i[o+4>>2])==(0|t):0),I=n,0|(u=o)}function WA(A,e,r){r|=0;var t,n,o,a,f=0;if(o=I,I=I+16|0,n=o,f=0|Qe(0|(A|=0),0|(e|=0),56),M(),-1==(0|(e=0|function(A,e,r){r|=0;var t=0,n=0;if(t=0|UA(A=A|0,e=e|0),(r+-1|0)>>>0>5)return 0|(r=-1);if(1==(0|r)&(n=0!=(0|t)))return 0|(r=-1);return t=0|function(A,e){var r=0,t=0,n=0,o=0,a=0,f=0,s=0,u=0;if(u=I,I=I+32|0,o=u,YA(A=A|0,e=e|0,n=u+16|0),a=0|IA(A,e),s=0|GA(A,e),function(A,e){A=7728+(28*(A|=0)|0)|0,i[(e|=0)>>2]=i[A>>2],i[e+4>>2]=i[A+4>>2],i[e+8>>2]=i[A+8>>2],i[e+12>>2]=i[A+12>>2]}(a,o),e=0|function(A,e){A|=0;var r=0,t=0;if((e|=0)>>>0>20)return-1;do{if((0|i[11152+(216*e|0)>>2])!=(0|A))if((0|i[11152+(216*e|0)+8>>2])!=(0|A))if((0|i[11152+(216*e|0)+16>>2])!=(0|A))if((0|i[11152+(216*e|0)+24>>2])!=(0|A))if((0|i[11152+(216*e|0)+32>>2])!=(0|A))if((0|i[11152+(216*e|0)+40>>2])!=(0|A))if((0|i[11152+(216*e|0)+48>>2])!=(0|A))if((0|i[11152+(216*e|0)+56>>2])!=(0|A))if((0|i[11152+(216*e|0)+64>>2])!=(0|A))if((0|i[11152+(216*e|0)+72>>2])!=(0|A))if((0|i[11152+(216*e|0)+80>>2])!=(0|A))if((0|i[11152+(216*e|0)+88>>2])!=(0|A))if((0|i[11152+(216*e|0)+96>>2])!=(0|A))if((0|i[11152+(216*e|0)+104>>2])!=(0|A))if((0|i[11152+(216*e|0)+112>>2])!=(0|A))if((0|i[11152+(216*e|0)+120>>2])!=(0|A))if((0|i[11152+(216*e|0)+128>>2])!=(0|A)){if((0|i[11152+(216*e|0)+136>>2])!=(0|A)){if((0|i[11152+(216*e|0)+144>>2])==(0|A)){A=0,r=2,t=0;break}if((0|i[11152+(216*e|0)+152>>2])==(0|A)){A=0,r=2,t=1;break}if((0|i[11152+(216*e|0)+160>>2])==(0|A)){A=0,r=2,t=2;break}if((0|i[11152+(216*e|0)+168>>2])==(0|A)){A=1,r=2,t=0;break}if((0|i[11152+(216*e|0)+176>>2])==(0|A)){A=1,r=2,t=1;break}if((0|i[11152+(216*e|0)+184>>2])==(0|A)){A=1,r=2,t=2;break}if((0|i[11152+(216*e|0)+192>>2])==(0|A)){A=2,r=2,t=0;break}if((0|i[11152+(216*e|0)+200>>2])==(0|A)){A=2,r=2,t=1;break}if((0|i[11152+(216*e|0)+208>>2])==(0|A)){A=2,r=2,t=2;break}return-1}A=2,r=1,t=2}else A=2,r=1,t=1;else A=2,r=1,t=0;else A=1,r=1,t=2;else A=1,r=1,t=1;else A=1,r=1,t=0;else A=0,r=1,t=2;else A=0,r=1,t=1;else A=0,r=1,t=0;else A=2,r=0,t=2;else A=2,r=0,t=1;else A=2,r=0,t=0;else A=1,r=0,t=2;else A=1,r=0,t=1;else A=1,r=0,t=0;else A=0,r=0,t=2;else A=0,r=0,t=1;else A=0,r=0,t=0}while(0);return 0|i[11152+(216*e|0)+(72*r|0)+(24*A|0)+(t<<3)+4>>2]}(a,0|i[n>>2]),!(0|S(a)))return I=u,0|(s=e);switch(0|a){case 4:A=0,r=14;break;case 14:A=1,r=14;break;case 24:A=2,r=14;break;case 38:A=3,r=14;break;case 49:A=4,r=14;break;case 58:A=5,r=14;break;case 63:A=6,r=14;break;case 72:A=7,r=14;break;case 83:A=8,r=14;break;case 97:A=9,r=14;break;case 107:A=10,r=14;break;case 117:A=11,r=14;break;default:f=0,t=0}14==(0|r)&&(f=0|i[22096+(24*A|0)+8>>2],t=0|i[22096+(24*A|0)+16>>2]);(0|(A=0|i[n>>2]))!=(0|i[o>>2])&&(a=0|T(a))|(0|(A=0|i[n>>2]))==(0|t)&&(e=(e+1|0)%6|0);if(3==(0|s)&(0|A)==(0|t))return I=u,0|(s=(e+5|0)%6|0);if(!(5==(0|s)&(0|A)==(0|f)))return I=u,0|(s=e);return I=u,0|(s=(e+1|0)%6|0)}(A,e),n?0|(r=(5-t+(0|i[22384+(r<<2)>>2])|0)%5|0):0|(r=(6-t+(0|i[22416+(r<<2)>>2])|0)%6|0)}(t=(a=!0&268435456==(2013265920&e|0))?A:0,A=a?-2130706433&e|134217728:0,7&f))))return i[r>>2]=0,void(I=o);YA(t,A,n),f=0|Qe(0|t,0|A,52),M(),f&=15,0|UA(t,A)?vA(n,f,e,2,r):QA(n,f,e,2,r),I=o}function JA(A){A|=0;var e,r,t=0;return(e=0|be(1,12))||Q(22691,22646,49,22704),0|(t=0|i[(r=A+4|0)>>2])?(i[(t=t+8|0)>>2]=e,i[r>>2]=e,0|e):(0|i[A>>2]&&Q(22721,22646,61,22744),i[(t=A)>>2]=e,i[r>>2]=e,0|e)}function KA(A,e){A|=0,e|=0;var r,t;return(t=0|pe(24))||Q(22758,22646,78,22772),i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2],i[t+16>>2]=0,0|(r=0|i[(e=A+4|0)>>2])?(i[r+16>>2]=t,i[e>>2]=t,0|t):(0|i[A>>2]&&Q(22787,22646,82,22772),i[A>>2]=t,i[e>>2]=t,0|t)}function XA(A){var e,r,t=0,o=0,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,y=0,E=0,x=0,D=0,_=0,I=0,F=0,C=0,P=0,U=0,G=0,S=0;if(0|i[(s=(A|=0)+8|0)>>2])return 0|(S=1);if(!(a=0|i[A>>2]))return 0|(S=0);t=a,o=0;do{o=o+1|0,t=0|i[t+8>>2]}while(0!=(0|t));if(o>>>0<2)return 0|(S=0);(r=0|pe(o<<2))||Q(22807,22646,317,22826),(e=0|pe(o<<5))||Q(22848,22646,321,22826),i[A>>2]=0,i[(D=A+4|0)>>2]=0,i[s>>2]=0,o=0,U=0,x=0,w=0;A:for(;;){if(g=0|i[a>>2]){u=0,l=g;do{if(c=+n[l+8>>3],t=l,l=0|i[l+16>>2],h=+n[(s=(d=0==(0|l))?g:l)+8>>3],+f(+(c-h))>3.141592653589793){S=14;break}u+=(h-c)*(+n[t>>3]+ +n[s>>3])}while(!d);if(14==(0|S)){S=0,u=0,t=g;do{E=+n[t+8>>3],C=0|i[(P=t+16|0)>>2],y=+n[(C=0==(0|C)?g:C)+8>>3],u+=(+n[t>>3]+ +n[C>>3])*((y<0?y+6.283185307179586:y)-(E<0?E+6.283185307179586:E)),t=0|i[(0==(0|t)?a:P)>>2]}while(0!=(0|t))}u>0?(i[r+(U<<2)>>2]=a,U=U+1|0,s=x,t=w):S=19}else S=19;if(19==(0|S)){S=0;do{if(!o){if(w){s=D,l=w+8|0,t=a,o=A;break}if(0|i[A>>2]){S=27;break A}s=D,l=A,t=a,o=A;break}if(0|i[(t=o+8|0)>>2]){S=21;break A}if(!(o=0|be(1,12))){S=23;break A}i[t>>2]=o,s=o+4|0,l=o,t=w}while(0);if(i[l>>2]=a,i[s>>2]=a,l=e+(x<<5)|0,d=0|i[a>>2]){for(n[(g=e+(x<<5)+8|0)>>3]=17976931348623157e292,n[(w=e+(x<<5)+24|0)>>3]=17976931348623157e292,n[l>>3]=-17976931348623157e292,n[(p=e+(x<<5)+16|0)>>3]=-17976931348623157e292,k=17976931348623157e292,M=-17976931348623157e292,s=0,B=d,c=17976931348623157e292,v=17976931348623157e292,m=-17976931348623157e292,h=-17976931348623157e292;u=+n[B>>3],E=+n[B+8>>3],B=0|i[B+16>>2],y=+n[((b=0==(0|B))?d:B)+8>>3],u>3]=u,c=u),E>3]=E,v=E),u>m?n[l>>3]=u:u=m,E>h&&(n[p>>3]=E,h=E),k=E>0&EM?E:M,s|=+f(+(E-y))>3.141592653589793,!b;)m=u;s&&(n[p>>3]=M,n[w>>3]=k)}else i[l>>2]=0,i[l+4>>2]=0,i[l+8>>2]=0,i[l+12>>2]=0,i[l+16>>2]=0,i[l+20>>2]=0,i[l+24>>2]=0,i[l+28>>2]=0;s=x+1|0}if(a=0|i[(P=a+8|0)>>2],i[P>>2]=0,!a){S=45;break}x=s,w=t}if(21==(0|S))Q(22624,22646,35,22658);else if(23==(0|S))Q(22678,22646,37,22658);else if(27==(0|S))Q(22721,22646,61,22744);else if(45==(0|S)){A:do{if((0|U)>0){for(P=0==(0|s),F=s<<2,C=0==(0|A),I=0,t=0;;){if(_=0|i[r+(I<<2)>>2],P)S=73;else{if(!(x=0|pe(F))){S=50;break}if(!(D=0|pe(F))){S=52;break}e:do{if(C)o=0;else{for(s=0,o=0,l=A;a=e+(s<<5)|0,0|qA(0|i[l>>2],a,0|i[_>>2])?(i[x+(o<<2)>>2]=l,i[D+(o<<2)>>2]=a,b=o+1|0):b=o,l=0|i[l+8>>2];)s=s+1|0,o=b;if((0|b)>0)if(a=0|i[x>>2],1==(0|b))o=a;else for(p=0,B=-1,o=a,w=a;;){for(d=0|i[w>>2],a=0,l=0;g=(0|(s=0|i[i[x+(l<<2)>>2]>>2]))==(0|d)?a:a+(1&(0|qA(s,0|i[D+(l<<2)>>2],0|i[d>>2])))|0,(0|(l=l+1|0))!=(0|b);)a=g;if(o=(s=(0|g)>(0|B))?w:o,(0|(a=p+1|0))==(0|b))break e;p=a,B=s?g:B,w=0|i[x+(a<<2)>>2]}else o=0}}while(0);if(Be(x),Be(D),o){if(a=0|i[(s=o+4|0)>>2])o=a+8|0;else if(0|i[o>>2]){S=70;break}i[o>>2]=_,i[s>>2]=_}else S=73}if(73==(0|S)){if(S=0,0|(t=0|i[_>>2]))do{D=t,t=0|i[t+16>>2],Be(D)}while(0!=(0|t));Be(_),t=2}if((0|(I=I+1|0))>=(0|U)){G=t;break A}}50==(0|S)?Q(22863,22646,249,22882):52==(0|S)?Q(22901,22646,252,22882):70==(0|S)&&Q(22721,22646,61,22744)}else G=0}while(0);return Be(r),Be(e),0|(S=G)}return 0}function qA(A,e,r){A|=0;var t,o=0,a=0,f=0,s=0,u=0,l=0,h=0;if(!(0|O(e|=0,r|=0)))return 0|(A=0);if(e=0|Y(e),t=+n[r>>3],o=e&(o=+n[r+8>>3])<0?o+6.283185307179586:o,!(A=0|i[A>>2]))return 0|(A=0);if(e){e=0,r=A;A:for(;;){for(;s=+n[r>>3],l=+n[r+8>>3],h=0|i[(r=r+16|0)>>2],f=+n[(h=0==(0|h)?A:h)>>3],a=+n[h+8>>3],s>f?(u=s,s=l):(u=f,f=s,s=a,a=l),tu;)if(!(r=0|i[r>>2])){r=22;break A}if(o=(s=s<0?s+6.283185307179586:s)==o|(l=a<0?a+6.283185307179586:a)==o?o+-2220446049250313e-31:o,((l+=(t-f)/(u-f)*(s-l))<0?l+6.283185307179586:l)>o&&(e^=1),!(r=0|i[r>>2])){r=22;break}}if(22==(0|r))return 0|e}else{e=0,r=A;A:for(;;){for(;s=+n[r>>3],l=+n[r+8>>3],h=0|i[(r=r+16|0)>>2],f=+n[(h=0==(0|h)?A:h)>>3],a=+n[h+8>>3],s>f?(u=s,s=l):(u=f,f=s,s=a,a=l),tu;)if(!(r=0|i[r>>2])){r=22;break A}if(a+(t-f)/(u-f)*(s-a)>(o=s==o|a==o?o+-2220446049250313e-31:o)&&(e^=1),!(r=0|i[r>>2])){r=22;break}}if(22==(0|r))return 0|e}return 0}function $A(A,e,r,n,o){r|=0,n|=0,o|=0;var a,f,s,u,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0;if(u=I,I=I+32|0,v=u+16|0,s=u,l=0|Qe(0|(A|=0),0|(e|=0),52),M(),l&=15,p=0|Qe(0|r,0|n,52),M(),(0|l)!=(15&p|0))return I=u,0|(v=1);if(g=0|Qe(0|A,0|e,45),M(),g&=127,w=0|Qe(0|r,0|n,45),M(),p=(0|g)!=(0|(w&=127))){if(7==(0|(c=0|z(g,w))))return I=u,0|(v=2);7==(0|(d=0|z(w,g)))?Q(22925,22949,151,22959):(B=c,h=d)}else B=0,h=0;a=0|S(g),f=0|S(w),i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0;do{if(B){if(c=(0|(w=0|i[4304+(28*g|0)+(B<<2)>>2]))>0,f)if(c){g=0,d=r,c=n;do{d=0|VA(d,c),c=0|M(),1==(0|(h=0|sA(h)))&&(h=0|sA(1)),g=g+1|0}while((0|g)!=(0|w));w=h,g=d,d=c}else w=h,g=r,d=n;else if(c){g=0,d=r,c=n;do{d=0|HA(d,c),c=0|M(),h=0|sA(h),g=g+1|0}while((0|g)!=(0|w));w=h,g=d,d=c}else w=h,g=r,d=n;if(zA(g,d,v),p||Q(22972,22949,181,22959),(c=0!=(0|a))&(h=0!=(0|f))&&Q(22999,22949,182,22959),c){if(h=0|GA(A,e),0|t[22032+(7*h|0)+B>>0]){l=3;break}g=d=0|i[21200+(28*h|0)+(B<<2)>>2],b=26}else if(h){if(h=0|GA(g,d),0|t[22032+(7*h|0)+w>>0]){l=4;break}g=0,d=0|i[21200+(28*w|0)+(h<<2)>>2],b=26}else h=0;if(26==(0|b))if((0|d)<=-1&&Q(23030,22949,212,22959),(0|g)<=-1&&Q(23053,22949,213,22959),(0|d)>0){c=v+4|0,h=0;do{aA(c),h=h+1|0}while((0|h)!=(0|d));h=g}else h=g;if(i[s>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,nA(s,B),0|l)for(;0|RA(l)?tA(s):iA(s),(0|l)>1;)l=l+-1|0;if((0|h)>0){l=0;do{aA(s),l=l+1|0}while((0|l)!=(0|h))}X(b=v+4|0,s,b),J(b),b=50}else if(zA(r,n,v),0!=(0|a)&0!=(0|f))if((0|w)!=(0|g)&&Q(23077,22949,243,22959),h=0|GA(A,e),l=0|GA(r,n),0|t[22032+(7*h|0)+l>>0])l=5;else if((0|(h=0|i[21200+(28*h|0)+(l<<2)>>2]))>0){c=v+4|0,l=0;do{aA(c),l=l+1|0}while((0|l)!=(0|h));b=50}else b=50;else b=50}while(0);return 50==(0|b)&&(l=v+4|0,i[o>>2]=i[l>>2],i[o+4>>2]=i[l+4>>2],i[o+8>>2]=i[l+8>>2],l=0),I=u,0|(v=l)}function Ae(A,e,r,t){r|=0,t|=0;var n,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0;if(o=I,I=I+48|0,s=o+36|0,u=o+24|0,l=o+12|0,h=o,f=0|Qe(0|(A|=0),0|(e|=0),52),M(),f&=15,d=0|Qe(0|A,0|e,45),M(),n=0|S(d&=127),ye(0|f,0,52),p=134225919|M(),i[(w=t)>>2]=-1,i[w+4>>2]=p,!f)return(0|i[r>>2])>1||(0|i[r+4>>2])>1||(0|i[r+8>>2])>1||127==(0|(a=0|L(d,0|AA(r))))?(I=o,0|(p=1)):(g=0|ye(0|a,0,45),w=0|M(),w=-1040385&i[(d=t)+4>>2]|w,i[(p=t)>>2]=i[d>>2]|g,i[p+4>>2]=w,I=o,0|(p=0));for(i[s>>2]=i[r>>2],i[s+4>>2]=i[r+4>>2],i[s+8>>2]=i[r+8>>2];i[u>>2]=i[s>>2],i[u+4>>2]=i[s+4>>2],i[u+8>>2]=i[s+8>>2],0|RA(f)?(eA(s),i[l>>2]=i[s>>2],i[l+4>>2]=i[s+4>>2],i[l+8>>2]=i[s+8>>2],tA(l)):(rA(s),i[l>>2]=i[s>>2],i[l+4>>2]=i[s+4>>2],i[l+8>>2]=i[s+8>>2],iA(l)),q(u,l,h),J(h),B=0|i[(w=t)>>2],w=0|i[w+4>>2],r=0|ye(7,0,0|(b=3*(15-f|0)|0)),w&=~(0|M()),b=0|ye(0|AA(h),0,0|b),w=0|M()|w,i[(p=t)>>2]=b|B&~r,i[p+4>>2]=w,(0|f)>1;)f=f+-1|0;A:do{if((0|i[s>>2])<=1&&(0|i[s+4>>2])<=1&&(0|i[s+8>>2])<=1){h=127==(0|(u=0|L(d,f=0|AA(s))))?0:0|S(u);e:do{if(f){if(n){if(s=21408+(28*(0|GA(A,e))|0)+(f<<2)|0,(0|(s=0|i[s>>2]))>0){r=0;do{f=0|fA(f),r=r+1|0}while((0|r)!=(0|s))}if(1==(0|f)){a=3;break A}127==(0|(r=0|L(d,f)))&&Q(23104,22949,376,23134),0|S(r)?Q(23147,22949,377,23134):(g=s,c=f,a=r)}else g=0,c=f,a=u;if((0|(l=0|i[4304+(28*d|0)+(c<<2)>>2]))<=-1&&Q(23178,22949,384,23134),!h){if((0|g)<=-1&&Q(23030,22949,417,23134),0|g){f=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];do{r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,f=f+1|0}while((0|f)<(0|g))}if((0|l)<=0){f=54;break}for(f=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];;)if(r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,(0|(f=f+1|0))==(0|l)){f=54;break e}}if(7==(0|(u=0|z(a,d)))&&Q(22925,22949,393,23134),r=0|i[(f=t)>>2],f=0|i[f+4>>2],(0|l)>0){s=0;do{r=0|TA(r,f),f=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=f,s=s+1|0}while((0|s)!=(0|l))}if(r=0|GA(r,f),b=0|T(a),(0|(r=0|i[(b?21824:21616)+(28*u|0)+(r<<2)>>2]))<=-1&&Q(23030,22949,412,23134),r){f=0,s=0|i[(u=t)>>2],u=0|i[u+4>>2];do{s=0|SA(s,u),u=0|M(),i[(b=t)>>2]=s,i[b+4>>2]=u,f=f+1|0}while((0|f)<(0|r));f=54}else f=54}else if(0!=(0|n)&0!=(0|h))if(f=21408+(28*(b=0|GA(A,e))|0)+((0|GA(0|i[(f=t)>>2],0|i[f+4>>2]))<<2)|0,(0|(f=0|i[f>>2]))<=-1&&Q(23201,22949,433,23134),f){a=0,r=0|i[(s=t)>>2],s=0|i[s+4>>2];do{r=0|TA(r,s),s=0|M(),i[(b=t)>>2]=r,i[b+4>>2]=s,a=a+1|0}while((0|a)<(0|f));a=u,f=54}else a=u,f=55;else a=u,f=54}while(0);if(54==(0|f)&&h&&(f=55),55==(0|f)&&1==(0|GA(0|i[(b=t)>>2],0|i[b+4>>2]))){a=4;break}p=0|i[(b=t)>>2],b=-1040385&i[b+4>>2],B=0|ye(0|a,0,45),b=0|b|M(),i[(a=t)>>2]=p|B,i[a+4>>2]=b,a=0}else a=2}while(0);return I=o,0|(b=a)}function ee(A,e){var r=0;if(!(e|=0))return 0|(r=1);r=A|=0,A=1;do{A=0|b(0==(1&e|0)?1:r,A),e>>=1,r=0|b(r,r)}while(0!=(0|e));return 0|A}function re(A,e,r){A|=0;var t,o,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0;if(!(0|O(e|=0,r|=0)))return 0|(d=0);if(e=0|Y(e),o=+n[r>>3],a=e&(a=+n[r+8>>3])<0?a+6.283185307179586:a,(0|(d=0|i[A>>2]))<=0)return 0|(d=0);if(t=0|i[A+4>>2],e){e=0,r=-1,A=0;A:for(;;){for(c=A;u=+n[t+(c<<4)>>3],h=+n[t+(c<<4)+8>>3],s=+n[t+((A=(r+2|0)%(0|d)|0)<<4)>>3],f=+n[t+(A<<4)+8>>3],u>s?(l=u,u=h):(l=s,s=u,u=f,f=h),ol;){if(!((0|(r=c+1|0))<(0|d))){r=22;break A}A=c,c=r,r=A}if(a=(u=u<0?u+6.283185307179586:u)==a|(h=f<0?f+6.283185307179586:f)==a?a+-2220446049250313e-31:a,((h+=(o-s)/(l-s)*(u-h))<0?h+6.283185307179586:h)>a&&(e^=1),(0|(A=c+1|0))>=(0|d)){r=22;break}r=c}if(22==(0|r))return 0|e}else{e=0,r=-1,A=0;A:for(;;){for(c=A;u=+n[t+(c<<4)>>3],h=+n[t+(c<<4)+8>>3],s=+n[t+((A=(r+2|0)%(0|d)|0)<<4)>>3],f=+n[t+(A<<4)+8>>3],u>s?(l=u,u=h):(l=s,s=u,u=f,f=h),ol;){if(!((0|(r=c+1|0))<(0|d))){r=22;break A}A=c,c=r,r=A}if(f+(o-s)/(l-s)*(u-f)>(a=u==a|f==a?a+-2220446049250313e-31:a)&&(e^=1),(0|(A=c+1|0))>=(0|d)){r=22;break}r=c}if(22==(0|r))return 0|e}return 0}function te(A,e){e|=0;var r,t,o,a,s,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0;if(!(t=0|i[(A|=0)>>2]))return i[e>>2]=0,i[e+4>>2]=0,i[e+8>>2]=0,i[e+12>>2]=0,i[e+16>>2]=0,i[e+20>>2]=0,i[e+24>>2]=0,void(i[e+28>>2]=0);if(n[(o=e+8|0)>>3]=17976931348623157e292,n[(a=e+24|0)>>3]=17976931348623157e292,n[e>>3]=-17976931348623157e292,n[(s=e+16|0)>>3]=-17976931348623157e292,!((0|t)<=0)){for(r=0|i[A+4>>2],p=17976931348623157e292,B=-17976931348623157e292,b=0,A=-1,c=17976931348623157e292,d=17976931348623157e292,w=-17976931348623157e292,l=-17976931348623157e292,v=0;u=+n[r+(v<<4)>>3],g=+n[r+(v<<4)+8>>3],h=+n[r+(((0|(A=A+2|0))==(0|t)?0:A)<<4)+8>>3],u>3]=u,c=u),g>3]=g,d=g),u>w?n[e>>3]=u:u=w,g>l&&(n[s>>3]=g,l=g),p=g>0&gB?g:B,b|=+f(+(g-h))>3.141592653589793,(0|(A=v+1|0))!=(0|t);)m=v,w=u,v=A,A=m;b&&(n[s>>3]=B,n[a>>3]=p)}}function ie(A,e){e|=0;var r,t=0,o=0,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,Q=0,y=0,E=0;if(B=0|i[(A|=0)>>2]){if(n[(b=e+8|0)>>3]=17976931348623157e292,n[(v=e+24|0)>>3]=17976931348623157e292,n[e>>3]=-17976931348623157e292,n[(m=e+16|0)>>3]=-17976931348623157e292,(0|B)>0){for(a=0|i[A+4>>2],w=17976931348623157e292,p=-17976931348623157e292,o=0,t=-1,h=17976931348623157e292,c=17976931348623157e292,g=-17976931348623157e292,u=-17976931348623157e292,k=0;s=+n[a+(k<<4)>>3],d=+n[a+(k<<4)+8>>3],l=+n[a+(((0|(y=t+2|0))==(0|B)?0:y)<<4)+8>>3],s>3]=s,h=s),d>3]=d,c=d),s>g?n[e>>3]=s:s=g,d>u&&(n[m>>3]=d,u=d),w=d>0&dp?d:p,o|=+f(+(d-l))>3.141592653589793,(0|(t=k+1|0))!=(0|B);)y=k,g=s,k=t,t=y;o&&(n[m>>3]=p,n[v>>3]=w)}}else i[e>>2]=0,i[e+4>>2]=0,i[e+8>>2]=0,i[e+12>>2]=0,i[e+16>>2]=0,i[e+20>>2]=0,i[e+24>>2]=0,i[e+28>>2]=0;if(!((0|(t=0|i[(y=A+8|0)>>2]))<=0)){r=A+12|0,Q=0;do{if(a=0|i[r>>2],o=Q,v=e+((Q=Q+1|0)<<5)|0,m=0|i[a+(o<<3)>>2]){if(n[(k=e+(Q<<5)+8|0)>>3]=17976931348623157e292,n[(A=e+(Q<<5)+24|0)>>3]=17976931348623157e292,n[v>>3]=-17976931348623157e292,n[(M=e+(Q<<5)+16|0)>>3]=-17976931348623157e292,(0|m)>0){for(B=0|i[a+(o<<3)+4>>2],w=17976931348623157e292,p=-17976931348623157e292,a=0,o=-1,b=0,h=17976931348623157e292,c=17976931348623157e292,d=-17976931348623157e292,u=-17976931348623157e292;s=+n[B+(b<<4)>>3],g=+n[B+(b<<4)+8>>3],l=+n[B+(((0|(o=o+2|0))==(0|m)?0:o)<<4)+8>>3],s>3]=s,h=s),g>3]=g,c=g),s>d?n[v>>3]=s:s=d,g>u&&(n[M>>3]=g,u=g),w=g>0&gp?g:p,a|=+f(+(g-l))>3.141592653589793,(0|(o=b+1|0))!=(0|m);)E=b,b=o,d=s,o=E;a&&(n[M>>3]=p,n[A>>3]=w)}}else i[v>>2]=0,i[v+4>>2]=0,i[v+8>>2]=0,i[v+12>>2]=0,i[v+16>>2]=0,i[v+20>>2]=0,i[v+24>>2]=0,i[v+28>>2]=0,t=0|i[y>>2]}while((0|Q)<(0|t))}}function ne(A,e,r){var t=0,n=0,o=0;if(!(0|re(A|=0,e|=0,r|=0)))return 0|(n=0);if((0|i[(n=A+8|0)>>2])<=0)return 0|(n=1);for(t=A+12|0,A=0;;){if(o=A,A=A+1|0,0|re((0|i[t>>2])+(o<<3)|0,e+(A<<5)|0,r)){A=0,t=6;break}if((0|A)>=(0|i[n>>2])){A=1,t=6;break}}return 6==(0|t)?0|A:0}function oe(A,e,r,t,i){e|=0,r|=0,t|=0,i|=0;var o,a,f,s,u,l,h,c=0;s=+n[(A|=0)>>3],f=+n[e>>3]-s,a=+n[A+8>>3],o=+n[e+8>>3]-a,l=+n[r>>3],c=((c=+n[t>>3]-l)*(a-(h=+n[r+8>>3]))-(s-l)*(u=+n[t+8>>3]-h))/(f*u-o*c),n[i>>3]=s+f*c,n[i+8>>3]=a+o*c}function ae(A,e){return e|=0,+n[(A|=0)>>3]!=+n[e>>3]?0|(e=0):0|(e=+n[A+8>>3]==+n[e+8>>3])}function fe(A,e){e|=0;var r,t,i;return+((i=+n[(A|=0)>>3]-+n[e>>3])*i+(t=+n[A+8>>3]-+n[e+8>>3])*t+(r=+n[A+16>>3]-+n[e+16>>3])*r)}function se(A,e,r){A|=0,r|=0;var t=0;(0|(e|=0))>0?(t=0|be(e,4),i[A>>2]=t,t||Q(23230,23253,40,23267)):i[A>>2]=0,i[A+4>>2]=e,i[A+8>>2]=0,i[A+12>>2]=r}function ue(A){var e,r,t,o=0,a=0,s=0,l=0;e=(A|=0)+4|0,r=A+12|0,t=A+8|0;A:for(;;){for(a=0|i[e>>2],o=0;;){if((0|o)>=(0|a))break A;if(s=0|i[A>>2],l=0|i[s+(o<<2)>>2])break;o=o+1|0}o=s+(~~(+f(+ +u(10,+ +(15-(0|i[r>>2])|0))*(+n[l>>3]+ +n[l+8>>3]))%+(0|a))>>>0<<2)|0,a=0|i[o>>2];e:do{if(0|a){if(s=l+32|0,(0|a)==(0|l))i[o>>2]=i[s>>2];else{if(!(o=0|i[(a=a+32|0)>>2]))break;for(;(0|o)!=(0|l);)if(!(o=0|i[(a=o+32|0)>>2]))break e;i[a>>2]=i[s>>2]}Be(l),i[t>>2]=(0|i[t>>2])-1}}while(0)}Be(0|i[A>>2])}function le(A){var e,r=0,t=0;for(e=0|i[(A|=0)+4>>2],t=0;;){if((0|t)>=(0|e)){r=0,t=4;break}if(r=0|i[(0|i[A>>2])+(t<<2)>>2]){t=4;break}t=t+1|0}return 4==(0|t)?0|r:0}function he(A,e){e|=0;var r=0,t=0,o=0,a=0;if(r=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,r=(0|i[A>>2])+(r<<2)|0,!(t=0|i[r>>2]))return 0|(a=1);a=e+32|0;do{if((0|t)!=(0|e)){if(!(r=0|i[t+32>>2]))return 0|(a=1);for(o=r;;){if((0|o)==(0|e)){o=8;break}if(!(r=0|i[o+32>>2])){r=1,o=10;break}t=o,o=r}if(8==(0|o)){i[t+32>>2]=i[a>>2];break}if(10==(0|o))return 0|r}else i[r>>2]=i[a>>2]}while(0);return Be(e),i[(a=A+8|0)>>2]=(0|i[a>>2])-1,0|(a=0)}function ce(A,e,r){A|=0,e|=0,r|=0;var t,o=0,a=0,s=0;(t=0|pe(40))||Q(23283,23253,98,23296),i[t>>2]=i[e>>2],i[t+4>>2]=i[e+4>>2],i[t+8>>2]=i[e+8>>2],i[t+12>>2]=i[e+12>>2],i[(a=t+16|0)>>2]=i[r>>2],i[a+4>>2]=i[r+4>>2],i[a+8>>2]=i[r+8>>2],i[a+12>>2]=i[r+12>>2],i[t+32>>2]=0,a=~~(+f(+ +u(10,+ +(15-(0|i[A+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,a=(0|i[A>>2])+(a<<2)|0,o=0|i[a>>2];do{if(o){for(;!(0|xA(o,e)&&0|xA(o+16|0,r));)if(a=0|i[o+32>>2],!(0|i[(o=0==(0|a)?o:a)+32>>2])){s=10;break}if(10==(0|s)){i[o+32>>2]=t;break}return Be(t),0|(s=o)}i[a>>2]=t}while(0);return i[(s=A+8|0)>>2]=1+(0|i[s>>2]),0|(s=t)}function de(A,e,r){e|=0,r|=0;var t=0,o=0;if(o=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,!(o=0|i[(0|i[A>>2])+(o<<2)>>2]))return 0|(r=0);if(!r){for(A=o;;){if(0|xA(A,e)){t=10;break}if(!(A=0|i[A+32>>2])){A=0,t=10;break}}if(10==(0|t))return 0|A}for(A=o;;){if(0|xA(A,e)&&0|xA(A+16|0,r)){t=10;break}if(!(A=0|i[A+32>>2])){A=0,t=10;break}}return 10==(0|t)?0|A:0}function ge(A,e){e|=0;var r=0;if(r=~~(+f(+ +u(10,+ +(15-(0|i[(A|=0)+12>>2])|0))*(+n[e>>3]+ +n[e+8>>3]))%+(0|i[A+4>>2]))>>>0,!(A=0|i[(0|i[A>>2])+(r<<2)>>2]))return 0|(r=0);for(;;){if(0|xA(A,e)){e=5;break}if(!(A=0|i[A+32>>2])){A=0,e=5;break}}return 5==(0|e)?0|A:0}function we(A){return 0|~~+function(A){return+ +Ie(+(A=+A))}(A=+A)}function pe(A){A|=0;var e,r=0,t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0;e=I,I=I+16|0,d=e;do{if(A>>>0<245){if(A=(l=A>>>0<11?16:A+11&-8)>>>3,3&(t=(c=0|i[5829])>>>A)|0)return n=0|i[(t=(A=23356+((r=(1&t^1)+A|0)<<1<<2)|0)+8|0)>>2],(0|(a=0|i[(o=n+8|0)>>2]))==(0|A)?i[5829]=c&~(1<>2]=A,i[t>>2]=a),k=r<<3,i[n+4>>2]=3|k,i[(k=n+k+4|0)>>2]=1|i[k>>2],I=e,0|(k=o);if(l>>>0>(h=0|i[5831])>>>0){if(0|t)return r=((r=t<>>=s=r>>>12&16)>>>5&8)|s|(a=(r>>>=t)>>>2&4)|(A=(r>>>=a)>>>1&2)|(n=(r>>>=A)>>>1&1))+(r>>>n)|0)<<1<<2)|0)+8|0)>>2],(0|(t=0|i[(s=a+8|0)>>2]))==(0|r)?(A=c&~(1<>2]=r,i[A>>2]=t,A=c),f=(k=n<<3)-l|0,i[a+4>>2]=3|l,i[(o=a+l|0)+4>>2]=1|f,i[a+k>>2]=f,0|h&&(n=0|i[5834],t=23356+((r=h>>>3)<<1<<2)|0,A&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=n,i[r+12>>2]=n,i[n+8>>2]=r,i[n+12>>2]=t),i[5831]=f,i[5834]=o,I=e,0|(k=s);if(a=0|i[5830]){for(t=(a&0-a)-1|0,t=u=0|i[23620+(((n=(t>>>=o=t>>>12&16)>>>5&8)|o|(f=(t>>>=n)>>>2&4)|(s=(t>>>=f)>>>1&2)|(u=(t>>>=s)>>>1&1))+(t>>>u)<<2)>>2],s=u,u=(-8&i[u+4>>2])-l|0;(A=0|i[t+16>>2])||(A=0|i[t+20>>2]);)t=A,s=(o=(f=(-8&i[A+4>>2])-l|0)>>>0>>0)?A:s,u=o?f:u;if((f=s+l|0)>>>0>s>>>0){o=0|i[s+24>>2],r=0|i[s+12>>2];do{if((0|r)==(0|s)){if(!(r=0|i[(A=s+20|0)>>2])&&!(r=0|i[(A=s+16|0)>>2])){t=0;break}for(;;)if(t=0|i[(n=r+20|0)>>2])r=t,A=n;else{if(!(t=0|i[(n=r+16|0)>>2]))break;r=t,A=n}i[A>>2]=0,t=r}else t=0|i[s+8>>2],i[t+12>>2]=r,i[r+8>>2]=t,t=r}while(0);do{if(0|o){if(r=0|i[s+28>>2],(0|s)==(0|i[(A=23620+(r<<2)|0)>>2])){if(i[A>>2]=t,!t){i[5830]=a&~(1<>2])==(0|s)?k:o+20|0)>>2]=t,!t)break;i[t+24>>2]=o,0|(r=0|i[s+16>>2])&&(i[t+16>>2]=r,i[r+24>>2]=t),0|(r=0|i[s+20>>2])&&(i[t+20>>2]=r,i[r+24>>2]=t)}}while(0);return u>>>0<16?(k=u+l|0,i[s+4>>2]=3|k,i[(k=s+k+4|0)>>2]=1|i[k>>2]):(i[s+4>>2]=3|l,i[f+4>>2]=1|u,i[f+u>>2]=u,0|h&&(n=0|i[5834],t=23356+((r=h>>>3)<<1<<2)|0,(r=1<>2]:(i[5829]=r|c,r=t,A=t+8|0),i[A>>2]=n,i[r+12>>2]=n,i[n+8>>2]=r,i[n+12>>2]=t),i[5831]=u,i[5834]=f),I=e,0|(k=s+8|0)}c=l}else c=l}else c=l}else if(A>>>0<=4294967231)if(l=-8&(A=A+11|0),n=0|i[5830]){o=0-l|0,u=(A>>>=8)?l>>>0>16777215?31:l>>>((u=14-((s=((p=A<<(c=(A+1048320|0)>>>16&8))+520192|0)>>>16&4)|c|(u=((p<<=s)+245760|0)>>>16&2))+(p<>>15)|0)+7|0)&1|u<<1:0,t=0|i[23620+(u<<2)>>2];A:do{if(t)for(A=0,s=l<<(31==(0|u)?0:25-(u>>>1)|0),a=0;;){if((f=(-8&i[t+4>>2])-l|0)>>>0>>0){if(!f){A=t,o=0,p=65;break A}A=t,o=f}if(a=0==(0|(p=0|i[t+20>>2]))|(0|p)==(0|(t=0|i[t+16+(s>>>31<<2)>>2]))?a:p,!t){t=a,p=61;break}s<<=1}else t=0,A=0,p=61}while(0);if(61==(0|p)){if(0==(0|t)&0==(0|A)){if(!(A=((A=2<>>=f=c>>>12&16)>>>5&8)|f|(s=(c>>>=a)>>>2&4)|(u=(c>>>=s)>>>1&2)|(t=(c>>>=u)>>>1&1))+(c>>>t)<<2)>>2]}t?p=65:(s=A,f=o)}if(65==(0|p))for(a=t;;){if(o=(t=(c=(-8&i[a+4>>2])-l|0)>>>0>>0)?c:o,A=t?a:A,(t=0|i[a+16>>2])||(t=0|i[a+20>>2]),!t){s=A,f=o;break}a=t}if(0!=(0|s)&&f>>>0<((0|i[5831])-l|0)>>>0&&(h=s+l|0)>>>0>s>>>0){a=0|i[s+24>>2],r=0|i[s+12>>2];do{if((0|r)==(0|s)){if(!(r=0|i[(A=s+20|0)>>2])&&!(r=0|i[(A=s+16|0)>>2])){r=0;break}for(;;)if(t=0|i[(o=r+20|0)>>2])r=t,A=o;else{if(!(t=0|i[(o=r+16|0)>>2]))break;r=t,A=o}i[A>>2]=0}else k=0|i[s+8>>2],i[k+12>>2]=r,i[r+8>>2]=k}while(0);do{if(a){if(A=0|i[s+28>>2],(0|s)==(0|i[(t=23620+(A<<2)|0)>>2])){if(i[t>>2]=r,!r){n&=~(1<>2])==(0|s)?k:a+20|0)>>2]=r,!r)break;i[r+24>>2]=a,0|(A=0|i[s+16>>2])&&(i[r+16>>2]=A,i[A+24>>2]=r),(A=0|i[s+20>>2])&&(i[r+20>>2]=A,i[A+24>>2]=r)}}while(0);A:do{if(f>>>0<16)k=f+l|0,i[s+4>>2]=3|k,i[(k=s+k+4|0)>>2]=1|i[k>>2];else{if(i[s+4>>2]=3|l,i[h+4>>2]=1|f,i[h+f>>2]=f,r=f>>>3,f>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=h,i[r+12>>2]=h,i[h+8>>2]=r,i[h+12>>2]=t;break}if(r=23620+((t=(r=f>>>8)?f>>>0>16777215?31:f>>>((t=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(t=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|t<<1:0)<<2)|0,i[h+28>>2]=t,i[(A=h+16|0)+4>>2]=0,i[A>>2]=0,!(n&(A=1<>2]=h,i[h+24>>2]=r,i[h+12>>2]=h,i[h+8>>2]=h;break}r=0|i[r>>2];e:do{if((-8&i[r+4>>2]|0)!=(0|f)){for(n=f<<(31==(0|t)?0:25-(t>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|f)){r=A;break e}n<<=1,r=A}i[t>>2]=h,i[h+24>>2]=r,i[h+12>>2]=h,i[h+8>>2]=h;break A}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=h,i[m>>2]=h,i[h+8>>2]=k,i[h+12>>2]=r,i[h+24>>2]=0}}while(0);return I=e,0|(k=s+8|0)}c=l}else c=l;else c=-1}while(0);if((t=0|i[5831])>>>0>=c>>>0)return r=t-c|0,A=0|i[5834],r>>>0>15?(k=A+c|0,i[5834]=k,i[5831]=r,i[k+4>>2]=1|r,i[A+t>>2]=r,i[A+4>>2]=3|c):(i[5831]=0,i[5834]=0,i[A+4>>2]=3|t,i[(k=A+t+4|0)>>2]=1|i[k>>2]),I=e,0|(k=A+8|0);if((f=0|i[5832])>>>0>c>>>0)return v=f-c|0,i[5832]=v,m=(k=0|i[5835])+c|0,i[5835]=m,i[m+4>>2]=1|v,i[k+4>>2]=3|c,I=e,0|(k=k+8|0);if(0|i[5947]?A=0|i[5949]:(i[5949]=4096,i[5948]=4096,i[5950]=-1,i[5951]=-1,i[5952]=0,i[5940]=0,i[5947]=-16&d^1431655768,A=4096),s=c+48|0,(l=(a=A+(u=c+47|0)|0)&(o=0-A|0))>>>0<=c>>>0)return I=e,0|(k=0);if(0|(A=0|i[5939])&&(d=(h=0|i[5937])+l|0)>>>0<=h>>>0|d>>>0>A>>>0)return I=e,0|(k=0);A:do{if(4&i[5940])r=0,p=143;else{t=0|i[5835];e:do{if(t){for(n=23764;!((d=0|i[n>>2])>>>0<=t>>>0&&(d+(0|i[n+4>>2])|0)>>>0>t>>>0);){if(!(A=0|i[n+8>>2])){p=128;break e}n=A}if((r=a-f&o)>>>0<2147483647)if((0|(A=0|Fe(0|r)))==((0|i[n>>2])+(0|i[n+4>>2])|0)){if(-1!=(0|A)){f=r,a=A,p=145;break A}}else n=A,p=136;else r=0}else p=128}while(0);do{if(128==(0|p))if(-1!=(0|(t=0|Fe(0)))&&(r=t,w=(r=(0==((w=(g=0|i[5948])+-1|0)&r|0)?0:(w+r&0-g)-r|0)+l|0)+(g=0|i[5937])|0,r>>>0>c>>>0&r>>>0<2147483647)){if(0|(d=0|i[5939])&&w>>>0<=g>>>0|w>>>0>d>>>0){r=0;break}if((0|(A=0|Fe(0|r)))==(0|t)){f=r,a=t,p=145;break A}n=A,p=136}else r=0}while(0);do{if(136==(0|p)){if(t=0-r|0,!(s>>>0>r>>>0&r>>>0<2147483647&-1!=(0|n))){if(-1==(0|n)){r=0;break}f=r,a=n,p=145;break A}if((A=u-r+(A=0|i[5949])&0-A)>>>0>=2147483647){f=r,a=n,p=145;break A}if(-1==(0|Fe(0|A))){Fe(0|t),r=0;break}f=A+r|0,a=n,p=145;break A}}while(0);i[5940]=4|i[5940],p=143}}while(0);if(143==(0|p)&&l>>>0<2147483647&&!(-1==(0|(v=0|Fe(0|l)))|1^(b=(B=(w=0|Fe(0))-v|0)>>>0>(c+40|0)>>>0)|v>>>0>>0&-1!=(0|v)&-1!=(0|w)^1)&&(f=b?B:r,a=v,p=145),145==(0|p)){r=(0|i[5937])+f|0,i[5937]=r,r>>>0>(0|i[5938])>>>0&&(i[5938]=r),u=0|i[5835];A:do{if(u){for(r=23764;;){if((0|a)==((A=0|i[r>>2])+(t=0|i[r+4>>2])|0)){p=154;break}if(!(n=0|i[r+8>>2]))break;r=n}if(154==(0|p)&&(m=r+4|0,0==(8&i[r+12>>2]|0))&&a>>>0>u>>>0&A>>>0<=u>>>0){i[m>>2]=t+f,m=u+(v=0==(7&(v=u+8|0)|0)?0:0-v&7)|0,v=(k=(0|i[5832])+f|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[u+k+4>>2]=40,i[5836]=i[5951];break}for(a>>>0<(0|i[5833])>>>0&&(i[5833]=a),t=a+f|0,r=23764;;){if((0|i[r>>2])==(0|t)){p=162;break}if(!(A=0|i[r+8>>2]))break;r=A}if(162==(0|p)&&0==(8&i[r+12>>2]|0)){i[r>>2]=a,i[(h=r+4|0)>>2]=(0|i[h>>2])+f,l=(h=a+(0==(7&(h=a+8|0)|0)?0:0-h&7)|0)+c|0,s=(r=t+(0==(7&(r=t+8|0)|0)?0:0-r&7)|0)-h-c|0,i[h+4>>2]=3|c;e:do{if((0|u)==(0|r))k=(0|i[5832])+s|0,i[5832]=k,i[5835]=l,i[l+4>>2]=1|k;else{if((0|i[5834])==(0|r)){k=(0|i[5831])+s|0,i[5831]=k,i[5834]=l,i[l+4>>2]=1|k,i[l+k>>2]=k;break}if(1==(3&(A=0|i[r+4>>2])|0)){f=-8&A,n=A>>>3;r:do{if(A>>>0<256){if(A=0|i[r+8>>2],(0|(t=0|i[r+12>>2]))==(0|A)){i[5829]=i[5829]&~(1<>2]=t,i[t+8>>2]=A;break}a=0|i[r+24>>2],A=0|i[r+12>>2];do{if((0|A)==(0|r)){if(A=0|i[(n=(t=r+16|0)+4|0)>>2])t=n;else if(!(A=0|i[t>>2])){A=0;break}for(;;)if(n=0|i[(o=A+20|0)>>2])A=n,t=o;else{if(!(n=0|i[(o=A+16|0)>>2]))break;A=n,t=o}i[t>>2]=0}else k=0|i[r+8>>2],i[k+12>>2]=A,i[A+8>>2]=k}while(0);if(!a)break;n=23620+((t=0|i[r+28>>2])<<2)|0;do{if((0|i[n>>2])==(0|r)){if(i[n>>2]=A,0|A)break;i[5830]=i[5830]&~(1<>2])==(0|r)?k:a+20|0)>>2]=A,!A)break r}while(0);if(i[A+24>>2]=a,0|(n=0|i[(t=r+16|0)>>2])&&(i[A+16>>2]=n,i[n+24>>2]=A),!(t=0|i[t+4>>2]))break;i[A+20>>2]=t,i[t+24>>2]=A}while(0);r=r+f|0,o=f+s|0}else o=s;if(i[(r=r+4|0)>>2]=-2&i[r>>2],i[l+4>>2]=1|o,i[l+o>>2]=o,r=o>>>3,o>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=l,i[r+12>>2]=l,i[l+8>>2]=r,i[l+12>>2]=t;break}r=o>>>8;do{if(r){if(o>>>0>16777215){n=31;break}n=o>>>((n=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(n=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|n<<1}else n=0}while(0);if(r=23620+(n<<2)|0,i[l+28>>2]=n,i[(A=l+16|0)+4>>2]=0,i[A>>2]=0,!((A=0|i[5830])&(t=1<>2]=l,i[l+24>>2]=r,i[l+12>>2]=l,i[l+8>>2]=l;break}r=0|i[r>>2];r:do{if((-8&i[r+4>>2]|0)!=(0|o)){for(n=o<<(31==(0|n)?0:25-(n>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|o)){r=A;break r}n<<=1,r=A}i[t>>2]=l,i[l+24>>2]=r,i[l+12>>2]=l,i[l+8>>2]=l;break e}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=l,i[m>>2]=l,i[l+8>>2]=k,i[l+12>>2]=r,i[l+24>>2]=0}}while(0);return I=e,0|(k=h+8|0)}for(r=23764;!((A=0|i[r>>2])>>>0<=u>>>0&&(k=A+(0|i[r+4>>2])|0)>>>0>u>>>0);)r=0|i[r+8>>2];r=(A=(A=(o=k+-47|0)+(0==(7&(A=o+8|0)|0)?0:0-A&7)|0)>>>0<(o=u+16|0)>>>0?u:A)+8|0,m=a+(v=0==(7&(v=a+8|0)|0)?0:0-v&7)|0,v=(t=f+-40|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[a+t+4>>2]=40,i[5836]=i[5951],i[(t=A+4|0)>>2]=27,i[r>>2]=i[5941],i[r+4>>2]=i[5942],i[r+8>>2]=i[5943],i[r+12>>2]=i[5944],i[5941]=a,i[5942]=f,i[5944]=0,i[5943]=r,r=A+24|0;do{m=r,i[(r=r+4|0)>>2]=7}while((m+8|0)>>>0>>0);if((0|A)!=(0|u)){if(a=A-u|0,i[t>>2]=-2&i[t>>2],i[u+4>>2]=1|a,i[A>>2]=a,r=a>>>3,a>>>0<256){t=23356+(r<<1<<2)|0,(A=0|i[5829])&(r=1<>2]:(i[5829]=A|r,r=t,A=t+8|0),i[A>>2]=u,i[r+12>>2]=u,i[u+8>>2]=r,i[u+12>>2]=t;break}if(t=23620+((n=(r=a>>>8)?a>>>0>16777215?31:a>>>((n=14-((v=((k=r<<(m=(r+1048320|0)>>>16&8))+520192|0)>>>16&4)|m|(n=((k<<=v)+245760|0)>>>16&2))+(k<>>15)|0)+7|0)&1|n<<1:0)<<2)|0,i[u+28>>2]=n,i[u+20>>2]=0,i[o>>2]=0,!((r=0|i[5830])&(A=1<>2]=u,i[u+24>>2]=t,i[u+12>>2]=u,i[u+8>>2]=u;break}r=0|i[t>>2];e:do{if((-8&i[r+4>>2]|0)!=(0|a)){for(n=a<<(31==(0|n)?0:25-(n>>>1)|0);A=0|i[(t=r+16+(n>>>31<<2)|0)>>2];){if((-8&i[A+4>>2]|0)==(0|a)){r=A;break e}n<<=1,r=A}i[t>>2]=u,i[u+24>>2]=r,i[u+12>>2]=u,i[u+8>>2]=u;break A}}while(0);k=0|i[(m=r+8|0)>>2],i[k+12>>2]=u,i[m>>2]=u,i[u+8>>2]=k,i[u+12>>2]=r,i[u+24>>2]=0}}else 0==(0|(k=0|i[5833]))|a>>>0>>0&&(i[5833]=a),i[5941]=a,i[5942]=f,i[5944]=0,i[5838]=i[5947],i[5837]=-1,i[5842]=23356,i[5841]=23356,i[5844]=23364,i[5843]=23364,i[5846]=23372,i[5845]=23372,i[5848]=23380,i[5847]=23380,i[5850]=23388,i[5849]=23388,i[5852]=23396,i[5851]=23396,i[5854]=23404,i[5853]=23404,i[5856]=23412,i[5855]=23412,i[5858]=23420,i[5857]=23420,i[5860]=23428,i[5859]=23428,i[5862]=23436,i[5861]=23436,i[5864]=23444,i[5863]=23444,i[5866]=23452,i[5865]=23452,i[5868]=23460,i[5867]=23460,i[5870]=23468,i[5869]=23468,i[5872]=23476,i[5871]=23476,i[5874]=23484,i[5873]=23484,i[5876]=23492,i[5875]=23492,i[5878]=23500,i[5877]=23500,i[5880]=23508,i[5879]=23508,i[5882]=23516,i[5881]=23516,i[5884]=23524,i[5883]=23524,i[5886]=23532,i[5885]=23532,i[5888]=23540,i[5887]=23540,i[5890]=23548,i[5889]=23548,i[5892]=23556,i[5891]=23556,i[5894]=23564,i[5893]=23564,i[5896]=23572,i[5895]=23572,i[5898]=23580,i[5897]=23580,i[5900]=23588,i[5899]=23588,i[5902]=23596,i[5901]=23596,i[5904]=23604,i[5903]=23604,m=a+(v=0==(7&(v=a+8|0)|0)?0:0-v&7)|0,v=(k=f+-40|0)-v|0,i[5835]=m,i[5832]=v,i[m+4>>2]=1|v,i[a+k+4>>2]=40,i[5836]=i[5951]}while(0);if((r=0|i[5832])>>>0>c>>>0)return v=r-c|0,i[5832]=v,m=(k=0|i[5835])+c|0,i[5835]=m,i[m+4>>2]=1|v,i[k+4>>2]=3|c,I=e,0|(k=k+8|0)}return i[(k=23312)>>2]=12,I=e,0|(k=0)}function Be(A){var e=0,r=0,t=0,n=0,o=0,a=0,f=0,s=0;if(A|=0){r=A+-8|0,n=0|i[5833],s=r+(e=-8&(A=0|i[A+-4>>2]))|0;do{if(1&A)f=r,a=r;else{if(t=0|i[r>>2],!(3&A))return;if(o=t+e|0,(a=r+(0-t)|0)>>>0>>0)return;if((0|i[5834])==(0|a)){if(3!=(3&(e=0|i[(A=s+4|0)>>2])|0)){f=a,e=o;break}return i[5831]=o,i[A>>2]=-2&e,i[a+4>>2]=1|o,void(i[a+o>>2]=o)}if(r=t>>>3,t>>>0<256){if(A=0|i[a+8>>2],(0|(e=0|i[a+12>>2]))==(0|A)){i[5829]=i[5829]&~(1<>2]=e,i[e+8>>2]=A,f=a,e=o;break}n=0|i[a+24>>2],A=0|i[a+12>>2];do{if((0|A)==(0|a)){if(A=0|i[(r=(e=a+16|0)+4|0)>>2])e=r;else if(!(A=0|i[e>>2])){A=0;break}for(;;)if(r=0|i[(t=A+20|0)>>2])A=r,e=t;else{if(!(r=0|i[(t=A+16|0)>>2]))break;A=r,e=t}i[e>>2]=0}else f=0|i[a+8>>2],i[f+12>>2]=A,i[A+8>>2]=f}while(0);if(n){if(e=0|i[a+28>>2],(0|i[(r=23620+(e<<2)|0)>>2])==(0|a)){if(i[r>>2]=A,!A){i[5830]=i[5830]&~(1<>2])==(0|a)?f:n+20|0)>>2]=A,!A){f=a,e=o;break}i[A+24>>2]=n,0|(r=0|i[(e=a+16|0)>>2])&&(i[A+16>>2]=r,i[r+24>>2]=A),(e=0|i[e+4>>2])?(i[A+20>>2]=e,i[e+24>>2]=A,f=a,e=o):(f=a,e=o)}else f=a,e=o}}while(0);if(!(a>>>0>=s>>>0)&&1&(t=0|i[(A=s+4|0)>>2])){if(2&t)i[A>>2]=-2&t,i[f+4>>2]=1|e,i[a+e>>2]=e,n=e;else{if((0|i[5835])==(0|s)){if(s=(0|i[5832])+e|0,i[5832]=s,i[5835]=f,i[f+4>>2]=1|s,(0|f)!=(0|i[5834]))return;return i[5834]=0,void(i[5831]=0)}if((0|i[5834])==(0|s))return s=(0|i[5831])+e|0,i[5831]=s,i[5834]=a,i[f+4>>2]=1|s,void(i[a+s>>2]=s);n=(-8&t)+e|0,r=t>>>3;do{if(t>>>0<256){if(e=0|i[s+8>>2],(0|(A=0|i[s+12>>2]))==(0|e)){i[5829]=i[5829]&~(1<>2]=A,i[A+8>>2]=e;break}o=0|i[s+24>>2],A=0|i[s+12>>2];do{if((0|A)==(0|s)){if(A=0|i[(r=(e=s+16|0)+4|0)>>2])e=r;else if(!(A=0|i[e>>2])){r=0;break}for(;;)if(r=0|i[(t=A+20|0)>>2])A=r,e=t;else{if(!(r=0|i[(t=A+16|0)>>2]))break;A=r,e=t}i[e>>2]=0,r=A}else r=0|i[s+8>>2],i[r+12>>2]=A,i[A+8>>2]=r,r=A}while(0);if(0|o){if(A=0|i[s+28>>2],(0|i[(e=23620+(A<<2)|0)>>2])==(0|s)){if(i[e>>2]=r,!r){i[5830]=i[5830]&~(1<>2])==(0|s)?t:o+20|0)>>2]=r,!r)break;i[r+24>>2]=o,0|(e=0|i[(A=s+16|0)>>2])&&(i[r+16>>2]=e,i[e+24>>2]=r),0|(A=0|i[A+4>>2])&&(i[r+20>>2]=A,i[A+24>>2]=r)}}while(0);if(i[f+4>>2]=1|n,i[a+n>>2]=n,(0|f)==(0|i[5834]))return void(i[5831]=n)}if(A=n>>>3,n>>>0<256)return r=23356+(A<<1<<2)|0,(e=0|i[5829])&(A=1<>2]:(i[5829]=e|A,A=r,e=r+8|0),i[e>>2]=f,i[A+12>>2]=f,i[f+8>>2]=A,void(i[f+12>>2]=r);A=23620+((t=(A=n>>>8)?n>>>0>16777215?31:n>>>((t=14-((o=((s=A<<(a=(A+1048320|0)>>>16&8))+520192|0)>>>16&4)|a|(t=((s<<=o)+245760|0)>>>16&2))+(s<>>15)|0)+7|0)&1|t<<1:0)<<2)|0,i[f+28>>2]=t,i[f+20>>2]=0,i[f+16>>2]=0,e=0|i[5830],r=1<>2];e:do{if((-8&i[A+4>>2]|0)!=(0|n)){for(t=n<<(31==(0|t)?0:25-(t>>>1)|0);e=0|i[(r=A+16+(t>>>31<<2)|0)>>2];){if((-8&i[e+4>>2]|0)==(0|n)){A=e;break e}t<<=1,A=e}i[r>>2]=f,i[f+24>>2]=A,i[f+12>>2]=f,i[f+8>>2]=f;break A}}while(0);s=0|i[(a=A+8|0)>>2],i[s+12>>2]=f,i[a>>2]=f,i[f+8>>2]=s,i[f+12>>2]=A,i[f+24>>2]=0}else i[5830]=e|r,i[A>>2]=f,i[f+24>>2]=A,i[f+12>>2]=f,i[f+8>>2]=f}while(0);if(s=(0|i[5837])-1|0,i[5837]=s,!(0|s)){for(A=23772;A=0|i[A>>2];)A=A+8|0;i[5837]=-1}}}}function be(A,e){e|=0;var r=0;return(A|=0)?(r=0|b(e,A),(e|A)>>>0>65535&&(r=(0|(r>>>0)/(A>>>0))==(0|e)?r:-1)):r=0,(A=0|pe(r))&&3&i[A+-4>>2]?(_e(0|A,0,0|r),0|A):0|A}function ve(A,e,r,t){return 0|(k(0|(t=(e|=0)-(t|=0)-((r|=0)>>>0>(A|=0)>>>0|0)>>>0)),A-r>>>0|0)}function me(A){return 0|((A|=0)?31-(0|m(A^A-1))|0:32)}function ke(A,e,r,t,n){n|=0;var o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0;if(l=A|=0,a=r|=0,f=c=t|=0,!(u=s=e|=0))return o=0!=(0|n),f?o?(i[n>>2]=0|A,i[n+4>>2]=0&e,n=0,0|(k(0|(c=0)),n)):(n=0,0|(k(0|(c=0)),n)):(o&&(i[n>>2]=(l>>>0)%(a>>>0),i[n+4>>2]=0),n=(l>>>0)/(a>>>0)>>>0,0|(k(0|(c=0)),n));o=0==(0|f);do{if(a){if(!o){if((o=(0|m(0|f))-(0|m(0|u))|0)>>>0<=31){a=h=o+1|0,A=l>>>(h>>>0)&(e=o-31>>31)|u<<(f=31-o|0),e&=u>>>(h>>>0),o=0,f=l<>2]=0|A,i[n+4>>2]=s|0&e,n=0,0|(k(0|(c=0)),n)):(n=0,0|(k(0|(c=0)),n))}if((o=a-1|0)&a|0){a=f=33+(0|m(0|a))-(0|m(0|u))|0,A=(h=32-f|0)-1>>31&u>>>((d=f-32|0)>>>0)|(u<>>(f>>>0))&(e=d>>31),e&=u>>>(f>>>0),o=l<<(g=64-f|0)&(s=h>>31),f=(u<>>(d>>>0))&s|l<>31;break}return 0|n&&(i[n>>2]=o&l,i[n+4>>2]=0),1==(0|a)?(g=0|A,0|(k(0|(d=s|0&e)),g)):(d=u>>>((g=0|me(0|a))>>>0)|0,g=u<<32-g|l>>>(g>>>0)|0,0|(k(0|d),g))}if(o)return 0|n&&(i[n>>2]=(u>>>0)%(a>>>0),i[n+4>>2]=0),g=(u>>>0)/(a>>>0)>>>0,0|(k(0|(d=0)),g);if(!l)return 0|n&&(i[n>>2]=0,i[n+4>>2]=(u>>>0)%(f>>>0)),g=(u>>>0)/(f>>>0)>>>0,0|(k(0|(d=0)),g);if(!((o=f-1|0)&f))return 0|n&&(i[n>>2]=0|A,i[n+4>>2]=o&u|0&e),d=0,g=u>>>((0|me(0|f))>>>0),0|(k(0|d),g);if((o=(0|m(0|f))-(0|m(0|u))|0)>>>0<=30){a=e=o+1|0,A=u<<(f=31-o|0)|l>>>(e>>>0),e=u>>>(e>>>0),o=0,f=l<>2]=0|A,i[n+4>>2]=s|0&e,g=0,0|(k(0|(d=0)),g)):(g=0,0|(k(0|(d=0)),g))}while(0);if(a){u=0|function(A,e,r,t){return 0|(k((e|=0)+(t|=0)+((r=(A|=0)+(r|=0)>>>0)>>>0>>0|0)>>>0|0),0|r)}(0|(h=0|r),0|(l=c|0&t),-1,-1),r=0|M(),s=f,f=0;do{t=s,s=o>>>31|s<<1,o=f|o<<1,ve(0|u,0|r,0|(t=A<<1|t>>>31|0),0|(c=A>>>31|e<<1|0)),f=1&(d=(g=0|M())>>31|((0|g)<0?-1:0)<<1),A=0|ve(0|t,0|c,d&h|0,(((0|g)<0?-1:0)>>31|((0|g)<0?-1:0)<<1)&l|0),e=0|M(),a=a-1|0}while(0!=(0|a));u=s,s=0}else u=f,s=0,f=0;return a=0,0|n&&(i[n>>2]=A,i[n+4>>2]=e),g=-2&(o<<1|0)|f,0|(k(0|(d=(0|o)>>>31|(u|a)<<1|0&(a<<1|o>>>31)|s)),g)}function Me(A,e,r,t){var n,o;return o=I,I=I+16|0,ke(A|=0,e|=0,r|=0,t|=0,n=0|o),I=o,0|(k(0|i[n+4>>2]),0|i[n>>2])}function Qe(A,e,r){return A|=0,e|=0,(0|(r|=0))<32?(k(e>>>r|0),A>>>r|(e&(1<>>r-32|0)}function ye(A,e,r){return A|=0,e|=0,(0|(r|=0))<32?(k(e<>>32-r|0),A<=0?+a(A+.5):+B(A-.5)}function De(A,e,r){A|=0,e|=0;var n,o,a=0;if((0|(r|=0))>=8192)return x(0|A,0|e,0|r),0|A;if(o=0|A,n=A+r|0,(3&A)==(3&e)){for(;3&A;){if(!r)return 0|o;t[A>>0]=0|t[e>>0],A=A+1|0,e=e+1|0,r=r-1|0}for(a=(r=-4&n|0)-64|0;(0|A)<=(0|a);)i[A>>2]=i[e>>2],i[A+4>>2]=i[e+4>>2],i[A+8>>2]=i[e+8>>2],i[A+12>>2]=i[e+12>>2],i[A+16>>2]=i[e+16>>2],i[A+20>>2]=i[e+20>>2],i[A+24>>2]=i[e+24>>2],i[A+28>>2]=i[e+28>>2],i[A+32>>2]=i[e+32>>2],i[A+36>>2]=i[e+36>>2],i[A+40>>2]=i[e+40>>2],i[A+44>>2]=i[e+44>>2],i[A+48>>2]=i[e+48>>2],i[A+52>>2]=i[e+52>>2],i[A+56>>2]=i[e+56>>2],i[A+60>>2]=i[e+60>>2],A=A+64|0,e=e+64|0;for(;(0|A)<(0|r);)i[A>>2]=i[e>>2],A=A+4|0,e=e+4|0}else for(r=n-4|0;(0|A)<(0|r);)t[A>>0]=0|t[e>>0],t[A+1>>0]=0|t[e+1>>0],t[A+2>>0]=0|t[e+2>>0],t[A+3>>0]=0|t[e+3>>0],A=A+4|0,e=e+4|0;for(;(0|A)<(0|n);)t[A>>0]=0|t[e>>0],A=A+1|0,e=e+1|0;return 0|o}function _e(A,e,r){e|=0;var n,o=0,a=0,f=0;if(n=(A|=0)+(r|=0)|0,e&=255,(0|r)>=67){for(;3&A;)t[A>>0]=e,A=A+1|0;for(f=e|e<<8|e<<16|e<<24,a=(o=-4&n|0)-64|0;(0|A)<=(0|a);)i[A>>2]=f,i[A+4>>2]=f,i[A+8>>2]=f,i[A+12>>2]=f,i[A+16>>2]=f,i[A+20>>2]=f,i[A+24>>2]=f,i[A+28>>2]=f,i[A+32>>2]=f,i[A+36>>2]=f,i[A+40>>2]=f,i[A+44>>2]=f,i[A+48>>2]=f,i[A+52>>2]=f,i[A+56>>2]=f,i[A+60>>2]=f,A=A+64|0;for(;(0|A)<(0|o);)i[A>>2]=f,A=A+4|0}for(;(0|A)<(0|n);)t[A>>0]=e,A=A+1|0;return n-r|0}function Ie(A){return(A=+A)>=0?+a(A+.5):+B(A-.5)}function Fe(A){A|=0;var e,r,t;return t=0|E(),(0|A)>0&(0|(e=(r=0|i[o>>2])+A|0))<(0|r)|(0|e)<0?(_(0|e),y(12),-1):(0|e)>(0|t)&&!(0|D(0|e))?(y(12),-1):(i[o>>2]=e,0|r)}return{___uremdi3:Me,_bitshift64Lshr:Qe,_bitshift64Shl:ye,_calloc:be,_cellAreaKm2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))>0){if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1!=(0|e)){A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e))}}else o=0;return I=n,6371.007180918475*o*6371.007180918475},_cellAreaM2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))>0){if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1!=(0|e)){A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e))}}else o=0;return I=n,6371.007180918475*o*6371.007180918475*1e3*1e3},_cellAreaRads2:function(A,e){var r,t,n,o=0;if(n=I,I=I+192|0,t=n,OA(A|=0,e|=0,r=n+168|0),jA(A,e,t),(0|(e=0|i[t>>2]))<=0)return I=n,+(o=0);if(o=+_A(t+8|0,t+8+((1!=(0|e)&1)<<4)|0,r)+0,1==(0|e))return I=n,+o;A=1;do{o+=+_A(t+8+(A<<4)|0,t+8+(((0|(A=A+1|0))%(0|e)|0)<<4)|0,r)}while((0|A)<(0|e));return I=n,+o},_compact:function(A,e,r){e|=0;var t,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,Q=0,y=0,E=0;if(!(r|=0))return 0|(y=0);if(n=0|i[(o=A|=0)>>2],!0&0==(15728640&(o=0|i[o+4>>2])|0)){if((0|r)<=0)return 0|(y=0);if(i[(y=e)>>2]=n,i[y+4>>2]=o,1==(0|r))return 0|(y=0);n=1;do{Q=0|i[(k=A+(n<<3)|0)+4>>2],i[(y=e+(n<<3)|0)>>2]=i[k>>2],i[y+4>>2]=Q,n=n+1|0}while((0|n)!=(0|r));return 0|(n=0)}if(!(Q=0|pe(k=r<<3)))return 0|(y=-3);if(De(0|Q,0|A,0|k),!(t=0|be(r,8)))return Be(Q),0|(y=-3);n=r;A:for(;;){v=0|Qe(0|(h=0|i[(f=Q)>>2]),0|(f=0|i[f+4>>2]),52),M(),m=(v&=15)+-1|0,b=(0|n)>0;e:do{if(b){if(B=((0|n)<0)<<31>>31,w=0|ye(0|m,0,52),p=0|M(),m>>>0>15)for(o=0,A=h,r=f;;){if(!(0==(0|A)&0==(0|r))){if(a=0|Qe(0|A,0|r,52),M(),s=(0|(a&=15))<(0|m),a=(0|a)==(0|m),r=0|Me(0|(l=s?0:a?A:0),0|(A=s?0:a?r:0),0|n,0|B),M(),0==(0|(u=0|i[(s=a=t+(r<<3)|0)>>2]))&0==(0|(s=0|i[s+4>>2])))r=l;else for(w=0,g=r,d=s,r=l;;){if((0|w)>(0|n)){y=41;break A}if((0|u)==(0|r)&(-117440513&d|0)==(0|A)){l=0|Qe(0|u,0|d,56),M(),c=(l&=7)+1|0,p=0|Qe(0|u,0|d,45),M();r:do{if(0|S(127&p)){if(u=0|Qe(0|u,0|d,52),M(),!(u&=15)){s=6;break}for(s=1;;){if(!(0==((p=0|ye(7,0,3*(15-s|0)|0))&r|0)&0==((0|M())&A|0))){s=7;break r}if(!(s>>>0>>0)){s=6;break}s=s+1|0}}else s=7}while(0);if((l+2|0)>>>0>s>>>0){y=51;break A}p=0|ye(0|c,0,56),A=0|M()|-117440513&A,i[(s=a)>>2]=0,i[s+4>>2]=0,s=g,r|=p}else s=(g+1|0)%(0|n)|0;if(0==(0|(u=0|i[(d=a=t+(s<<3)|0)>>2]))&0==(0|(d=0|i[d+4>>2])))break;w=w+1|0,g=s}i[(p=a)>>2]=r,i[p+4>>2]=A}if((0|(o=o+1|0))>=(0|n))break e;A=0|i[(r=Q+(o<<3)|0)>>2],r=0|i[r+4>>2]}for(o=0,A=h,r=f;;){if(!(0==(0|A)&0==(0|r))){if(s=0|Qe(0|A,0|r,52),M(),(0|(s&=15))>=(0|m)){if((0|s)!=(0|m)&&(A|=w,r=-15728641&r|p,s>>>0>=v>>>0)){a=m;do{g=0|ye(7,0,3*(14-a|0)|0),a=a+1|0,A|=g,r=0|M()|r}while(a>>>0>>0)}}else A=0,r=0;if(s=0|Me(0|A,0|r,0|n,0|B),M(),!(0==(0|(l=0|i[(u=a=t+(s<<3)|0)>>2]))&0==(0|(u=0|i[u+4>>2]))))for(g=0;;){if((0|g)>(0|n)){y=41;break A}if((0|l)==(0|A)&(-117440513&u|0)==(0|r)){c=0|Qe(0|l,0|u,56),M(),d=(c&=7)+1|0,E=0|Qe(0|l,0|u,45),M();r:do{if(0|S(127&E)){if(l=0|Qe(0|l,0|u,52),M(),!(l&=15)){u=6;break}for(u=1;;){if(!(0==((E=0|ye(7,0,3*(15-u|0)|0))&A|0)&0==((0|M())&r|0))){u=7;break r}if(!(u>>>0>>0)){u=6;break}u=u+1|0}}else u=7}while(0);if((c+2|0)>>>0>u>>>0){y=51;break A}E=0|ye(0|d,0,56),r=0|M()|-117440513&r,i[(d=a)>>2]=0,i[d+4>>2]=0,A|=E}else s=(s+1|0)%(0|n)|0;if(0==(0|(l=0|i[(u=a=t+(s<<3)|0)>>2]))&0==(0|(u=0|i[u+4>>2])))break;g=g+1|0}i[(E=a)>>2]=A,i[E+4>>2]=r}if((0|(o=o+1|0))>=(0|n))break e;A=0|i[(r=Q+(o<<3)|0)>>2],r=0|i[r+4>>2]}}}while(0);if((n+5|0)>>>0<11){y=99;break}if(!(p=0|be((0|n)/6|0,8))){y=58;break}e:do{if(b){g=0,d=0;do{if(!(0==(0|(o=0|i[(A=s=t+(g<<3)|0)>>2]))&0==(0|(A=0|i[A+4>>2])))){u=0|Qe(0|o,0|A,56),M(),r=(u&=7)+1|0,l=-117440513&A,E=0|Qe(0|o,0|A,45),M();r:do{if(0|S(127&E)){if(c=0|Qe(0|o,0|A,52),M(),0|(c&=15))for(a=1;;){if(!(0==(o&(E=0|ye(7,0,3*(15-a|0)|0))|0)&0==(l&(0|M())|0)))break r;if(!(a>>>0>>0))break;a=a+1|0}o|=A=0|ye(0|r,0,56),A=0|M()|l,i[(r=s)>>2]=o,i[r+4>>2]=A,r=u+2|0}}while(0);7==(0|r)&&(i[(E=p+(d<<3)|0)>>2]=o,i[E+4>>2]=-117440513&A,d=d+1|0)}g=g+1|0}while((0|g)!=(0|n));if(b){if(w=((0|n)<0)<<31>>31,c=0|ye(0|m,0,52),g=0|M(),m>>>0>15)for(A=0,o=0;;){do{if(!(0==(0|h)&0==(0|f))){for(u=0|Qe(0|h,0|f,52),M(),a=(0|(u&=15))<(0|m),u=(0|u)==(0|m),a=0|Me(0|(s=a?0:u?h:0),0|(u=a?0:u?f:0),0|n,0|w),M(),r=0;;){if((0|r)>(0|n)){y=98;break A}if((-117440513&(l=0|i[(E=t+(a<<3)|0)+4>>2])|0)==(0|u)&&(0|i[E>>2])==(0|s)){y=70;break}if((0|i[(E=t+((a=(a+1|0)%(0|n)|0)<<3)|0)>>2])==(0|s)&&(0|i[E+4>>2])==(0|u))break;r=r+1|0}if(70==(0|y)&&(y=0,!0&100663296==(117440512&l|0)))break;i[(E=e+(o<<3)|0)>>2]=h,i[E+4>>2]=f,o=o+1|0}}while(0);if((0|(A=A+1|0))>=(0|n)){n=d;break e}h=0|i[(f=Q+(A<<3)|0)>>2],f=0|i[f+4>>2]}for(A=0,o=0;;){do{if(!(0==(0|h)&0==(0|f))){if(u=0|Qe(0|h,0|f,52),M(),(0|(u&=15))>=(0|m))if((0|u)!=(0|m))if(r=h|c,a=-15728641&f|g,u>>>0>>0)u=a;else{s=m;do{E=0|ye(7,0,3*(14-s|0)|0),s=s+1|0,r|=E,a=0|M()|a}while(s>>>0>>0);u=a}else r=h,u=f;else r=0,u=0;for(s=0|Me(0|r,0|u,0|n,0|w),M(),a=0;;){if((0|a)>(0|n)){y=98;break A}if((-117440513&(l=0|i[(E=t+(s<<3)|0)+4>>2])|0)==(0|u)&&(0|i[E>>2])==(0|r)){y=93;break}if((0|i[(E=t+((s=(s+1|0)%(0|n)|0)<<3)|0)>>2])==(0|r)&&(0|i[E+4>>2])==(0|u))break;a=a+1|0}if(93==(0|y)&&(y=0,!0&100663296==(117440512&l|0)))break;i[(E=e+(o<<3)|0)>>2]=h,i[E+4>>2]=f,o=o+1|0}}while(0);if((0|(A=A+1|0))>=(0|n)){n=d;break e}h=0|i[(f=Q+(A<<3)|0)>>2],f=0|i[f+4>>2]}}else o=0,n=d}else o=0,n=0}while(0);if(_e(0|t,0,0|k),De(0|Q,0|p,n<<3|0),Be(p),!n)break;e=e+(o<<3)|0}return 41==(0|y)?(Be(Q),Be(t),0|(E=-1)):51==(0|y)?(Be(Q),Be(t),0|(E=-2)):58==(0|y)?(Be(Q),Be(t),0|(E=-3)):98==(0|y)?(Be(p),Be(Q),Be(t),0|(E=-1)):(99==(0|y)&&De(0|e,0|Q,n<<3|0),Be(Q),Be(t),0|(E=0))},_destroyLinkedPolygon:function(A){var e=0,r=0,t=0,n=0;if(A|=0)for(t=1;;){if(0|(e=0|i[A>>2]))do{if(0|(r=0|i[e>>2]))do{n=r,r=0|i[r+16>>2],Be(n)}while(0!=(0|r));n=e,e=0|i[e+8>>2],Be(n)}while(0!=(0|e));if(e=A,A=0|i[A+8>>2],t||Be(e),!A)break;t=0}},_edgeLengthKm:function(A){return+ +n[20752+((A|=0)<<3)>>3]},_edgeLengthM:function(A){return+ +n[20880+((A|=0)<<3)>>3]},_emscripten_replace_memory:function(A){return t=new Int8Array(A),new Uint8Array(A),i=new Int32Array(A),new Float32Array(A),n=new Float64Array(A),r=A,!0},_exactEdgeLengthKm:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+c)*+l(+a)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)!=(0|e));return I=t,+(d=6371.007180918475*o)},_exactEdgeLengthM:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+c)*+l(+a)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)!=(0|e));return I=t,+(d=6371.007180918475*o*1e3)},_exactEdgeLengthRads:function(A,e){var r,t,o=0,a=0,f=0,u=0,c=0,d=0;if(t=I,I=I+176|0,WA(A|=0,e|=0,r=t),(0|(A=0|i[r>>2]))<=1)return I=t,+(f=0);e=A+-1|0,A=0,o=0,a=+n[r+8>>3],f=+n[r+16>>3];do{c=a,a=+n[r+8+((A=A+1|0)<<4)>>3],d=+h(.5*(a-c)),u=f,f=+n[r+8+(A<<4)+8>>3],u=d*d+(u=+h(.5*(f-u)))*(+l(+a)*+l(+c)*u),o+=2*+p(+ +s(+u),+ +s(+(1-u)))}while((0|A)<(0|e));return I=t,+o},_experimentalH3ToLocalIj:function(A,e,r,t,i){var n,o;return i|=0,o=I,I=I+16|0,(A=0|$A(A|=0,e|=0,r|=0,t|=0,n=o))||(cA(n,i),A=0),I=o,0|A},_experimentalLocalIjToH3:function(A,e,r,t){var i,n;return A|=0,e|=0,t|=0,i=I,I=I+16|0,dA(r|=0,n=i),t=0|Ae(A,e,n,t),I=i,0|t},_free:Be,_geoToH3:LA,_getDestinationH3IndexFromUnidirectionalEdge:function(A,e){A|=0;var r,t,n=0;return r=I,I=I+16|0,n=r,!0&268435456==(2013265920&(e|=0)|0)?(t=0|Qe(0|A,0|e,56),M(),i[n>>2]=0,n=0|U(A,-2130706433&e|134217728,7&t,n),e=0|M(),k(0|e),I=r,0|n):(n=0,k(0|(e=0)),I=r,0|n)},_getH3IndexesFromUnidirectionalEdge:function(A,e,r){A|=0;var t,n,o,a,f=0;o=I,I=I+16|0,t=o,a=!0&268435456==(2013265920&(e|=0)|0),n=-2130706433&e|134217728,i[(f=r|=0)>>2]=a?A:0,i[f+4>>2]=a?n:0,a?(e=0|Qe(0|A,0|e,56),M(),i[t>>2]=0,A=0|U(A,n,7&e,t),e=0|M()):(A=0,e=0),i[(f=r+8|0)>>2]=A,i[f+4>>2]=e,I=o},_getH3UnidirectionalEdge:function(A,e,r,t){var n,o,a=0,f=0,s=0,u=0,l=0;if(o=I,I=I+16|0,n=o,!(0|ZA(A|=0,e|=0,r|=0,t|=0)))return u=0,k(0|(s=0)),I=o,0|u;for(s=-2130706433&e,a=(a=0==(0|UA(A,e)))?1:2;i[n>>2]=0,f=a+1|0,!((0|(l=0|U(A,e,a,n)))==(0|r)&(0|M())==(0|t));){if(!(f>>>0<7)){a=0,A=0,u=6;break}a=f}return 6==(0|u)?(k(0|a),I=o,0|A):(l=0|ye(0|a,0,56),u=0|s|M()|268435456,l|=A,k(0|u),I=o,0|l)},_getH3UnidirectionalEdgeBoundary:WA,_getH3UnidirectionalEdgesFromHexagon:function(A,e,r){r|=0;var t,n=0;t=0==(0|UA(A|=0,e|=0)),e&=-2130706433,i[(n=r)>>2]=t?A:0,i[n+4>>2]=t?285212672|e:0,i[(n=r+8|0)>>2]=A,i[n+4>>2]=301989888|e,i[(n=r+16|0)>>2]=A,i[n+4>>2]=318767104|e,i[(n=r+24|0)>>2]=A,i[n+4>>2]=335544320|e,i[(n=r+32|0)>>2]=A,i[n+4>>2]=352321536|e,i[(r=r+40|0)>>2]=A,i[r+4>>2]=369098752|e},_getOriginH3IndexFromUnidirectionalEdge:function(A,e){var r;return A|=0,k(0|((r=!0&268435456==(2013265920&(e|=0)|0))?-2130706433&e|134217728:0)),0|(r?A:0)},_getPentagonIndexes:NA,_getRes0Indexes:function(A){A|=0;var e=0,r=0,t=0;e=0;do{ye(0|e,0,45),t=134225919|M(),i[(r=A+(e<<3)|0)>>2]=-1,i[r+4>>2]=t,e=e+1|0}while(122!=(0|e))},_h3Distance:function(A,e,r,t){var i,n,o;return r|=0,t|=0,o=I,I=I+32|0,n=o,A=0==(0|$A(A|=0,e|=0,A,e,i=o+12|0))&&0==(0|$A(A,e,r,t,n))?0|hA(i,n):-1,I=o,0|A},_h3GetBaseCell:IA,_h3GetFaces:function A(e,r,t){t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0;n=I,I=I+128|0,h=n+112|0,f=n+96|0,c=n,a=0|Qe(0|(e|=0),0|(r|=0),52),M(),u=15&a,i[h>>2]=u,s=0|Qe(0|e,0|r,45),M(),s&=127;A:do{if(0|S(s)){if(0|u)for(o=1;;){if(!(0==((l=0|ye(7,0,3*(15-o|0)|0))&e|0)&0==((0|M())&r|0))){a=0;break A}if(!(o>>>0>>0))break;o=o+1|0}if(!(1&a))return l=0|ye(u+1|0,0,52),c=0|M()|-15728641&r,A((l|e)&~(h=0|ye(7,0,3*(14-u|0)|0)),c&~(0|M()),t),void(I=n);a=1}else a=0}while(0);YA(e,r,f),a?(mA(f,h,c),l=5):(yA(f,h,c),l=6);A:do{if(0|S(s))if(u)for(o=1;;){if(!(0==((s=0|ye(7,0,3*(15-o|0)|0))&e|0)&0==((0|M())&r|0))){o=8;break A}if(!(o>>>0>>0)){o=20;break}o=o+1|0}else o=20;else o=8}while(0);if(_e(0|t,-1,0|o),a){a=0;do{for(MA(f=c+(a<<4)|0,0|i[h>>2]),f=0|i[f>>2],o=0;!(-1==(0|(u=0|i[(s=t+(o<<2)|0)>>2]))|(0|u)==(0|f));)o=o+1|0;i[s>>2]=f,a=a+1|0}while((0|a)!=(0|l))}else{a=0;do{for(kA(f=c+(a<<4)|0,0|i[h>>2],0,1),f=0|i[f>>2],o=0;!(-1==(0|(u=0|i[(s=t+(o<<2)|0)>>2]))|(0|u)==(0|f));)o=o+1|0;i[s>>2]=f,a=a+1|0}while((0|a)!=(0|l))}I=n},_h3GetResolution:function(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),52),M(),15&e|0},_h3IndexesAreNeighbors:ZA,_h3IsPentagon:UA,_h3IsResClassIII:function(A,e){return e=0|Qe(0|(A|=0),0|(e|=0),52),M(),1&e|0},_h3IsValid:FA,_h3Line:function(A,e,r,t,n){r|=0,t|=0,n|=0;var o,a=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,M=0,Q=0;if(o=I,I=I+48|0,s=o+12|0,M=o,0==(0|$A(A|=0,e|=0,A,e,a=o+24|0))&&0==(0|$A(A,e,r,t,s))){if((0|(k=0|hA(a,s)))<0)return I=o,0|(M=k);for(i[a>>2]=0,i[a+4>>2]=0,i[a+8>>2]=0,i[s>>2]=0,i[s+4>>2]=0,i[s+8>>2]=0,$A(A,e,A,e,a),$A(A,e,r,t,s),gA(a),gA(s),k?(w=+(0|k),m=a,r=c=0|i[a>>2],t=d=0|i[(b=a+4|0)>>2],a=g=0|i[(v=a+8|0)>>2],p=+((0|i[s>>2])-c|0)/w,B=+((0|i[s+4>>2])-d|0)/w,w=+((0|i[s+8>>2])-g|0)/w):(b=t=a+4|0,v=g=a+8|0,m=a,r=0|i[a>>2],t=0|i[t>>2],a=0|i[g>>2],p=0,B=0,w=0),i[M>>2]=r,i[(g=M+4|0)>>2]=t,i[(d=M+8|0)>>2]=a,c=0;;){Q=p*(l=+(0|c))+ +(0|r),u=B*l+ +(0|i[b>>2]),l=w*l+ +(0|i[v>>2]),t=~~+xe(+Q),s=~~+xe(+u),r=~~+xe(+l),Q=+f(+(+(0|t)-Q)),u=+f(+(+(0|s)-u)),l=+f(+(+(0|r)-l));do{if(!(Q>u&Q>l)){if(h=0-t|0,u>l){a=h-r|0;break}a=s,r=h-s|0;break}t=0-(s+r)|0,a=s}while(0);if(i[M>>2]=t,i[g>>2]=a,i[d>>2]=r,wA(M),Ae(A,e,M,n+(c<<3)|0),(0|c)==(0|k))break;c=c+1|0,r=0|i[m>>2]}return I=o,0|(M=0)}return I=o,0|(M=-1)},_h3LineSize:function(A,e,r,t){var i,n,o;return r|=0,t|=0,o=I,I=I+32|0,n=o,A=0==(0|$A(A|=0,e|=0,A,e,i=o+12|0))&&0==(0|$A(A,e,r,t,n))?0|hA(i,n):-1,I=o,(A>>>31^1)+A|0},_h3SetToLinkedGeo:function(A,e,r){r|=0;var t,n,o,a=0;if(o=I,I=I+32|0,t=o,function(A,e,r){A|=0,r|=0;var t,n,o=0,a=0,f=0,s=0,u=0;if(n=I,I=I+176|0,t=n,(0|(e|=0))<1)return se(r,0,0),void(I=n);s=0|Qe(0|i[(s=A)>>2],0|i[s+4>>2],52),M(),se(r,(0|e)>6?e:6,15&s),s=0;do{if(jA(0|i[(o=A+(s<<3)|0)>>2],0|i[o+4>>2],t),(0|(o=0|i[t>>2]))>0){u=0;do{f=t+8+(u<<4)|0,(a=0|de(r,o=t+8+(((0|(u=u+1|0))%(0|o)|0)<<4)|0,f))?he(r,a):ce(r,f,o),o=0|i[t>>2]}while((0|u)<(0|o))}s=s+1|0}while((0|s)!=(0|e));I=n}(A|=0,e|=0,n=o+16|0),i[r>>2]=0,i[r+4>>2]=0,i[r+8>>2]=0,!(A=0|le(n)))return XA(r),ue(n),void(I=o);do{e=0|JA(r);do{KA(e,A),a=A+16|0,i[t>>2]=i[a>>2],i[t+4>>2]=i[a+4>>2],i[t+8>>2]=i[a+8>>2],i[t+12>>2]=i[a+12>>2],he(n,A),A=0|ge(n,t)}while(0!=(0|A));A=0|le(n)}while(0!=(0|A));XA(r),ue(n),I=o},_h3ToCenterChild:function(A,e,r){r|=0;var t=0,i=0;if(t=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(t&=15))<=(0|r)){if((0|t)!=(0|r)&&(A|=i=0|ye(0|r,0,52),e=0|M()|-15728641&e,(0|t)<(0|r)))do{i=0|ye(7,0,3*(14-t|0)|0),t=t+1|0,A&=~i,e&=~(0|M())}while((0|t)<(0|r))}else e=0,A=0;return k(0|e),0|A},_h3ToChildren:PA,_h3ToGeo:OA,_h3ToGeoBoundary:jA,_h3ToParent:CA,_h3UnidirectionalEdgeIsValid:function(A,e){var r=0;if(!(!0&268435456==(2013265920&(e|=0)|0)))return 0|(r=0);switch(r=0|Qe(0|(A|=0),0|e,56),M(),7&r){case 0:case 7:return 0|(r=0)}return!0&16777216==(117440512&e|0)&0!=(0|UA(A,r=-2130706433&e|134217728))?0|(r=0):0|(r=0|FA(A,r))},_hexAreaKm2:function(A){return+ +n[20496+((A|=0)<<3)>>3]},_hexAreaM2:function(A){return+ +n[20624+((A|=0)<<3)>>3]},_hexRing:function(A,e,r,t){A|=0,e|=0,t|=0;var n,o=0,a=0,f=0,s=0,u=0,l=0,h=0;if(n=I,I=I+16|0,h=n,!(r|=0))return i[(h=t)>>2]=A,i[h+4>>2]=e,I=n,0|(h=0);i[h>>2]=0;A:do{if(0|UA(A,e))A=1;else{if(a=(0|r)>0){o=0,l=A;do{if(0==(0|(l=0|U(l,e,4,h)))&0==(0|(e=0|M()))){A=2;break A}if(o=o+1|0,0|UA(l,e)){A=1;break A}}while((0|o)<(0|r));if(i[(u=t)>>2]=l,i[u+4>>2]=e,u=r+-1|0,a){a=0,f=1,o=l,A=e;do{if(0==(0|(o=0|U(o,A,2,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(f<<3)|0)>>2]=o,i[s+4>>2]=A,f=f+1|0,0|UA(o,A)){A=1;break A}a=a+1|0}while((0|a)<(0|r));s=0,a=f;do{if(0==(0|(o=0|U(o,A,3,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(f=t+(a<<3)|0)>>2]=o,i[f+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}s=s+1|0}while((0|s)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,1,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,5,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));f=0;do{if(0==(0|(o=0|U(o,A,4,h)))&0==(0|(A=0|M()))){A=2;break A}if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,a=a+1|0,0|UA(o,A)){A=1;break A}f=f+1|0}while((0|f)<(0|r));for(f=0;;){if(0==(0|(o=0|U(o,A,6,h)))&0==(0|(A=0|M()))){A=2;break A}if((0|f)!=(0|u)){if(i[(s=t+(a<<3)|0)>>2]=o,i[s+4>>2]=A,0|UA(o,A)){A=1;break A}a=a+1|0}if((0|(f=f+1|0))>=(0|r)){f=l,a=e;break}}}else f=l,o=l,a=e,A=e}else i[(f=t)>>2]=A,i[f+4>>2]=e,f=A,o=A,a=e,A=e;A=1&((0|f)!=(0|o)|(0|a)!=(0|A))}}while(0);return I=n,0|(h=A)},_i64Subtract:ve,_kRing:F,_kRingDistances:function(A,e,r,t,i){var n;if(0|C(A|=0,e|=0,r|=0,t|=0,i|=0)){if(_e(0|t,0,(n=1+(0|b(3*r|0,r+1|0))|0)<<3|0),0|i)return _e(0|i,0,n<<2|0),void P(A,e,r,t,i,n,0);(i=0|be(n,4))&&(P(A,e,r,t,i,n,0),Be(i))}},_llvm_minnum_f64:Ee,_llvm_round_f64:xe,_malloc:pe,_maxFaceCount:function(A,e){var r=0,t=0;if(t=0|Qe(0|(A|=0),0|(e|=0),45),M(),!(0|S(127&t)))return 0|(t=2);if(t=0|Qe(0|A,0|e,52),M(),!(t&=15))return 0|(t=5);for(r=1;;){if(!(0==((0|ye(7,0,3*(15-r|0)|0))&A|0)&0==((0|M())&e|0))){r=2,A=6;break}if(!(r>>>0>>0)){r=5,A=6;break}r=r+1|0}return 6==(0|A)?0|r:0},_maxH3ToChildrenSize:function(A,e,r){return r|=0,A=0|Qe(0|(A|=0),0|(e|=0),52),M(),(0|r)<16&(0|(A&=15))<=(0|r)?0|(r=0|ee(7,r-A|0)):0|(r=0)},_maxKringSize:function(A){return 1+(0|b(3*(A|=0)|0,A+1|0))|0},_maxPolyfillSize:function(A,e){e|=0;var r,t=0,n=0,o=0,a=0,f=0;if(r=I,I=I+48|0,o=r+8|0,n=r,a=0|i[(f=A|=0)+4>>2],i[(t=n)>>2]=i[f>>2],i[t+4>>2]=a,te(n,o),o=0|j(o,e),e=0|i[n>>2],(0|(n=0|i[A+8>>2]))<=0)return I=r,0|(f=(f=(a=(0|o)<(0|(f=e)))?f:o)+12|0);t=0|i[A+12>>2],A=0;do{e=(0|i[t+(A<<3)>>2])+e|0,A=A+1|0}while((0|A)<(0|n));return I=r,0|(f=(f=(f=(0|o)<(0|e))?e:o)+12|0)},_maxUncompactSize:function(A,e,r){A|=0,r|=0;var t=0,n=0,o=0,a=0;if((0|(e|=0))<=0)return 0|(r=0);if((0|r)>=16){for(t=0;;){if(!(0==(0|i[(a=A+(t<<3)|0)>>2])&0==(0|i[a+4>>2]))){t=-1,n=13;break}if((0|(t=t+1|0))>=(0|e)){t=0,n=13;break}}if(13==(0|n))return 0|t}t=0,a=0;A:for(;;){o=0|i[(n=A+(a<<3)|0)>>2],n=0|i[n+4>>2];do{if(!(0==(0|o)&0==(0|n))){if(n=0|Qe(0|o,0|n,52),M(),(0|(n&=15))>(0|r)){t=-1,n=13;break A}if((0|n)==(0|r)){t=t+1|0;break}t=(0|ee(7,r-n|0))+t|0;break}}while(0);if((0|(a=a+1|0))>=(0|e)){n=13;break}}return 13==(0|n)?0|t:0},_memcpy:De,_memset:_e,_numHexagons:function(A){var e;return A=0|i[(e=21008+((A|=0)<<3)|0)>>2],k(0|i[e+4>>2]),0|A},_pentagonIndexCount:function(){return 12},_pointDistKm:DA,_pointDistM:function(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))*6371.007180918475*1e3},_pointDistRads:function(A,e){A|=0;var r,t,i,o=0;return t=+n[(e|=0)>>3],r=+n[A>>3],o=(i=+h(.5*(t-r)))*i+(o=+h(.5*(+n[e+8>>3]-+n[A+8>>3])))*(+l(+t)*+l(+r)*o),2*+p(+ +s(+o),+ +s(+(1-o)))},_polyfill:function(A,e,r){var t,n=0,o=0,a=0,f=0,s=0;if(t=I,I=I+48|0,n=t+8|0,o=t,0|function(A,e,r){e|=0,r|=0;var t=0,n=0,o=0,a=0,f=0,s=0,u=0,l=0,h=0,c=0,d=0,g=0,w=0,p=0,B=0,b=0,v=0,m=0,k=0,y=0,E=0,x=0,D=0,_=0,F=0,U=0,S=0,T=0,V=0,H=0;H=I,I=I+112|0,U=H+80|0,s=H+72|0,S=H,T=H+56|0,(V=0|pe(32+(i[(u=(A=A|0)+8|0)>>2]<<5)|0))||Q(22848,22448,800,22456);if(ie(A,V),t=0|i[(o=A)+4>>2],i[(f=s)>>2]=i[o>>2],i[f+4>>2]=t,te(s,U),f=0|j(U,e),t=0|i[s>>2],(0|(o=0|i[u>>2]))>0){a=0|i[A+12>>2],n=0;do{t=(0|i[a+(n<<3)>>2])+t|0,n=n+1|0}while((0|n)!=(0|o))}if(n=0|be(F=(f=(0|f)<(0|t)?t:f)+12|0,8),l=0|be(F,8),i[U>>2]=0,_=0|i[(D=A)+4>>2],i[(t=s)>>2]=i[D>>2],i[t+4>>2]=_,0|(t=0|G(s,F,e,U,n,l)))return Be(n),Be(l),Be(V),I=H,0|(V=t);A:do{if((0|i[u>>2])>0){for(o=A+12|0,t=0;a=0|G((0|i[o>>2])+(t<<3)|0,F,e,U,n,l),t=t+1|0,!(0|a);)if((0|t)>=(0|i[u>>2]))break A;return Be(n),Be(l),Be(V),I=H,0|(V=a)}}while(0);(0|f)>-12&&_e(0|l,0,((0|F)>1?F:1)<<3|0);A:do{if((0|i[U>>2])>0){_=((0|F)<0)<<31>>31,m=n,k=l,y=n,E=n,x=l,D=n,t=n,p=n,B=l,b=l,v=l,n=l;e:for(;;){for(w=0|i[U>>2],d=0,g=0,o=0;;){f=(a=S)+56|0;do{i[a>>2]=0,a=a+4|0}while((0|a)<(0|f));if(0|C(s=0|i[(e=m+(d<<3)|0)>>2],e=0|i[e+4>>2],1,S,0)){f=(a=S)+56|0;do{i[a>>2]=0,a=a+4|0}while((0|a)<(0|f));0|(a=0|be(7,4))&&(P(s,e,1,S,a,7,0),Be(a))}c=0;do{l=0|i[(h=S+(c<<3)|0)>>2],h=0|i[h+4>>2];r:do{if(!(0==(0|l)&0==(0|h))){if(s=0|Me(0|l,0|h,0|F,0|_),M(),!(0==(0|(e=0|i[(f=a=r+(s<<3)|0)>>2]))&0==(0|(f=0|i[f+4>>2]))))for(u=0;;){if((0|u)>(0|F))break e;if((0|e)==(0|l)&(0|f)==(0|h))break r;if(0==(0|(e=0|i[(f=a=r+((s=(s+1|0)%(0|F)|0)<<3)|0)>>2]))&0==(0|(f=0|i[f+4>>2])))break;u=u+1|0}0==(0|l)&0==(0|h)||(OA(l,h,T),0|ne(A,V,T)&&(i[(u=a)>>2]=l,i[u+4>>2]=h,i[(u=k+(o<<3)|0)>>2]=l,i[u+4>>2]=h,o=o+1|0))}}while(0);c=c+1|0}while(c>>>0<7);if((0|(g=g+1|0))>=(0|w))break;d=d+1|0}if((0|w)>0&&_e(0|y,0,w<<3|0),i[U>>2]=o,!((0|o)>0))break A;l=n,h=v,c=D,d=b,g=B,w=k,n=p,v=t,b=E,B=y,p=l,t=h,D=x,x=c,E=d,y=g,k=m,m=w}return Be(E),Be(x),Be(V),I=H,0|(V=-1)}t=l}while(0);return Be(V),Be(n),Be(t),I=H,0|(V=0)}(A|=0,e|=0,r|=0)){if(a=0|i[(s=A)+4>>2],i[(f=o)>>2]=i[s>>2],i[f+4>>2]=a,te(o,n),f=0|j(n,e),e=0|i[o>>2],(0|(a=0|i[A+8>>2]))>0){o=0|i[A+12>>2],n=0;do{e=(0|i[o+(n<<3)>>2])+e|0,n=n+1|0}while((0|n)!=(0|a))}(0|(e=(0|f)<(0|e)?e:f))<=-12||_e(0|r,0,8+(((0|(s=e+11|0))>0?s:0)<<3)|0),I=t}else I=t},_res0IndexCount:function(){return 122},_round:Ie,_sbrk:Fe,_sizeOfCoordIJ:function(){return 8},_sizeOfGeoBoundary:function(){return 168},_sizeOfGeoCoord:function(){return 16},_sizeOfGeoPolygon:function(){return 16},_sizeOfGeofence:function(){return 8},_sizeOfH3Index:function(){return 8},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompact:function(A,e,r,t,n){A|=0,r|=0,t|=0,n|=0;var o=0,a=0,f=0,s=0,u=0,l=0;if((0|(e|=0))<=0)return 0|(n=0);if((0|n)>=16){for(o=0;;){if(!(0==(0|i[(l=A+(o<<3)|0)>>2])&0==(0|i[l+4>>2]))){o=14;break}if((0|(o=o+1|0))>=(0|e)){a=0,o=16;break}}if(14==(0|o))return 0|((0|t)>0?-2:-1);if(16==(0|o))return 0|a}o=0,l=0;A:for(;;){a=0|i[(f=u=A+(l<<3)|0)>>2],f=0|i[f+4>>2];do{if(!(0==(0|a)&0==(0|f))){if((0|o)>=(0|t)){a=-1,o=16;break A}if(s=0|Qe(0|a,0|f,52),M(),(0|(s&=15))>(0|n)){a=-2,o=16;break A}if((0|s)==(0|n)){i[(u=r+(o<<3)|0)>>2]=a,i[u+4>>2]=f,o=o+1|0;break}if((0|(a=(0|ee(7,n-s|0))+o|0))>(0|t)){a=-1,o=16;break A}PA(0|i[u>>2],0|i[u+4>>2],n,r+(o<<3)|0),o=a}}while(0);if((0|(l=l+1|0))>=(0|e)){a=0,o=16;break}}return 16==(0|o)?0|a:0},establishStackSpace:function(A,e){I=A|=0},stackAlloc:function(A){var e;return e=I,I=(I=I+(A|=0)|0)+15&-16,0|e},stackRestore:function(A){I=A|=0},stackSave:function(){return 0|I}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{a:fA,b:function(A){s=A},c:u,d:function(A,e,r,t){fA("Assertion failed: "+g(A)+", at: "+[e?g(e):"unknown filename",r,t?g(t):"unknown function"])},e:function(A){return r.___errno_location&&(v[r.___errno_location()>>2]=A),A},f:N,g:function(A,e,r){B.set(B.subarray(e,e+r),A)},h:function(A){var e=N(),r=16777216,t=2130706432;if(A>t)return!1;for(var i=Math.max(e,16777216);i>0]=e;break;case"i16":b[A>>1]=e;break;case"i32":v[A>>2]=e;break;case"i64":H=[e>>>0,(V=e,+F(V)>=1?V>0?(0|U(+P(V/4294967296),4294967295))>>>0:~~+C((V-+(~~V>>>0))/4294967296)>>>0:0)],v[A>>2]=H[0],v[A+4>>2]=H[1];break;case"float":m[A>>2]=e;break;case"double":k[A>>3]=e;break;default:fA("invalid type for setValue: "+r)}},r.getValue=function(A,e,r){switch("*"===(e=e||"i8").charAt(e.length-1)&&(e="i32"),e){case"i1":case"i8":return p[A>>0];case"i16":return b[A>>1];case"i32":case"i64":return v[A>>2];case"float":return m[A>>2];case"double":return k[A>>3];default:fA("invalid type for getValue: "+e)}return null},r.getTempRet0=u,R){z(R)||(K=R,R=r.locateFile?r.locateFile(K,o):o+K),G++,r.monitorRunDependencies&&r.monitorRunDependencies(G);var tA=function(A){A.byteLength&&(A=new Uint8Array(A)),B.set(A,8),r.memoryInitializerRequest&&delete r.memoryInitializerRequest.response,function(A){if(G--,r.monitorRunDependencies&&r.monitorRunDependencies(G),0==G&&(null!==S&&(clearInterval(S),S=null),T)){var e=T;T=null,e()}}()},iA=function(){i(R,tA,(function(){throw"could not load memory initializer "+R}))},nA=J(R);if(nA)tA(nA.buffer);else if(r.memoryInitializerRequest){var oA=function(){var A=r.memoryInitializerRequest,e=A.response;if(200!==A.status&&0!==A.status){var t=J(r.memoryInitializerRequestURL);if(!t)return console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+A.status+", retrying "+R),void iA();e=t.buffer}tA(e)};r.memoryInitializerRequest.response?setTimeout(oA,0):r.memoryInitializerRequest.addEventListener("load",oA)}else iA()}function aA(A){function e(){X||(X=!0,l||(E(D),E(_),r.onRuntimeInitialized&&r.onRuntimeInitialized(),function(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)A=r.postRun.shift(),I.unshift(A);var A;E(I)}()))}A=A||n,G>0||(!function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)A=r.preRun.shift(),x.unshift(A);var A;E(x)}(),G>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),e()}),1)):e()))}function fA(A){throw r.onAbort&&r.onAbort(A),a(A+=""),f(A),l=!0,"abort("+A+"). Build with -s ASSERTIONS=1 for more info."}if(T=function A(){X||aA(),X||(T=A)},r.run=aA,r.abort=fA,r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return aA(),A}("object"==typeof t?t:{}),i="number",n={};[["sizeOfH3Index",i],["sizeOfGeoCoord",i],["sizeOfGeoBoundary",i],["sizeOfGeoPolygon",i],["sizeOfGeofence",i],["sizeOfLinkedGeoPolygon",i],["sizeOfCoordIJ",i],["h3IsValid",i,[i,i]],["geoToH3",i,[i,i,i]],["h3ToGeo",null,[i,i,i]],["h3ToGeoBoundary",null,[i,i,i]],["maxKringSize",i,[i]],["kRing",null,[i,i,i,i]],["kRingDistances",null,[i,i,i,i,i]],["hexRing",null,[i,i,i,i]],["maxPolyfillSize",i,[i,i]],["polyfill",null,[i,i,i]],["h3SetToLinkedGeo",null,[i,i,i]],["destroyLinkedPolygon",null,[i]],["compact",i,[i,i,i]],["uncompact",i,[i,i,i,i,i]],["maxUncompactSize",i,[i,i,i]],["h3IsPentagon",i,[i,i]],["h3IsResClassIII",i,[i,i]],["h3GetBaseCell",i,[i,i]],["h3GetResolution",i,[i,i]],["maxFaceCount",i,[i,i]],["h3GetFaces",null,[i,i,i]],["h3ToParent",i,[i,i,i]],["h3ToChildren",null,[i,i,i,i]],["h3ToCenterChild",i,[i,i,i]],["maxH3ToChildrenSize",i,[i,i,i]],["h3IndexesAreNeighbors",i,[i,i,i,i]],["getH3UnidirectionalEdge",i,[i,i,i,i]],["getOriginH3IndexFromUnidirectionalEdge",i,[i,i]],["getDestinationH3IndexFromUnidirectionalEdge",i,[i,i]],["h3UnidirectionalEdgeIsValid",i,[i,i]],["getH3IndexesFromUnidirectionalEdge",null,[i,i,i]],["getH3UnidirectionalEdgesFromHexagon",null,[i,i,i]],["getH3UnidirectionalEdgeBoundary",null,[i,i,i]],["h3Distance",i,[i,i,i,i]],["h3Line",i,[i,i,i,i,i]],["h3LineSize",i,[i,i,i,i]],["experimentalH3ToLocalIj",i,[i,i,i,i,i]],["experimentalLocalIjToH3",i,[i,i,i,i]],["hexAreaM2",i,[i]],["hexAreaKm2",i,[i]],["edgeLengthM",i,[i]],["edgeLengthKm",i,[i]],["pointDistM",i,[i,i]],["pointDistKm",i,[i,i]],["pointDistRads",i,[i,i]],["cellAreaM2",i,[i,i]],["cellAreaKm2",i,[i,i]],["cellAreaRads2",i,[i,i]],["exactEdgeLengthM",i,[i,i]],["exactEdgeLengthKm",i,[i,i]],["exactEdgeLengthRads",i,[i,i]],["numHexagons",i,[i]],["getRes0Indexes",null,[i]],["res0IndexCount",i],["getPentagonIndexes",null,[i,i]],["pentagonIndexCount",i]].forEach((function(A){n[A[0]]=t.cwrap.apply(t,A)}));var o=16,a=n.sizeOfH3Index(),f=n.sizeOfGeoCoord(),s=n.sizeOfGeoBoundary(),u=n.sizeOfGeoPolygon(),l=n.sizeOfGeofence(),h=n.sizeOfLinkedGeoPolygon(),c=n.sizeOfCoordIJ(),d={m:"m",m2:"m2",km:"km",km2:"km2",rads:"rads",rads2:"rads2"};function g(A){if("number"!=typeof A||A<0||A>15||Math.floor(A)!==A)throw new Error("Invalid resolution: "+A)}var w=/[^0-9a-fA-F]/;function p(A){if(Array.isArray(A)&&2===A.length&&Number.isInteger(A[0])&&Number.isInteger(A[1]))return A;if("string"!=typeof A||w.test(A))return[0,0];var e=parseInt(A.substring(0,A.length-8),o);return[parseInt(A.substring(A.length-8),o),e]}function B(A){if(A>=0)return A.toString(o);var e=v(8,(A&=2147483647).toString(o));return e=(parseInt(e[0],o)+8).toString(o)+e.substring(1)}function b(A,e){return B(e)+v(8,B(A))}function v(A,e){for(var r=A-e.length,t="",i=0;i=0&&r.push(n)}return r}(a,o);return t._free(a),f},r.h3GetResolution=function(A){var e=p(A),r=e[0],t=e[1];return n.h3IsValid(r,t)?n.h3GetResolution(r,t):-1},r.geoToH3=function(A,e,r){var i=t._malloc(f);t.HEAPF64.set([A,e].map(U),i/8);var o=M(n.geoToH3(i,r));return t._free(i),o},r.h3ToGeo=function(A){var e=t._malloc(f),r=p(A),i=r[0],o=r[1];n.h3ToGeo(i,o,e);var a=I(e);return t._free(e),a},r.h3ToGeoBoundary=function(A,e){var r=t._malloc(s),i=p(A),o=i[0],a=i[1];n.h3ToGeoBoundary(o,a,r);var f=C(r,e,e);return t._free(r),f},r.h3ToParent=function(A,e){var r=p(A),t=r[0],i=r[1];return M(n.h3ToParent(t,i,e))},r.h3ToChildren=function(A,e){if(!P(A))return[];var r=p(A),i=r[0],o=r[1],f=n.maxH3ToChildrenSize(i,o,e),s=t._calloc(f,a);n.h3ToChildren(i,o,e,s);var u=E(s,f);return t._free(s),u},r.h3ToCenterChild=function(A,e){var r=p(A),t=r[0],i=r[1];return M(n.h3ToCenterChild(t,i,e))},r.kRing=function(A,e){var r=p(A),i=r[0],o=r[1],f=n.maxKringSize(e),s=t._calloc(f,a);n.kRing(i,o,e,s);var u=E(s,f);return t._free(s),u},r.kRingDistances=function(A,e){var r=p(A),i=r[0],o=r[1],f=n.maxKringSize(e),s=t._calloc(f,a),u=t._calloc(f,4);n.kRingDistances(i,o,e,s,u);for(var l=[],h=0;h0){r=t._calloc(i,l);for(var f=0;f0){for(var n=t.getValue(A+r,"i32"),o=0;o */ +r.read=function(A,e,r,t,i){var n,o,a=8*i-t-1,f=(1<>1,u=-7,l=r?i-1:0,h=r?-1:1,c=A[e+l];for(l+=h,n=c&(1<<-u)-1,c>>=-u,u+=a;u>0;n=256*n+A[e+l],l+=h,u-=8);for(o=n&(1<<-u)-1,n>>=-u,u+=t;u>0;o=256*o+A[e+l],l+=h,u-=8);if(0===n)n=1-s;else{if(n===f)return o?NaN:1/0*(c?-1:1);o+=Math.pow(2,t),n-=s}return(c?-1:1)*o*Math.pow(2,n-t)},r.write=function(A,e,r,t,i,n){var o,a,f,s=8*n-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,c=t?0:n-1,d=t?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),(e+=o+l>=1?h/f:h*Math.pow(2,1-l))*f>=2&&(o++,f/=2),o+l>=u?(a=0,o=u):o+l>=1?(a=(e*f-1)*Math.pow(2,i),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;A[r+c]=255&a,c+=d,a/=256,i-=8);for(o=o<0;A[r+c]=255&o,c+=d,o/=256,s-=8);A[r+c-d]|=128*g}},{}],9:[function(A,e,r){"use strict";e.exports=i;var t=A("ieee754");function i(A){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(A)?A:new Uint8Array(A||0),this.pos=0,this.type=0,this.length=this.buf.length}i.Varint=0,i.Fixed64=1,i.Bytes=2,i.Fixed32=5;var n=4294967296,o=1/n,a="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function f(A){return A.type===i.Bytes?A.readVarint()+A.pos:A.pos+1}function s(A,e,r){return r?4294967296*e+(A>>>0):4294967296*(e>>>0)+(A>>>0)}function u(A,e,r){var t=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(t);for(var i=r.pos-1;i>=A;i--)r.buf[i+t]=r.buf[i]}function l(A,e){for(var r=0;r>>8,A[r+2]=e>>>16,A[r+3]=e>>>24}function k(A,e){return(A[e]|A[e+1]<<8|A[e+2]<<16)+(A[e+3]<<24)}i.prototype={destroy:function(){this.buf=null},readFields:function(A,e,r){for(r=r||this.length;this.pos>3,n=this.pos;this.type=7&t,A(i,e,this),this.pos===n&&this.skip(t)}return e},readMessage:function(A,e){return this.readFields(A,e,this.readVarint()+this.pos)},readFixed32:function(){var A=v(this.buf,this.pos);return this.pos+=4,A},readSFixed32:function(){var A=k(this.buf,this.pos);return this.pos+=4,A},readFixed64:function(){var A=v(this.buf,this.pos)+v(this.buf,this.pos+4)*n;return this.pos+=8,A},readSFixed64:function(){var A=v(this.buf,this.pos)+k(this.buf,this.pos+4)*n;return this.pos+=8,A},readFloat:function(){var A=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,A},readDouble:function(){var A=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,A},readVarint:function(A){var e,r,t=this.buf;return e=127&(r=t[this.pos++]),r<128?e:(e|=(127&(r=t[this.pos++]))<<7,r<128?e:(e|=(127&(r=t[this.pos++]))<<14,r<128?e:(e|=(127&(r=t[this.pos++]))<<21,r<128?e:function(A,e,r){var t,i,n=r.buf;if(i=n[r.pos++],t=(112&i)>>4,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<3,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<10,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<17,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(127&i)<<24,i<128)return s(A,t,e);if(i=n[r.pos++],t|=(1&i)<<31,i<128)return s(A,t,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=t[this.pos]))<<28,A,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var A=this.readVarint();return A%2==1?(A+1)/-2:A/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var A=this.readVarint()+this.pos,e=this.pos;return this.pos=A,A-e>=12&&a?function(A,e,r){return a.decode(A.subarray(e,r))}(this.buf,e,A):function(A,e,r){var t="",i=e;for(;i239?4:f>223?3:f>191?2:1;if(i+u>r)break;1===u?f<128&&(s=f):2===u?128==(192&(n=A[i+1]))&&(s=(31&f)<<6|63&n)<=127&&(s=null):3===u?(n=A[i+1],o=A[i+2],128==(192&n)&&128==(192&o)&&((s=(15&f)<<12|(63&n)<<6|63&o)<=2047||s>=55296&&s<=57343)&&(s=null)):4===u&&(n=A[i+1],o=A[i+2],a=A[i+3],128==(192&n)&&128==(192&o)&&128==(192&a)&&((s=(15&f)<<18|(63&n)<<12|(63&o)<<6|63&a)<=65535||s>=1114112)&&(s=null)),null===s?(s=65533,u=1):s>65535&&(s-=65536,t+=String.fromCharCode(s>>>10&1023|55296),s=56320|1023&s),t+=String.fromCharCode(s),i+=u}return t}(this.buf,e,A)},readBytes:function(){var A=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,A);return this.pos=A,e},readPackedVarint:function(A,e){if(this.type!==i.Bytes)return A.push(this.readVarint(e));var r=f(this);for(A=A||[];this.pos127;);else if(e===i.Bytes)this.pos=this.readVarint()+this.pos;else if(e===i.Fixed32)this.pos+=4;else{if(e!==i.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(A,e){this.writeVarint(A<<3|e)},realloc:function(A){for(var e=this.length||16;e268435455||A<0?function(A,e){var r,t;A>=0?(r=A%4294967296|0,t=A/4294967296|0):(t=~(-A/4294967296),4294967295^(r=~(-A%4294967296))?r=r+1|0:(r=0,t=t+1|0));if(A>=0x10000000000000000||A<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(A,e,r){r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos++]=127&A|128,A>>>=7,r.buf[r.pos]=127&A}(r,0,e),function(A,e){var r=(7&A)<<4;if(e.buf[e.pos++]|=r|((A>>>=3)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;if(e.buf[e.pos++]=127&A|((A>>>=7)?128:0),!A)return;e.buf[e.pos++]=127&A}(t,e)}(A,this):(this.realloc(4),this.buf[this.pos++]=127&A|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=A>>>7&127))))},writeSVarint:function(A){this.writeVarint(A<0?2*-A-1:2*A)},writeBoolean:function(A){this.writeVarint(Boolean(A))},writeString:function(A){A=String(A),this.realloc(4*A.length),this.pos++;var e=this.pos;this.pos=function(A,e,r){for(var t,i,n=0;n55295&&t<57344){if(!i){t>56319||n+1===e.length?(A[r++]=239,A[r++]=191,A[r++]=189):i=t;continue}if(t<56320){A[r++]=239,A[r++]=191,A[r++]=189,i=t;continue}t=i-55296<<10|t-56320|65536,i=null}else i&&(A[r++]=239,A[r++]=191,A[r++]=189,i=null);t<128?A[r++]=t:(t<2048?A[r++]=t>>6|192:(t<65536?A[r++]=t>>12|224:(A[r++]=t>>18|240,A[r++]=t>>12&63|128),A[r++]=t>>6&63|128),A[r++]=63&t|128)}return r}(this.buf,A,this.pos);var r=this.pos-e;r>=128&&u(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(A){this.realloc(4),t.write(this.buf,A,this.pos,!0,23,4),this.pos+=4},writeDouble:function(A){this.realloc(8),t.write(this.buf,A,this.pos,!0,52,8),this.pos+=8},writeBytes:function(A){var e=A.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&u(r,t,this),this.pos=r-1,this.writeVarint(t),this.pos+=t},writeMessage:function(A,e,r){this.writeTag(A,i.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(A,e){e.length&&this.writeMessage(A,l,e)},writePackedSVarint:function(A,e){e.length&&this.writeMessage(A,h,e)},writePackedBoolean:function(A,e){e.length&&this.writeMessage(A,g,e)},writePackedFloat:function(A,e){e.length&&this.writeMessage(A,c,e)},writePackedDouble:function(A,e){e.length&&this.writeMessage(A,d,e)},writePackedFixed32:function(A,e){e.length&&this.writeMessage(A,w,e)},writePackedSFixed32:function(A,e){e.length&&this.writeMessage(A,p,e)},writePackedFixed64:function(A,e){e.length&&this.writeMessage(A,B,e)},writePackedSFixed64:function(A,e){e.length&&this.writeMessage(A,b,e)},writeBytesField:function(A,e){this.writeTag(A,i.Bytes),this.writeBytes(e)},writeFixed32Field:function(A,e){this.writeTag(A,i.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(A,e){this.writeTag(A,i.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(A,e){this.writeTag(A,i.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(A,e){this.writeTag(A,i.Fixed64),this.writeSFixed64(e)},writeVarintField:function(A,e){this.writeTag(A,i.Varint),this.writeVarint(e)},writeSVarintField:function(A,e){this.writeTag(A,i.Varint),this.writeSVarint(e)},writeStringField:function(A,e){this.writeTag(A,i.Bytes),this.writeString(e)},writeFloatField:function(A,e){this.writeTag(A,i.Fixed32),this.writeFloat(e)},writeDoubleField:function(A,e){this.writeTag(A,i.Fixed64),this.writeDouble(e)},writeBooleanField:function(A,e){this.writeVarintField(A,Boolean(e))}}},{ieee754:8}],10:[function(A,e,r){var t=A("pbf"),i=A("./lib/geojson_wrapper");function n(A){var e=new t;return function(A,e){for(var r in A.layers)e.writeMessage(3,o,A.layers[r])}(A,e),e.finish()}function o(A,e){var r;e.writeVarintField(15,A.version||1),e.writeStringField(1,A.name||""),e.writeVarintField(5,A.extent||4096);var t={keys:[],values:[],keycache:{},valuecache:{}};for(r=0;r>31}function l(A,e){for(var r=A.loadGeometry(),t=A.type,i=0,n=0,o=r.length,a=0;anew Promise(((r,t)=>{var i;r((i=e,{type:"FeatureCollection",features:A.cells.map((A=>{const e={properties:A,geometry:{type:i.geometry_type,coordinates:i.generate(A.h3id)}};return i.promoteID||(e.id=parseInt(A.h3id,16)),e}))}))})),a=A=>{const e=["type","data","maxzoom","attribution","buffer","filter","tolerance","cluster","clusterRadius","clusterMaxZoom","clusterMinPoints","clusterProperties","lineMetrics","generateId","promoteId"];return f(A,((A,r)=>e.includes(A)))},f=(A,e)=>Object.fromEntries(Object.entries(A).filter((([A,r])=>e(A,r))));t.Map.prototype.addH3TSource=function(A,e){const r=Object.assign({},n,e,{type:"vector",format:"pbf"});r.generate=A=>"Polygon"===r.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),r.promoteId&&(r.promoteId="h3id"),t.addProtocol("h3tiles",((A,e)=>{const t=`http${!1===r.https?"":"s"}://${A.url.split("://")[1]}`,n=A.url.split(/\/|\./i),a=n.length,f=n.slice(a-4,a-1).map((A=>1*A)),s=new AbortController,u=s.signal;let l;r.timeout>0&&setTimeout((()=>s.abort()),r.timeout),fetch(t,{signal:u}).then((A=>{if(A.ok)return l=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,r))).then((A=>{const t=i.tovt(A).getTile(...f),n={};n[r.sourcelayer]=t;const o=i.topbf.fromGeojsonVt(n,{version:2});r.debug&&console.log(`${f}: ${A.features.length} features, ${(performance.now()-l).toFixed(0)} ms`),e(null,o,null,null)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Tile .../${f.join("/")}.h3t is taking too long to fetch`),e(new Error(A))}))})),this.addSource(A,(A=>{const e=["type","url","tiles","bounds","scheme","minzoom","maxzoom","attribution","promoteId","volatile"];return f(A,((A,r)=>e.includes(A)))})(r))};t.Map.prototype.addH3JSource=function(A,e){const r=new AbortController,t=r.signal,f=Object.assign({},n,e,{type:"geojson"});let s;if(f.generate=A=>"Polygon"===f.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),f.promoteId&&(f.promoteId="h3id"),f.timeout>0&&setTimeout((()=>r.abort()),f.timeout),"string"==typeof f.data)return f.timeout>0&&setTimeout((()=>r.abort()),f.timeout),new Promise(((e,r)=>{fetch(f.data,{signal:t}).then((A=>{if(A.ok)return s=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,f))).then((r=>{f.data=r,this.addSource(A,a(f)),f.debug&&console.log(`${r.features.length} features, ${(performance.now()-s).toFixed(0)} ms`),e(this)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Source file ${f.data} is taking too long to fetch`),console.error(A.message)}))}));o(f.data,f).then((e=>(f.data=e,this.addSource(A,a(f)),new Promise(((A,e)=>A(this))))))};t.Map.prototype.setH3JData=function(A,e,r){const t=Object.assign({},n,r);t.generate=A=>"Polygon"===t.geometry_type?[i.h3.h3ToGeoBoundary(A,!0)]:i.h3.h3ToGeo(A).reverse(),t.promoteId&&(t.promoteId="h3id");const a=new AbortController,f=a.signal,s=this.getSource(A);let u;"string"==typeof e?(t.timeout>0&&setTimeout((()=>a.abort()),t.timeout),fetch(e,{signal:f}).then((A=>{if(A.ok)return u=performance.now(),A.json();throw new Error(A.statusText)})).then((A=>o(A,t))).then((A=>{s.setData(A),t.debug&&console.log(`${A.features.length} features, ${(performance.now()-u).toFixed(0)} ms`)})).catch((A=>{"AbortError"===A.name&&(A.message=`Timeout: Data file ${e} is taking too long to fetch`),console.error(A.message)}))):o(e,t).then((A=>s.setData(A)))}},{"geojson-vt":6,"h3-js":7,"vt-pbf":10}]},{},[12])(12)})); \ No newline at end of file diff --git a/inst/htmlwidgets/lib/mapbox-gl-draw/mapbox-gl-draw.js b/inst/htmlwidgets/lib/mapbox-gl-draw/mapbox-gl-draw.js index 2252f10d..271f1f7f 100644 --- a/inst/htmlwidgets/lib/mapbox-gl-draw/mapbox-gl-draw.js +++ b/inst/htmlwidgets/lib/mapbox-gl-draw/mapbox-gl-draw.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).MapboxDraw=e()}(this,(function(){"use strict";var t=function(t,e){var n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},o={on:function(t,e,o){if(void 0===n[t])throw new Error("Invalid event type: "+t);n[t].push({selector:e,fn:o})},render:function(t){e.store.featureChanged(t)}},r=function(t,r){for(var i=n[t],a=i.length;a--;){var s=i[a];if(s.selector(r)){s.fn.call(o,r)||e.store.render(),e.ui.updateMapClasses();break}}};return t.start.call(o),{render:t.render,stop:function(){t.stop&&t.stop()},trash:function(){t.trash&&(t.trash(),e.store.render())},combineFeatures:function(){t.combineFeatures&&t.combineFeatures()},uncombineFeatures:function(){t.uncombineFeatures&&t.uncombineFeatures()},drag:function(t){r("drag",t)},click:function(t){r("click",t)},mousemove:function(t){r("mousemove",t)},mousedown:function(t){r("mousedown",t)},mouseup:function(t){r("mouseup",t)},mouseout:function(t){r("mouseout",t)},keydown:function(t){r("keydown",t)},keyup:function(t){r("keyup",t)},touchstart:function(t){r("touchstart",t)},touchmove:function(t){r("touchmove",t)},touchend:function(t){r("touchend",t)},tap:function(t){r("tap",t)}}};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function n(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){if(this instanceof t){var n=[null];n.push.apply(n,arguments);var o=Function.bind.apply(e,n);return new o}return e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,o.get?o:{enumerable:!0,get:function(){return t[e]}})})),n}var o={},r={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142},i=r;function a(t){var e=0;if(t&&t.length>0){e+=Math.abs(s(t[0]));for(var n=1;n2){for(s=0;s=Math.pow(2,t)?R(t,e):i};R.rack=function(t,e,n){var o=function(o){var i=0;do{if(i++>10){if(!n)throw new Error("too many ID collisions, use more bits");t+=n}var a=R(t,e)}while(Object.hasOwnProperty.call(r,a));return r[a]=o,a},r=o.hats={};return o.get=function(t){return o.hats[t]},o.set=function(t,e){return o.hats[t]=e,o},o.bits=t||128,o.base=e||16,o};var k=e(w.exports),D=function(t,e){this.ctx=t,this.properties=e.properties||{},this.coordinates=e.geometry.coordinates,this.id=e.id||k(),this.type=e.geometry.type};D.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},D.prototype.incomingCoords=function(t){this.setCoordinates(t)},D.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},D.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},D.prototype.setProperty=function(t,e){this.properties[t]=e},D.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:f.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},D.prototype.internal=function(t){var e={id:this.id,meta:v.FEATURE,"meta:type":this.type,active:m.INACTIVE,mode:t};if(this.ctx.options.userProperties)for(var n in this.properties)e["user_"+n]=this.properties[n];return{type:f.FEATURE,properties:e,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var U=function(t,e){D.call(this,t,e)};(U.prototype=Object.create(D.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},U.prototype.updateCoordinate=function(t,e,n){this.coordinates=3===arguments.length?[e,n]:[t,e],this.changed()},U.prototype.getCoordinate=function(){return this.getCoordinates()};var j=function(t,e){D.call(this,t,e)};(j.prototype=Object.create(D.prototype)).isValid=function(){return this.coordinates.length>1},j.prototype.addCoordinate=function(t,e,n){this.changed();var o=parseInt(t,10);this.coordinates.splice(o,0,[e,n])},j.prototype.getCoordinate=function(t){var e=parseInt(t,10);return JSON.parse(JSON.stringify(this.coordinates[e]))},j.prototype.removeCoordinate=function(t){this.changed(),this.coordinates.splice(parseInt(t,10),1)},j.prototype.updateCoordinate=function(t,e,n){var o=parseInt(t,10);this.coordinates[o]=[e,n],this.changed()};var V=function(t,e){D.call(this,t,e),this.coordinates=this.coordinates.map((function(t){return t.slice(0,-1)}))};(V.prototype=Object.create(D.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every((function(t){return t.length>2}))},V.prototype.incomingCoords=function(t){this.coordinates=t.map((function(t){return t.slice(0,-1)})),this.changed()},V.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},V.prototype.addCoordinate=function(t,e,n){this.changed();var o=t.split(".").map((function(t){return parseInt(t,10)}));this.coordinates[o[0]].splice(o[1],0,[e,n])},V.prototype.removeCoordinate=function(t){this.changed();var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];n&&(n.splice(e[1],1),n.length<3&&this.coordinates.splice(e[0],1))},V.prototype.getCoordinate=function(t){var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];return JSON.parse(JSON.stringify(n[e[1]]))},V.prototype.getCoordinates=function(){return this.coordinates.map((function(t){return t.concat([t[0]])}))},V.prototype.updateCoordinate=function(t,e,n){this.changed();var o=t.split("."),r=parseInt(o[0],10),i=parseInt(o[1],10);void 0===this.coordinates[r]&&(this.coordinates[r]=[]),this.coordinates[r][i]=[e,n]};var B={MultiPoint:U,MultiLineString:j,MultiPolygon:V},G=function(t,e,n,o,r){var i=n.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return t[a][e](s,o,r)},J=function(t,e){if(D.call(this,t,e),delete this.coordinates,this.model=B[e.geometry.type],void 0===this.model)throw new TypeError(e.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(e.geometry.coordinates)};function z(t){this.map=t.map,this.drawConfig=JSON.parse(JSON.stringify(t.options||{})),this._ctx=t}(J.prototype=Object.create(D.prototype))._coordinatesToFeatures=function(t){var e=this,n=this.model.bind(this);return t.map((function(t){return new n(e.ctx,{id:k(),type:f.FEATURE,properties:{},geometry:{coordinates:t,type:e.type.replace("Multi","")}})}))},J.prototype.isValid=function(){return this.features.every((function(t){return t.isValid()}))},J.prototype.setCoordinates=function(t){this.features=this._coordinatesToFeatures(t),this.changed()},J.prototype.getCoordinate=function(t){return G(this.features,"getCoordinate",t)},J.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map((function(t){return t.type===f.POLYGON?t.getCoordinates():t.coordinates}))))},J.prototype.updateCoordinate=function(t,e,n){G(this.features,"updateCoordinate",t,e,n),this.changed()},J.prototype.addCoordinate=function(t,e,n){G(this.features,"addCoordinate",t,e,n),this.changed()},J.prototype.removeCoordinate=function(t){G(this.features,"removeCoordinate",t),this.changed()},J.prototype.getFeatures=function(){return this.features},z.prototype.setSelected=function(t){return this._ctx.store.setSelected(t)},z.prototype.setSelectedCoordinates=function(t){var e=this;this._ctx.store.setSelectedCoordinates(t),t.reduce((function(t,n){return void 0===t[n.feature_id]&&(t[n.feature_id]=!0,e._ctx.store.get(n.feature_id).changed()),t}),{})},z.prototype.getSelected=function(){return this._ctx.store.getSelected()},z.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},z.prototype.isSelected=function(t){return this._ctx.store.isSelected(t)},z.prototype.getFeature=function(t){return this._ctx.store.get(t)},z.prototype.select=function(t){return this._ctx.store.select(t)},z.prototype.deselect=function(t){return this._ctx.store.deselect(t)},z.prototype.deleteFeature=function(t,e){return void 0===e&&(e={}),this._ctx.store.delete(t,e)},z.prototype.addFeature=function(t){return this._ctx.store.add(t)},z.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},z.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},z.prototype.setActionableState=function(t){void 0===t&&(t={});var e={trash:t.trash||!1,combineFeatures:t.combineFeatures||!1,uncombineFeatures:t.uncombineFeatures||!1};return this._ctx.events.actionable(e)},z.prototype.changeMode=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),this._ctx.events.changeMode(t,e,n)},z.prototype.updateUIClasses=function(t){return this._ctx.ui.queueMapClasses(t)},z.prototype.activateUIButton=function(t){return this._ctx.ui.setActiveButton(t)},z.prototype.featuresAt=function(t,e,n){if(void 0===n&&(n="click"),"click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return M[n](t,e,this._ctx)},z.prototype.newFeature=function(t){var e=t.geometry.type;return e===f.POINT?new U(this._ctx,t):e===f.LINE_STRING?new j(this._ctx,t):e===f.POLYGON?new V(this._ctx,t):new J(this._ctx,t)},z.prototype.isInstanceOf=function(t,e){if(t===f.POINT)return e instanceof U;if(t===f.LINE_STRING)return e instanceof j;if(t===f.POLYGON)return e instanceof V;if("MultiFeature"===t)return e instanceof J;throw new Error("Unknown feature class: "+t)},z.prototype.doRender=function(t){return this._ctx.store.featureChanged(t)},z.prototype.onSetup=function(){},z.prototype.onDrag=function(){},z.prototype.onClick=function(){},z.prototype.onMouseMove=function(){},z.prototype.onMouseDown=function(){},z.prototype.onMouseUp=function(){},z.prototype.onMouseOut=function(){},z.prototype.onKeyUp=function(){},z.prototype.onKeyDown=function(){},z.prototype.onTouchStart=function(){},z.prototype.onTouchMove=function(){},z.prototype.onTouchEnd=function(){},z.prototype.onTap=function(){},z.prototype.onStop=function(){},z.prototype.onTrash=function(){},z.prototype.onCombineFeature=function(){},z.prototype.onUncombineFeature=function(){},z.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var Y={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},$=Object.keys(Y);function q(t){var e=Object.keys(t);return function(n,o){void 0===o&&(o={});var r={},i=e.reduce((function(e,n){return e[n]=t[n],e}),new z(n));return{start:function(){var e=this;r=i.onSetup(o),$.forEach((function(n){var o,a=Y[n],s=function(){return!1};t[a]&&(s=function(){return!0}),e.on(n,s,(o=a,function(t){return i[o](r,t)}))}))},stop:function(){i.onStop(r)},trash:function(){i.onTrash(r)},combineFeatures:function(){i.onCombineFeatures(r)},uncombineFeatures:function(){i.onUncombineFeatures(r)},render:function(t,e){i.toDisplayFeatures(r,t,e)}}}}function H(t){return[].concat(t).filter((function(t){return void 0!==t}))}function X(){var t=this;if(!(t.ctx.map&&void 0!==t.ctx.map.getSource(l.HOT)))return u();var e=t.ctx.events.currentModeName();t.ctx.ui.queueMapClasses({mode:e});var n=[],o=[];t.isDirty?o=t.getAllIds():(n=t.getChangedIds().filter((function(e){return void 0!==t.get(e)})),o=t.sources.hot.filter((function(e){return e.properties.id&&-1===n.indexOf(e.properties.id)&&void 0!==t.get(e.properties.id)})).map((function(t){return t.properties.id}))),t.sources.hot=[];var r=t.sources.cold.length;t.sources.cold=t.isDirty?[]:t.sources.cold.filter((function(t){var e=t.properties.id||t.properties.parent;return-1===n.indexOf(e)}));var i=r!==t.sources.cold.length||o.length>0;function a(n,o){var r=t.get(n).internal(e);t.ctx.events.currentModeRender(r,(function(e){t.sources[o].push(e)}))}if(n.forEach((function(t){return a(t,"hot")})),o.forEach((function(t){return a(t,"cold")})),i&&t.ctx.map.getSource(l.COLD).setData({type:f.FEATURE_COLLECTION,features:t.sources.cold}),t.ctx.map.getSource(l.HOT).setData({type:f.FEATURE_COLLECTION,features:t.sources.hot}),t._emitSelectionChange&&(t.ctx.map.fire(g.SELECTION_CHANGE,{features:t.getSelected().map((function(t){return t.toGeoJSON()})),points:t.getSelectedCoordinates().map((function(t){return{type:f.FEATURE,properties:{},geometry:{type:f.POINT,coordinates:t.coordinates}}}))}),t._emitSelectionChange=!1),t._deletedFeaturesToEmit.length){var s=t._deletedFeaturesToEmit.map((function(t){return t.toGeoJSON()}));t._deletedFeaturesToEmit=[],t.ctx.map.fire(g.DELETE,{features:s})}function u(){t.isDirty=!1,t.clearChangedIds()}u(),t.ctx.map.fire(g.RENDER,{})}function Z(t){var e,n=this;this._features={},this._featureIds=new I,this._selectedFeatureIds=new I,this._selectedCoordinates=[],this._changedFeatureIds=new I,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=t,this.sources={hot:[],cold:[]},this.render=function(){e||(e=requestAnimationFrame((function(){e=null,X.call(n)})))},this.isDirty=!1}function W(t,e){var n=t._selectedCoordinates.filter((function(e){return t._selectedFeatureIds.has(e.feature_id)}));t._selectedCoordinates.length===n.length||e.silent||(t._emitSelectionChange=!0),t._selectedCoordinates=n}Z.prototype.createRenderBatch=function(){var t=this,e=this.render,n=0;return this.render=function(){n++},function(){t.render=e,n>0&&t.render()}},Z.prototype.setDirty=function(){return this.isDirty=!0,this},Z.prototype.featureChanged=function(t){return this._changedFeatureIds.add(t),this},Z.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Z.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Z.prototype.getAllIds=function(){return this._featureIds.values()},Z.prototype.add=function(t){return this.featureChanged(t.id),this._features[t.id]=t,this._featureIds.add(t.id),this},Z.prototype.delete=function(t,e){var n=this;return void 0===e&&(e={}),H(t).forEach((function(t){n._featureIds.has(t)&&(n._featureIds.delete(t),n._selectedFeatureIds.delete(t),e.silent||-1===n._deletedFeaturesToEmit.indexOf(n._features[t])&&n._deletedFeaturesToEmit.push(n._features[t]),delete n._features[t],n.isDirty=!0)})),W(this,e),this},Z.prototype.get=function(t){return this._features[t]},Z.prototype.getAll=function(){var t=this;return Object.keys(this._features).map((function(e){return t._features[e]}))},Z.prototype.select=function(t,e){var n=this;return void 0===e&&(e={}),H(t).forEach((function(t){n._selectedFeatureIds.has(t)||(n._selectedFeatureIds.add(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0))})),this},Z.prototype.deselect=function(t,e){var n=this;return void 0===e&&(e={}),H(t).forEach((function(t){n._selectedFeatureIds.has(t)&&(n._selectedFeatureIds.delete(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0))})),W(this,e),this},Z.prototype.clearSelected=function(t){return void 0===t&&(t={}),this.deselect(this._selectedFeatureIds.values(),{silent:t.silent}),this},Z.prototype.setSelected=function(t,e){var n=this;return void 0===e&&(e={}),t=H(t),this.deselect(this._selectedFeatureIds.values().filter((function(e){return-1===t.indexOf(e)})),{silent:e.silent}),this.select(t.filter((function(t){return!n._selectedFeatureIds.has(t)})),{silent:e.silent}),this},Z.prototype.setSelectedCoordinates=function(t){return this._selectedCoordinates=t,this._emitSelectionChange=!0,this},Z.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Z.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Z.prototype.getSelected=function(){var t=this;return this._selectedFeatureIds.values().map((function(e){return t.get(e)}))},Z.prototype.getSelectedCoordinates=function(){var t=this;return this._selectedCoordinates.map((function(e){return{coordinates:t.get(e.feature_id).getCoordinate(e.coord_path)}}))},Z.prototype.isSelected=function(t){return this._selectedFeatureIds.has(t)},Z.prototype.setFeatureProperty=function(t,e,n){this.get(t).setProperty(e,n),this.featureChanged(t)},Z.prototype.storeMapConfig=function(){var t=this;_.forEach((function(e){t.ctx.map[e]&&(t._mapInitialConfig[e]=t.ctx.map[e].isEnabled())}))},Z.prototype.restoreMapConfig=function(){var t=this;Object.keys(this._mapInitialConfig).forEach((function(e){t._mapInitialConfig[e]?t.ctx.map[e].enable():t.ctx.map[e].disable()}))},Z.prototype.getInitialConfigValue=function(t){return void 0===this._mapInitialConfig[t]||this._mapInitialConfig[t]};var K=function(){for(var t=arguments,e={},n=0;n=48&&t<=57)};function c(o,r,i){void 0===i&&(i={}),s.stop();var u=n[o];if(void 0===u)throw new Error(o+" is not valid");a=o;var c=u(e,r);s=t(c,e),i.silent||e.map.fire(g.MODE_CHANGE,{mode:o}),e.store.setDirty(),e.store.render()}i.keydown=function(t){(t.srcElement||t.target).classList.contains("mapboxgl-canvas")&&(8!==t.keyCode&&46!==t.keyCode||!e.options.controls.trash?u(t.keyCode)?s.keydown(t):49===t.keyCode&&e.options.controls.point?c(h.DRAW_POINT):50===t.keyCode&&e.options.controls.line_string?c(h.DRAW_LINE_STRING):51===t.keyCode&&e.options.controls.polygon&&c(h.DRAW_POLYGON):(t.preventDefault(),s.trash()))},i.keyup=function(t){u(t.keyCode)&&s.keyup(t)},i.zoomend=function(){e.store.changeZoom()},i.data=function(t){if("style"===t.dataType){var n=e.setup,o=e.map,r=e.options,i=e.store;r.styles.some((function(t){return o.getLayer(t.id)}))||(n.addLayers(),i.setDirty(),i.render())}};var l={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){a=e.options.defaultMode,s=t(n[a](e),e)},changeMode:c,actionable:function(t){var n=!1;Object.keys(t).forEach((function(e){if(void 0===l[e])throw new Error("Invalid action type");l[e]!==t[e]&&(n=!0),l[e]=t[e]})),n&&e.map.fire(g.ACTIONABLE,{actions:l})},currentModeName:function(){return a},currentModeRender:function(t,e){return s.render(t,e)},fire:function(t,e){i[t]&&i[t](e)},addEventListeners:function(){e.map.on("mousemove",i.mousemove),e.map.on("mousedown",i.mousedown),e.map.on("mouseup",i.mouseup),e.map.on("data",i.data),e.map.on("touchmove",i.touchmove),e.map.on("touchstart",i.touchstart),e.map.on("touchend",i.touchend),e.container.addEventListener("mouseout",i.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",i.keydown),e.container.addEventListener("keyup",i.keyup))},removeEventListeners:function(){e.map.off("mousemove",i.mousemove),e.map.off("mousedown",i.mousedown),e.map.off("mouseup",i.mouseup),e.map.off("data",i.data),e.map.off("touchmove",i.touchmove),e.map.off("touchstart",i.touchstart),e.map.off("touchend",i.touchend),e.container.removeEventListener("mouseout",i.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",i.keydown),e.container.removeEventListener("keyup",i.keyup))},trash:function(t){s.trash(t)},combineFeatures:function(){s.combineFeatures()},uncombineFeatures:function(){s.uncombineFeatures()},getMode:function(){return a}}}(e),e.ui=function(t){var e={},n=null,o={mode:null,feature:null,mouse:null},r={mode:null,feature:null,mouse:null};function i(t){r=tt(r,t)}function a(){var e,n;if(t.container){var i=[],a=[];et.forEach((function(t){r[t]!==o[t]&&(i.push(t+"-"+o[t]),null!==r[t]&&a.push(t+"-"+r[t]))})),i.length>0&&(e=t.container.classList).remove.apply(e,i),a.length>0&&(n=t.container.classList).add.apply(n,a),o=tt(o,r)}}function s(t,e){void 0===e&&(e={});var o=document.createElement("button");return o.className=c.CONTROL_BUTTON+" "+e.className,o.setAttribute("title",e.title),e.container.appendChild(o),o.addEventListener("click",(function(o){if(o.preventDefault(),o.stopPropagation(),o.target===n)return u(),void e.onDeactivate();l(t),e.onActivate()}),!0),o}function u(){n&&(n.classList.remove(c.ACTIVE_BUTTON),n=null)}function l(t){u();var o=e[t];o&&o&&"trash"!==t&&(o.classList.add(c.ACTIVE_BUTTON),n=o)}return{setActiveButton:l,queueMapClasses:i,updateMapClasses:a,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),a()},addButtons:function(){var n=t.options.controls,o=document.createElement("div");return o.className=c.CONTROL_GROUP+" "+c.CONTROL_BASE,n?(n[p.LINE]&&(e[p.LINE]=s(p.LINE,{container:o,className:c.CONTROL_BUTTON_LINE,title:"LineString tool "+(t.options.keybindings?"(l)":""),onActivate:function(){return t.events.changeMode(h.DRAW_LINE_STRING)},onDeactivate:function(){return t.events.trash()}})),n[p.POLYGON]&&(e[p.POLYGON]=s(p.POLYGON,{container:o,className:c.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(t.options.keybindings?"(p)":""),onActivate:function(){return t.events.changeMode(h.DRAW_POLYGON)},onDeactivate:function(){return t.events.trash()}})),n[p.POINT]&&(e[p.POINT]=s(p.POINT,{container:o,className:c.CONTROL_BUTTON_POINT,title:"Marker tool "+(t.options.keybindings?"(m)":""),onActivate:function(){return t.events.changeMode(h.DRAW_POINT)},onDeactivate:function(){return t.events.trash()}})),n.trash&&(e.trash=s("trash",{container:o,className:c.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:function(){t.events.trash()}})),n.combine_features&&(e.combine_features=s("combineFeatures",{container:o,className:c.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:function(){t.events.combineFeatures()}})),n.uncombine_features&&(e.uncombine_features=s("uncombineFeatures",{container:o,className:c.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:function(){t.events.uncombineFeatures()}})),o):o},removeButtons:function(){Object.keys(e).forEach((function(t){var n=e[t];n.parentNode&&n.parentNode.removeChild(n),delete e[t]}))}}}(e),e.container=i.getContainer(),e.store=new Z(e),n=e.ui.addButtons(),e.options.boxSelect&&(e.boxZoomInitial=i.boxZoom.isEnabled(),i.boxZoom.disable(),i.dragPan.disable(),i.dragPan.enable()),i.loaded()?r.connect():(i.on("load",r.connect),o=setInterval((function(){i.loaded()&&r.connect()}),16)),e.events.start(),n},addLayers:function(){e.map.addSource(l.COLD,{data:{type:f.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(l.HOT,{data:{type:f.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach((function(t){e.map.addLayer(t)})),e.store.setDirty(!0),e.store.render()},removeLayers:function(){e.options.styles.forEach((function(t){e.map.getLayer(t.id)&&e.map.removeLayer(t.id)})),e.map.getSource(l.COLD)&&e.map.removeSource(l.COLD),e.map.getSource(l.HOT)&&e.map.removeSource(l.HOT)}};return e.setup=r,r}var ot=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}];function rt(t){return function(e){var n=e.featureTarget;return!!n&&(!!n.properties&&n.properties.meta===t)}}function it(t){return!!t.originalEvent&&(!!t.originalEvent.shiftKey&&0===t.originalEvent.button)}function at(t){return!!t.featureTarget&&(!!t.featureTarget.properties&&(t.featureTarget.properties.active===m.ACTIVE&&t.featureTarget.properties.meta===v.FEATURE))}function st(t){return!!t.featureTarget&&(!!t.featureTarget.properties&&(t.featureTarget.properties.active===m.INACTIVE&&t.featureTarget.properties.meta===v.FEATURE))}function ut(t){return void 0===t.featureTarget}function ct(t){return!!t.featureTarget&&(!!t.featureTarget.properties&&t.featureTarget.properties.meta===v.FEATURE)}function lt(t){var e=t.featureTarget;return!!e&&(!!e.properties&&e.properties.meta===v.VERTEX)}function dt(t){return!!t.originalEvent&&!0===t.originalEvent.shiftKey}function pt(t){return 27===t.keyCode}function ft(t){return 13===t.keyCode}var ht=Object.freeze({__proto__:null,isOfMetaType:rt,isShiftMousedown:it,isActiveFeature:at,isInactiveFeature:st,noTarget:ut,isFeature:ct,isVertex:lt,isShiftDown:dt,isEscapeKey:pt,isEnterKey:ft,isTrue:function(){return!0}}),gt=yt;function yt(t,e){this.x=t,this.y=e}yt.prototype={clone:function(){return new yt(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),o=e*this.x-n*this.y,r=n*this.x+e*this.y;return this.x=o,this.y=r,this},_rotateAround:function(t,e){var n=Math.cos(t),o=Math.sin(t),r=e.x+n*(this.x-e.x)-o*(this.y-e.y),i=e.y+o*(this.x-e.x)+n*(this.y-e.y);return this.x=r,this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},yt.convert=function(t){return t instanceof yt?t:Array.isArray(t)?new yt(t[0],t[1]):t};var vt=e(gt);function mt(t,e){var n=e.getBoundingClientRect();return new vt(t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0))}function _t(t,e,n,o){return{type:f.FEATURE,properties:{meta:v.VERTEX,parent:t,coord_path:n,active:o?m.ACTIVE:m.INACTIVE},geometry:{type:f.POINT,coordinates:e}}}function bt(t,e,n){var o=e.geometry.coordinates,r=n.geometry.coordinates;if(o[1]>85||o[1]85||r[1]=e&&this._bbox[3]>=n},Jt.prototype.intersect=function(t){return this._valid?(e=t instanceof Jt?t.bbox():t,!(this._bbox[0]>e[2]||this._bbox[2]e[3])):null;var e},Jt.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var t="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",t)},Jt.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var zt=function(t){if(!t)return[];var e=Lt(Mt(t)),n=[];return e.features.forEach((function(t){t.geometry&&(n=n.concat(Nt(t.geometry.coordinates)))})),n},Yt=Bt,$t=Gt,qt={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},Ht=Object.keys(qt);function Xt(t){for(var e=$t(),n=zt(t),o=0;on&&(n=u),cr&&(r=c),us&&(s=d)}));var u=e;return n+u.lat>85&&(u.lat=85-n),r+u.lat>90&&(u.lat=90-r),o+u.lat<-85&&(u.lat=-85-o),i+u.lat=270&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function Qt(t,e){var n=Kt(t.map((function(t){return t.toGeoJSON()})),e);t.forEach((function(t){var e,o=t.getCoordinates(),r=function(t){var e={lng:t[0]+n.lng,lat:t[1]+n.lat};return[e.lng,e.lat]},i=function(t){return t.map((function(t){return r(t)}))};t.type===f.POINT?e=r(o):t.type===f.LINE_STRING||t.type===f.MULTI_POINT?e=o.map(r):t.type===f.POLYGON||t.type===f.MULTI_LINE_STRING?e=o.map(i):t.type===f.MULTI_POLYGON&&(e=o.map((function(t){return t.map((function(t){return i(t)}))}))),t.incomingCoords(e)}))}var te={onSetup:function(t){var e=this,n={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:t.featureIds||[]};return this.setSelected(n.initiallySelectedFeatureIds.filter((function(t){return void 0!==e.getFeature(t)}))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),n},fireUpdate:function(){this.map.fire(g.UPDATE,{action:y.MOVE,features:this.getSelected().map((function(t){return t.toGeoJSON()}))})},fireActionable:function(){var t=this,e=this.getSelected(),n=e.filter((function(e){return t.isInstanceOf("MultiFeature",e)})),o=!1;if(e.length>1){o=!0;var r=e[0].type.replace("Multi","");e.forEach((function(t){t.type.replace("Multi","")!==r&&(o=!1)}))}var i=n.length>0,a=e.length>0;this.setActionableState({combineFeatures:o,uncombineFeatures:i,trash:a})},getUniqueIds:function(t){return t.length?t.map((function(t){return t.properties.id})).filter((function(t){return void 0!==t})).reduce((function(t,e){return t.add(e),t}),new I).values():[]},stopExtendedInteractions:function(t){t.boxSelectElement&&(t.boxSelectElement.parentNode&&t.boxSelectElement.parentNode.removeChild(t.boxSelectElement),t.boxSelectElement=null),this.map.dragPan.enable(),t.boxSelecting=!1,t.canBoxSelect=!1,t.dragMoving=!1,t.canDragMove=!1},onStop:function(){Tt.enable(this)},onMouseMove:function(t,e){return ct(e)&&t.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(t),!0},onMouseOut:function(t){return!t.dragMoving||this.fireUpdate()}};te.onTap=te.onClick=function(t,e){return ut(e)?this.clickAnywhere(t,e):rt(v.VERTEX)(e)?this.clickOnVertex(t,e):ct(e)?this.clickOnFeature(t,e):void 0},te.clickAnywhere=function(t){var e=this,n=this.getSelectedIds();n.length&&(this.clearSelectedFeatures(),n.forEach((function(t){return e.doRender(t)}))),Tt.enable(this),this.stopExtendedInteractions(t)},te.clickOnVertex=function(t,e){this.changeMode(h.DIRECT_SELECT,{featureId:e.featureTarget.properties.parent,coordPath:e.featureTarget.properties.coord_path,startPos:e.lngLat}),this.updateUIClasses({mouse:d.MOVE})},te.startOnActiveFeature=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),this.doRender(e.featureTarget.properties.id),t.canDragMove=!0,t.dragMoveLocation=e.lngLat},te.clickOnFeature=function(t,e){var n=this;Tt.disable(this),this.stopExtendedInteractions(t);var o=dt(e),r=this.getSelectedIds(),i=e.featureTarget.properties.id,a=this.isSelected(i);if(!o&&a&&this.getFeature(i).type!==f.POINT)return this.changeMode(h.DIRECT_SELECT,{featureId:i});a&&o?(this.deselect(i),this.updateUIClasses({mouse:d.POINTER}),1===r.length&&Tt.enable(this)):!a&&o?(this.select(i),this.updateUIClasses({mouse:d.MOVE})):a||o||(r.forEach((function(t){return n.doRender(t)})),this.setSelected(i),this.updateUIClasses({mouse:d.MOVE})),this.doRender(i)},te.onMouseDown=function(t,e){return at(e)?this.startOnActiveFeature(t,e):this.drawConfig.boxSelect&&it(e)?this.startBoxSelect(t,e):void 0},te.startBoxSelect=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),t.boxSelectStartLocation=mt(e.originalEvent,this.map.getContainer()),t.canBoxSelect=!0},te.onTouchStart=function(t,e){if(at(e))return this.startOnActiveFeature(t,e)},te.onDrag=function(t,e){return t.canDragMove?this.dragMove(t,e):this.drawConfig.boxSelect&&t.canBoxSelect?this.whileBoxSelect(t,e):void 0},te.whileBoxSelect=function(t,e){t.boxSelecting=!0,this.updateUIClasses({mouse:d.ADD}),t.boxSelectElement||(t.boxSelectElement=document.createElement("div"),t.boxSelectElement.classList.add(c.BOX_SELECT),this.map.getContainer().appendChild(t.boxSelectElement));var n=mt(e.originalEvent,this.map.getContainer()),o=Math.min(t.boxSelectStartLocation.x,n.x),r=Math.max(t.boxSelectStartLocation.x,n.x),i=Math.min(t.boxSelectStartLocation.y,n.y),a=Math.max(t.boxSelectStartLocation.y,n.y),s="translate("+o+"px, "+i+"px)";t.boxSelectElement.style.transform=s,t.boxSelectElement.style.WebkitTransform=s,t.boxSelectElement.style.width=r-o+"px",t.boxSelectElement.style.height=a-i+"px"},te.dragMove=function(t,e){t.dragMoving=!0,e.originalEvent.stopPropagation();var n={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};Qt(this.getSelected(),n),t.dragMoveLocation=e.lngLat},te.onTouchEnd=te.onMouseUp=function(t,e){var n=this;if(t.dragMoving)this.fireUpdate();else if(t.boxSelecting){var o=[t.boxSelectStartLocation,mt(e.originalEvent,this.map.getContainer())],r=this.featuresAt(null,o,"click"),i=this.getUniqueIds(r).filter((function(t){return!n.isSelected(t)}));i.length&&(this.select(i),i.forEach((function(t){return n.doRender(t)})),this.updateUIClasses({mouse:d.MOVE}))}this.stopExtendedInteractions(t)},te.toDisplayFeatures=function(t,e,n){e.properties.active=this.isSelected(e.properties.id)?m.ACTIVE:m.INACTIVE,n(e),this.fireActionable(),e.properties.active===m.ACTIVE&&e.geometry.type!==f.POINT&&Et(e).forEach(n)},te.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},te.onCombineFeatures=function(){var t=this.getSelected();if(!(0===t.length||t.length<2)){for(var e=[],n=[],o=t[0].type.replace("Multi",""),r=0;r1){var a=this.newFeature({type:f.FEATURE,properties:n[0].properties,geometry:{type:"Multi"+o,coordinates:e}});this.addFeature(a),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([a.id]),this.map.fire(g.COMBINE_FEATURES,{createdFeatures:[a.toGeoJSON()],deletedFeatures:n})}this.fireActionable()}},te.onUncombineFeatures=function(){var t=this,e=this.getSelected();if(0!==e.length){for(var n=[],o=[],r=function(r){var i=e[r];t.isInstanceOf("MultiFeature",i)&&(i.getFeatures().forEach((function(e){t.addFeature(e),e.properties=i.properties,n.push(e.toGeoJSON()),t.select([e.id])})),t.deleteFeature(i.id,{silent:!0}),o.push(i.toGeoJSON()))},i=0;i1&&this.map.fire(g.UNCOMBINE_FEATURES,{createdFeatures:n,deletedFeatures:o}),this.fireActionable()}};var ee=rt(v.VERTEX),ne=rt(v.MIDPOINT),oe={fireUpdate:function(){this.map.fire(g.UPDATE,{action:y.CHANGE_COORDINATES,features:this.getSelected().map((function(t){return t.toGeoJSON()}))})},fireActionable:function(t){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:t.selectedCoordPaths.length>0})},startDragging:function(t,e){this.map.dragPan.disable(),t.canDragMove=!0,t.dragMoveLocation=e.lngLat},stopDragging:function(t){this.map.dragPan.enable(),t.dragMoving=!1,t.canDragMove=!1,t.dragMoveLocation=null},onVertex:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties,o=t.selectedCoordPaths.indexOf(n.coord_path);dt(e)||-1!==o?dt(e)&&-1===o&&t.selectedCoordPaths.push(n.coord_path):t.selectedCoordPaths=[n.coord_path];var r=this.pathsToCoordinates(t.featureId,t.selectedCoordPaths);this.setSelectedCoordinates(r)},onMidpoint:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties;t.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),t.selectedCoordPaths=[n.coord_path]},pathsToCoordinates:function(t,e){return e.map((function(e){return{feature_id:t,coord_path:e}}))},onFeature:function(t,e){0===t.selectedCoordPaths.length?this.startDragging(t,e):this.stopDragging(t)},dragFeature:function(t,e,n){Qt(this.getSelected(),n),t.dragMoveLocation=e.lngLat},dragVertex:function(t,e,n){for(var o=t.selectedCoordPaths.map((function(e){return t.feature.getCoordinate(e)})),r=Kt(o.map((function(t){return{type:f.FEATURE,properties:{},geometry:{type:f.POINT,coordinates:t}}})),n),i=0;i0?this.dragVertex(t,e,n):this.dragFeature(t,e,n),t.dragMoveLocation=e.lngLat}},oe.onClick=function(t,e){return ut(e)?this.clickNoTarget(t,e):at(e)?this.clickActiveFeature(t,e):st(e)?this.clickInactive(t,e):void this.stopDragging(t)},oe.onTap=function(t,e){return ut(e)?this.clickNoTarget(t,e):at(e)?this.clickActiveFeature(t,e):st(e)?this.clickInactive(t,e):void 0},oe.onTouchEnd=oe.onMouseUp=function(t){t.dragMoving&&this.fireUpdate(),this.stopDragging(t)};var re={};function ie(t,e){return!!t.lngLat&&(t.lngLat.lng===e[0]&&t.lngLat.lat===e[1])}re.onSetup=function(){var t=this.newFeature({type:f.FEATURE,properties:{},geometry:{type:f.POINT,coordinates:[]}});return this.addFeature(t),this.clearSelectedFeatures(),this.updateUIClasses({mouse:d.ADD}),this.activateUIButton(p.POINT),this.setActionableState({trash:!0}),{point:t}},re.stopDrawingAndRemove=function(t){this.deleteFeature([t.point.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT)},re.onTap=re.onClick=function(t,e){this.updateUIClasses({mouse:d.MOVE}),t.point.updateCoordinate("",e.lngLat.lng,e.lngLat.lat),this.map.fire(g.CREATE,{features:[t.point.toGeoJSON()]}),this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.point.id]})},re.onStop=function(t){this.activateUIButton(),t.point.getCoordinate().length||this.deleteFeature([t.point.id],{silent:!0})},re.toDisplayFeatures=function(t,e,n){var o=e.properties.id===t.point.id;if(e.properties.active=o?m.ACTIVE:m.INACTIVE,!o)return n(e)},re.onTrash=re.stopDrawingAndRemove,re.onKeyUp=function(t,e){if(pt(e)||ft(e))return this.stopDrawingAndRemove(t,e)};var ae={onSetup:function(){var t=this.newFeature({type:f.FEATURE,properties:{},geometry:{type:f.POLYGON,coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),Tt.disable(this),this.updateUIClasses({mouse:d.ADD}),this.activateUIButton(p.POLYGON),this.setActionableState({trash:!0}),{polygon:t,currentVertexPosition:0}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&ie(e,t.polygon.coordinates[0][t.currentVertexPosition-1]))return this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.polygon.id]});this.updateUIClasses({mouse:d.ADD}),t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),t.currentVertexPosition++,t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat)},clickOnVertex:function(t){return this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},onMouseMove:function(t,e){t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),lt(e)&&this.updateUIClasses({mouse:d.POINTER})}};ae.onTap=ae.onClick=function(t,e){return lt(e)?this.clickOnVertex(t,e):this.clickAnywhere(t,e)},ae.onKeyUp=function(t,e){pt(e)?(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT)):ft(e)&&this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},ae.onStop=function(t){this.updateUIClasses({mouse:d.NONE}),Tt.enable(this),this.activateUIButton(),void 0!==this.getFeature(t.polygon.id)&&(t.polygon.removeCoordinate("0."+t.currentVertexPosition),t.polygon.isValid()?this.map.fire(g.CREATE,{features:[t.polygon.toGeoJSON()]}):(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT,{},{silent:!0})))},ae.toDisplayFeatures=function(t,e,n){var o=e.properties.id===t.polygon.id;if(e.properties.active=o?m.ACTIVE:m.INACTIVE,!o)return n(e);if(0!==e.geometry.coordinates.length){var r=e.geometry.coordinates[0].length;if(!(r<3)){if(e.properties.meta=v.FEATURE,n(_t(t.polygon.id,e.geometry.coordinates[0][0],"0.0",!1)),r>3){var i=e.geometry.coordinates[0].length-3;n(_t(t.polygon.id,e.geometry.coordinates[0][i],"0."+i,!1))}if(r<=4){var a=[[e.geometry.coordinates[0][0][0],e.geometry.coordinates[0][0][1]],[e.geometry.coordinates[0][1][0],e.geometry.coordinates[0][1][1]]];if(n({type:f.FEATURE,properties:e.properties,geometry:{coordinates:a,type:f.LINE_STRING}}),3===r)return}return n(e)}}},ae.onTrash=function(t){this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT)};var se={onSetup:function(t){var e,n,o=(t=t||{}).featureId,r="forward";if(o){if(!(e=this.getFeature(o)))throw new Error("Could not find a feature with the provided featureId");var i=t.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");var a=e.coordinates.length-1;if(e.coordinates[a][0]===i[0]&&e.coordinates[a][1]===i[1])n=a+1,e.addCoordinate.apply(e,[n].concat(e.coordinates[a]));else{if(e.coordinates[0][0]!==i[0]||e.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");r="backwards",n=0,e.addCoordinate.apply(e,[n].concat(e.coordinates[0]))}}else e=this.newFeature({type:f.FEATURE,properties:{},geometry:{type:f.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(e);return this.clearSelectedFeatures(),Tt.disable(this),this.updateUIClasses({mouse:d.ADD}),this.activateUIButton(p.LINE),this.setActionableState({trash:!0}),{line:e,currentVertexPosition:n,direction:r}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&ie(e,t.line.coordinates[t.currentVertexPosition-1])||"backwards"===t.direction&&ie(e,t.line.coordinates[t.currentVertexPosition+1]))return this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.line.id]});this.updateUIClasses({mouse:d.ADD}),t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),"forward"===t.direction?(t.currentVertexPosition++,t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat)):t.line.addCoordinate(0,e.lngLat.lng,e.lngLat.lat)},clickOnVertex:function(t){return this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.line.id]})},onMouseMove:function(t,e){t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),lt(e)&&this.updateUIClasses({mouse:d.POINTER})}};se.onTap=se.onClick=function(t,e){if(lt(e))return this.clickOnVertex(t,e);this.clickAnywhere(t,e)},se.onKeyUp=function(t,e){ft(e)?this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.line.id]}):pt(e)&&(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT))},se.onStop=function(t){Tt.enable(this),this.activateUIButton(),void 0!==this.getFeature(t.line.id)&&(t.line.removeCoordinate(""+t.currentVertexPosition),t.line.isValid()?this.map.fire(g.CREATE,{features:[t.line.toGeoJSON()]}):(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT,{},{silent:!0})))},se.onTrash=function(t){this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT)},se.toDisplayFeatures=function(t,e,n){var o=e.properties.id===t.line.id;if(e.properties.active=o?m.ACTIVE:m.INACTIVE,!o)return n(e);e.geometry.coordinates.length<2||(e.properties.meta=v.FEATURE,n(_t(t.line.id,e.geometry.coordinates["forward"===t.direction?e.geometry.coordinates.length-2:1],""+("forward"===t.direction?e.geometry.coordinates.length-2:1),!1)),n(e))};var ue={simple_select:te,direct_select:oe,draw_point:re,draw_polygon:ae,draw_line_string:se},ce={defaultMode:h.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:ot,modes:ue,controls:{},userProperties:!1},le={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},de={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function pe(t,e){return t.map((function(t){return t.source?t:tt(t,{id:t.id+"."+e,source:"hot"===e?l.HOT:l.COLD})}))}var fe={exports:{}};!function(t,e){var n="__lodash_hash_undefined__",o=9007199254740991,r="[object Arguments]",i="[object Array]",a="[object Boolean]",s="[object Date]",u="[object Error]",c="[object Function]",l="[object Map]",d="[object Number]",p="[object Object]",f="[object Promise]",h="[object RegExp]",g="[object Set]",y="[object String]",v="[object Symbol]",m="[object WeakMap]",_="[object ArrayBuffer]",b="[object DataView]",E=/^\[object .+?Constructor\]$/,T=/^(?:0|[1-9]\d*)$/,C={};C["[object Float32Array]"]=C["[object Float64Array]"]=C["[object Int8Array]"]=C["[object Int16Array]"]=C["[object Int32Array]"]=C["[object Uint8Array]"]=C["[object Uint8ClampedArray]"]=C["[object Uint16Array]"]=C["[object Uint32Array]"]=!0,C[r]=C[i]=C[_]=C[a]=C[b]=C[s]=C[u]=C[c]=C[l]=C[d]=C[p]=C[h]=C[g]=C[y]=C[m]=!1;var O="object"==typeof global&&global&&global.Object===Object&&global,S="object"==typeof self&&self&&self.Object===Object&&self,I=O||S||Function("return this")(),x=e&&!e.nodeType&&e,M=x&&t&&!t.nodeType&&t,L=M&&M.exports===x,N=L&&O.process,A=function(){try{return N&&N.binding&&N.binding("util")}catch(t){}}(),P=A&&A.isTypedArray;function F(t,e){for(var n=-1,o=null==t?0:t.length;++ns))return!1;var c=i.get(t);if(c&&i.get(e))return c==e;var l=-1,d=!0,p=2&n?new _t:void 0;for(i.set(t,e),i.set(e,t);++l-1},vt.prototype.set=function(t,e){var n=this.__data__,o=Tt(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this},mt.prototype.clear=function(){this.size=0,this.__data__={hash:new yt,map:new(rt||vt),string:new yt}},mt.prototype.delete=function(t){var e=Nt(this,t).delete(t);return this.size-=e?1:0,e},mt.prototype.get=function(t){return Nt(this,t).get(t)},mt.prototype.has=function(t){return Nt(this,t).has(t)},mt.prototype.set=function(t,e){var n=Nt(this,t),o=n.size;return n.set(t,e),this.size+=n.size==o?0:1,this},_t.prototype.add=_t.prototype.push=function(t){return this.__data__.set(t,n),this},_t.prototype.has=function(t){return this.__data__.has(t)},bt.prototype.clear=function(){this.__data__=new vt,this.size=0},bt.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},bt.prototype.get=function(t){return this.__data__.get(t)},bt.prototype.has=function(t){return this.__data__.has(t)},bt.prototype.set=function(t,e){var n=this.__data__;if(n instanceof vt){var o=n.__data__;if(!rt||o.length<199)return o.push([t,e]),this.size=++n.size,this;n=this.__data__=new mt(o)}return n.set(t,e),this.size=n.size,this};var Pt=tt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,o=null==t?0:t.length,r=0,i=[];++n-1&&t%1==0&&t-1&&t%1==0&&t<=o}function Gt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Jt(t){return null!=t&&"object"==typeof t}var zt=P?function(t){return function(e){return t(e)}}(P):function(t){return Jt(t)&&Bt(t.length)&&!!C[Ct(t)]};function Yt(t){return null!=(e=t)&&Bt(e.length)&&!Vt(e)?Et(t):xt(t);var e}t.exports=function(t,e){return St(t,e)}}(fe,fe.exports);var he=e(fe.exports);function ge(t,e){return t.length===e.length&&JSON.stringify(t.map((function(t){return t})).sort())===JSON.stringify(e.map((function(t){return t})).sort())}var ye={Polygon:V,LineString:j,Point:U,MultiPolygon:J,MultiLineString:J,MultiPoint:J};var ve=Object.freeze({__proto__:null,CommonSelectors:ht,constrainFeatureMovement:Kt,createMidPoint:bt,createSupplementaryPoints:Et,createVertex:_t,doubleClickZoom:Tt,euclideanDistance:A,featuresAt:M,getFeatureAtAndSetCursors:N,isClick:P,isEventAtCoordinates:ie,isTap:F,mapEventToBoundingBox:S,ModeHandler:t,moveFeatures:Qt,sortFeatures:O,stringSetsAreEqual:ge,StringSet:I,theme:ot,toDenseArray:H}),me=function(t,e){var n={options:t=function(t){void 0===t&&(t={});var e=tt(t);return t.controls||(e.controls={}),!1===t.displayControlsDefault?e.controls=tt(de,t.controls):e.controls=tt(le,t.controls),(e=tt(ce,e)).styles=pe(e.styles,"cold").concat(pe(e.styles,"hot")),e}(t)};e=function(t,e){return e.modes=h,e.getFeatureIdsAt=function(e){return M.click({point:e},null,t).map((function(t){return t.properties.id}))},e.getSelectedIds=function(){return t.store.getSelectedIds()},e.getSelected=function(){return{type:f.FEATURE_COLLECTION,features:t.store.getSelectedIds().map((function(e){return t.store.get(e)})).map((function(t){return t.toGeoJSON()}))}},e.getSelectedPoints=function(){return{type:f.FEATURE_COLLECTION,features:t.store.getSelectedCoordinates().map((function(t){return{type:f.FEATURE,properties:{},geometry:{type:f.POINT,coordinates:t.coordinates}}}))}},e.set=function(n){if(void 0===n.type||n.type!==f.FEATURE_COLLECTION||!Array.isArray(n.features))throw new Error("Invalid FeatureCollection");var o=t.store.createRenderBatch(),r=t.store.getAllIds().slice(),i=e.add(n),a=new I(i);return(r=r.filter((function(t){return!a.has(t)}))).length&&e.delete(r),o(),i},e.add=function(e){var n=JSON.parse(JSON.stringify(It(e))).features.map((function(e){if(e.id=e.id||k(),null===e.geometry)throw new Error("Invalid geometry: null");if(void 0===t.store.get(e.id)||t.store.get(e.id).type!==e.geometry.type){var n=ye[e.geometry.type];if(void 0===n)throw new Error("Invalid geometry type: "+e.geometry.type+".");var o=new n(t,e);t.store.add(o)}else{var r=t.store.get(e.id);r.properties=e.properties,he(r.properties,e.properties)||t.store.featureChanged(r.id),he(r.getCoordinates(),e.geometry.coordinates)||r.incomingCoords(e.geometry.coordinates)}return e.id}));return t.store.render(),n},e.get=function(e){var n=t.store.get(e);if(n)return n.toGeoJSON()},e.getAll=function(){return{type:f.FEATURE_COLLECTION,features:t.store.getAll().map((function(t){return t.toGeoJSON()}))}},e.delete=function(n){return t.store.delete(n,{silent:!0}),e.getMode()!==h.DIRECT_SELECT||t.store.getSelectedIds().length?t.store.render():t.events.changeMode(h.SIMPLE_SELECT,void 0,{silent:!0}),e},e.deleteAll=function(){return t.store.delete(t.store.getAllIds(),{silent:!0}),e.getMode()===h.DIRECT_SELECT?t.events.changeMode(h.SIMPLE_SELECT,void 0,{silent:!0}):t.store.render(),e},e.changeMode=function(n,o){return void 0===o&&(o={}),n===h.SIMPLE_SELECT&&e.getMode()===h.SIMPLE_SELECT?(ge(o.featureIds||[],t.store.getSelectedIds())||(t.store.setSelected(o.featureIds,{silent:!0}),t.store.render()),e):(n===h.DIRECT_SELECT&&e.getMode()===h.DIRECT_SELECT&&o.featureId===t.store.getSelectedIds()[0]||t.events.changeMode(n,o,{silent:!0}),e)},e.getMode=function(){return t.events.getMode()},e.trash=function(){return t.events.trash({silent:!0}),e},e.combineFeatures=function(){return t.events.combineFeatures({silent:!0}),e},e.uncombineFeatures=function(){return t.events.uncombineFeatures({silent:!0}),e},e.setFeatureProperty=function(n,o,r){return t.store.setFeatureProperty(n,o,r),e},e}(n,e),n.api=e;var o=nt(n);return e.onAdd=o.onAdd,e.onRemove=o.onRemove,e.types=p,e.options=t,e};function _e(t){me(t,this)}return _e.modes=ue,_e.constants=E,_e.lib=ve,_e})); +var e,t;e=this,t=function(){const e=function(e,t){const o={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},n={on(e,t,n){if(void 0===o[e])throw new Error(`Invalid event type: ${e}`);o[e].push({selector:t,fn:n})},render(e){t.store.featureChanged(e)}},r=function(e,r){const i=o[e];let s=i.length;for(;s--;){const e=i[s];if(e.selector(r)){e.fn.call(n,r)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(n),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(e){r("drag",e)},click(e){r("click",e)},mousemove(e){r("mousemove",e)},mousedown(e){r("mousedown",e)},mouseup(e){r("mouseup",e)},mouseout(e){r("mouseout",e)},keydown(e){r("keydown",e)},keyup(e){r("keyup",e)},touchstart(e){r("touchstart",e)},touchmove(e){r("touchmove",e)},touchend(e){r("touchend",e)},tap(e){r("tap",e)}}};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var o,n,r={},i={};function s(){return o||(o=1,i.RADIUS=6378137,i.FLATTENING=1/298.257223563,i.POLAR_RADIUS=6356752.3142),i}var a=function(){if(n)return r;n=1;var e=s();function t(e){var t=0;if(e&&e.length>0){t+=Math.abs(o(e[0]));for(var n=1;n2){for(c=0;c(e.geometry.type===h.POLYGON&&(e.area=c.geometry({type:h.FEATURE,property:{},geometry:e.geometry})),e))).sort(S).map((e=>(delete e.area,e)))}function L(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]}function M(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,o=e.length;t{e.push({k:t,v:this._items[t]})})),Object.keys(this._nums).forEach((t=>{e.push({k:JSON.parse(t),v:this._nums[t]})})),e.sort(((e,t)=>e.v-t.v)).map((e=>e.k))},M.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const N=[y.FEATURE,y.MIDPOINT,y.VERTEX];var b={click:function(e,t,o){return x(e,t,o,o.options.clickBuffer)},touch:function(e,t,o){return x(e,t,o,o.options.touchBuffer)}};function x(e,t,o,n){if(null===o.map)return[];const r=e?L(e,n):t,i={};o.options.styles&&(i.layers=o.options.styles.map((e=>e.id)).filter((e=>null!=o.map.getLayer(e))));const s=o.map.queryRenderedFeatures(r,i).filter((e=>-1!==N.indexOf(e.properties.meta))),a=new M,c=[];return s.forEach((e=>{const t=e.properties.id;a.has(t)||(a.add(t),c.push(e))})),O(c)}function A(e,t){const o=b.click(e,null,t),n={mouse:d.NONE};return o[0]&&(n.mouse=o[0].properties.active===E.ACTIVE?d.MOVE:d.POINTER,n.feature=o[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(n.mouse=d.ADD),t.ui.queueMapClasses(n),t.ui.updateMapClasses(),o[0]}function P(e,t){const o=e.x-t.x,n=e.y-t.y;return Math.sqrt(o*o+n*n)}const F=4,R=12,w=500;function D(e,t,o={}){const n=null!=o.fineTolerance?o.fineTolerance:F,r=null!=o.grossTolerance?o.grossTolerance:R,i=null!=o.interval?o.interval:w;e.point=e.point||t.point,e.time=e.time||t.time;const s=P(e.point,t.point);return s(o=t)=>{let n="",r=0|o;for(;r--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function B(){return G()}const j=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||B(),this.type=t.geometry.type};j.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},j.prototype.incomingCoords=function(e){this.setCoordinates(e)},j.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},j.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},j.prototype.setProperty=function(e,t){this.properties[e]=t},j.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:h.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},j.prototype.internal=function(e){const t={id:this.id,meta:y.FEATURE,"meta:type":this.type,active:E.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const e in this.properties)t[`user_${e}`]=this.properties[e];return{type:h.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const J=function(e,t){j.call(this,e,t)};(J.prototype=Object.create(j.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},J.prototype.updateCoordinate=function(e,t,o){this.coordinates=3===arguments.length?[t,o]:[e,t],this.changed()},J.prototype.getCoordinate=function(){return this.getCoordinates()};const $=function(e,t){j.call(this,e,t)};($.prototype=Object.create(j.prototype)).isValid=function(){return this.coordinates.length>1},$.prototype.addCoordinate=function(e,t,o){this.changed();const n=parseInt(e,10);this.coordinates.splice(n,0,[t,o])},$.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},$.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},$.prototype.updateCoordinate=function(e,t,o){const n=parseInt(e,10);this.coordinates[n]=[t,o],this.changed()};const Y=function(e,t){j.call(this,e,t),this.coordinates=this.coordinates.map((e=>e.slice(0,-1)))};(Y.prototype=Object.create(j.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every((e=>e.length>2))},Y.prototype.incomingCoords=function(e){this.coordinates=e.map((e=>e.slice(0,-1))),this.changed()},Y.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},Y.prototype.addCoordinate=function(e,t,o){this.changed();const n=e.split(".").map((e=>parseInt(e,10)));this.coordinates[n[0]].splice(n[1],0,[t,o])},Y.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map((e=>parseInt(e,10))),o=this.coordinates[t[0]];o&&(o.splice(t[1],1),o.length<3&&this.coordinates.splice(t[0],1))},Y.prototype.getCoordinate=function(e){const t=e.split(".").map((e=>parseInt(e,10))),o=this.coordinates[t[0]];return JSON.parse(JSON.stringify(o[t[1]]))},Y.prototype.getCoordinates=function(){return this.coordinates.map((e=>e.concat([e[0]])))},Y.prototype.updateCoordinate=function(e,t,o){this.changed();const n=e.split("."),r=parseInt(n[0],10),i=parseInt(n[1],10);void 0===this.coordinates[r]&&(this.coordinates[r]=[]),this.coordinates[r][i]=[t,o]};const H={MultiPoint:J,MultiLineString:$,MultiPolygon:Y},X=(e,t,o,n,r)=>{const i=o.split("."),s=parseInt(i[0],10),a=i[1]?i.slice(1).join("."):null;return e[s][t](a,n,r)},q=function(e,t){if(j.call(this,e,t),delete this.coordinates,this.model=H[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};function Z(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}(q.prototype=Object.create(j.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map((e=>new t(this.ctx,{id:B(),type:h.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}})))},q.prototype.isValid=function(){return this.features.every((e=>e.isValid()))},q.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},q.prototype.getCoordinate=function(e){return X(this.features,"getCoordinate",e)},q.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map((e=>e.type===h.POLYGON?e.getCoordinates():e.coordinates))))},q.prototype.updateCoordinate=function(e,t,o){X(this.features,"updateCoordinate",e,t,o),this.changed()},q.prototype.addCoordinate=function(e,t,o){X(this.features,"addCoordinate",e,t,o),this.changed()},q.prototype.removeCoordinate=function(e){X(this.features,"removeCoordinate",e),this.changed()},q.prototype.getFeatures=function(){return this.features},Z.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},Z.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce(((e,t)=>(void 0===e[t.feature_id]&&(e[t.feature_id]=!0,this._ctx.store.get(t.feature_id).changed()),e)),{})},Z.prototype.getSelected=function(){return this._ctx.store.getSelected()},Z.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},Z.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},Z.prototype.getFeature=function(e){return this._ctx.store.get(e)},Z.prototype.select=function(e){return this._ctx.store.select(e)},Z.prototype.deselect=function(e){return this._ctx.store.deselect(e)},Z.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},Z.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},Z.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},Z.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},Z.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},Z.prototype.changeMode=function(e,t={},o={}){return this._ctx.events.changeMode(e,t,o)},Z.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},Z.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},Z.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},Z.prototype.featuresAt=function(e,t,o="click"){if("click"!==o&&"touch"!==o)throw new Error("invalid buffer type");return b[o](e,t,this._ctx)},Z.prototype.newFeature=function(e){const t=e.geometry.type;return t===h.POINT?new J(this._ctx,e):t===h.LINE_STRING?new $(this._ctx,e):t===h.POLYGON?new Y(this._ctx,e):new q(this._ctx,e)},Z.prototype.isInstanceOf=function(e,t){if(e===h.POINT)return t instanceof J;if(e===h.LINE_STRING)return t instanceof $;if(e===h.POLYGON)return t instanceof Y;if("MultiFeature"===e)return t instanceof q;throw new Error(`Unknown feature class: ${e}`)},Z.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)},Z.prototype.onSetup=function(){},Z.prototype.onDrag=function(){},Z.prototype.onClick=function(){},Z.prototype.onMouseMove=function(){},Z.prototype.onMouseDown=function(){},Z.prototype.onMouseUp=function(){},Z.prototype.onMouseOut=function(){},Z.prototype.onKeyUp=function(){},Z.prototype.onKeyDown=function(){},Z.prototype.onTouchStart=function(){},Z.prototype.onTouchMove=function(){},Z.prototype.onTouchEnd=function(){},Z.prototype.onTap=function(){},Z.prototype.onStop=function(){},Z.prototype.onTrash=function(){},Z.prototype.onCombineFeature=function(){},Z.prototype.onUncombineFeature=function(){},Z.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const W={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},K=Object.keys(W);function z(e){const t=Object.keys(e);return function(o,n={}){let r={};const i=t.reduce(((t,o)=>(t[o]=e[o],t)),new Z(o));return{start(){r=i.onSetup(n),K.forEach((t=>{const o=W[t];let n=()=>!1;var s;e[o]&&(n=()=>!0),this.on(t,n,(s=o,e=>i[s](r,e)))}))},stop(){i.onStop(r)},trash(){i.onTrash(r)},combineFeatures(){i.onCombineFeatures(r)},uncombineFeatures(){i.onUncombineFeatures(r)},render(e,t){i.toDisplayFeatures(r,e,t)}}}}function Q(e){return[].concat(e).filter((e=>void 0!==e))}function ee(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(l.HOT))return a();const t=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:t});let o=[],n=[];e.isDirty?n=e.getAllIds():(o=e.getChangedIds().filter((t=>void 0!==e.get(t))),n=e.sources.hot.filter((t=>t.properties.id&&-1===o.indexOf(t.properties.id)&&void 0!==e.get(t.properties.id))).map((e=>e.properties.id))),e.sources.hot=[];const r=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter((e=>{const t=e.properties.id||e.properties.parent;return-1===o.indexOf(t)}));const i=r!==e.sources.cold.length||n.length>0;function s(o,n){const r=e.get(o).internal(t);e.ctx.events.currentModeRender(r,(o=>{o.properties.mode=t,e.sources[n].push(o)}))}function a(){e.isDirty=!1,e.clearChangedIds()}o.forEach((e=>s(e,"hot"))),n.forEach((e=>s(e,"cold"))),i&&e.ctx.map.getSource(l.COLD).setData({type:h.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(l.HOT).setData({type:h.FEATURE_COLLECTION,features:e.sources.hot}),a()}function te(e){let t;this._features={},this._featureIds=new M,this._selectedFeatureIds=new M,this._selectedCoordinates=[],this._changedFeatureIds=new M,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame((()=>{t=null,ee.call(this),this._emitSelectionChange&&(this.ctx.events.fire(g.SELECTION_CHANGE,{features:this.getSelected().map((e=>e.toGeoJSON())),points:this.getSelectedCoordinates().map((e=>({type:h.FEATURE,properties:{},geometry:{type:h.POINT,coordinates:e.coordinates}})))}),this._emitSelectionChange=!1),this.ctx.events.fire(g.RENDER,{})})))},this.isDirty=!1}function oe(e,t={}){const o=e._selectedCoordinates.filter((t=>e._selectedFeatureIds.has(t.feature_id)));e._selectedCoordinates.length===o.length||t.silent||(e._emitSelectionChange=!0),e._selectedCoordinates=o}te.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},te.prototype.setDirty=function(){return this.isDirty=!0,this},te.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const t=this.get(e);this.ctx.events.fire(g.CREATE,{features:[t.toGeoJSON()]})}return this},te.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(g.UPDATE,{action:t.action?t.action:m.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},te.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},te.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},te.prototype.getAllIds=function(){return this._featureIds.values()},te.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},te.prototype.delete=function(e,t={}){const o=[];return Q(e).forEach((e=>{this._featureIds.has(e)&&(this._featureIds.delete(e),this._selectedFeatureIds.delete(e),t.silent||-1===o.indexOf(this._features[e])&&o.push(this._features[e].toGeoJSON()),delete this._features[e],this.isDirty=!0)})),o.length&&this.ctx.events.fire(g.DELETE,{features:o}),oe(this,t),this},te.prototype.get=function(e){return this._features[e]},te.prototype.getAll=function(){return Object.keys(this._features).map((e=>this._features[e]))},te.prototype.select=function(e,t={}){return Q(e).forEach((e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))})),this},te.prototype.deselect=function(e,t={}){return Q(e).forEach((e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))})),oe(this,t),this},te.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},te.prototype.setSelected=function(e,t={}){return e=Q(e),this.deselect(this._selectedFeatureIds.values().filter((t=>-1===e.indexOf(t))),{silent:t.silent}),this.select(e.filter((e=>!this._selectedFeatureIds.has(e))),{silent:t.silent}),this},te.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},te.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},te.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},te.prototype.getSelected=function(){return this.getSelectedIds().map((e=>this.get(e)))},te.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map((e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)})))},te.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},te.prototype.setFeatureProperty=function(e,t,o,n={}){this.get(e).setProperty(t,o),this.featureChanged(e,{silent:n.silent,action:m.CHANGE_PROPERTIES})},te.prototype.storeMapConfig=function(){T.forEach((e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())}))},te.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach((e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()}))},te.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const ne=["mode","feature","mouse"];function re(t){let o=null,n=null;const r={onRemove(){return t.map.off("load",r.connect),clearInterval(n),r.removeLayers(),t.store.restoreMapConfig(),t.ui.removeButtons(),t.events.removeEventListeners(),t.ui.clearMapClasses(),t.boxZoomInitial&&t.map.boxZoom.enable(),t.map=null,t.container=null,t.store=null,o&&o.parentNode&&o.parentNode.removeChild(o),o=null,this},connect(){t.map.off("load",r.connect),clearInterval(n),r.addLayers(),t.store.storeMapConfig(),t.events.addEventListeners()},onAdd(i){if(t.map=i,t.events=function(t){const o=Object.keys(t.options.modes).reduce(((e,o)=>(e[o]=z(t.options.modes[o]),e)),{});let n={},r={};const i={};let s=null,a=null;i.drag=function(e,o){o({point:e.point,time:(new Date).getTime()})?(t.ui.queueMapClasses({mouse:d.DRAG}),a.drag(e)):e.originalEvent.stopPropagation()},i.mousedrag=function(e){i.drag(e,(e=>!D(n,e)))},i.touchdrag=function(e){i.drag(e,(e=>!V(r,e)))},i.mousemove=function(e){if(1===(void 0!==e.originalEvent.buttons?e.originalEvent.buttons:e.originalEvent.which))return i.mousedrag(e);const o=A(e,t);e.featureTarget=o,a.mousemove(e)},i.mousedown=function(e){n={time:(new Date).getTime(),point:e.point};const o=A(e,t);e.featureTarget=o,a.mousedown(e)},i.mouseup=function(e){const o=A(e,t);e.featureTarget=o,D(n,{point:e.point,time:(new Date).getTime()})?a.click(e):a.mouseup(e)},i.mouseout=function(e){a.mouseout(e)},i.touchstart=function(e){if(!t.options.touchEnabled)return;r={time:(new Date).getTime(),point:e.point};const o=b.touch(e,null,t)[0];e.featureTarget=o,a.touchstart(e)},i.touchmove=function(e){if(t.options.touchEnabled)return a.touchmove(e),i.touchdrag(e)},i.touchend=function(e){if(e.originalEvent.preventDefault(),!t.options.touchEnabled)return;const o=b.touch(e,null,t)[0];e.featureTarget=o,V(r,{time:(new Date).getTime(),point:e.point})?a.tap(e):a.touchend(e)};const c=e=>!(8===e||46===e||e>=48&&e<=57);function l(n,r,i={}){a.stop();const c=o[n];if(void 0===c)throw new Error(`${n} is not valid`);s=n;const u=c(t,r);a=e(u,t),i.silent||t.map.fire(g.MODE_CHANGE,{mode:n}),t.store.setDirty(),t.store.render()}i.keydown=function(e){(e.srcElement||e.target).classList.contains(u.CANVAS)&&(8!==e.keyCode&&46!==e.keyCode||!t.options.controls.trash?c(e.keyCode)?a.keydown(e):49===e.keyCode&&t.options.controls.point?l(f.DRAW_POINT):50===e.keyCode&&t.options.controls.line_string?l(f.DRAW_LINE_STRING):51===e.keyCode&&t.options.controls.polygon&&l(f.DRAW_POLYGON):(e.preventDefault(),a.trash()))},i.keyup=function(e){c(e.keyCode)&&a.keyup(e)},i.zoomend=function(){t.store.changeZoom()},i.data=function(e){if("style"===e.dataType){const{setup:e,map:o,options:n,store:r}=t;n.styles.some((e=>o.getLayer(e.id)))||(e.addLayers(),r.setDirty(),r.render())}};const p={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start(){s=t.options.defaultMode,a=e(o[s](t),t)},changeMode:l,actionable:function(e){let o=!1;Object.keys(e).forEach((t=>{if(void 0===p[t])throw new Error("Invalid action type");p[t]!==e[t]&&(o=!0),p[t]=e[t]})),o&&t.map.fire(g.ACTIONABLE,{actions:p})},currentModeName:()=>s,currentModeRender:(e,t)=>a.render(e,t),fire(e,o){t.map&&t.map.fire(e,o)},addEventListeners(){t.map.on("mousemove",i.mousemove),t.map.on("mousedown",i.mousedown),t.map.on("mouseup",i.mouseup),t.map.on("data",i.data),t.map.on("touchmove",i.touchmove),t.map.on("touchstart",i.touchstart),t.map.on("touchend",i.touchend),t.container.addEventListener("mouseout",i.mouseout),t.options.keybindings&&(t.container.addEventListener("keydown",i.keydown),t.container.addEventListener("keyup",i.keyup))},removeEventListeners(){t.map.off("mousemove",i.mousemove),t.map.off("mousedown",i.mousedown),t.map.off("mouseup",i.mouseup),t.map.off("data",i.data),t.map.off("touchmove",i.touchmove),t.map.off("touchstart",i.touchstart),t.map.off("touchend",i.touchend),t.container.removeEventListener("mouseout",i.mouseout),t.options.keybindings&&(t.container.removeEventListener("keydown",i.keydown),t.container.removeEventListener("keyup",i.keyup))},trash(e){a.trash(e)},combineFeatures(){a.combineFeatures()},uncombineFeatures(){a.uncombineFeatures()},getMode:()=>s}}(t),t.ui=function(e){const t={};let o=null,n={mode:null,feature:null,mouse:null},r={mode:null,feature:null,mouse:null};function i(e){r=Object.assign(r,e)}function s(){if(!e.container)return;const t=[],o=[];ne.forEach((e=>{r[e]!==n[e]&&(t.push(`${e}-${n[e]}`),null!==r[e]&&o.push(`${e}-${r[e]}`))})),t.length>0&&e.container.classList.remove(...t),o.length>0&&e.container.classList.add(...o),n=Object.assign(n,r)}function a(e,t={}){const n=document.createElement("button");return n.className=`${u.CONTROL_BUTTON} ${t.className}`,n.setAttribute("title",t.title),t.container.appendChild(n),n.addEventListener("click",(n=>{if(n.preventDefault(),n.stopPropagation(),n.target===o)return c(),void t.onDeactivate();l(e),t.onActivate()}),!0),n}function c(){o&&(o.classList.remove(u.ACTIVE_BUTTON),o=null)}function l(e){c();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(u.ACTIVE_BUTTON),o=n)}return{setActiveButton:l,queueMapClasses:i,updateMapClasses:s,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),s()},addButtons:function(){const o=e.options.controls,n=document.createElement("div");return n.className=`${u.CONTROL_GROUP} ${u.CONTROL_BASE}`,o?(o[p.LINE]&&(t[p.LINE]=a(p.LINE,{container:n,className:u.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(l)":""),onActivate:()=>e.events.changeMode(f.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),o[p.POLYGON]&&(t[p.POLYGON]=a(p.POLYGON,{container:n,className:u.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(p)":""),onActivate:()=>e.events.changeMode(f.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),o[p.POINT]&&(t[p.POINT]=a(p.POINT,{container:n,className:u.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(m)":""),onActivate:()=>e.events.changeMode(f.DRAW_POINT),onDeactivate:()=>e.events.trash()})),o.trash&&(t.trash=a("trash",{container:n,className:u.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),o.combine_features&&(t.combine_features=a("combineFeatures",{container:n,className:u.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),o.uncombine_features&&(t.uncombine_features=a("uncombineFeatures",{container:n,className:u.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}})),n):n},removeButtons:function(){Object.keys(t).forEach((e=>{const o=t[e];o.parentNode&&o.parentNode.removeChild(o),delete t[e]}))}}}(t),t.container=i.getContainer(),t.store=new te(t),o=t.ui.addButtons(),t.options.boxSelect){t.boxZoomInitial=i.boxZoom.isEnabled(),i.boxZoom.disable();const e=i.dragPan.isEnabled();i.dragPan.disable(),i.dragPan.enable(),e||i.dragPan.disable()}return i.loaded()?r.connect():(i.on("load",r.connect),n=setInterval((()=>{i.loaded()&&r.connect()}),16)),t.events.start(),o},addLayers(){t.map.addSource(l.COLD,{data:{type:h.FEATURE_COLLECTION,features:[]},type:"geojson"}),t.map.addSource(l.HOT,{data:{type:h.FEATURE_COLLECTION,features:[]},type:"geojson"}),t.options.styles.forEach((e=>{t.map.addLayer(e)})),t.store.setDirty(!0),t.store.render()},removeLayers(){t.options.styles.forEach((e=>{t.map.getLayer(e.id)&&t.map.removeLayer(e.id)})),t.map.getSource(l.COLD)&&t.map.removeSource(l.COLD),t.map.getSource(l.HOT)&&t.map.removeSource(l.HOT)}};return t.setup=r,r}const ie="#3bb2d0",se="#fbb03b",ae="#fff";var ce=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],se,ie],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],se,ie],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":ae}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],se,ie]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":ae}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":se}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":se}}];function ue(e){return function(t){const o=t.featureTarget;return!!o&&!!o.properties&&o.properties.meta===e}}function le(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function de(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===E.ACTIVE&&e.featureTarget.properties.meta===y.FEATURE}function pe(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===E.INACTIVE&&e.featureTarget.properties.meta===y.FEATURE}function he(e){return void 0===e.featureTarget}function fe(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===y.FEATURE}function ge(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===y.VERTEX}function me(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function ye(e){return 27===e.keyCode}function Ee(e){return 13===e.keyCode}var Te=Object.freeze({__proto__:null,isActiveFeature:de,isEnterKey:Ee,isEscapeKey:ye,isFeature:fe,isInactiveFeature:pe,isOfMetaType:ue,isShiftDown:me,isShiftMousedown:le,isTrue:function(){return!0},isVertex:ge,noTarget:he});function Ce(e,t){this.x=e,this.y=t}function _e(e,t){const o=t.getBoundingClientRect();return new Ce(e.clientX-o.left-(t.clientLeft||0),e.clientY-o.top-(t.clientTop||0))}function ve(e,t,o,n){return{type:h.FEATURE,properties:{meta:y.VERTEX,parent:e,coord_path:o,active:n?E.ACTIVE:E.INACTIVE},geometry:{type:h.POINT,coordinates:t}}}function Ie(e,t,o){const n=t.geometry.coordinates,r=o.geometry.coordinates;if(n[1]>_||n[1]_||r[1]{const u=null!=o?`${o}.${a}`:String(a),l=ve(i,e,u,c(u));if(t.midpoints&&r){const e=Ie(i,r,l);e&&s.push(e)}r=l;const d=JSON.stringify(e);n!==d&&s.push(l),0===a&&(n=d)}))}function c(e){return!!t.selectedPaths&&-1!==t.selectedPaths.indexOf(e)}return n===h.POINT?s.push(ve(i,r,o,c(o))):n===h.POLYGON?r.forEach(((e,t)=>{a(e,null!==o?`${o}.${t}`:String(t))})):n===h.LINE_STRING?a(r,o):0===n.indexOf(h.MULTI_PREFIX)&&function(){const o=n.replace(h.MULTI_PREFIX,"");r.forEach(((n,r)=>{const i={type:h.FEATURE,properties:e.properties,geometry:{type:o,coordinates:n}};s=s.concat(Se(i,t,r))}))}(),s}Ce.prototype={clone(){return new Ce(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,o=e.y-this.y;return t*t+o*o},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,o=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=o,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),o=Math.sin(e),n=t*this.x-o*this.y,r=o*this.x+t*this.y;return this.x=n,this.y=r,this},_rotateAround(e,t){const o=Math.cos(e),n=Math.sin(e),r=t.x+o*(this.x-t.x)-n*(this.y-t.y),i=t.y+n*(this.x-t.x)+o*(this.y-t.y);return this.x=r,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ce},Ce.convert=function(e){if(e instanceof Ce)return e;if(Array.isArray(e))return new Ce(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Ce(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var Oe={enable(e){setTimeout((()=>{e.map&&e.map.doubleClickZoom&&e._ctx&&e._ctx.store&&e._ctx.store.getInitialConfigValue&&e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()}),0)},disable(e){setTimeout((()=>{e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.disable()}),0)}};const{LAT_MIN:Le,LAT_MAX:Me,LAT_RENDERED_MIN:Ne,LAT_RENDERED_MAX:be,LNG_MIN:xe,LNG_MAX:Ae}=v;function Pe(e,t){let o=Le,n=Me,r=Le,i=Me,s=Ae,a=xe;e.forEach((e=>{const t=function(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],o=[e.geometry.coordinates].flat(t),n=o.map((e=>e[0])),r=o.map((e=>e[1])),i=e=>Math.min.apply(null,e),s=e=>Math.max.apply(null,e);return[i(n),i(r),s(n),s(r)]}(e),c=t[1],u=t[3],l=t[0],d=t[2];c>o&&(o=c),ur&&(r=u),ca&&(a=d)}));const c=t;return o+c.lat>be&&(c.lat=be-o),r+c.lat>Me&&(c.lat=Me-r),n+c.lat=Ae&&(c.lng-=360*Math.ceil(Math.abs(c.lng)/360)),c}function Fe(e,t){const o=Pe(e.map((e=>e.toGeoJSON())),t);e.forEach((e=>{const t=e.getCoordinates(),n=e=>{const t={lng:e[0]+o.lng,lat:e[1]+o.lat};return[t.lng,t.lat]},r=e=>e.map((e=>n(e))),i=e=>e.map((e=>r(e)));let s;e.type===h.POINT?s=n(t):e.type===h.LINE_STRING||e.type===h.MULTI_POINT?s=t.map(n):e.type===h.POLYGON||e.type===h.MULTI_LINE_STRING?s=t.map(r):e.type===h.MULTI_POLYGON&&(s=t.map(i)),e.incomingCoords(s)}))}const Re={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter((e=>void 0!==this.getFeature(e)))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(g.UPDATE,{action:m.MOVE,features:this.getSelected().map((e=>e.toGeoJSON()))})},fireActionable:function(){const e=this.getSelected(),t=e.filter((e=>this.isInstanceOf("MultiFeature",e)));let o=!1;if(e.length>1){o=!0;const t=e[0].type.replace("Multi","");e.forEach((e=>{e.type.replace("Multi","")!==t&&(o=!1)}))}const n=t.length>0,r=e.length>0;this.setActionableState({combineFeatures:o,uncombineFeatures:n,trash:r})},getUniqueIds:function(e){return e.length?e.map((e=>e.properties.id)).filter((e=>void 0!==e)).reduce(((e,t)=>(e.add(t),e)),new M).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){Oe.enable(this)},onMouseMove:function(e,t){return fe(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};Re.onTap=Re.onClick=function(e,t){return he(t)?this.clickAnywhere(e,t):ue(y.VERTEX)(t)?this.clickOnVertex(e,t):fe(t)?this.clickOnFeature(e,t):void 0},Re.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach((e=>this.doRender(e)))),Oe.enable(this),this.stopExtendedInteractions(e)},Re.clickOnVertex=function(e,t){this.changeMode(f.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:d.MOVE})},Re.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},Re.clickOnFeature=function(e,t){Oe.disable(this),this.stopExtendedInteractions(e);const o=me(t),n=this.getSelectedIds(),r=t.featureTarget.properties.id,i=this.isSelected(r);if(!o&&i&&this.getFeature(r).type!==h.POINT)return this.changeMode(f.DIRECT_SELECT,{featureId:r});i&&o?(this.deselect(r),this.updateUIClasses({mouse:d.POINTER}),1===n.length&&Oe.enable(this)):!i&&o?(this.select(r),this.updateUIClasses({mouse:d.MOVE})):i||o||(n.forEach((e=>this.doRender(e))),this.setSelected(r),this.updateUIClasses({mouse:d.MOVE})),this.doRender(r)},Re.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),de(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&le(t)?this.startBoxSelect(e,t):void 0},Re.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=_e(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},Re.onTouchStart=function(e,t){if(de(t))return this.startOnActiveFeature(e,t)},Re.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},Re.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:d.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(u.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const o=_e(t.originalEvent,this.map.getContainer()),n=Math.min(e.boxSelectStartLocation.x,o.x),r=Math.max(e.boxSelectStartLocation.x,o.x),i=Math.min(e.boxSelectStartLocation.y,o.y),s=Math.max(e.boxSelectStartLocation.y,o.y),a=`translate(${n}px, ${i}px)`;e.boxSelectElement.style.transform=a,e.boxSelectElement.style.WebkitTransform=a,e.boxSelectElement.style.width=r-n+"px",e.boxSelectElement.style.height=s-i+"px"},Re.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const o={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Fe(this.getSelected(),o),e.dragMoveLocation=t.lngLat},Re.onTouchEnd=Re.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const o=[e.boxSelectStartLocation,_e(t.originalEvent,this.map.getContainer())],n=this.featuresAt(null,o,"click"),r=this.getUniqueIds(n).filter((e=>!this.isSelected(e)));r.length&&(this.select(r),r.forEach((e=>this.doRender(e))),this.updateUIClasses({mouse:d.MOVE}))}this.stopExtendedInteractions(e)},Re.toDisplayFeatures=function(e,t,o){t.properties.active=this.isSelected(t.properties.id)?E.ACTIVE:E.INACTIVE,o(t),this.fireActionable(),t.properties.active===E.ACTIVE&&t.geometry.type!==h.POINT&&Se(t).forEach(o)},Re.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Re.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],o=[],n=e[0].type.replace("Multi","");for(let r=0;r{t.push(e)})):t.push(i.getCoordinates()),o.push(i.toGeoJSON())}if(o.length>1){const e=this.newFeature({type:h.FEATURE,properties:o[0].properties,geometry:{type:`Multi${n}`,coordinates:t}});this.addFeature(e),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([e.id]),this.fire(g.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:o})}this.fireActionable()},Re.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],o=[];for(let n=0;n{this.addFeature(e),e.properties=r.properties,t.push(e.toGeoJSON()),this.select([e.id])})),this.deleteFeature(r.id,{silent:!0}),o.push(r.toGeoJSON()))}t.length>1&&this.fire(g.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:o}),this.fireActionable()};const we=ue(y.VERTEX),De=ue(y.MIDPOINT),Ue={fireUpdate:function(){this.fire(g.UPDATE,{action:m.CHANGE_COORDINATES,features:this.getSelected().map((e=>e.toGeoJSON()))})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){e.initialDragPanState=this.map.dragPan.isEnabled(),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const o=t.featureTarget.properties,n=e.selectedCoordPaths.indexOf(o.coord_path);me(t)||-1!==n?me(t)&&-1===n&&e.selectedCoordPaths.push(o.coord_path):e.selectedCoordPaths=[o.coord_path];const r=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(r)},onMidpoint:function(e,t){this.startDragging(e,t);const o=t.featureTarget.properties;e.feature.addCoordinate(o.coord_path,o.lng,o.lat),this.fireUpdate(),e.selectedCoordPaths=[o.coord_path]},pathsToCoordinates:function(e,t){return t.map((t=>({feature_id:e,coord_path:t})))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,o){Fe(this.getSelected(),o),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,o){const n=e.selectedCoordPaths.map((t=>e.feature.getCoordinate(t))),r=Pe(n.map((e=>({type:h.FEATURE,properties:{},geometry:{type:h.POINT,coordinates:e}}))),o);for(let t=0;tt.localeCompare(e,"en",{numeric:!0}))).forEach((t=>e.feature.removeCoordinate(t))),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(f.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const o=de(t),n=we(t),r=De(t),i=0===e.selectedCoordPaths.length;return o&&i||n&&!i?this.updateUIClasses({mouse:d.MOVE}):this.updateUIClasses({mouse:d.NONE}),(n||o||r)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};Ue.onTouchStart=Ue.onMouseDown=function(e,t){return we(t)?this.onVertex(e,t):de(t)?this.onFeature(e,t):De(t)?this.onMidpoint(e,t):void 0},Ue.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const o={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,o):this.dragFeature(e,t,o),e.dragMoveLocation=t.lngLat},Ue.onClick=function(e,t){return he(t)?this.clickNoTarget(e,t):de(t)?this.clickActiveFeature(e,t):pe(t)?this.clickInactive(e,t):void this.stopDragging(e)},Ue.onTap=function(e,t){return he(t)?this.clickNoTarget(e,t):de(t)?this.clickActiveFeature(e,t):pe(t)?this.clickInactive(e,t):void 0},Ue.onTouchEnd=Ue.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const ke={};function Ve(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]}ke.onSetup=function(){const e=this.newFeature({type:h.FEATURE,properties:{},geometry:{type:h.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:d.ADD}),this.activateUIButton(p.POINT),this.setActionableState({trash:!0}),{point:e}},ke.stopDrawingAndRemove=function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT)},ke.onTap=ke.onClick=function(e,t){this.updateUIClasses({mouse:d.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(g.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(f.SIMPLE_SELECT,{featureIds:[e.point.id]})},ke.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},ke.toDisplayFeatures=function(e,t,o){const n=t.properties.id===e.point.id;if(t.properties.active=n?E.ACTIVE:E.INACTIVE,!n)return o(t)},ke.onTrash=ke.stopDrawingAndRemove,ke.onKeyUp=function(e,t){if(ye(t)||Ee(t))return this.stopDrawingAndRemove(e,t)};const Ge={onSetup:function(){const e=this.newFeature({type:h.FEATURE,properties:{},geometry:{type:h.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),Oe.disable(this),this.updateUIClasses({mouse:d.ADD}),this.activateUIButton(p.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Ve(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(f.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:d.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(f.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),ge(t)&&this.updateUIClasses({mouse:d.POINTER})}};Ge.onTap=Ge.onClick=function(e,t){return ge(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},Ge.onKeyUp=function(e,t){ye(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT)):Ee(t)&&this.changeMode(f.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},Ge.onStop=function(e){this.updateUIClasses({mouse:d.NONE}),Oe.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(g.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT,{},{silent:!0})))},Ge.toDisplayFeatures=function(e,t,o){const n=t.properties.id===e.polygon.id;if(t.properties.active=n?E.ACTIVE:E.INACTIVE,!n)return o(t);if(0===t.geometry.coordinates.length)return;const r=t.geometry.coordinates[0].length;if(!(r<3)){if(t.properties.meta=y.FEATURE,o(ve(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),r>3){const n=t.geometry.coordinates[0].length-3;o(ve(e.polygon.id,t.geometry.coordinates[0][n],`0.${n}`,!1))}if(r<=4){const e=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(o({type:h.FEATURE,properties:t.properties,geometry:{coordinates:e,type:h.LINE_STRING}}),3===r)return}return o(t)}},Ge.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT)};const Be={onSetup:function(e){const t=(e=e||{}).featureId;let o,n,r="forward";if(t){if(o=this.getFeature(t),!o)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const s=o.coordinates.length-1;if(o.coordinates[s][0]===i[0]&&o.coordinates[s][1]===i[1])n=s+1,o.addCoordinate(n,...o.coordinates[s]);else{if(o.coordinates[0][0]!==i[0]||o.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");r="backwards",n=0,o.addCoordinate(n,...o.coordinates[0])}}else o=this.newFeature({type:h.FEATURE,properties:{},geometry:{type:h.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(o);return this.clearSelectedFeatures(),Oe.disable(this),this.updateUIClasses({mouse:d.ADD}),this.activateUIButton(p.LINE),this.setActionableState({trash:!0}),{line:o,currentVertexPosition:n,direction:r}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Ve(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&Ve(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(f.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:d.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(f.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),ge(t)&&this.updateUIClasses({mouse:d.POINTER})}};Be.onTap=Be.onClick=function(e,t){if(ge(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},Be.onKeyUp=function(e,t){Ee(t)?this.changeMode(f.SIMPLE_SELECT,{featureIds:[e.line.id]}):ye(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT))},Be.onStop=function(e){Oe.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(g.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT,{},{silent:!0})))},Be.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT)},Be.toDisplayFeatures=function(e,t,o){const n=t.properties.id===e.line.id;if(t.properties.active=n?E.ACTIVE:E.INACTIVE,!n)return o(t);t.geometry.coordinates.length<2||(t.properties.meta=y.FEATURE,o(ve(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),o(t))};var je={simple_select:Re,direct_select:Ue,draw_point:ke,draw_polygon:Ge,draw_line_string:Be};const Je={defaultMode:f.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:ce,modes:je,controls:{},userProperties:!1,suppressAPIEvents:!0},$e={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Ye={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function He(e,t){return e.map((e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?l.HOT:l.COLD})))}var Xe,qe,Ze,We,Ke=t(qe?Xe:(qe=1,Xe=function e(t,o){if(t===o)return!0;if(t&&o&&"object"==typeof t&&"object"==typeof o){if(t.constructor!==o.constructor)return!1;var n,r,i;if(Array.isArray(t)){if((n=t.length)!=o.length)return!1;for(r=n;0!=r--;)if(!e(t[r],o[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===o.source&&t.flags===o.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===o.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===o.toString();if((n=(i=Object.keys(t)).length)!==Object.keys(o).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(o,i[r]))return!1;for(r=n;0!=r--;){var s=i[r];if(!e(t[s],o[s]))return!1}return!0}return t!=t&&o!=o})),ze=function(){if(We)return Ze;We=1,Ze=function(t){if(!t||!t.type)return null;var o=e[t.type];return o?"geometry"===o?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]}:"feature"===o?{type:"FeatureCollection",features:[t]}:"featurecollection"===o?t:void 0:null};var e={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};return Ze}(),Qe=t(ze);function et(e,t){return e.length===t.length&&JSON.stringify(e.map((e=>e)).sort())===JSON.stringify(t.map((e=>e)).sort())}const tt={Polygon:Y,LineString:$,Point:J,MultiPolygon:q,MultiLineString:q,MultiPoint:q};var ot=Object.freeze({__proto__:null,CommonSelectors:Te,ModeHandler:e,StringSet:M,constrainFeatureMovement:Pe,createMidPoint:Ie,createSupplementaryPoints:Se,createVertex:ve,doubleClickZoom:Oe,euclideanDistance:P,featuresAt:b,getFeatureAtAndSetCursors:A,isClick:D,isEventAtCoordinates:Ve,isTap:V,mapEventToBoundingBox:L,moveFeatures:Fe,sortFeatures:O,stringSetsAreEqual:et,theme:ce,toDenseArray:Q});const nt=function(e,t){const o={options:e=function(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),!1===e.displayControlsDefault?t.controls=Object.assign({},Ye,e.controls):t.controls=Object.assign({},$e,e.controls),t=Object.assign({},Je,t),t.styles=He(t.styles,"cold").concat(He(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=f;const o=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return b.click({point:t},null,e).map((e=>e.properties.id))},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:h.FEATURE_COLLECTION,features:e.store.getSelectedIds().map((t=>e.store.get(t))).map((e=>e.toGeoJSON()))}},t.getSelectedPoints=function(){return{type:h.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map((e=>({type:h.FEATURE,properties:{},geometry:{type:h.POINT,coordinates:e.coordinates}})))}},t.set=function(o){if(void 0===o.type||o.type!==h.FEATURE_COLLECTION||!Array.isArray(o.features))throw new Error("Invalid FeatureCollection");const n=e.store.createRenderBatch();let r=e.store.getAllIds().slice();const i=t.add(o),s=new M(i);return r=r.filter((e=>!s.has(e))),r.length&&t.delete(r),n(),i},t.add=function(t){const n=JSON.parse(JSON.stringify(Qe(t))).features.map((t=>{if(t.id=t.id||B(),null===t.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(t.id)||e.store.get(t.id).type!==t.geometry.type){const n=tt[t.geometry.type];if(void 0===n)throw new Error(`Invalid geometry type: ${t.geometry.type}.`);const r=new n(e,t);e.store.add(r,{silent:o})}else{const n=e.store.get(t.id),r=n.properties;n.properties=t.properties,Ke(r,t.properties)||e.store.featureChanged(n.id,{silent:o}),Ke(n.getCoordinates(),t.geometry.coordinates)||n.incomingCoords(t.geometry.coordinates)}return t.id}));return e.store.render(),n},t.get=function(t){const o=e.store.get(t);if(o)return o.toGeoJSON()},t.getAll=function(){return{type:h.FEATURE_COLLECTION,features:e.store.getAll().map((e=>e.toGeoJSON()))}},t.delete=function(n){return e.store.delete(n,{silent:o}),t.getMode()!==f.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(f.SIMPLE_SELECT,void 0,{silent:o}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:o}),t.getMode()===f.DIRECT_SELECT?e.events.changeMode(f.SIMPLE_SELECT,void 0,{silent:o}):e.store.render(),t},t.changeMode=function(n,r={}){return n===f.SIMPLE_SELECT&&t.getMode()===f.SIMPLE_SELECT?(et(r.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(r.featureIds,{silent:o}),e.store.render()),t):(n===f.DIRECT_SELECT&&t.getMode()===f.DIRECT_SELECT&&r.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(n,r,{silent:o}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:o}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:o}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:o}),t},t.setFeatureProperty=function(n,r,i){return e.store.setFeatureProperty(n,r,i,{silent:o}),t},t}(o,t),o.api=t;const n=re(o);return t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.types=p,t.options=e,t};function rt(e){nt(e,this)}return rt.modes=je,rt.constants=v,rt.lib=ot,rt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).MapboxDraw=t(); //# sourceMappingURL=mapbox-gl-draw.js.map diff --git a/inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.css b/inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.css index 6ceb5de9..aa4f4650 100644 --- a/inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.css +++ b/inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.css @@ -1 +1 @@ -.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(width <= 480px){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file +.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} \ No newline at end of file diff --git a/inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.js b/inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.js index 2caee97b..fd0c3b11 100644 --- a/inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.js +++ b/inst/htmlwidgets/lib/maplibre-gl/maplibre-gl.js @@ -1,6 +1,6 @@ /** * MapLibre GL JS - * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.7.1/LICENSE.txt + * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.5.0/LICENSE.txt */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -39,11 +39,11 @@ function define(moduleName, _dependencies, moduleFactory) { -define("shared",["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t));}catch(t){s(t);}}function o(t){try{l(n.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(a,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var n=i;function i(t,e){this.x=t,this.y=e;}i.prototype={clone:function(){return new i(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},i.convert=function(t){return t instanceof i?t:Array.isArray(t)?new i(t[0],t[1]):t};var s=r(n),a=o;function o(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}o.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var l=r(a);let u,c;function h(){return null==u&&(u="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),u}function p(){if(null==c&&(c=!1,h())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;ri.solve(t)}const d=f(.25,.1,.25,1);function y(t,e,r){return Math.min(r,Math.max(e,t))}function m(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function g(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let x=1;function v(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function b(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function w(t){return Array.isArray(t)?t.map(w):"object"==typeof t&&t?v(t,w):t}const _={};function A(t){_[t]||("undefined"!=typeof console&&console.warn(t),_[t]=!0);}function S(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function k(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let M=null;function I(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const z="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function P(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,r,n,i){const s=4*Math.max(-e,0),a=(Math.max(0,r)-r)*n*4+s,o=4*n,l=Math.max(0,e),u=Math.max(0,r);return {rect:{x:l,y:u,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-u},layout:[{offset:a,stride:o}]}}(t,r,n,i,s)),o)for(let t=0;tk(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,O=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=T(t.url);if(e)return e(t,r);if(k(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:$},r)}if(!(/^file:/.test(n=t.url)||/^file:/.test(D())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:D(),signal:r.signal});"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");const n=yield fetch(e);if(!n.ok){const e=yield n.blob();throw new L(n.status,n.statusText,t.url,e)}let i;i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw E();return {data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(k(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:$},r)}var n;return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new L(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),n(E());})),s.send(t.body);}))}(t,r)};function j(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function R(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function U(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class q{constructor(t,e={}){g(this,e),this.type=t;}}class N extends q{constructor(t,e={}){super("error",g({error:t},e));}}class Z{on(t,e){return this._listeners=this._listeners||{},R(t,e,this._listeners),this}off(t,e){return U(t,e,this._listeners),U(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},R(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new q(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)U(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(g(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof N&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var G={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"enum",default:"mercator",values:{mercator:{},globe:{}}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const K=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function X(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return K.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function H(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const _t=[lt,ut,ct,ht,pt,mt,ft,bt(dt),gt,xt,vt];function At(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!At(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of _t)if(!At(t,e))return null}return `Expected ${wt(t)} but found ${wt(e)} instead.`}function St(t,e){return e.some((e=>e.kind===t.kind))}function kt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function Mt(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const It=.96422,zt=.82521,Pt=4/29,Ct=6/29,Bt=3*Ct*Ct,Vt=Ct*Ct*Ct,Et=Math.PI/180,Ft=180/Math.PI;function Tt(t){return (t%=360)<0&&(t+=360),t}function $t([t,e,r,n]){let i,s;const a=Dt((.2225045*(t=Lt(t))+.7168786*(e=Lt(e))+.0606169*(r=Lt(r)))/1);t===e&&e===r?i=s=a:(i=Dt((.4360747*t+.3850649*e+.1430804*r)/It),s=Dt((.0139322*t+.0971045*e+.7141733*r)/zt));const o=116*a-16;return [o<0?0:o,500*(i-a),200*(a-s),n]}function Lt(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Dt(t){return t>Vt?Math.pow(t,1/3):t/Bt+Pt}function Ot([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*Rt(i),s=It*Rt(s),a=zt*Rt(a),[jt(3.1338561*s-1.6168667*i-.4906146*a),jt(-.9787684*s+1.9161415*i+.033454*a),jt(.0719453*s-.2289914*i+1.4052427*a),n]}function jt(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function Rt(t){return t>Ct?t*t*t:Bt*(t-Pt)}function Ut(t){return parseInt(t.padEnd(2,t),16)/255}function qt(t,e){return Nt(e?t/100:t,0,1)}function Nt(t,e,r){return Math.min(Math.max(e,t),r)}function Zt(t){return !t.some(Number.isNaN)}const Gt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class Kt{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof Kt)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=Gt[t];if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [Ut(t.slice(r,r+=e)),Ut(t.slice(r,r+=e)),Ut(t.slice(r,r+=e)),Ut(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[Nt(+r/e,0,1),Nt(+s/e,0,1),Nt(+l/e,0,1),h?qt(+h,p):1];if(Zt(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,Nt(+i,0,100),Nt(+a,0,100),l?qt(+l,u):1];if(Zt(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=Tt(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new Kt(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=$t(t),s=Math.sqrt(r*r+n*n);return [Math.round(1e4*s)?Tt(Math.atan2(n,r)*Ft):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",$t(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}}Kt.black=new Kt(0,0,0,1),Kt.white=new Kt(1,1,1,1),Kt.transparent=new Kt(0,0,0,0),Kt.red=new Kt(1,0,0,1);class Xt{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Ht{constructor(t,e,r,n,i){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i;}}class Yt{constructor(t){this.sections=t;}static fromString(t){return new Yt([new Ht(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Yt?t:Yt.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Jt{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Jt)return t;if("number"==typeof t)return new Jt([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new Jt(t)}}toString(){return JSON.stringify(this.values)}}const Wt=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Qt{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Qt)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function re(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Kt||t instanceof Xt||t instanceof Yt||t instanceof Jt||t instanceof Qt||t instanceof te)return !0;if(Array.isArray(t)){for(const e of t)if(!re(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!re(t[e]))return !1;return !0}return !1}function ne(t){if(null===t)return lt;if("string"==typeof t)return ct;if("boolean"==typeof t)return ht;if("number"==typeof t)return ut;if(t instanceof Kt)return pt;if(t instanceof Xt)return yt;if(t instanceof Yt)return mt;if(t instanceof Jt)return gt;if(t instanceof Qt)return vt;if(t instanceof te)return xt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=ne(e);if(r){if(r===t)continue;r=dt;break}r=t;}return bt(r||dt,e)}return ft}function ie(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Kt||t instanceof Yt||t instanceof Jt||t instanceof Qt||t instanceof te?t.toString():JSON.stringify(t)}class se{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!re(t[1]))return e.error("invalid value");const r=t[1];let n=ne(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new se(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}class ae{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}}const oe={string:ct,number:ut,boolean:ht,object:ft};class le{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in oe)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=oe[r],n++;}else i=dt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=bt(i,s);}else {if(!oe[i])throw new Error(`Types doesn't contain name = ${i}`);r=oe[i];}const s=[];for(;nt.outputDefined()))}}const ue={"to-boolean":ht,"to-color":pt,"to-number":ut,"to-string":ct};class ce{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!ue[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=ue[r],i=[];for(let r=1;r4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ee(e[0],e[1],e[2],e[3]),!r))return new Kt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ae(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=Jt.parse(e);if(n)return n}throw new ae(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=Qt.parse(e);if(n)return n}throw new ae(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new ae(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return Yt.fromString(ie(this.args[0].evaluate(t)));case"resolvedImage":return te.fromString(ie(this.args[0].evaluate(t)));default:return ie(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const he=["Unknown","Point","LineString","Polygon"];class pe{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null;}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?he[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Kt.parse(t)),e}}class fe{constructor(t,e,r=[],n,i=new ot,s=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new le(e,[t]):"coerce"===r?new ce(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind)if("padding"!==t.kind||"value"!==i.kind&&"number"!==i.kind&&"array"!==i.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==i.kind&&"array"!==i.kind){if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof se)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new pe;try{n=new se(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new fe(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new at(r,t));}checkSubtype(t,e){const r=At(t,e);return r&&this.error(r),r}}class de{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new ae(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new ae(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class ge{constructor(t,e){this.type=ht,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,dt),n=e.parse(t[2],2,dt);return r&&n?St(r.type,[ht,ct,ut,lt,dt])?new ge(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${wt(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!kt(e,["boolean","string","number","null"]))throw new ae(`Expected first argument to be of type boolean, string, number or null, but found ${wt(ne(e))} instead.`);if(!kt(r,["string","array"]))throw new ae(`Expected second argument to be of type array or string, but found ${wt(ne(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class xe{constructor(t,e,r){this.type=ut,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,dt),n=e.parse(t[2],2,dt);if(!r||!n)return null;if(!St(r.type,[ht,ct,ut,lt,dt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${wt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,ut);return i?new xe(r,n,i):null}return new xe(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!kt(e,["boolean","string","number","null"]))throw new ae(`Expected first argument to be of type boolean, string, number or null, but found ${wt(ne(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),kt(r,["string"])){const t=r.indexOf(e,n);return -1===t?-1:[...r.slice(0,t)].length}if(kt(r,["array"]))return r.indexOf(e,n);throw new ae(`Expected second argument to be of type array or string, but found ${wt(ne(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class ve{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,ne(t)))return null}else r=ne(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,dt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new ve(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (ne(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class be{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class we{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,dt),n=e.parse(t[2],2,ut);if(!r||!n)return null;if(!St(r.type,[bt(dt),ct,dt]))return e.error(`Expected first argument to be of type array or string, but found ${wt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,ut);return i?new we(r.type,r,n,i):null}return new we(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),kt(e,["string"]))return [...e].slice(r,n).join("");if(kt(e,["array"]))return e.slice(r,n);throw new ae(`Expected first argument to be of type array or string, but found ${wt(ne(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function _e(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new ae("Input is not a number.");a=o-1;}return 0}class Ae{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,ut);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Ae(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[_e(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Se(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ke=Me;function Me(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}Me.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var Ie=Se(ke);function ze(t,e,r){return t+r*(e-t)}function Pe(t,e,r){return t.map(((t,n)=>ze(t,e[n],r)))}const Ce={number:ze,color:function(t,e,r,n="rgb"){switch(n){case"rgb":{const[n,i,s,a]=Pe(t.rgb,e.rgb,r);return new Kt(n,i,s,a,!1)}case"hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*Et,Ot([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:ze(i,l,r),ze(s,u,r),ze(a,c,r)]);return new Kt(f,d,y,m,!1)}case"lab":{const[n,i,s,a]=Ot(Pe(t.lab,e.lab,r));return new Kt(n,i,s,a,!1)}}},array:Pe,padding:function(t,e,r){return new Jt(Pe(t.values,e.values,r))},variableAnchorOffsetCollection:function(t,e,r){const n=t.values,i=e.values;if(n.length!==i.length)throw new ae(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const s=[];for(let t=0;t"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,ut),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=pt:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return Mt(o,ut)||Mt(o,pt)||Mt(o,gt)||Mt(o,vt)||Mt(o,bt(ut))?new Be(o,r,n,i,a):e.error(`Type ${wt(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=_e(e,n),a=Be.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case"interpolate":return Ce[this.type.kind](o,l,a);case"interpolate-hcl":return Ce.color(o,l,a,"hcl");case"interpolate-lab":return Ce.color(o,l,a,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Ve(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}class Ee{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const s=n&&i.some((t=>At(n,t.type)));return new Ee(s?dt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof te&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function Fe(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Te(t,e,r,n){return 0===n.compare(e,r)}function $e(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=ht,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,dt);if(!s)return null;if(!Fe(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${wt(s.type)}'.`);let a=e.parse(t[2],2,dt);if(!a)return null;if(!Fe(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${wt(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${wt(s.type)}' and '${wt(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new le(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new le(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,yt),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=ne(s),r=ne(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new ae(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=ne(s),r=ne(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const Le=$e("==",(function(t,e,r){return e===r}),Te),De=$e("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !Te(0,e,r,n)})),Oe=$e("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),Re=$e("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),Ue=$e(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class qe{constructor(t,e,r){this.type=yt,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,ht);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,ht);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,ct),!s)?null:new qe(n,i,s)}evaluate(t){return new Xt(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class Ne{constructor(t,e,r,n,i){this.type=ct,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,ut);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,ct),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,ct),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,ut),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,ut),!o)?null:new Ne(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class Ze{constructor(t){this.type=mt,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,ut),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,bt(ct)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,pt),!a))return null;const o=n[n.length-1];o.scale=t,o.font=r,o.textColor=a;}else {const s=e.parse(t[r],1,dt);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new Ze(n)}evaluate(t){return new Yt(this.sections.map((e=>{const r=e.content.evaluate(t);return ne(r)===xt?new Ht("",r,null,null,null):new Ht(ie(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor);}outputDefined(){return !1}}class Ge{constructor(t){this.type=xt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,ct);return r?new Ge(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=te.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class Ke{constructor(t){this.type=ut,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${wt(r.type)} instead.`):new Ke(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new ae(`Expected value to be of type string or array, but found ${wt(ne(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const Xe=8192;function He(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*Xe),Math.round(n*i*Xe)]}function Ye(t,e){const r=Math.pow(2,e.z);return [(i=(t[0]/Xe+e.x)/r,360*i-180),(n=(t[1]/Xe+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i;}function Je(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function We(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Qe(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function tr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!ar(t,e,r,n)||!ar(r,n,t,e));var i,s;}function er(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(a=o[e+1])[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}var i,s,a;return n}function nr(t,e){for(const r of e)if(rr(t,r))return !0;return !1}function ir(t,e){for(const r of t)if(!rr(r,e))return !1;for(let r=0;r0&&o<0||a<0&&o>0}function or(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Je(e,t);}function cr(t,e,r,n){const i=Math.pow(2,n.z)*Xe,s=[n.x*Xe,n.y*Xe],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];ur(n,e,r,i),a.push(n);}return a}function hr(t,e,r,n){const i=Math.pow(2,n.z)*Xe,s=[n.x*Xe,n.y*Xe],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Je(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)ur(n,e,r,i);}var o;return a}class pr{constructor(t,e){this.type=ht,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(re(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n);}if(t.length)return new pr(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new pr(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new pr(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=or(e.coordinates,n,i),a=cr(t.geometry(),r,n,i);if(!We(r,n))return !1;for(const t of a)if(!rr(t,s))return !1}if("MultiPolygon"===e.type){const s=lr(e.coordinates,n,i),a=cr(t.geometry(),r,n,i);if(!We(r,n))return !1;for(const t of a)if(!nr(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=or(e.coordinates,n,i),a=hr(t.geometry(),r,n,i);if(!We(r,n))return !1;for(const t of a)if(!ir(t,s))return !1}if("MultiPolygon"===e.type){const s=lr(e.coordinates,n,i),a=hr(t.geometry(),r,n,i);if(!We(r,n))return !1;for(const t of a)if(!sr(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let fr=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}};function dr(t,e,r,n,i){yr(t,e,r,n||t.length-1,i||gr);}function yr(t,e,r,n,i){for(;n>r;){if(n-r>600){var s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);yr(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}var c=t[e],h=r,p=n;for(mr(t,r,e),i(t[n],c)>0&&mr(t,r,n);h0;)p--;}0===i(t[r],c)?mr(t,r,p):mr(t,++p,n),p<=e&&(r=p+1),e<=p&&(n=p-1);}}function mr(t,e,r){var n=t[e];t[e]=t[r],t[r]=n;}function gr(t,e){return te?1:0}function xr(t,e){if(t.length<=1)return [t];const r=[];let n,i;for(const e of t){const t=br(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e));}if(n&&r.push(n),e>1)for(let t=0;t1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function kr(t,e){return e[0]-t[0]}function Mr(t){return t[1]-t[0]+1}function Ir(t,e){return t[1]>=t[0]&&t[1]t[1])return [null,null];const r=Mr(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return [t,null];const n=Math.floor(r/2)-1;return [[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function Pr(t,e){if(!Ir(e,t.length))return [1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)Je(r,t[n]);return r}function Cr(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)Je(e,t);return e}function Br(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Vr(t,e,r){if(!Br(t)||!Br(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(We(i,s)){if(Or(t,e))return 0}else if(Or(e,t))return 0;let a=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=a.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(Mr(l)<=u){if(!Ir(l,t.length))return NaN;if(e){const e=Dr(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=Lr(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else {const r=zr(l,e);Rr(a,s,n,t,o,r[0]),Rr(a,s,n,t,o,r[1]);}}return s}function Nr(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new fr([[0,[0,t.length-1],[0,r.length-1]]],kr);for(;o.length>0;){const s=o.pop();if(s[0]>=a)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(Mr(l)<=c&&Mr(u)<=h){if(!Ir(l,t.length)&&Ir(u,r.length))return NaN;let s;if(e&&n)s=Tr(t,l,r,u,i),a=Math.min(a,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=Er(r[t],e,i),a=Math.min(a,s),0===a)return a}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=Er(t[r],e,i),a=Math.min(a,s),0===a)return a}else s=$r(t,l,r,u,i),a=Math.min(a,s);}else {const s=zr(l,e),c=zr(u,n);Ur(o,a,i,t,r,s[0],c[0]),Ur(o,a,i,t,r,s[0],c[1]),Ur(o,a,i,t,r,s[1],c[0]),Ur(o,a,i,t,r,s[1],c[1]);}}return a}function Zr(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class Gr{constructor(t,e){this.type=ut,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(re(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new Gr(e,e.features.map((t=>Zr(t.geometry))).flat());if("Feature"===e.type)return new Gr(e,Zr(e.geometry));if("type"in e&&"coordinates"in e)return new Gr(e,Zr(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>Ye([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Sr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,Nr(n,!1,[t.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,Nr(n,!1,t.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,qr(n,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>Ye([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Sr(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,Nr(n,!0,[t.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,Nr(n,!0,t.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,qr(n,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=xr(r,0).map((e=>e.map((e=>e.map((e=>Ye([e.x,e.y],t.canonical))))))),i=new Sr(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case"Point":s=Math.min(s,qr([t.coordinates],!1,e,i,s));break;case"LineString":s=Math.min(s,qr(t.coordinates,!0,e,i,s));break;case"Polygon":s=Math.min(s,jr(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}const Kr={"==":Le,"!=":De,">":je,"<":Oe,">=":Ue,"<=":Re,array:le,at:me,boolean:le,case:be,coalesce:Ee,collator:qe,format:Ze,image:Ge,in:ge,"index-of":xe,interpolate:Be,"interpolate-hcl":Be,"interpolate-lab":Be,length:Ke,let:de,literal:se,match:ve,number:le,"number-format":Ne,object:le,slice:we,step:Ae,string:le,"to-boolean":ce,"to-color":ce,"to-number":ce,"to-string":ce,var:ye,within:pr,distance:Gr};class Xr{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const r=t[0],n=Xr.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new fe(e.registry,Qr,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(wt).join(", ")})`:`(${wt(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&Qr(t):r&&t instanceof se;})),!!r&&tn(t)&&rn(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function tn(t){if(t instanceof Xr){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof pr)return !1;if(t instanceof Gr)return !1;let e=!0;return t.eachChild((t=>{e&&!tn(t)&&(e=!1);})),e}function en(t){if(t instanceof Xr&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!en(t)&&(e=!1);})),e}function rn(t,e){if(t instanceof Xr&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!rn(t,e)&&(r=!1);})),r}function nn(t){return {result:"success",value:t}}function sn(t){return {result:"error",value:t}}function an(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function on(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function ln(t){return !!t.expression&&t.expression.interpolated}function un(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function cn(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function hn(t){return t}function pn(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(ln(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?Kt.parse:Jt.parse;(t=st({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default);}if(t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;let o,l,u;if("exponential"===s)o=mn;else if("interval"===s)o=yn;else if("categorical"===s){o=dn,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=gn;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>mn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:Be.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?fn(t.default,e.default):o(t,e,i,l,u)}}}function fn(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function dn(t,e,r,n,i){return fn(typeof r===i?n[r]:void 0,t.default,e.default)}function yn(t,e,r){if("number"!==un(r))return fn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=_e(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function mn(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==un(r))return fn(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=_e(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=Ce[e.type]||hn;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function gn(t,e,r){switch(e.type){case"color":r=Kt.parse(r);break;case"formatted":r=Yt.fromString(r.toString());break;case"resolvedImage":r=te.fromString(r.toString());break;case"padding":r=Jt.parse(r);break;default:un(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return fn(r,t.default,e.default)}Xr.register(Kr,{error:[{kind:"error"},[ct],(t,[e])=>{throw new ae(e.evaluate(t))}],typeof:[ct,[dt],(t,[e])=>wt(ne(e.evaluate(t)))],"to-rgba":[bt(ut,4),[pt],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return [255*r,255*n,255*i,s]}],rgb:[pt,[ut,ut,ut],Hr],rgba:[pt,[ut,ut,ut,ut],Hr],has:{type:ht,overloads:[[[ct],(t,[e])=>Yr(e.evaluate(t),t.properties())],[[ct,ft],(t,[e,r])=>Yr(e.evaluate(t),r.evaluate(t))]]},get:{type:dt,overloads:[[[ct],(t,[e])=>Jr(e.evaluate(t),t.properties())],[[ct,ft],(t,[e,r])=>Jr(e.evaluate(t),r.evaluate(t))]]},"feature-state":[dt,[ct],(t,[e])=>Jr(e.evaluate(t),t.featureState||{})],properties:[ft,[],t=>t.properties()],"geometry-type":[ct,[],t=>t.geometryType()],id:[dt,[],t=>t.id()],zoom:[ut,[],t=>t.globals.zoom],"heatmap-density":[ut,[],t=>t.globals.heatmapDensity||0],"line-progress":[ut,[],t=>t.globals.lineProgress||0],accumulated:[dt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ut,Wr(ut),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[ut,Wr(ut),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:ut,overloads:[[[ut,ut],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[ut],(t,[e])=>-e.evaluate(t)]]},"/":[ut,[ut,ut],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[ut,[ut,ut],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[ut,[],()=>Math.LN2],pi:[ut,[],()=>Math.PI],e:[ut,[],()=>Math.E],"^":[ut,[ut,ut],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[ut,[ut],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ut,[ut],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ut,[ut],(t,[e])=>Math.log(e.evaluate(t))],log2:[ut,[ut],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ut,[ut],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ut,[ut],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ut,[ut],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ut,[ut],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ut,[ut],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ut,[ut],(t,[e])=>Math.atan(e.evaluate(t))],min:[ut,Wr(ut),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ut,Wr(ut),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ut,[ut],(t,[e])=>Math.abs(e.evaluate(t))],round:[ut,[ut],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[ut,[ut],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[ut,[ut],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[ht,[ct,dt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[ht,[dt],(t,[e])=>t.id()===e.value],"filter-type-==":[ht,[ct],(t,[e])=>t.geometryType()===e.value],"filter-<":[ht,[ct,dt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[ht,[ct,dt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[ht,[dt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[ht,[ct,dt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[ht,[dt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[ht,[ct,dt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[ht,[dt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[ht,[dt],(t,[e])=>e.value in t.properties()],"filter-has-id":[ht,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[ht,[bt(ct)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[ht,[bt(dt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[ht,[ct,bt(dt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[ht,[ct,bt(dt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:ht,overloads:[[[ht,ht],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Wr(ht),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:ht,overloads:[[[ht,ht],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Wr(ht),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[ht,[ht],(t,[e])=>!e.evaluate(t)],"is-supported-script":[ht,[ct],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[ct,[ct],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ct,[ct],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ct,Wr(dt),(t,e)=>e.map((e=>ie(e.evaluate(t)))).join("")],"resolved-locale":[ct,[yt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class xn{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new pe,this._defaultValue=e?"color"===(r=e).type&&cn(r.default)?new Kt(0,0,0,0):"color"===r.type?Kt.parse(r.default)||null:"padding"===r.type?Jt.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?Qt.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new ae(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function vn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Kr}function bn(t,e){const r=new fe(Kr,Qr,[],e?function(t){const e={color:pt,string:ct,number:ut,enum:ct,boolean:ht,formatted:mt,padding:gt,resolvedImage:xt,variableAnchorOffsetCollection:vt};return "array"===t.type?bt(e[t.value]||dt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?nn(new xn(n,e)):sn(r.errors)}class wn{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!en(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class _n{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!en(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?Be.interpolationFactor(this.interpolationType,t,e,r):0}}function An(t,e){const r=bn(t,e);if("error"===r.result)return r;const n=r.value.expression,i=tn(n);if(!i&&!an(e))return sn([new at("","data expressions not supported")]);const s=rn(n,["zoom"]);if(!s&&!on(e))return sn([new at("","zoom expressions not supported")]);const a=kn(n);return a||s?a instanceof at?sn([a]):a instanceof Be&&!ln(e)?sn([new at("",'"interpolate" expressions cannot be used with this property')]):nn(a?new _n(i?"camera":"composite",r.value,a.labels,a instanceof Be?a.interpolation:void 0):new wn(i?"constant":"source",r.value)):sn([new at("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Sn{constructor(t,e){this._parameters=t,this._specification=e,st(this,pn(this._parameters,this._specification));}static deserialize(t){return new Sn(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function kn(t){let e=null;if(t instanceof de)e=kn(t.result);else if(t instanceof Ee){for(const r of t.args)if(e=kn(r),e)break}else (t instanceof Ae||t instanceof Be)&&t.input instanceof Xr&&"zoom"===t.input.name&&(e=t);return e instanceof at||t.eachChild((t=>{const r=kn(t);r instanceof at?e=r:!e&&r?e=new at("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new at("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function Mn(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Mn(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const In={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function zn(t){if(null==t)return {filter:()=>!0,needGeometry:!1};Mn(t)||(t=Bn(t));const e=bn(t,In);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:Cn(t)}}function Pn(t,e){return te?1:0}function Cn(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?Vn(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(Bn))):"all"===e?["all"].concat(t.slice(1).map(Bn)):"none"===e?["all"].concat(t.slice(1).map(Bn).map(Tn)):"in"===e?En(t[1],t.slice(2)):"!in"===e?Tn(En(t[1],t.slice(2))):"has"===e?Fn(t[1]):"!has"!==e||Tn(Fn(t[1]));var r;}function Vn(t,e,r){switch(t){case"$type":return [`filter-type-${r}`,e];case"$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function En(t,e){if(0===e.length)return !1;switch(t){case"$type":return ["filter-type-in",["literal",e]];case"$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(Pn)]]:["filter-in-small",t,["literal",e]]}}function Fn(t){switch(t){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",t]}}function Tn(t){return ["!",t]}function $n(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${$n(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new it(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function Nn(t){const e=t.valueSpec,r=On(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===un(t.value.stops)&&"array"===un(t.value.stops[0])&&"object"===un(t.value.stops[0][0]),c=Rn({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new it(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(Un({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===un(n)&&0===n.length&&e.push(new it(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new it(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new it(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!ln(t.valueSpec)&&c.push(new it(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!an(t.valueSpec)?c.push(new it(t.key,t.value,"property functions not supported")):o&&!on(t.valueSpec)&&c.push(new it(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new it(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==un(n))return [new it(o,n,`array expected, ${un(n)} found`)];if(2!==n.length)return [new it(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==un(n[0]))return [new it(o,n,`object expected, ${un(n[0])} found`)];if(void 0===n[0].zoom)return [new it(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new it(o,n,"object stop key must have value")];if(s&&s>On(n[0].zoom))return [new it(o,n[0].zoom,"stop zoom values must appear in ascending order")];On(n[0].zoom)!==s&&(s=On(n[0].zoom),i=void 0,a={}),r=r.concat(Rn({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:qn,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return vn(jn(n[1]))?r.concat([new it(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=un(t.value),l=On(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return [new it(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new it(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return an(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new it(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew it(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new it(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!en(r))return [new it(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!en(r))return [new it(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!rn(r,["zoom","feature-state"]))return [new it(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!tn(r))return [new it(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function Gn(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(On(r))&&i.push(new it(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(On(r))&&i.push(new it(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function Kn(t){return Mn(jn(t.value))?Zn(st({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Xn(t)}function Xn(t){const e=t.value,r=t.key;if("array"!==un(e))return [new it(r,e,`array expected, ${un(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return [new it(r,e,"filter array must have at least 1 element")];switch(s=s.concat(Gn({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),On(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===On(e[1])&&s.push(new it(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new it(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=un(e[1]),"string"!==i&&s.push(new it(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new it(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{On(e.id)===o&&(t=e);})),t?t.ref?e.push(new it(n,r.ref,"ref cannot reference another ref layer")):a=On(t.type):e.push(new it(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&On(t.type);t?"vector"===s&&"raster"===a?e.push(new it(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new it(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new it(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new it(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new it(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new it(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new it(n,r.source,`source "${r.source}" not found`));}else e.push(new it(n,r,'missing required property "source"'));return e=e.concat(Rn({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:Kn,layout:t=>Rn({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Jn(st({layerType:a},t))}}),paint:t=>Rn({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Yn(st({layerType:a},t))}})}})),e}function Qn(t){const e=t.value,r=t.key,n=un(e);return "string"!==n?[new it(r,e,`string expected, ${n} found`)]:[]}const ti={promoteId:function({key:t,value:e}){if("string"===un(e))return Qn({key:t,value:e});{const r=[];for(const n in e)r.push(...Qn({key:`${t}.${n}`,value:e[n]}));return r}}};function ei(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new it(r,e,'"type" is required')];const a=On(e.type);let o;switch(a){case"vector":case"raster":return o=Rn({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:ti,validateSpec:s}),o;case"raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=un(n);if(void 0===n)return o;if("object"!==l)return o.push(new it("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===On(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new it(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new it(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case"geojson":if(o=Rn({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:ti}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],a="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...Zn({key:`${r}.${t}.map`,value:i,validateSpec:s,expressionContext:"cluster-map"})),o.push(...Zn({key:`${r}.${t}.reduce`,value:a,validateSpec:s,expressionContext:"cluster-reduce"}));}return o;case"video":return Rn({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case"image":return Rn({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case"canvas":return [new it(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Gn({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:s,styleSpec:n})}}function ri(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=un(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new it("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new it(a,e[a],`unknown property "${a}"`)]);}return s}function ni(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=un(e);if(void 0===e)return [];if("object"!==s)return [new it("sky",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new it(s,e[s],`unknown property "${s}"`)]);return a}function ii(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=un(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new it("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new it(a,e[a],`unknown property "${a}"`)]);return s}function si(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new it(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new it(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(Rn({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Qn({key:n,value:r})}const ai={"*":()=>[],array:Un,boolean:function(t){const e=t.value,r=t.key,n=un(e);return "boolean"!==n?[new it(r,e,`boolean expected, ${n} found`)]:[]},number:qn,color:function(t){const e=t.key,r=t.value,n=un(r);return "string"!==n?[new it(e,r,`color expected, ${n} found`)]:Kt.parse(String(r))?[]:[new it(e,r,`color expected, "${r}" found`)]},constants:Dn,enum:Gn,filter:Kn,function:Nn,layer:Wn,object:Rn,source:ei,light:ri,sky:ni,terrain:ii,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=un(e);if(void 0===e)return [];if("object"!==s)return [new it("projection",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new it(s,e[s],`unknown property "${s}"`)]);return a},string:Qn,formatted:function(t){return 0===Qn(t).length?[]:Zn(t)},resolvedImage:function(t){return 0===Qn(t).length?[]:Zn(t)},padding:function(t){const e=t.key,r=t.value;if("array"===un(r)){if(r.length<1||r.length>4)return [new it(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(Dn({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:oi}))),hi(r)}function ci(t){return function(e){return t({...e,validateSpec:oi})}}function hi(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function pi(t){return function(...e){return hi(t.apply(this,e))}}ui.source=pi(ci(ei)),ui.sprite=pi(ci(si)),ui.glyphs=pi(ci(li)),ui.light=pi(ci(ri)),ui.sky=pi(ci(ni)),ui.terrain=pi(ci(ii)),ui.layer=pi(ci(Wn)),ui.filter=pi(ci(Kn)),ui.paintProperty=pi(ci(Yn)),ui.layoutProperty=pi(ci(Jn));const fi=ui,di=fi.light,yi=fi.sky,mi=fi.paintProperty,gi=fi.layoutProperty;function xi(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new N(new Error(n.message))),r=!0;return r}class vi{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1;}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const s=t[n];i[n]=bi[r].shallow.indexOf(n)>=0?s:ki(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(i.$name=r),i}function Mi(t){if(Si(t))return t;if(Array.isArray(t))return t.map(Mi);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=Ai(t)||"Object";if(!bi[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=bi[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=bi[e].shallow.indexOf(r)>=0?i:Mi(i);}return n}class Ii{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function Pi(t){for(const e of t)if(Ti(e.charCodeAt(0)))return !0;return !1}function Ci(t){for(const e of t)if(!Ei(e.charCodeAt(0)))return !1;return !0}function Bi(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const Vi=Bi(["Arab","Dupl","Mong","Ougr","Syrc"]);function Ei(t){return !Vi.test(String.fromCodePoint(t))}const Fi=Bi(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Ti(t){return !(746!==t&&747!==t&&(t<4352||!(zi["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||zi["CJK Compatibility"](t)||zi["CJK Strokes"](t)||!(!zi["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||zi["Enclosed CJK Letters and Months"](t)||zi["Ideographic Description Characters"](t)||zi.Kanbun(t)||zi.Katakana(t)&&12540!==t||!(!zi["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!zi["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||zi["Vertical Forms"](t)||zi["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||Fi.test(String.fromCodePoint(t)))))}function $i(t){return !(Ti(t)||function(t){return !!(zi["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||zi["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||zi["Letterlike Symbols"](t)||zi["Number Forms"](t)||zi["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||zi["Control Pictures"](t)&&9251!==t||zi["Optical Character Recognition"](t)||zi["Enclosed Alphanumerics"](t)||zi["Geometric Shapes"](t)||zi["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||zi["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||zi["CJK Symbols and Punctuation"](t)||zi.Katakana(t)||zi["Private Use Area"](t)||zi["CJK Compatibility Forms"](t)||zi["Small Form Variants"](t)||zi["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const Li=Bi(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Di(t){return Li.test(String.fromCodePoint(t))}function Oi(t,e){return !(!e&&Di(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||zi.Khmer(t))}function ji(t){for(const e of t)if(Di(e.charCodeAt(0)))return !0;return !1}const Ri=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null;}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText;}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class Ui{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ii,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!Oi(r.charCodeAt(0),e))return !1;return !0}(t,"loaded"===Ri.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class qi{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(cn(t))return new Sn(t,e);if(vn(t)){const r=An(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=Kt.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)&&(r=Qt.parse(t)):r=Jt.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class Ni{constructor(t){this.property=t,this.value=new qi(t,void 0);}transitioned(t,e){return new Gi(this.property,this.value,e,g({},t.transition,this.transition),t.now)}untransitioned(){return new Gi(this.property,this.value,null,{},0)}}class Zi{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return w(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Ni(this._values[t].property)),this._values[t].value=new qi(this._values[t].property,null===e?void 0:w(e));}getTransition(t){return w(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Ni(this._values[t].property)),this._values[t].transition=w(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new Ki(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new Ki(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Gi{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}(a))}}return i}}class Ki{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues);}possiblyEvaluate(t,e,r){const n=new Yi(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return !0;return !1}}class Xi{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues);}hasValue(t){return void 0!==this._values[t].value}getValue(t){return w(this._values[t].value)}setValue(t,e){this._values[t]=new qi(this._values[t].property,null===e?void 0:w(e));}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);}return t}possiblyEvaluate(t,e,r){const n=new Yi(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}}class Hi{constructor(t,e,r){this.property=t,this.value=e,this.parameters=r;}isConstant(){return "constant"===this.value.kind}constantOr(t){return "constant"===this.value.kind?this.value.value:t}evaluate(t,e,r,n){return this.property.evaluate(this.value,this.parameters,t,e,r,n)}}class Yi{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues);}get(t){return this._values[t]}}class Ji{constructor(t){this.specification=t;}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,r){const n=Ce[this.specification.type];return n?n(t,e,r):t}}class Wi{constructor(t,e){this.specification=t,this.overrides=e;}possiblyEvaluate(t,e,r,n){return new Hi(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},r,n)}:t.expression,e)}interpolate(t,e,r){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Hi(this,{kind:"constant",value:void 0},t.parameters);const n=Ce[this.specification.type];if(n){const i=n(t.value.value,e.value.value,r);return new Hi(this,{kind:"constant",value:i},t.parameters)}return t}evaluate(t,e,r,n,i,s){return "constant"===t.kind?t.value:t.evaluate(e,r,n,i,s)}}class Qi extends Wi{possiblyEvaluate(t,e,r,n){if(void 0===t.value)return new Hi(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n),s="resolvedImage"===t.property.specification.type&&"string"!=typeof i?i.name:i,a=this._calculate(s,s,s,e);return new Hi(this,{kind:"constant",value:a},e)}if("camera"===t.expression.kind){const r=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new Hi(this,{kind:"constant",value:r},e)}return new Hi(this,t.expression,e)}evaluate(t,e,r,n,i,s){if("source"===t.kind){const a=t.evaluate(e,r,n,i,s);return this._calculate(a,a,a,e)}return "composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},r,n),t.evaluate({zoom:Math.floor(e.zoom)},r,n),t.evaluate({zoom:Math.floor(e.zoom)+1},r,n),e):t.value}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class ts{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new Ui(Math.floor(e.zoom-1),e)),t.expression.evaluate(new Ui(Math.floor(e.zoom),e)),t.expression.evaluate(new Ui(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class es{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class rs{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new qi(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Ni(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}wi("DataDrivenProperty",Wi),wi("DataConstantProperty",Ji),wi("CrossFadedDataDrivenProperty",Qi),wi("CrossFadedProperty",ts),wi("ColorRampProperty",es);const ns="-transition";class is extends Z{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Xi(e.layout)),e.paint)){this._transitionablePaint=new Zi(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Yi(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(gi,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(ns)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(mi,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(ns))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),b(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&xi(this,t.call(fi,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:G,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Hi&&an(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const ss={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class as{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class os{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function ls(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=ss[t.type].BYTES_PER_ELEMENT,s=r=us(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:us(r,Math.max(n,e)),alignment:e}}function us(t,e){return Math.ceil(t/e)*e}class cs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}cs.prototype.bytesPerElement=4,wi("StructArrayLayout2i4",cs);class hs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}hs.prototype.bytesPerElement=6,wi("StructArrayLayout3i6",hs);class ps extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}ps.prototype.bytesPerElement=8,wi("StructArrayLayout4i8",ps);class fs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}fs.prototype.bytesPerElement=12,wi("StructArrayLayout2i4i12",fs);class ds extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}ds.prototype.bytesPerElement=8,wi("StructArrayLayout2i4ub8",ds);class ys extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}ys.prototype.bytesPerElement=8,wi("StructArrayLayout2f8",ys);class ms extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}ms.prototype.bytesPerElement=20,wi("StructArrayLayout10ui20",ms);class gs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}gs.prototype.bytesPerElement=24,wi("StructArrayLayout4i4ui4i24",gs);class xs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}xs.prototype.bytesPerElement=12,wi("StructArrayLayout3f12",xs);class vs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}vs.prototype.bytesPerElement=4,wi("StructArrayLayout1ul4",vs);class bs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}bs.prototype.bytesPerElement=20,wi("StructArrayLayout6i1ul2ui20",bs);class ws extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}ws.prototype.bytesPerElement=12,wi("StructArrayLayout2i2i2i12",ws);class _s extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}_s.prototype.bytesPerElement=16,wi("StructArrayLayout2f1f2i16",_s);class As extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=16*t,l=4*t,u=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=a,t}}As.prototype.bytesPerElement=16,wi("StructArrayLayout2ub2f2i16",As);class Ss extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Ss.prototype.bytesPerElement=6,wi("StructArrayLayout3ui6",Ss);class ks extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}ks.prototype.bytesPerElement=48,wi("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ks);class Ms extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=A,this.uint32[C+12]=S,this.float32[C+13]=k,this.float32[C+14]=M,this.uint16[P+30]=I,this.uint16[P+31]=z,t}}Ms.prototype.bytesPerElement=64,wi("StructArrayLayout8i15ui1ul2f2ui64",Ms);class Is extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Is.prototype.bytesPerElement=4,wi("StructArrayLayout1f4",Is);class zs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}zs.prototype.bytesPerElement=12,wi("StructArrayLayout1ui2f12",zs);class Ps extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}Ps.prototype.bytesPerElement=8,wi("StructArrayLayout1ul2ui8",Ps);class Cs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}Cs.prototype.bytesPerElement=4,wi("StructArrayLayout2ui4",Cs);class Bs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Bs.prototype.bytesPerElement=2,wi("StructArrayLayout1ui2",Bs);class Vs extends os{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}Vs.prototype.bytesPerElement=16,wi("StructArrayLayout4f16",Vs);class Es extends as{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new s(this.anchorPointX,this.anchorPointY)}}Es.prototype.size=20;class Fs extends bs{get(t){return new Es(this,t)}}wi("CollisionBoxArray",Fs);class Ts extends as{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Ts.prototype.size=48;class $s extends ks{get(t){return new Ts(this,t)}}wi("PlacedSymbolArray",$s);class Ls extends as{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ls.prototype.size=64;class Ds extends Ms{get(t){return new Ls(this,t)}}wi("SymbolInstanceArray",Ds);class Os extends Is{getoffsetX(t){return this.float32[1*t+0]}}wi("GlyphOffsetArray",Os);class js extends hs{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}wi("SymbolLineVertexArray",js);class Rs extends as{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Rs.prototype.size=12;class Us extends zs{get(t){return new Rs(this,t)}}wi("TextAnchorOffsetArray",Us);class qs extends as{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}qs.prototype.size=8;class Ns extends Ps{get(t){return new qs(this,t)}}wi("FeatureIndexArray",Ns);class Zs extends cs{}class Gs extends cs{}class Ks extends cs{}class Xs extends fs{}class Hs extends ds{}class Ys extends ys{}class Js extends ms{}class Ws extends gs{}class Qs extends xs{}class ta extends vs{}class ea extends ws{}class ra extends As{}class na extends Ss{}class ia extends Cs{}const sa=ls([{name:"a_pos",components:2,type:"Int16"}],4),{members:aa}=sa;class oa{constructor(t=[]){this.segments=t;}prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>oa.MAX_VERTEX_ARRAY_LENGTH&&A(`Max vertices per segment is ${oa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>oa.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new oa([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function la(t,e){return 256*(t=y(Math.floor(t),0,255))+y(Math.floor(e),0,255)}oa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,wi("SegmentVector",oa);const ua=ls([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var ca={exports:{}},ha={exports:{}};ha.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var pa=ha.exports,fa={exports:{}};fa.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var da=pa,ya=fa.exports;ca.exports=da,ca.exports.murmur3=da,ca.exports.murmur2=ya;var ma=r(ca.exports);class ga{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(xa(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=xa(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return va(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new ga;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function xa(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ma(String(t))}function va(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;ba(t,s,a),ba(e,3*s,3*a),ba(e,3*s+1,3*a+1),ba(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new Sa(t,e):new _a(t,e)}}class za{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new Aa(t,e):new _a(t,e)}}class Pa{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new Ui(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=Ma(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new Ui(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new Ui(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Ma(r),s=Ma(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Pa||r instanceof Ca)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Va(n,e,r);this.needsUpload=!1,this._featureMap=new ga,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function Fa(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function Ta(t,e,r){const n={color:{source:ys,composite:Vs},number:{source:Is,composite:ys}},i=function(t){return {"line-pattern":{source:Js,composite:Js},"fill-pattern":{source:Js,composite:Js},"fill-extrusion-pattern":{source:Js,composite:Js}}[t]}(t);return i&&i[r]||n[e][r]}wi("ConstantBinder",Ia),wi("CrossFadedConstantBinder",za),wi("SourceExpressionBinder",Pa),wi("CrossFadedCompositeBinder",Ba),wi("CompositeExpressionBinder",Ca),wi("ProgramConfiguration",Va,{omit:["_buffers"]}),wi("ProgramConfigurationSet",Ea);const $a=8192,La=Math.pow(2,14)-1,Da=-La-1;function Oa(t){const e=$a/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&A("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function ja(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?Oa(t):[]}}function Ra(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2);}class Ua{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Gs,this.indexArray=new na,this.segments=new oa,this.programConfigurations=new Ea(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1;"circle"===n.type&&(s=n.layout.get("circle-sort-key"),a=!s.isConstant());for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ja(e,t);if(!this.layers[0]._featureFilter.filter(new Ui(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Oa(e),patterns:{},sortKey:c};i.push(h);}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r),e.featureIndex.insert(o,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,aa),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=$a||n<0||n>=$a)continue;const i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),s=i.vertexLength;Ra(this.layoutVertexArray,r,n,-1,-1),Ra(this.layoutVertexArray,r,n,1,-1),Ra(this.layoutVertexArray,r,n,1,1),Ra(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+3,s+2),i.vertexLength+=4,i.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n);}}function qa(t,e){for(let r=0;r1){if(Ka(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function Ja(t,e){let r,n,i,s=!1;for(let a=0;ae.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function Wa(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function Qa(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=S(t,e,r[0]);return s!==S(t,e,r[1])||s!==S(t,e,r[2])||s!==S(t,e,r[3])}function to(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function eo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ro(t,e,r,n,i){if(!e[0]&&!e[1])return t;const a=s.convert(e)._mult(i);"viewport"===r&&a._rotate(-n);const o=[];for(let e=0;eyo(t,e)))}(l,o),p=c?u*a:u;for(const t of n)for(const e of t){const t=c?e:yo(e,o);let r=p;const n=po([],[e.x,e.y,0,1],o);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n[3]/s.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=s.cameraToCenterDistance/n[3]),Na(h,t,r))return !0}return !1}}function yo(t,e){const r=po([],[t.x,t.y,0,1],e);return new s(r[0]/r[3],r[1]/r[3])}class mo extends Ua{}let go;wi("HeatmapBucket",mo,{omit:["layers"]});var xo={get paint(){return go=go||new rs({"heatmap-radius":new Wi(G.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Wi(G.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ji(G.paint_heatmap["heatmap-intensity"]),"heatmap-color":new es(G.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ji(G.paint_heatmap["heatmap-opacity"])})}};function vo(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function bo(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=vo({},{width:e,height:r},n);wo(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function wo(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a);};if(t.clips)for(let e=0,i=0;e80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return To(s,a,r,o,l,u,0),a}function Eo(t,e,r,n,i){let s;if(i===function(t,e,r,n){let i=0;for(let s=e,a=r-n;s0)for(let i=e;i=e;i-=n)s=tl(i/n|0,t[i],t[i+1],s);return s&&Xo(s,s.next)&&(el(s),s=s.next),s}function Fo(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Xo(n,n.next)&&0!==Ko(n.prev,n,n.next))n=n.next;else {if(el(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function To(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=qo(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?Lo(t,n,i,s):$o(t))e.push(l.i,t.i,u.i),el(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?To(t=Do(Fo(t),e),e,r,n,i,s,2):2===a&&Oo(t,e,r,n,i,s):To(Fo(t),e,r,n,i,s,1);break}}}function $o(t){const e=t.prev,r=t,n=t.next;if(Ko(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=is?i>a?i:a:s>a?s:a,f=o>l?o>u?o:u:l>u?l:u;let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&Zo(i,o,s,l,a,u,d.x,d.y)&&Ko(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function Lo(t,e,r,n){const i=t.prev,s=t,a=t.next;if(Ko(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=ol?o>u?o:u:l>u?l:u,m=c>h?c>p?c:p:h>p?h:p,g=qo(f,d,e,r,n),x=qo(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Zo(o,c,l,h,u,p,v.x,v.y)&&Ko(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Zo(o,c,l,h,u,p,b.x,b.y)&&Ko(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Zo(o,c,l,h,u,p,v.x,v.y)&&Ko(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Zo(o,c,l,h,u,p,b.x,b.y)&&Ko(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function Do(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Xo(n,i)&&Ho(n,r,r.next,i)&&Wo(n,i)&&Wo(i,n)&&(e.push(n.i,r.i,i.i),el(r),el(r.next),r=t=i),r=r.next;}while(r!==t);return Fo(r)}function Oo(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&Go(a,t)){let o=Qo(a,t);return a=Fo(a,a.next),o=Fo(o,o.next),To(a,e,r,n,i,s,0),void To(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function jo(t,e){return t.x-e.x}function Ro(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&Zo(is.x||r.x===s.x&&Uo(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=Qo(r,t);return Fo(n,n.next),Fo(r,r.next)}function Uo(t,e){return Ko(t.prev,t,e.prev)<0&&Ko(e.next,t,t.next)<0}function qo(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function No(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function Go(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Ho(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(Wo(t,e)&&Wo(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Ko(t.prev,t,e.prev)||Ko(t,e.prev,e))||Xo(t,e)&&Ko(t.prev,t,t.next)>0&&Ko(e.prev,e,e.next)>0)}function Ko(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Xo(t,e){return t.x===e.x&&t.y===e.y}function Ho(t,e,r,n){const i=Jo(Ko(t,e,r)),s=Jo(Ko(t,e,n)),a=Jo(Ko(r,n,t)),o=Jo(Ko(r,n,e));return i!==s&&a!==o||!(0!==i||!Yo(t,r,e))||!(0!==s||!Yo(t,n,e))||!(0!==a||!Yo(r,t,n))||!(0!==o||!Yo(r,e,n))}function Yo(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Jo(t){return t>0?1:t<0?-1:0}function Wo(t,e){return Ko(t.prev,t,t.next)<0?Ko(t,e,t.next)>=0&&Ko(t,t.prev,e)>=0:Ko(t,e,t.prev)<0||Ko(t,t.next,e)<0}function Qo(t,e){const r=rl(t.i,t.x,t.y),n=rl(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function tl(t,e,r,n){const i=rl(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function el(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function rl(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function nl(t,e,r){const n=r.patternDependencies;let i=!1;for(const r of e){const e=r.paint.get(`${t}-pattern`);e.isConstant()||(i=!0);const s=e.constantOr(null);s&&(i=!0,n[s.to]=!0,n[s.from]=!0);}return i}function il(t,e,r,n,i){const s=i.patternDependencies;for(const a of e){const e=a.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:n-1},r,{},i.availableImages),o=e.evaluate({zoom:n},r,{},i.availableImages),l=e.evaluate({zoom:n+1},r,{},i.availableImages);t=t&&t.name?t.name:t,o=o&&o.name?o.name:o,l=l&&l.name?l.name:l,s[t]=!0,s[o]=!0,s[l]=!0,r.patterns[a.id]={min:t,mid:o,max:l};}}return r}class sl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ks,this.indexArray=new na,this.indexArray2=new ia,this.programConfigurations=new Ea(t.layers,t.zoom),this.segments=new oa,this.segments2=new oa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=nl("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ja(a,t);if(!this.layers[0]._featureFilter.filter(new Ui(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Oa(a),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=il("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{});e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Bo),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i){for(const t of xr(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],s=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&s.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;t>3;}if(i--,1===n||2===n)s+=t.readSVarint(),a+=t.readSVarint(),1===n&&(e&&o.push(e),e=[]),e.push(new dl(s,a));else {if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone());}}return e&&o.push(e),o},ml.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},ml.prototype.toGeoJSON=function(t,e,r){var n,i,s=this.extent*Math.pow(2,r),a=this.extent*t,o=this.extent*e,l=this.loadGeometry(),u=ml.types[this.type];function c(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}wl.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new vl(this._pbf,e,this.extent,this._keys,this._values)};var Al=bl;function Sl(t,e,r){if(3===t){var n=new Al(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n);}}fl.VectorTile=function(t,e){this.layers=t.readFields(Sl,{},e);},fl.VectorTileFeature=yl,fl.VectorTileLayer=bl;const kl=fl.VectorTileFeature.types,Ml=Math.pow(2,13);function Il(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*Ml)+a,i*Ml*2,s*Ml*2,Math.round(o));}class zl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Xs,this.centroidVertexArray=new Zs,this.indexArray=new na,this.programConfigurations=new Ea(t.layers,t.zoom),this.segments=new oa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=nl("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=ja(n,t);if(!this.layers[0]._featureFilter.filter(new Ui(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:Oa(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(il("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{}),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0);}}addFeatures(t,e,r){for(const t of this.features){const{geometry:n}=t;this.addFeature(t,n,t.index,e,r);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,pl),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,hl.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i){for(const r of xr(e,500)){const e={x:0,y:0,vertexCount:0};let n=0;for(const t of r)n+=t.length;let i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of r){if(0===t.length)continue;if(Cl(t))continue;let r=0;for(let n=0;n=1){const a=t[n-1];if(!Pl(s,a)){i.vertexLength+4>oa.MAX_VERTEX_ARRAY_LENGTH&&(i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=s.sub(a)._perp()._unit(),n=a.dist(s);r+n>32768&&(r=0),Il(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,0,r),Il(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,1,r),e.x+=2*s.x,e.y+=2*s.y,e.vertexCount+=2,r+=n,Il(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,0,r),Il(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,1,r),e.x+=2*a.x,e.y+=2*a.y,e.vertexCount+=2;const o=i.vertexLength;this.indexArray.emplaceBack(o,o+2,o+1),this.indexArray.emplaceBack(o+1,o+2,o+3),i.vertexLength+=4,i.primitiveLength+=2;}}}}if(i.vertexLength+n>oa.MAX_VERTEX_ARRAY_LENGTH&&(i=this.segments.prepareSegment(n,this.layoutVertexArray,this.indexArray)),"Polygon"!==kl[t.type])continue;const s=[],a=[],o=i.vertexLength;for(const t of r)if(0!==t.length){t!==r[0]&&a.push(s.length/2);for(let r=0;r$a)||t.y===e.y&&(t.y<0||t.y>$a)}function Cl(t){return t.every((t=>t.x<0))||t.every((t=>t.x>$a))||t.every((t=>t.y<0))||t.every((t=>t.y>$a))}let Bl;wi("FillExtrusionBucket",zl,{omit:["layers","features"]});var Vl={get paint(){return Bl=Bl||new rs({"fill-extrusion-opacity":new Ji(G["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Wi(G["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ji(G["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ji(G["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Qi(G["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Wi(G["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Wi(G["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ji(G["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class El extends is{constructor(t){super(t,Vl);}createBucket(t){return new zl(t)}queryRadius(){return eo(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature(t,e,r,n,i,a,o,l){const u=ro(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,o),c=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),p=function(t,e,r,n){const i=[];for(const r of t){const t=[r.x,r.y,0,1];po(t,t,e),i.push(new s(t[0]/t[3],t[1]/t[3]));}return i}(u,l),f=function(t,e,r,n){const i=[],a=[],o=n[8]*e,l=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,a=i.y,y=n[0]*e+n[4]*a+n[12],m=n[1]*e+n[5]*a+n[13],g=n[2]*e+n[6]*a+n[14],x=n[3]*e+n[7]*a+n[15],v=g+u,b=x+c,w=y+h,_=m+p,A=g+f,S=x+d,k=new s((y+o)/b,(m+l)/b);k.z=v/b,t.push(k);const M=new s(w/S,_/S);M.z=A/S,r.push(M);}i.push(t),a.push(r);}return [i,a]}(n,h,c,l);return function(t,e,r){let n=1/0;Za(r,e)&&(n=Tl(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new Hs,this.layoutVertexArray2=new Ys,this.indexArray=new na,this.programConfigurations=new Ea(t.layers,t.zoom),this.segments=new oa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=nl("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ja(e,t);if(!this.layers[0]._featureFilter.filter(new Ui(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Oa(e),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=il("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{});e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ol)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ll),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),o=s.get("line-cap"),l=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,a,o,l,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l0;if(w&&e>l){const t=h.dist(p);if(t>2*u){const e=h.sub(h.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,d,0,0,c),p=e;}}const A=p&&f;let S=A?r:a?"butt":n;if(A&&"round"===S&&(vi&&(S="bevel"),"bevel"===S&&(v>2&&(S="flipbevel"),v100)m=y.mult(-1);else {const t=v*d.add(y).mag()/d.sub(y).mag();m._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(h,m,0,0,c),this.addCurrentVertex(h,m.mult(-1),0,0,c);}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(p&&this.addCurrentVertex(h,d,e,r,c),"fakeround"===S){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*u){const e=h.add(f.sub(h)._mult(u/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,y,0,0,c),h=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>Ul/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s));}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(Ul-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let Nl,Zl;wi("LineBucket",ql,{omit:["layers","patternFeatures"]});var Gl={get paint(){return Zl=Zl||new rs({"line-opacity":new Wi(G.paint_line["line-opacity"]),"line-color":new Wi(G.paint_line["line-color"]),"line-translate":new Ji(G.paint_line["line-translate"]),"line-translate-anchor":new Ji(G.paint_line["line-translate-anchor"]),"line-width":new Wi(G.paint_line["line-width"]),"line-gap-width":new Wi(G.paint_line["line-gap-width"]),"line-offset":new Wi(G.paint_line["line-offset"]),"line-blur":new Wi(G.paint_line["line-blur"]),"line-dasharray":new ts(G.paint_line["line-dasharray"]),"line-pattern":new Qi(G.paint_line["line-pattern"]),"line-gradient":new es(G.paint_line["line-gradient"])})},get layout(){return Nl=Nl||new rs({"line-cap":new Ji(G.layout_line["line-cap"]),"line-join":new Wi(G.layout_line["line-join"]),"line-miter-limit":new Ji(G.layout_line["line-miter-limit"]),"line-round-limit":new Ji(G.layout_line["line-round-limit"]),"line-sort-key":new Wi(G.layout_line["line-sort-key"])})}};class Kl extends Wi{possiblyEvaluate(t,e){return e=new Ui(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=g({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let Xl;class Hl extends is{constructor(t){super(t,Gl),this.gradientVersion=0,Xl||(Xl=new Kl(Gl.paint.properties["line-width"].specification),Xl.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Ae,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Xl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new ql(t)}queryRadius(t){const e=t,r=Yl(to("line-width",this,e),to("line-gap-width",this,e)),n=to("line-offset",this,e);return r/2+Math.abs(n)+eo(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,i,a,o){const l=ro(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,o),u=o/2*Yl(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),c=this.paint.get("line-offset").evaluate(e,r);return c&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Jl=ls([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Wl=ls([{name:"a_projected_pos",components:3,type:"Float32"}],4);ls([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ql=ls([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);ls([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const tu=ls([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),eu=ls([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ru(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ri.applyArabicShaping&&(t=Ri.applyArabicShaping(t)),t}(t.text,e,r);})),t}ls([{name:"triangle",components:3,type:"Uint16"}]),ls([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),ls([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),ls([{type:"Float32",name:"offsetX"}]),ls([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),ls([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const nu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var iu=24,su=lu,au=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},ou=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;};function lu(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}lu.Varint=0,lu.Fixed64=1,lu.Bytes=2,lu.Fixed32=5;var uu=4294967296,cu=1/uu,hu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function pu(t){return t.type===lu.Bytes?t.readVarint()+t.pos:t.pos+1}function fu(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function du(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function yu(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function Mu(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}lu.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Su(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Mu(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Su(this.buf,this.pos)+Su(this.buf,this.pos+4)*uu;return this.pos+=8,t},readSFixed64:function(){var t=Su(this.buf,this.pos)+Mu(this.buf,this.pos+4)*uu;return this.pos+=8,t},readFloat:function(){var t=au(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=au(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return fu(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return fu(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return fu(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return fu(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return fu(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return fu(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&hu?function(t,e,r){return hu.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==lu.Bytes)return t.push(this.readVarint(e));var r=pu(this);for(t=t||[];this.pos127;);else if(e===lu.Bytes)this.pos=this.readVarint()+this.pos;else if(e===lu.Fixed32)this.pos+=4;else {if(e!==lu.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&du(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(t){this.realloc(4),ou(this.buf,t,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(t){this.realloc(8),ou(this.buf,t,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&du(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,e,r){this.writeTag(t,lu.Bytes),this.writeRawMessage(e,r);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,yu,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,mu,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,vu,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,gu,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,xu,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,bu,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,wu,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,_u,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Au,e);},writeBytesField:function(t,e){this.writeTag(t,lu.Bytes),this.writeBytes(e);},writeFixed32Field:function(t,e){this.writeTag(t,lu.Fixed32),this.writeFixed32(e);},writeSFixed32Field:function(t,e){this.writeTag(t,lu.Fixed32),this.writeSFixed32(e);},writeFixed64Field:function(t,e){this.writeTag(t,lu.Fixed64),this.writeFixed64(e);},writeSFixed64Field:function(t,e){this.writeTag(t,lu.Fixed64),this.writeSFixed64(e);},writeVarintField:function(t,e){this.writeTag(t,lu.Varint),this.writeVarint(e);},writeSVarintField:function(t,e){this.writeTag(t,lu.Varint),this.writeSVarint(e);},writeStringField:function(t,e){this.writeTag(t,lu.Bytes),this.writeString(e);},writeFloatField:function(t,e){this.writeTag(t,lu.Fixed32),this.writeFloat(e);},writeDoubleField:function(t,e){this.writeTag(t,lu.Fixed64),this.writeDouble(e);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}};var Iu=r(su);const zu=3;function Pu(t,e,r){1===t&&r.readMessage(Cu,e);}function Cu(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(Bu,{});e.push({id:t,bitmap:new _o({width:i+2*zu,height:s+2*zu},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}}function Bu(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const Vu=zu;function Eu(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&Uu[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new ju;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Ou.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ru(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=ju.fromFeature(e,s);let g;p===t.ah.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=Ri;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),Yu(m,c,a,r,i,d));for(const e of t){const t=new ju;t.text=e,t.sections=m.sections;for(let r=0;r0&&n>_&&(_=n);}else {const t=n[y.fontStack],e=t&&t[g];if(e&&e.rect)A=e.rect,b=e.metrics;else {const t=r[y.fontStack],e=t&&t[g];if(!e)continue;b=e.metrics;}x=(s-y.scale)*iu;}M?(e.verticalizable=!0,w.push({glyph:g,imageName:S,x:f,y:d+x,vertical:M,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:b,rect:A}),f+=k*y.scale+c):(w.push({glyph:g,imageName:S,x:f,y:d+x,vertical:M,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:b,rect:A}),f+=b.advance*y.scale+c);}0!==w.length&&(y=Math.max(f-c,y),Wu(w,0,w.length-1,g,_)),f=0;const A=a*s+_;b.lineOffset=Math.max(_,l),d+=A,m=Math.max(A,m),++x;}var v;const b=d-Du,{horizontalAlign:w,verticalAlign:_}=Ju(o);((function(t,e,r,n,i,s,a,o,l){const u=(e-r)*i;let c=0;c=s!==a?-o*n-Du:(-n*l+.5)*a;for(const e of t)for(const t of e.positionedGlyphs)t.x+=u,t.y+=c;}))(e.positionedLines,g,w,_,y,m,a,b,s.length),e.top+=-_*b,e.bottom=e.top+b,e.left+=-w*y,e.right=e.left+y;}(w,r,n,i,g,o,l,u,p,c,f,y),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return !1;return !0}(b)&&w}const Uu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},qu={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Nu={40:!0};function Zu(t,e,r,n,i,s){if(e.imageName){const t=n[e.imageName];return t?t.displaySize[0]*e.scale*iu/s+i:0}{const n=r[e.fontStack],s=n&&n[t];return s?s.metrics.advance*e.scale+i:0}}function Gu(t,e,r,n){const i=Math.pow(t-e,2);return n?t=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/a,a=t;}return {x1:n,y1:i,x2:n+s,y2:i+a}}function ec(t,e,r,n,i,s){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-a.displaySize[1])/2,p=c+a.displaySize[1]),{image:a,top:c,right:h,bottom:p,left:f,collisionPadding:o}}const rc=255,nc=128,ic=rc*nc;function sc(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new Ui(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=lo([]),this.placementViewportMatrix=lo([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=sc(this.zoom,r["text-size"]),this.iconSizeData=sc(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap="never"!==ac(n,"text-overlap","text-allow-overlap")||"never"!==ac(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ah[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new pc(new Ea(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new pc(new Ea(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Os,this.lineVertexArray=new js,this.symbolInstances=new Ds,this.textAnchorOffsets=new Us;}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new Ui(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=ja(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=Oa(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=Yt.factory(t),r=this.hasRTLText=this.hasRTLText||hc(e);(!r||"unavailable"===Ri.getRTLTextPluginStatus()||r&&Ri.isParsed())&&(x=ru(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof te?t:te.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:oc[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=a.evaluate(g,{},n).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ah.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=Pi(x.toString()),i=t.fontStack||e,s=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,s,r,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let yc,mc;wi("SymbolBucket",dc,{omit:["layers","collisionBoxArray","features","compareText"]}),dc.MAX_GLYPHS=65535,dc.addDynamicAttributes=cc;var gc={get paint(){return mc=mc||new rs({"icon-opacity":new Wi(G.paint_symbol["icon-opacity"]),"icon-color":new Wi(G.paint_symbol["icon-color"]),"icon-halo-color":new Wi(G.paint_symbol["icon-halo-color"]),"icon-halo-width":new Wi(G.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Wi(G.paint_symbol["icon-halo-blur"]),"icon-translate":new Ji(G.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ji(G.paint_symbol["icon-translate-anchor"]),"text-opacity":new Wi(G.paint_symbol["text-opacity"]),"text-color":new Wi(G.paint_symbol["text-color"],{runtimeType:pt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Wi(G.paint_symbol["text-halo-color"]),"text-halo-width":new Wi(G.paint_symbol["text-halo-width"]),"text-halo-blur":new Wi(G.paint_symbol["text-halo-blur"]),"text-translate":new Ji(G.paint_symbol["text-translate"]),"text-translate-anchor":new Ji(G.paint_symbol["text-translate-anchor"])})},get layout(){return yc=yc||new rs({"symbol-placement":new Ji(G.layout_symbol["symbol-placement"]),"symbol-spacing":new Ji(G.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ji(G.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Wi(G.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ji(G.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ji(G.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ji(G.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ji(G.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ji(G.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ji(G.layout_symbol["icon-rotation-alignment"]),"icon-size":new Wi(G.layout_symbol["icon-size"]),"icon-text-fit":new Ji(G.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ji(G.layout_symbol["icon-text-fit-padding"]),"icon-image":new Wi(G.layout_symbol["icon-image"]),"icon-rotate":new Wi(G.layout_symbol["icon-rotate"]),"icon-padding":new Wi(G.layout_symbol["icon-padding"]),"icon-keep-upright":new Ji(G.layout_symbol["icon-keep-upright"]),"icon-offset":new Wi(G.layout_symbol["icon-offset"]),"icon-anchor":new Wi(G.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ji(G.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ji(G.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ji(G.layout_symbol["text-rotation-alignment"]),"text-field":new Wi(G.layout_symbol["text-field"]),"text-font":new Wi(G.layout_symbol["text-font"]),"text-size":new Wi(G.layout_symbol["text-size"]),"text-max-width":new Wi(G.layout_symbol["text-max-width"]),"text-line-height":new Ji(G.layout_symbol["text-line-height"]),"text-letter-spacing":new Wi(G.layout_symbol["text-letter-spacing"]),"text-justify":new Wi(G.layout_symbol["text-justify"]),"text-radial-offset":new Wi(G.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ji(G.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Wi(G.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Wi(G.layout_symbol["text-anchor"]),"text-max-angle":new Ji(G.layout_symbol["text-max-angle"]),"text-writing-mode":new Ji(G.layout_symbol["text-writing-mode"]),"text-rotate":new Wi(G.layout_symbol["text-rotate"]),"text-padding":new Ji(G.layout_symbol["text-padding"]),"text-keep-upright":new Ji(G.layout_symbol["text-keep-upright"]),"text-transform":new Wi(G.layout_symbol["text-transform"]),"text-offset":new Wi(G.layout_symbol["text-offset"]),"text-allow-overlap":new Ji(G.layout_symbol["text-allow-overlap"]),"text-overlap":new Ji(G.layout_symbol["text-overlap"]),"text-ignore-placement":new Ji(G.layout_symbol["text-ignore-placement"]),"text-optional":new Ji(G.layout_symbol["text-optional"])})}};class xc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:lt,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}wi("FormatSectionOverride",xc,{omit:["defaultValue"]});class vc extends is{constructor(t){super(t,gc);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||vn(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new dc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of gc.paint.overridableProperties){if(!vc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new xc(e),n=new xn(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new wn("source",n):new _n("composite",n,e.value.zoomStops),this.paint._values[t]=new Hi(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&vc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=gc.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Yt)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof se&&ne(e.value)===mt?s(e.value.sections):e instanceof Ze?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let bc;var wc={get paint(){return bc=bc||new rs({"background-color":new Ji(G.paint_background["background-color"]),"background-pattern":new ts(G.paint_background["background-pattern"]),"background-opacity":new Ji(G.paint_background["background-opacity"])})}};class _c extends is{constructor(t){super(t,wc);}}let Ac;var Sc={get paint(){return Ac=Ac||new rs({"raster-opacity":new Ji(G.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ji(G.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ji(G.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ji(G.paint_raster["raster-brightness-max"]),"raster-saturation":new Ji(G.paint_raster["raster-saturation"]),"raster-contrast":new Ji(G.paint_raster["raster-contrast"]),"raster-resampling":new Ji(G.paint_raster["raster-resampling"]),"raster-fade-duration":new Ji(G.paint_raster["raster-fade-duration"])})}};class kc extends is{constructor(t){super(t,Sc);}}class Mc extends is{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Ic{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle();}),0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const zc=6371008.8;class Pc{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Pc(m(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return zc*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof Pc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Pc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Pc(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Cc=2*Math.PI*zc;function Bc(t){return Cc*Math.cos(t*Math.PI/180)}function Vc(t){return (180+t)/360}function Ec(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Fc(t,e){return t/Bc(e)}function Tc(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class $c{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=Pc.convert(t);return new $c(Vc(r.lng),Ec(r.lat),Fc(e,r.lat))}toLngLat(){return new Pc(360*this.x-180,Tc(this.y))}toAltitude(){return this.z*Bc(Tc(this.y))}meterInMercatorCoordinateUnits(){return 1/Cc*(t=Tc(this.y),1/Math.cos(t*Math.PI/180));var t;}}function Lc(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Dc{constructor(t,e,r){if(!function(t,e,r){return !(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=Rc(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=Lc(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=Lc(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new s((t.x*e-this.x)*$a,(t.y*e-this.y)*$a)}toString(){return `${this.z}/${this.x}/${this.y}`}}class Oc{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Rc(t,e.z,e.z,e.x,e.y);}}class jc{constructor(t,e,r,n,i){if(t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Dc(r,+n,+i),this.key=Rc(e,t,r,n,i);}clone(){return new jc(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new jc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new jc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?Rc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Rc(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new jc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new jc(e,this.wrap,e,r,n),new jc(e,this.wrap,e,r+1,n),new jc(e,this.wrap,e,r,n+1),new jc(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new Ao({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Nc{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class Zc{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new vi($a,16,0),this.grid3D=new vi($a,16,0),this.featureIndexArray=new Ns,this.promoteId=e;}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new fl.VectorTile(new Iu(this.rawTileData)).layers,this.sourceLayerCoder=new qc(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},a=$a/t.tileSize/t.scale,o=zn(i.filter),l=t.queryGeometry,u=t.queryPadding*a,c=Kc(l),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=Kc(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const a=[new s(e,r),new s(e,i),new s(n,i),new s(n,r)];if(t.length>2)for(const e of a)if(Wa(t,e))return !0;for(let e=0;e(p||(p=Oa(e)),r.queryIntersectsFeature(l,e,n,p,this.z,t.transform,a,t.pixelPosMatrix))));}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!function(t,e){for(let r=0;r=0)return !0;return !1}(s,h))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=ja(f,!0);if(!i.filter(new Ui(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ui(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const a=e instanceof Yi?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function Kc(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {minX:e,minY:r,maxX:n,maxY:i}}function Xc(t,e){return e-t}function Hc(t,e,r,n,i){const a=[];for(let o=0;o=n&&c.x>=n||(o.x>=n?o=new s(n,o.y+(n-o.x)/(c.x-o.x)*(c.y-o.y))._round():c.x>=n&&(c=new s(n,o.y+(n-o.x)/(c.x-o.x)*(c.y-o.y))._round()),o.y>=i&&c.y>=i||(o.y>=i?o=new s(o.x+(i-o.y)/(c.y-o.y)*(c.x-o.x),i)._round():c.y>=i&&(c=new s(o.x+(i-o.y)/(c.y-o.y)*(c.x-o.x),i)._round()),u&&o.equals(u[u.length-1])||(u=[o],a.push(u)),u.push(c)))));}}return a}wi("FeatureIndex",Zc,{omit:["rawTileData","sourceLayerCoder"]});class Yc extends s{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new Yc(this.x,this.y,this.angle,this.segment)}}function Jc(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function Wc(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=Ce.number(n.x,i.x,c),p=Ce.number(n.y,i.y,c),f=new Yc(h,p,i.angleTo(n),r);return f._round(),!a||Jc(t,f,o,a,e)?f:void 0}l+=s;}}function rh(t,e,r,n,i,s,a,o,l){const u=Qc(n,s,a),c=th(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new Yc(g,x,y,e);r._round(),n&&!Jc(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=nh(t,h/2,r,n,i,s,a,!0,l)),f}wi("Anchor",Yc);const ih=Fu;function sh(t,e,r,n){const i=[],a=t.image,o=a.pixelRatio,l=a.paddedRect.w-2*ih,u=a.paddedRect.h-2*ih;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=a.stretchX||[[0,l]],p=a.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=l-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,A=m,S=0,k=g;if(a.content&&n){const e=a.content,r=e[2]-e[0],n=e[3]-e[1];(a.textFitWidth||a.textFitHeight)&&(c=tc(t)),x=ah(h,0,e[0]),b=ah(p,0,e[1]),v=ah(h,e[0],e[2]),w=ah(p,e[1],e[3]),_=e[0]-x,S=e[1]-b,A=r-v,k=n-w;}const M=c.x1,I=c.y1,z=c.x2-M,P=c.y2-I,C=(t,n,i,l)=>{const u=lh(t.stretch-x,v,z,M),c=uh(t.fixed-_,A,t.stretch,d),h=lh(n.stretch-b,w,P,I),p=uh(n.fixed-S,k,n.stretch,y),f=lh(i.stretch-x,v,z,M),m=uh(i.fixed-_,A,i.stretch,d),g=lh(l.stretch-b,w,P,I),C=uh(l.fixed-S,k,l.stretch,y),B=new s(u,h),V=new s(f,h),E=new s(f,g),F=new s(u,g),T=new s(c/o,p/o),$=new s(m/o,C/o),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),r=[e,-t,t,e];B._matMult(r),V._matMult(r),F._matMult(r),E._matMult(r);}const D=t.stretch+t.fixed,O=n.stretch+n.fixed;return {tl:B,tr:V,bl:F,br:E,tex:{x:a.paddedRect.x+ih+D,y:a.paddedRect.y+ih+O,w:i.stretch+i.fixed-D,h:l.stretch+l.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:T,pixelOffsetBR:$,minFontScaleX:A/o/z,minFontScaleY:k/o/P,isSDF:r}};if(n&&(a.stretchX||a.stretchY)){const t=oh(h,m,d),e=oh(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {const u=(null===(h=a.image)||void 0===h?void 0:h.content)&&(a.image.textFitWidth||a.image.textFitHeight)?tc(a):{x1:a.left,y1:a.top,x2:a.right,y2:a.bottom};u.y1=u.y1*o-l[0],u.y2=u.y2*o+l[2],u.x1=u.x1*o-l[3],u.x2=u.x2*o+l[1];const p=a.collisionPadding;if(p&&(u.x1-=p[0]*o,u.y1-=p[1]*o,u.x2+=p[2]*o,u.y2+=p[3]*o),c){const t=new s(u.x1,u.y1),e=new s(u.x2,u.y1),r=new s(u.x1,u.y2),n=new s(u.x2,u.y2),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,i);}this.boxEndIndex=t.length;}}class hh{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}function ph(t,e=1,r=!1){let n=1/0,i=1/0,a=-1/0,o=-1/0;const l=t[0];for(let t=0;ta)&&(a=e.x),(!t||e.y>o)&&(o=e.y);}const u=Math.min(a-n,o-i);let c=u/2;const h=new hh([],fh);if(0===u)return new s(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new dh(n.p.x-c,n.p.y-c,c,t)),h.push(new dh(n.p.x+c,n.p.y-c,c,t)),h.push(new dh(n.p.x-c,n.p.y+c,c,t)),h.push(new dh(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function fh(t,e){return e.max-t.max}function dh(t,e,r,n){this.p=new s(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Ya(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var yh;t.aq=void 0,(yh=t.aq||(t.aq={}))[yh.center=1]="center",yh[yh.left=2]="left",yh[yh.right=3]="right",yh[yh.top=4]="top",yh[yh.bottom=5]="bottom",yh[yh["top-left"]=6]="top-left",yh[yh["top-right"]=7]="top-right",yh[yh["bottom-left"]=8]="bottom-left",yh[yh["bottom-right"]=9]="bottom-right";const mh=7,gh=Number.POSITIVE_INFINITY;function xh(t,e){return e[1]!==gh?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-mh;break;case"bottom-right":case"bottom-left":case"bottom":i=-r+mh;}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case"top-right":case"top-left":n=i-mh;break;case"bottom-right":case"bottom-left":n=-i+mh;break;case"bottom":n=-e+mh;break;case"top":n=e-mh;}switch(t){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=e;break;case"right":r=-e;}return [r,n]}(t,e[0])}function vh(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*iu));n.startsWith("top")?i[1]-=mh:n.startsWith("bottom")&&(i[1]+=mh),e[r+1]=i;}return new Qt(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*iu,gh]:i.get("text-offset").evaluate(e,{},r).map((t=>t*iu));const s=[];for(const t of a)s.push(t,xh(t,n));return new Qt(s)}return null}function bh(t){switch(t){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function wh(e,r,n,i,s,a,o,l,u,c,h){let p=a.textMaxSize.evaluate(r,{});void 0===p&&(p=o);const f=e.layers[0].layout,d=f.get("icon-offset").evaluate(r,{},h),y=Ah(n.horizontal),m=o/24,g=e.tilePixelRatio*m,x=e.tilePixelRatio*p/24,v=e.tilePixelRatio*l,b=e.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*e.tilePixelRatio,_=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),s=i&&i.values;return [s[0]*n,s[1]*n,s[2]*n,s[3]*n]}(f,r,h,e.tilePixelRatio),S=f.get("text-max-angle")/180*Math.PI,k="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),M="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),I=f.get("symbol-placement"),z=b/2,P=f.get("icon-text-fit");let C;i&&"none"!==P&&(e.allowVerticalPlacement&&n.vertical&&(C=ec(i,n.vertical,P,f.get("icon-text-fit-padding"),d,m)),y&&(i=ec(i,y,P,f.get("icon-text-fit-padding"),d,m)));const B=(l,p)=>{p.x<0||p.x>=$a||p.y<0||p.y>=$a||function(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,k,M){const I=e.addToLineVertexArray(r,n);let z,P,C,B,V=0,E=0,F=0,T=0,$=-1,L=-1;const D={};let O=ma("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},k)+90;C=new ch(u,r,c,h,p,i.vertical,f,d,y,t),o&&(B=new ch(u,r,c,h,p,o,g,x,y,t));}if(s){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),a=sh(s,n,S,i),f=o?sh(o,n,S,i):void 0;P=new ch(u,r,c,h,p,s,g,x,!1,n),V=4*a.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[nc*l.layout.get("icon-size").evaluate(w,{})],y[0]>ic&&A(`${e.layerIds[0]}: Value for "icon-size" is >= ${rc}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[nc*_.compositeIconSizes[0].evaluate(w,{},k),nc*_.compositeIconSizes[1].evaluate(w,{},k)],(y[0]>ic||y[1]>ic)&&A(`${e.layerIds[0]}: Value for "icon-size" is >= ${rc}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,y,b,v,w,t.ah.none,r,I.lineStartIndex,I.lineLength,-1,k),$=e.icon.placedSymbolArray.length-1,f&&(E=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.ah.vertical,r,I.lineStartIndex,I.lineLength,-1,k),L=e.icon.placedSymbolArray.length-1);}const j=Object.keys(i.horizontal);for(const n of j){const s=i.horizontal[n];if(!z){O=ma(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},k);z=new ch(u,r,c,h,p,s,f,d,y,t);}const o=1===s.positionedLines.length;if(F+=_h(e,r,s,a,l,y,w,m,I,i.vertical?t.ah.horizontal:t.ah.horizontalOnly,o?j:[n],D,$,_,k),o)break}i.vertical&&(T+=_h(e,r,i.vertical,a,l,y,w,m,I,t.ah.vertical,["vertical"],D,L,_,k));const R=z?z.boxStartIndex:e.collisionBoxArray.length,U=z?z.boxEndIndex:e.collisionBoxArray.length,q=C?C.boxStartIndex:e.collisionBoxArray.length,N=C?C.boxEndIndex:e.collisionBoxArray.length,Z=P?P.boxStartIndex:e.collisionBoxArray.length,G=P?P.boxEndIndex:e.collisionBoxArray.length,K=B?B.boxStartIndex:e.collisionBoxArray.length,X=B?B.boxEndIndex:e.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(z,H),H=Y(C,H),H=Y(P,H),H=Y(B,H);const J=H>-1?1:0;J&&(H*=M/iu),e.glyphOffsetArray.length>=dc.MAX_GLYPHS&&A("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=vh(l,w,k),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?D.right:-1,D.center>=0?D.center:-1,D.left>=0?D.left:-1,D.vertical||-1,$,L,O,R,U,q,N,Z,G,K,X,c,F,T,V,E,J,0,f,H,Q,tt);}(e,p,l,n,i,s,C,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,g,[w,w,w,w],k,u,v,_,M,d,r,a,c,h,o);};if("line"===I)for(const t of Hc(r.geometry,0,0,$a,$a)){const r=rh(t,b,S,n.vertical||y,i,24,x,e.overscaling,$a);for(const n of r)y&&Sh(e,y.text,z,n)||B(t,n);}else if("line-center"===I){for(const t of r.geometry)if(t.length>1){const e=eh(t,S,n.vertical||y,i,24,x);e&&B(t,e);}}else if("Polygon"===r.type)for(const t of xr(r.geometry,0)){const e=ph(t,16);B(t[0],new Yc(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry)B(t,new Yc(t[0].x,t[0].y,0));else if("Point"===r.type)for(const t of r.geometry)for(const e of t)B([e],new Yc(e.x,e.y,0));}function _h(t,e,r,n,i,a,o,l,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,a,o,l){const u=n.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const a=n.rect||{};let h=Vu+1,p=!0,f=1,d=0;const y=(i||l)&&n.vertical,m=n.metrics.advance*n.scale/2;if(l&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(iu-n.metrics.width*n.scale)/2:(n.scale-1)*iu)),n.imageName){const t=o[n.imageName];p=t.sdf,f=t.pixelRatio,h=Fu/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],A=w+a.w/b*n.scale/f,S=_+a.h/b*n.scale/f,k=new s(w,_),M=new s(A,_),I=new s(w,S),z=new s(A,S);if(y){const t=new s(-m,m-Du),e=-Math.PI/2,r=iu/2-m,i=new s(5-Du-r,-(n.imageName?r:0)),a=new s(...v);k._rotateAround(e,t)._add(i)._add(a),M._rotateAround(e,t)._add(i)._add(a),I._rotateAround(e,t)._add(i)._add(a),z._rotateAround(e,t)._add(i)._add(a);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),M._matMult(r),I._matMult(r),z._matMult(r);}const P=new s(0,0),C=new s(0,0);c.push({tl:k,tr:M,bl:I,br:z,tex:a,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,l,i,a,o,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[nc*i.layout.get("text-size").evaluate(o,{})],x[0]>ic&&A(`${t.layerIds[0]}: Value for "text-size" is >= ${rc}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[nc*d.compositeTextSizes[0].evaluate(o,{},y),nc*d.compositeTextSizes[1].evaluate(o,{},y)],(x[0]>ic||x[1]>ic)&&A(`${t.layerIds[0]}: Value for "text-size" is >= ${rc}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,l,a,o,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function Ah(t){for(const e in t)return t[e];return null}function Sh(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=kh[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new Mh(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=kh.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Ih(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)Bh(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Bh(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function Ih(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;zh(t,e,a,n,i,s),Ih(t,e,r,n,a-1,1-s),Ih(t,e,r,a+1,i,1-s);}function zh(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);zh(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(Ph(t,e,n,r),e[2*i+s]>a&&Ph(t,e,n,i);oa;)l--;}e[2*n+s]===a?Ph(t,e,n,l):(l++,Ph(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function Ph(t,e,r,n){Ch(t,r,n),Ch(e,2*r,2*n),Ch(e,2*r+1,2*n+1);}function Ch(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Bh(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}var Vh;t.bg=void 0,(Vh=t.bg||(t.bg={})).create="create",Vh.load="load",Vh.fullLoad="fullLoad";let Eh=null,Fh=[];const Th=1e3/60,$h="loadTime",Lh="fullLoadTime",Dh={mark(t){performance.mark(t);},frame(t){const e=t;null!=Eh&&Fh.push(e-Eh),Eh=e;},clearMetrics(){Eh=null,Fh=[],performance.clearMeasures($h),performance.clearMeasures(Lh);for(const e in t.bg)performance.clearMarks(t.bg[e]);},getPerformanceMetrics(){performance.measure($h,t.bg.create,t.bg.load),performance.measure(Lh,t.bg.create,t.bg.fullLoad);const e=performance.getEntriesByName($h)[0].duration,r=performance.getEntriesByName(Lh)[0].duration,n=Fh.length,i=1/(Fh.reduce(((t,e)=>t+e),0)/n/1e3),s=Fh.filter((t=>t>Th)).reduce(((t,e)=>t+(e-Th)/Th),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:s/(n+s)*100,totalFrames:n}}};t.$=class extends ps{},t.A=oo,t.B=yi,t.C=function(t){if(null==M){const e=t.navigator?t.navigator.userAgent:null;M=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return M},t.D=Ji,t.E=Z,t.F=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Ic((()=>this.process())),this.subscription=function(t,e,r,n){return t.addEventListener(e,r,!1),{unsubscribe:()=>{t.removeEventListener(e,r,!1);}}}(this.target,"message",(t=>this.receive(t))),this.globalScope=k(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[i]={resolve:r,reject:n},e&&e.signal.addEventListener("abort",(()=>{delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),{once:!0});const s=[],a=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:ki(t.data,s)});this.target.postMessage(a,{transfer:s});}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(k(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(Mi(r.error)):e.resolve(Mi(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=Mi(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i);}catch(e){this.completeTask(t,e);}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?ki(e):null,data:ki(r,n)};this.target.postMessage(i,{transfer:n});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.G=$,t.H=function(){var t=new oo(16);return oo!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.I=Tu,t.J=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=a*y+c*m+d*g+e[15]),t},t.K=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.L=uo,t.M=function(t,e){const r={};for(let n=0;n{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e);};for(const r of t){const t=window.document.createElement("source");j(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t);}}))},t.a4=function(){return x++},t.a5=Fs,t.a6=dc,t.a7=zn,t.a8=ja,t.a9=Nc,t.aA=function(t){if("custom"===t.type)return new Mc(t);switch(t.type){case"background":return new _c(t);case"circle":return new fo(t);case"fill":return new ul(t);case"fill-extrusion":return new El(t);case"heatmap":return new Mo(t);case"hillshade":return new Po(t);case"line":return new Hl(t);case"raster":return new kc(t);case"symbol":return new vc(t)}},t.aB=w,t.aC=function(t,e){if(!t)return [{command:"setStyle",args:[e]}];let r=[];try{if(!H(t.version,e.version))return [{command:"setStyle",args:[e]}];H(t.center,e.center)||r.push({command:"setCenter",args:[e.center]}),H(t.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),H(t.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),H(t.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),H(t.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),H(t.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),H(t.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),H(t.light,e.light)||r.push({command:"setLight",args:[e.light]}),H(t.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),H(t.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),H(t.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const n={},i=[];!function(t,e,r,n){let i;for(i in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)||W(i,r,n));for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)?H(t[i],e[i])||("geojson"===t[i].type&&"geojson"===e[i].type&&tt(t,e,i)?Y(r,{command:"setGeoJSONSourceData",args:[i,e[i].data]}):Q(i,e,r,n)):J(i,e,r));}(t.sources,e.sources,i,n);const s=[];t.layers&&t.layers.forEach((t=>{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):s.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(rt),i=e.map(rt),s=t.reduce(nt,{}),a=e.reduce(nt,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;t@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.ab=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ac=y,t.ad=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.ae=function(t){var e=new oo(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.af=po,t.ag=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:a}=t,o=i?y(Be.interpolationFactor(i,e,s,a),0,1):0;"camera"===t.kind?n=Ce.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.ai=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/nc:"composite"===t.kind?Ce.number(n/nc,i/nc,r):e},t.aj=cc,t.ak=function(t,e,r,n){const i=e.y-t.y,a=e.x-t.x,o=n.y-r.y,l=n.x-r.x,u=o*a-l*i;if(0===u)return null;const c=(l*(t.y-r.y)-o*(t.x-r.x))/u;return new s(t.x+c*a,t.y+c*i)},t.al=Hc,t.am=qa,t.an=lo,t.ao=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return [e,r,n,i]},t.ap=iu,t.ar=ac,t.as=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,A=i*u-s*l,S=c*y-h*d,k=c*m-p*d,M=c*g-f*d,I=h*m-p*y,z=h*g-f*y,P=p*g-f*m,C=x*P-v*z+b*I+w*M-_*k+A*S;return C?(t[0]=(o*P-l*z+u*I)*(C=1/C),t[1]=(i*z-n*P-s*I)*C,t[2]=(y*A-m*_+g*w)*C,t[3]=(p*_-h*A-f*w)*C,t[4]=(l*M-a*P-u*k)*C,t[5]=(r*P-i*M+s*k)*C,t[6]=(m*b-d*A-g*v)*C,t[7]=(c*A-p*b+f*v)*C,t[8]=(a*z-o*M+u*S)*C,t[9]=(n*M-r*z-s*S)*C,t[10]=(d*_-y*b+g*x)*C,t[11]=(h*b-c*_-f*x)*C,t[12]=(o*k-a*I-l*S)*C,t[13]=(r*I-n*k+i*S)*C,t[14]=(y*v-d*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null},t.at=bh,t.au=Ju,t.av=Mh,t.aw=function(){const t={},e=G.$version;for(const r in G.$root){const n=G.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.ax=Ii,t.ay=D,t.az=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r25||n<0||n>=1||r<0||r>=1)},t.bc=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.bd=class extends hs{},t.be=zc,t.bf=Dh,t.bh=L,t.bi=function(t,e){F.REGISTERED_PROTOCOLS[t]=e;},t.bj=function(t){delete F.REGISTERED_PROTOCOLS[t];},t.bk=function(t,e){const r={};for(let n=0;nt*iu));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(i,{},e.canonical)*iu:1/0,w=()=>{e.bucket.allowVerticalPlacement&&Pi(s)&&(d.vertical=Ru(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,b,a,m,"left",f,g,t.ah.vertical,!0,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.e=g,t.f=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=z;}));},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):z;})),t.g=T,t.h=(t,e)=>O(g(t,{type:"json"}),e),t.i=k,t.j=N,t.k=q,t.l=(t,e)=>O(g(t,{type:"arrayBuffer"}),e),t.m=O,t.n=function(t){return new Iu(t).readFields(Pu,[])},t.o=_o,t.p=Eu,t.q=rs,t.r=di,t.s=j,t.t=xi,t.u=fi,t.v=G,t.w=A,t.x=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}},t.y=Ce,t.z=Ui;})); +define("shared",["exports"],(function(t){"use strict";function e(t,e,r,n){return new(r||(r=Promise))((function(i,s){function a(t){try{l(n.next(t));}catch(t){s(t);}}function o(t){try{l(n.throw(t));}catch(t){s(t);}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e);}))).then(a,o);}l((n=n.apply(t,e||[])).next());}))}function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var n,i;function s(){if(i)return n;function t(t,e){this.x=t,this.y=e;}return i=1,n=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},n}"function"==typeof SuppressedError&&SuppressedError;var a,o,l=r(s()),u=function(){if(o)return a;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return o=1,a=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},a}(),c=r(u);let h,p;function f(){return null==h&&(h="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),h}function d(){if(null==p&&(p=!1,f())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let r=0;r=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function E(t,e,r,n){const i=new c(t,e,r,n);return t=>i.solve(t)}const T=E(.25,.1,.25,1);function F(t,e,r){return Math.min(r,Math.max(e,t))}function $(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function L(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let O=1;function D(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function j(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function R(t){return Array.isArray(t)?t.map(R):"object"==typeof t&&t?D(t,R):t}const N={};function U(t){N[t]||("undefined"!=typeof console&&console.warn(t),N[t]=!0);}function q(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function G(t){return "undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let Z=null;function K(t){return "undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const X="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function H(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(i*s*4);if(yield e.copyTo(l,function(t,e,r,n,i){const s=4*Math.max(1,0),a=(Math.max(0,r)-r)*n*4+s,o=4*n,l=Math.max(0,e),u=Math.max(0,r);return {rect:{x:l,y:u,width:Math.min(t.width,e+n)-l,height:Math.min(t.height,r+i)-u},layout:[{offset:a,stride:o}]}}(t,r,n,i,s)),o)for(let t=0;t{t.removeEventListener(e,r,n);}}}function Q(t){return t*Math.PI/180}function tt(t){return t/Math.PI*180}const et={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},rt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},nt="AbortError";function it(){return new Error(nt)}const st={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function at(t){return st.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const ot="global-dispatcher";class lt extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n;}}const ut=()=>G(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ct=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=at(t.url);if(e)return e(t,r);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:ot},r)}if(!(/^file:/.test(n=t.url)||/^file:/.test(ut())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:ut(),signal:r.signal});let n,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e);}catch(e){throw new lt(0,e.message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new lt(n.status,n.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw it();return {data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(G(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:ot},r)}var n;return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText));},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response);}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")});}else {const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new lt(s.status,s.statusText,t.url,e));}},e.signal.addEventListener("abort",(()=>{s.abort(),n(it());})),s.send(t.body);}))}(t,r)};function ht(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return !0;const e=new URL(t),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function pt(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function ft(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class dt{constructor(t,e={}){L(this,e),this.type=t;}}class yt extends dt{constructor(t,e={}){super("error",L({error:t},e));}}class mt{on(t,e){return this._listeners=this._listeners||{},pt(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e);}}}off(t,e){return ft(t,e,this._listeners),ft(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},pt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new dt(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)ft(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(L(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t));}else t instanceof yt&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var gt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const xt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function vt(t,e){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return xt.forEach((t=>{t in e&&(r[t]=e[t]);})),r}function bt(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Yt=[Et,Tt,Ft,$t,Lt,Ot,Nt,Dt,Xt(jt),Ut,Gt,qt,Zt,Kt];function Jt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Jt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Yt)if(!Jt(t,e))return null}return `Expected ${Ht(t)} but found ${Ht(e)} instead.`}function Wt(t,e){return e.some((e=>e.kind===t.kind))}function Qt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function te(t,e){return "array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const ee=.96422,re=.82521,ne=4/29,ie=6/29,se=3*ie*ie,ae=ie*ie*ie,oe=Math.PI/180,le=180/Math.PI;function ue(t){return (t%=360)<0&&(t+=360),t}function ce([t,e,r,n]){let i,s;const a=pe((.2225045*(t=he(t))+.7168786*(e=he(e))+.0606169*(r=he(r)))/1);t===e&&e===r?i=s=a:(i=pe((.4360747*t+.3850649*e+.1430804*r)/ee),s=pe((.0139322*t+.0971045*e+.7141733*r)/re));const o=116*a-16;return [o<0?0:o,500*(i-a),200*(a-s),n]}function he(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pe(t){return t>ae?Math.pow(t,1/3):t/se+ne}function fe([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,a=isNaN(r)?i:i-r/200;return i=1*ye(i),s=ee*ye(s),a=re*ye(a),[de(3.1338561*s-1.6168667*i-.4906146*a),de(-.9787684*s+1.9161415*i+.033454*a),de(.0719453*s-.2289914*i+1.4052427*a),n]}function de(t){return (t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ye(t){return t>ie?t*t*t:se*(t-ne)}const me=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function ge(t,e){return me(t,e)?t[e]:void 0}function xe(t){return parseInt(t.padEnd(2,t),16)/255}function ve(t,e){return be(e?t/100:t,0,1)}function be(t,e,r){return Math.min(Math.max(e,t),r)}function we(t){return !t.some(Number.isNaN)}const _e={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Ae(t,e,r){return t+r*(e-t)}function Se(t,e,r){return t.map(((t,n)=>Ae(t,e[n],r)))}class ke{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]));}static parse(t){if(t instanceof ke)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return [0,0,0,0];const e=ge(_e,t);if(e){const[t,r,n]=e;return [t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return [xe(t.slice(r,r+=e)),xe(t.slice(r,r+=e)),xe(t.slice(r,r+=e)),xe(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,a,o,l,u,c,h,p]=e,f=[i||" ",o||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,a,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[be(+r/e,0,1),be(+s/e,0,1),be(+l/e,0,1),h?ve(+h,p):1];if(we(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,a,o,l,u]=r,c=[n||" ",s||" ",o].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,be(+i,0,100),be(+a,0,100),l?ve(+l,u):1];if(we(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=ue(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new ke(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=ce(t),s=Math.sqrt(r*r+n*n);return [Math.round(1e4*s)?ue(Math.atan2(n,r)*le):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ce(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return `rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}static interpolate(t,e,r,n="rgb"){switch(n){case "rgb":{const[n,i,s,a]=Se(t.rgb,e.rgb,r);return new ke(n,i,s,a,!1)}case "hcl":{const[n,i,s,a]=t.hcl,[o,l,u,c]=e.hcl;let h,p;if(isNaN(n)||isNaN(o))isNaN(n)?isNaN(o)?h=NaN:(h=o,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else {let t=o-n;o>n&&t>180?t-=360:o180&&(t+=360),h=n+r*t;}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*oe,fe([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:Ae(i,l,r),Ae(s,u,r),Ae(a,c,r)]);return new ke(f,d,y,m,!1)}case "lab":{const[n,i,s,a]=fe(Se(t.lab,e.lab,r));return new ke(n,i,s,a,!1)}}}}ke.black=new ke(0,0,0,1),ke.white=new ke(1,1,1,1),ke.transparent=new ke(0,0,0,0),ke.red=new ke(1,0,0,1);class Me{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Ie=["bottom","center","top"];class ze{constructor(t,e,r,n,i,s){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i,this.verticalAlign=s;}}class Pe{constructor(t){this.sections=t;}static fromString(t){return new Pe([new ze(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Pe?t:Pe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Ce{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Ce)return t;if("number"==typeof t)return new Ce([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]];}return new Ce(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new Ce(Se(t.values,e.values,r))}}class Be{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Be)return t;if("number"==typeof t)return new Be([t]);if(Array.isArray(t)){for(const e of t)if("number"!=typeof e)return;return new Be(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r){return new Be(Se(t.values,e.values,r))}}class Ve{constructor(t){this.values=t.slice();}static parse(t){if(t instanceof Ve)return t;if("string"==typeof t){const e=ke.parse(t);if(!e)return;return new Ve([e])}if(!Array.isArray(t))return;const e=[];for(const r of t){if("string"!=typeof r)return;const t=ke.parse(r);if(!t)return;e.push(t);}return new Ve(e)}toString(){return JSON.stringify(this.values)}static interpolate(t,e,r,n="rgb"){const i=[];if(t.values.length!=e.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${e.values.length}), cannot interpolate.`);for(let s=0;s=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function De(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Le||t instanceof ke||t instanceof Me||t instanceof Pe||t instanceof Ce||t instanceof Be||t instanceof Ve||t instanceof Fe||t instanceof $e)return !0;if(Array.isArray(t)){for(const e of t)if(!De(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!De(t[e]))return !1;return !0}return !1}function je(t){if(null===t)return Et;if("string"==typeof t)return Ft;if("boolean"==typeof t)return $t;if("number"==typeof t)return Tt;if(t instanceof ke)return Lt;if(t instanceof Le)return Ot;if(t instanceof Me)return Rt;if(t instanceof Pe)return Nt;if(t instanceof Ce)return Ut;if(t instanceof Be)return Gt;if(t instanceof Ve)return qt;if(t instanceof Fe)return Kt;if(t instanceof $e)return Zt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=je(e);if(r){if(r===t)continue;r=jt;break}r=t;}return Xt(r||jt,e)}return Dt}function Re(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ke||t instanceof Le||t instanceof Pe||t instanceof Ce||t instanceof Be||t instanceof Ve||t instanceof Fe||t instanceof $e?t.toString():JSON.stringify(t)}class Ne{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!De(t[1]))return e.error("invalid value");const r=t[1];let n=je(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Ne(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}}const Ue={string:Ft,number:Tt,boolean:$t,object:Dt};class qe{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in Ue)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=Ue[r],n++;}else i=jt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++;}r=Xt(i,s);}else {if(!Ue[i])throw new Error(`Types doesn't contain name = ${i}`);r=Ue[i];}const s=[];for(;nt.outputDefined()))}}const Ge={"to-boolean":$t,"to-color":Lt,"to-number":Tt,"to-string":Ft};class Ze{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!Ge[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=Ge[r],i=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Oe(e[0],e[1],e[2],e[3]),!r))return new ke(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ee(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=Ce.parse(e);if(n)return n}throw new Ee(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "numberArray":{let e;for(const r of this.args){e=r.evaluate(t);const n=Be.parse(e);if(n)return n}throw new Ee(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "colorArray":{let e;for(const r of this.args){e=r.evaluate(t);const n=Ve.parse(e);if(n)return n}throw new Ee(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=Fe.parse(e);if(n)return n}throw new Ee(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case "number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new Ee(`Could not convert ${JSON.stringify(e)} to number.`)}case "formatted":return Pe.fromString(Re(this.args[0].evaluate(t)));case "resolvedImage":return $e.fromString(Re(this.args[0].evaluate(t)));case "projectionDefinition":return this.args[0].evaluate(t);default:return Re(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ke=["Unknown","Point","LineString","Polygon"];class Xe{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null;}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ke[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=ke.parse(t),this._parseColorCache.set(t,e)),e}}class He{constructor(t,e,r=[],n,i=new Vt,s=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e;}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return "assert"===r?new qe(e,[t]):"coerce"===r?new Ze(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(i.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(i.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(i.kind)||"colorArray"===t.kind&&["value","string","array"].includes(i.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(i.kind))n=r(n,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"assert");}if(!(n instanceof Ne)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Xe;try{n=new Ne(n.type,n.evaluate(t));}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new He(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Bt(r,t));}checkSubtype(t,e){const r=Jt(t,e);return r&&this.error(r),r}}class Ye{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new Ee(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new Ee(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}}class Qe{constructor(t,e){this.type=$t,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,jt);return r&&n?Wt(r.type,[$t,Ft,Tt,Et,jt])?new Qe(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return !1;if(!Qt(e,["boolean","string","number","null"]))throw new Ee(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(je(e))} instead.`);if(!Qt(r,["string","array"]))throw new Ee(`Expected second argument to be of type array or string, but found ${Ht(je(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}}class tr{constructor(t,e,r){this.type=Tt,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,jt);if(!r||!n)return null;if(!Wt(r.type,[$t,Ft,Tt,Et,jt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Tt);return i?new tr(r,n,i):null}return new tr(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Qt(e,["boolean","string","number","null"]))throw new Ee(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(je(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),Qt(r,["string"])){const t=r.indexOf(e,n);return -1===t?-1:[...r.slice(0,t)].length}if(Qt(r,["array"]))return r.indexOf(e,n);throw new Ee(`Expected second argument to be of type array or string, but found ${Ht(je(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}}class er{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,je(t)))return null}else r=je(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,jt);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new er(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (je(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class rr{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class nr{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,jt),n=e.parse(t[2],2,Tt);if(!r||!n)return null;if(!Wt(r.type,[Xt(jt),Ft,jt]))return e.error(`Expected first argument to be of type array or string, but found ${Ht(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Tt);return i?new nr(r.type,r,n,i):null}return new nr(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),Qt(e,["string"]))return [...e].slice(r,n).join("");if(Qt(e,["array"]))return e.slice(r,n);throw new Ee(`Expected first argument to be of type array or string, but found ${Ht(je(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}}function ir(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new Ee("Input is not a number.");a=o-1;}return 0}class sr{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,Tt);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new sr(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[ir(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function ar(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var or,lr,ur=function(){if(lr)return or;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return lr=1,or=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},or}(),cr=ar(ur);class hr{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=pr(e,t.base,r,n);else if("linear"===t.name)i=pr(e,1,r,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new cr(s[0],s[1],s[2],s[3]).solve(pr(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Tt),!i)return null;const a=[];let o=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||e.expectedType==qt?e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType):o=Lt;for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return te(o,Tt)||te(o,Ot)||te(o,Lt)||te(o,Ut)||te(o,Gt)||te(o,qt)||te(o,Kt)||te(o,Xt(Tt))?new hr(o,r,n,i,a):e.error(`Type ${Ht(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=ir(e,n),a=hr.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case "interpolate":switch(this.type.kind){case "number":return Ae(o,l,a);case "color":return ke.interpolate(o,l,a);case "padding":return Ce.interpolate(o,l,a);case "colorArray":return Ve.interpolate(o,l,a);case "numberArray":return Be.interpolate(o,l,a);case "variableAnchorOffsetCollection":return Fe.interpolate(o,l,a);case "array":return Se(o,l,a);case "projectionDefinition":return Le.interpolate(o,l,a)}case "interpolate-hcl":switch(this.type.kind){case "color":return ke.interpolate(o,l,a,"hcl");case "colorArray":return Ve.interpolate(o,l,a,"hcl")}case "interpolate-lab":switch(this.type.kind){case "color":return ke.interpolate(o,l,a,"lab");case "colorArray":return Ve.interpolate(o,l,a,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function pr(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}const fr={color:ke.interpolate,number:Ae,padding:Ce.interpolate,numberArray:Be.interpolate,colorArray:Ve.interpolate,variableAnchorOffsetCollection:Fe.interpolate,array:Se};class dr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}if(!r)throw new Error("No output type");const s=n&&i.some((t=>Jt(n,t.type)));return new dr(s?jt:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof $e&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function yr(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function mr(t,e,r,n){return 0===n.compare(e,r)}function gr(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=$t,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,jt);if(!s)return null;if(!yr(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${Ht(s.type)}'.`);let a=e.parse(t[2],2,jt);if(!a)return null;if(!yr(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${Ht(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Ht(s.type)}' and '${Ht(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new qe(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new qe(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Rt),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=je(s),r=je(a);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ee(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=je(s),r=je(a);if("string"!==t.kind||"string"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}}}const xr=gr("==",(function(t,e,r){return e===r}),mr),vr=gr("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !mr(0,e,r,n)})),br=gr("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),_r=gr("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),Ar=gr(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class Sr{constructor(t,e,r){this.type=Rt,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,$t);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,$t);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,Ft),!s)?null:new Sr(n,i,s)}evaluate(t){return new Me(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}}class kr{constructor(t,e,r,n,i){this.type=Ft,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Tt);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,Ft),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Ft),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Tt),!a))return null;let o=null;return n["max-fraction-digits"]&&(o=e.parse(n["max-fraction-digits"],1,Tt),!o)?null:new kr(r,i,s,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}}class Mr{constructor(t){this.type=Nt,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Tt),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,Xt(Ft)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,Lt),!a))return null;let o=null;if(s["vertical-align"]){if("string"==typeof s["vertical-align"]&&!Ie.includes(s["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(o=e.parse(s["vertical-align"],1,Ft),!o)return null}const l=n[n.length-1];l.scale=t,l.font=r,l.textColor=a,l.verticalAlign=o;}else {const s=e.parse(t[r],1,jt);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null});}}return new Mr(n)}evaluate(t){return new Pe(this.sections.map((e=>{const r=e.content.evaluate(t);return je(r)===Zt?new ze("",r,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new ze(Re(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign);}outputDefined(){return !1}}class Ir{constructor(t){this.type=Zt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Ft);return r?new Ir(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=$e.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input);}outputDefined(){return !1}}class zr{constructor(t){this.type=Tt,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${Ht(r.type)} instead.`):new zr(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return [...e].length;if(Array.isArray(e))return e.length;throw new Ee(`Expected value to be of type string or array, but found ${Ht(je(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}}const Pr=8192;function Cr(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*Pr),Math.round(n*i*Pr)]}function Br(t,e){const r=Math.pow(2,e.z);return [(i=(t[0]/Pr+e.x)/r,360*i-180),(n=(t[1]/Pr+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i;}function Vr(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function Er(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Tr(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Fr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Rr(t,e,r,n)||!Rr(r,n,t,e));var i,s;}function $r(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(a=o[e+1])[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}var i,s,a;return n}function Or(t,e){for(const r of e)if(Lr(t,r))return !0;return !1}function Dr(t,e){for(const r of t)if(!Lr(r,e))return !1;for(let r=0;r0&&o<0||a<0&&o>0}function Nr(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Vr(e,t);}function Gr(t,e,r,n){const i=Math.pow(2,n.z)*Pr,s=[n.x*Pr,n.y*Pr],a=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];qr(n,e,r,i),a.push(n);}return a}function Zr(t,e,r,n){const i=Math.pow(2,n.z)*Pr,s=[n.x*Pr,n.y*Pr],a=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Vr(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)qr(n,e,r,i);}var o;return a}class Kr{constructor(t,e){this.type=$t,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(De(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n);}if(t.length)return new Kr(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Kr(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Kr(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Nr(e.coordinates,n,i),a=Gr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Lr(t,s))return !1}if("MultiPolygon"===e.type){const s=Ur(e.coordinates,n,i),a=Gr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Or(t,s))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Nr(e.coordinates,n,i),a=Zr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!Dr(t,s))return !1}if("MultiPolygon"===e.type){const s=Ur(e.coordinates,n,i),a=Zr(t.geometry(),r,n,i);if(!Er(r,n))return !1;for(const t of a)if(!jr(t,s))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}}let Xr=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}};function Hr(t,e,r=0,n=t.length-1,i=Jr){for(;n>r;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Hr(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(Yr(t,r,e),i(t[n],s)>0&&Yr(t,r,n);a0;)o--;}0===i(t[r],s)?Yr(t,r,o):(o++,Yr(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function Yr(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Jr(t,e){return te?1:0}function Wr(t,e){if(t.length<=1)return [t];const r=[];let n,i;for(const e of t){const t=tn(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e));}if(n&&r.push(n),e>1)for(let t=0;t1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function an(t,e){return e[0]-t[0]}function on(t){return t[1]-t[0]+1}function ln(t,e){return t[1]>=t[0]&&t[1]t[1])return [null,null];const r=on(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return [t,null];const n=Math.floor(r/2)-1;return [[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function cn(t,e){if(!ln(e,t.length))return [1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)Vr(r,t[n]);return r}function hn(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)Vr(e,t);return e}function pn(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function fn(t,e,r){if(!pn(t)||!pn(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Er(i,s)){if(bn(t,e))return 0}else if(bn(e,t))return 0;let a=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=a.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(on(l)<=u){if(!ln(l,t.length))return NaN;if(e){const e=vn(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e);}else for(let e=l[0];e<=l[1];++e){const i=xn(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else {const r=un(l,e);_n(a,s,n,t,o,r[0]),_n(a,s,n,t,o,r[1]);}}return s}function kn(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new Xr([[0,[0,t.length-1],[0,r.length-1]]],an);for(;o.length>0;){const s=o.pop();if(s[0]>=a)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(on(l)<=c&&on(u)<=h){if(!ln(l,t.length)&&ln(u,r.length))return NaN;let s;if(e&&n)s=mn(t,l,r,u,i),a=Math.min(a,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=dn(r[t],e,i),a=Math.min(a,s),0===a)return a}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=dn(t[r],e,i),a=Math.min(a,s),0===a)return a}else s=gn(t,l,r,u,i),a=Math.min(a,s);}else {const s=un(l,e),c=un(u,n);An(o,a,i,t,r,s[0],c[0]),An(o,a,i,t,r,s[0],c[1]),An(o,a,i,t,r,s[1],c[0]),An(o,a,i,t,r,s[1],c[1]);}}return a}function Mn(t){return "MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class In{constructor(t,e){this.type=Tt,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(De(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new In(e,e.features.map((t=>Mn(t.geometry))).flat());if("Feature"===e.type)return new In(e,Mn(e.geometry));if("type"in e&&"coordinates"in e)return new In(e,Mn(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>Br([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new sn(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,kn(n,!1,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,kn(n,!1,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,Sn(n,!1,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>Br([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new sn(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case "Point":s=Math.min(s,kn(n,!0,[t.coordinates],!1,i,s));break;case "LineString":s=Math.min(s,kn(n,!0,t.coordinates,!0,i,s));break;case "Polygon":s=Math.min(s,Sn(n,!0,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Wr(r,0).map((e=>e.map((e=>e.map((e=>Br([e.x,e.y],t.canonical))))))),i=new sn(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case "Point":s=Math.min(s,Sn([t.coordinates],!1,e,i,s));break;case "LineString":s=Math.min(s,Sn(t.coordinates,!0,e,i,s));break;case "Polygon":s=Math.min(s,wn(e,t.coordinates,i,s));}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return !0}}class zn{constructor(t){this.type=jt,this.key=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=t[1];return null==r?e.error("Global state property must be defined."):"string"!=typeof r?e.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new zn(r)}evaluate(t){var e;const r=null===(e=t.globals)||void 0===e?void 0:e.globalState;return r&&0!==Object.keys(r).length?ge(r,this.key):null}eachChild(){}outputDefined(){return !1}}const Pn={"==":xr,"!=":vr,">":wr,"<":br,">=":Ar,"<=":_r,array:qe,at:We,boolean:qe,case:rr,coalesce:dr,collator:Sr,format:Mr,image:Ir,in:Qe,"index-of":tr,interpolate:hr,"interpolate-hcl":hr,"interpolate-lab":hr,length:zr,let:Ye,literal:Ne,match:er,number:qe,"number-format":kr,object:qe,slice:nr,step:sr,string:qe,"to-boolean":Ze,"to-color":Ze,"to-number":Ze,"to-string":Ze,var:Je,within:Kr,distance:In,"global-state":zn};class Cn{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n;}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}static parse(t,e){const r=t[0],n=Cn.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[n,s]of a){o=new He(e.registry,Fn,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(Ht).join(", ")})`:`(${Ht(e.type)}...)`;var e;})).join(" | "),n=[];for(let r=1;r{r=e?r&&Fn(t):r&&t instanceof Ne;})),!!r&&$n(t)&&On(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function $n(t){if(t instanceof Cn){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Kr)return !1;if(t instanceof In)return !1;let e=!0;return t.eachChild((t=>{e&&!$n(t)&&(e=!1);})),e}function Ln(t){if(t instanceof Cn&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!Ln(t)&&(e=!1);})),e}function On(t,e){if(t instanceof Cn&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!On(t,e)&&(r=!1);})),r}function Dn(t){return {result:"success",value:t}}function jn(t){return {result:"error",value:t}}function Rn(t){return "data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Nn(t){return !!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Un(t){return !!t.expression&&t.expression.interpolated}function qn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Gn(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)&&je(t)===Dt}function Zn(t){return t}function Kn(t,e){const r=t.stops&&"object"==typeof t.stops[0][0],n=r||!(r||void 0!==t.property),i=t.type||(Un(e)?"exponential":"interval"),s=function(t){switch(t.type){case "color":return ke.parse;case "padding":return Ce.parse;case "numberArray":return Be.parse;case "colorArray":return Ve.parse;default:return null}}(e);if(s&&((t=Ct({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],s(t[1])]))),t.default=s(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;const o=function(t){switch(t){case "exponential":return Jn;case "interval":return Yn;case "categorical":return Hn;case "identity":return Wn;default:throw new Error(`Unknown function type "${t}"`)}}(i);let l,u;if("categorical"===i){l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0];}if(r){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Jn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(n){const r="exponential"===i?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:hr.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>o(t,e,r,l,u)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Xn(t.default,e.default):o(t,e,i,l,u)}}}function Xn(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Hn(t,e,r,n,i){return Xn(typeof r===i?n[r]:void 0,t.default,e.default)}function Yn(t,e,r){if("number"!==qn(r))return Xn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=ir(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Jn(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==qn(r))return Xn(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=ir(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1],u=fr[e.type]||Zn;return "function"==typeof o.evaluate?{evaluate(...e){const r=o.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,a,t.colorSpace)}}:u(o,l,a,t.colorSpace)}function Wn(t,e,r){switch(e.type){case "color":r=ke.parse(r);break;case "formatted":r=Pe.fromString(r.toString());break;case "resolvedImage":r=$e.fromString(r.toString());break;case "padding":r=Ce.parse(r);break;case "colorArray":r=Ve.parse(r);break;case "numberArray":r=Be.parse(r);break;default:qn(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0);}return Xn(r,t.default,e.default)}Cn.register(Pn,{error:[{kind:"error"},[Ft],(t,[e])=>{throw new Ee(e.evaluate(t))}],typeof:[Ft,[jt],(t,[e])=>Ht(je(e.evaluate(t)))],"to-rgba":[Xt(Tt,4),[Lt],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return [255*r,255*n,255*i,s]}],rgb:[Lt,[Tt,Tt,Tt],Bn],rgba:[Lt,[Tt,Tt,Tt,Tt],Bn],has:{type:$t,overloads:[[[Ft],(t,[e])=>Vn(e.evaluate(t),t.properties())],[[Ft,Dt],(t,[e,r])=>Vn(e.evaluate(t),r.evaluate(t))]]},get:{type:jt,overloads:[[[Ft],(t,[e])=>En(e.evaluate(t),t.properties())],[[Ft,Dt],(t,[e,r])=>En(e.evaluate(t),r.evaluate(t))]]},"feature-state":[jt,[Ft],(t,[e])=>En(e.evaluate(t),t.featureState||{})],properties:[Dt,[],t=>t.properties()],"geometry-type":[Ft,[],t=>t.geometryType()],id:[jt,[],t=>t.id()],zoom:[Tt,[],t=>t.globals.zoom],"heatmap-density":[Tt,[],t=>t.globals.heatmapDensity||0],"line-progress":[Tt,[],t=>t.globals.lineProgress||0],accumulated:[jt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Tt,Tn(Tt),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[Tt,Tn(Tt),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:Tt,overloads:[[[Tt,Tt],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Tt],(t,[e])=>-e.evaluate(t)]]},"/":[Tt,[Tt,Tt],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Tt,[Tt,Tt],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Tt,[],()=>Math.LN2],pi:[Tt,[],()=>Math.PI],e:[Tt,[],()=>Math.E],"^":[Tt,[Tt,Tt],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Tt,[Tt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Tt,[Tt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Tt,[Tt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Tt,[Tt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Tt,[Tt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Tt,[Tt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Tt,[Tt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Tt,[Tt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Tt,Tn(Tt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Tt,Tn(Tt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Tt,[Tt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Tt,[Tt],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Tt,[Tt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Tt,[Tt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[$t,[Ft,jt],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[$t,[jt],(t,[e])=>t.id()===e.value],"filter-type-==":[$t,[Ft],(t,[e])=>t.geometryType()===e.value],"filter-<":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[$t,[Ft,jt],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[$t,[jt],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[$t,[jt],(t,[e])=>e.value in t.properties()],"filter-has-id":[$t,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[$t,[Xt(Ft)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[$t,[Xt(jt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[$t,[Ft,Xt(jt)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[$t,[Ft,Xt(jt)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:$t,overloads:[[[$t,$t],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Tn($t),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:$t,overloads:[[[$t,$t],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Tn($t),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[$t,[$t],(t,[e])=>!e.evaluate(t)],"is-supported-script":[$t,[Ft],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Ft,[Ft],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Ft,[Ft],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Ft,Tn(jt),(t,e)=>e.map((e=>Re(e.evaluate(t)))).join("")],"resolved-locale":[Ft,[Rt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Qn{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Xe,this._defaultValue=e?function(t){if("color"===t.type&&Gn(t.default))return new ke(0,0,0,0);switch(t.type){case "color":return ke.parse(t.default)||null;case "padding":return Ce.parse(t.default)||null;case "numberArray":return Be.parse(t.default)||null;case "colorArray":return Ve.parse(t.default)||null;case "variableAnchorOffsetCollection":return Fe.parse(t.default)||null;case "projectionDefinition":return Le.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ee(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ti(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Pn}function ei(t,e){const r=new He(Pn,Fn,[],e?function(t){const e={color:Lt,string:Ft,number:Tt,enum:Ft,boolean:$t,formatted:Nt,padding:Ut,numberArray:Gt,colorArray:qt,projectionDefinition:Ot,resolvedImage:Zt,variableAnchorOffsetCollection:Kt};return "array"===t.type?Xt(e[t.value]||jt,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Dn(new Qn(n,e)):jn(r.errors)}class ri{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Ln(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class ni{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Ln(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?hr.interpolationFactor(this.interpolationType,t,e,r):0}}function ii(t,e){const r=ei(t,e);if("error"===r.result)return r;const n=r.value.expression,i=$n(n);if(!i&&!Rn(e))return jn([new Bt("","data expressions not supported")]);const s=On(n,["zoom"]);if(!s&&!Nn(e))return jn([new Bt("","zoom expressions not supported")]);const a=ai(n);return a||s?a instanceof Bt?jn([a]):a instanceof hr&&!Un(e)?jn([new Bt("",'"interpolate" expressions cannot be used with this property')]):Dn(a?new ni(i?"camera":"composite",r.value,a.labels,a instanceof hr?a.interpolation:void 0):new ri(i?"constant":"source",r.value)):jn([new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class si{constructor(t,e){this._parameters=t,this._specification=e,Ct(this,Kn(this._parameters,this._specification));}static deserialize(t){return new si(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function ai(t){let e=null;if(t instanceof Ye)e=ai(t.result);else if(t instanceof dr){for(const r of t.args)if(e=ai(r),e)break}else (t instanceof sr||t instanceof hr)&&t.input instanceof Cn&&"zoom"===t.input.name&&(e=t);return e instanceof Bt||t.eachChild((t=>{const r=ai(t);r instanceof Bt?e=r:!e&&r?e=new Bt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new Bt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}function oi(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case "has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case "in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case "any":case "all":for(const e of t.slice(1))if(!oi(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}const li={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ui(t){if(null==t)return {filter:()=>!0,needGeometry:!1};oi(t)||(t=pi(t));const e=ei(t,li);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return {filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:hi(t)}}function ci(t,e){return te?1:0}function hi(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e"===e||"<="===e||">="===e?fi(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(pi))):"all"===e?["all"].concat(t.slice(1).map(pi)):"none"===e?["all"].concat(t.slice(1).map(pi).map(mi)):"in"===e?di(t[1],t.slice(2)):"!in"===e?mi(di(t[1],t.slice(2))):"has"===e?yi(t[1]):"!has"!==e||mi(yi(t[1]));var r;}function fi(t,e,r){switch(t){case "$type":return [`filter-type-${r}`,e];case "$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function di(t,e){if(0===e.length)return !1;switch(t){case "$type":return ["filter-type-in",["literal",e]];case "$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ci)]]:["filter-in-small",t,["literal",e]]}}function yi(t){switch(t){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",t]}}function mi(t){return ["!",t]}function gi(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${gi(r)},`;return `${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new Pt(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function ki(t){const e=t.valueSpec,r=bi(t.value.type);let n,i,s,a={};const o="categorical"!==r&&void 0===t.value.property,l=!o,u="array"===qn(t.value.stops)&&"array"===qn(t.value.stops[0])&&"object"===qn(t.value.stops[0][0]),c=_i({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new Pt(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(Ai({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===qn(n)&&0===n.length&&e.push(new Pt(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return "identity"===r&&o&&c.push(new Pt(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new Pt(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!Un(t.valueSpec)&&c.push(new Pt(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Rn(t.valueSpec)?c.push(new Pt(t.key,t.value,"property functions not supported")):o&&!Nn(t.valueSpec)&&c.push(new Pt(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new Pt(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,o=t.key;if("array"!==qn(n))return [new Pt(o,n,`array expected, ${qn(n)} found`)];if(2!==n.length)return [new Pt(o,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==qn(n[0]))return [new Pt(o,n,`object expected, ${qn(n[0])} found`)];if(void 0===n[0].zoom)return [new Pt(o,n,"object stop key must have zoom")];if(void 0===n[0].value)return [new Pt(o,n,"object stop key must have value")];if(s&&s>bi(n[0].zoom))return [new Pt(o,n[0].zoom,"stop zoom values must appear in ascending order")];bi(n[0].zoom)!==s&&(s=bi(n[0].zoom),i=void 0,a={}),r=r.concat(_i({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Si,value:p}}));}else r=r.concat(p({key:`${o}[0]`,value:n[0],validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return ti(wi(n[1]))?r.concat([new Pt(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${o}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const o=qn(t.value),l=bi(t.value),u=null!==t.value?t.value:s;if(n){if(o!==n)return [new Pt(t.key,u,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return [new Pt(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let n=`number expected, ${o} found`;return Rn(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Pt(t.key,u,n)]}return "categorical"!==r||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&void 0!==i&&lnew Pt(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return [new Pt(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Ln(r))return [new Pt(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Ln(r))return [new Pt(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!On(r,["zoom","feature-state"]))return [new Pt(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!$n(r))return [new Pt(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function Ii(t){const e=t.key,r=t.value,n=qn(r);return "string"!==n?[new Pt(e,r,`color expected, ${n} found`)]:ke.parse(String(r))?[]:[new Pt(e,r,`color expected, "${r}" found`)]}function zi(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(bi(r))&&i.push(new Pt(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(bi(r))&&i.push(new Pt(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function Pi(t){return oi(wi(t.value))?Mi(Ct({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ci(t)}function Ci(t){const e=t.value,r=t.key;if("array"!==qn(e))return [new Pt(r,e,`array expected, ${qn(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return [new Pt(r,e,"filter array must have at least 1 element")];switch(s=s.concat(zi({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),bi(e[0])){case "<":case "<=":case ">":case ">=":e.length>=2&&"$type"===bi(e[1])&&s.push(new Pt(r,e,`"$type" cannot be use with operator "${e[0]}"`));case "==":case "!=":3!==e.length&&s.push(new Pt(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case "in":case "!in":e.length>=2&&(i=qn(e[1]),"string"!==i&&s.push(new Pt(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let a=2;a{t in r&&e.push(new Pt(n,r[t],`"${t}" is prohibited for ref layers`));})),i.layers.forEach((e=>{bi(e.id)===o&&(t=e);})),t?t.ref?e.push(new Pt(n,r.ref,"ref cannot reference another ref layer")):a=bi(t.type):e.push(new Pt(n,r.ref,`ref layer "${o}" not found`));}else if("background"!==a)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&bi(t.type);t?"vector"===s&&"raster"===a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==a?e.push(new Pt(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?e.push(new Pt(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new Pt(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Pt(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Pt(n,r.source,`source "${r.source}" not found`));}else e.push(new Pt(n,r,'missing required property "source"'));return e=e.concat(_i({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:Pi,layout:t=>_i({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Ei(Ct({layerType:a},t))}}),paint:t=>_i({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Vi(Ct({layerType:a},t))}})}})),e}function Fi(t){const e=t.value,r=t.key,n=qn(e);return "string"!==n?[new Pt(r,e,`string expected, ${n} found`)]:[]}const $i={promoteId:function({key:t,value:e}){if("string"===qn(e))return Fi({key:t,value:e});{const r=[];for(const n in e)r.push(...Fi({key:`${t}.${n}`,value:e[n]}));return r}}};function Li(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return [new Pt(r,e,'"type" is required')];const a=bi(e.type);let o;switch(a){case "vector":case "raster":return o=_i({key:r,value:e,valueSpec:n[`source_${a.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:$i,validateSpec:s}),o;case "raster-dem":return o=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,a=t.style;let o=[];const l=qn(n);if(void 0===n)return o;if("object"!==l)return o.push(new Pt("source_raster_dem",n,`object expected, ${l} found`)),o;const u="custom"===bi(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?o.push(new Pt(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?o=o.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:a,styleSpec:i})):o.push(new Pt(e,n[e],`unknown property "${e}"`));return o}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),o;case "geojson":if(o=_i({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:$i}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],s="string"==typeof n?[n,["accumulated"],["get",t]]:n;o.push(...Mi({key:`${r}.${t}.map`,value:i,expressionContext:"cluster-map"})),o.push(...Mi({key:`${r}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}));}return o;case "video":return _i({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case "image":return _i({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case "canvas":return [new Pt(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return zi({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Oi(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const a=qn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Pt("light",e,`object expected, ${a} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&n[o[1]]&&n[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Pt(a,e[a],`unknown property "${a}"`)]);}return s}function Di(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=qn(e);if(void 0===e)return [];if("object"!==s)return [new Pt("sky",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Pt(s,e[s],`unknown property "${s}"`)]);return a}function ji(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const a=qn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new Pt("terrain",e,`object expected, ${a} found`)]),s;for(const a in e)s=s.concat(n[a]?t.validateSpec({key:a,value:e[a],valueSpec:n[a],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new Pt(a,e[a],`unknown property "${a}"`)]);return s}function Ri(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const a in r)r[a].id&&i.includes(r[a].id)&&e.push(new Pt(n,r,`all the sprites' ids must be unique, but ${r[a].id} is duplicated`)),i.push(r[a].id),r[a].url&&s.includes(r[a].url)&&e.push(new Pt(n,r,`all the sprites' URLs must be unique, but ${r[a].url} is duplicated`)),s.push(r[a].url),e=e.concat(_i({key:`${n}[${a}]`,value:r[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Fi({key:n,value:r})}function Ni(t){return e=t.value,Boolean(e)&&e.constructor===Object?[]:[new Pt(t.key,t.value,`object expected, ${qn(t.value)} found`)];var e;}const Ui={"*":()=>[],array:Ai,boolean:function(t){const e=t.value,r=t.key,n=qn(e);return "boolean"!==n?[new Pt(r,e,`boolean expected, ${n} found`)]:[]},number:Si,color:Ii,constants:vi,enum:zi,filter:Pi,function:ki,layer:Ti,object:_i,source:Li,light:Oi,sky:Di,terrain:ji,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=qn(e);if(void 0===e)return [];if("object"!==s)return [new Pt("projection",e,`object expected, ${s} found`)];let a=[];for(const s in e)a=a.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new Pt(s,e[s],`unknown property "${s}"`)]);return a},projectionDefinition:function(t){const e=t.key;let r=t.value;r=r instanceof String?r.valueOf():r;const n=qn(r);return "array"!==n||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(r)||function(t){return !!["interpolate","step","literal"].includes(t[0])}(r)?["array","string"].includes(n)?[]:[new Pt(e,r,`projection expected, invalid type "${n}" found`)]:[new Pt(e,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:Fi,formatted:function(t){return 0===Fi(t).length?[]:Mi(t)},resolvedImage:function(t){return 0===Fi(t).length?[]:Mi(t)},padding:function(t){const e=t.key,r=t.value;if("array"===qn(r)){if(r.length<1||r.length>4)return [new Pt(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(vi({key:"constants",value:t.constants}))),Xi(r)}function Ki(t){return function(e){return t({...e,validateSpec:qi})}}function Xi(t){return [].concat(t).sort(((t,e)=>t.line-e.line))}function Hi(t){return function(...e){return Xi(t.apply(this,e))}}Zi.source=Hi(Ki(Li)),Zi.sprite=Hi(Ki(Ri)),Zi.glyphs=Hi(Ki(Gi)),Zi.light=Hi(Ki(Oi)),Zi.sky=Hi(Ki(Di)),Zi.terrain=Hi(Ki(ji)),Zi.state=Hi(Ki(Ni)),Zi.layer=Hi(Ki(Ti)),Zi.filter=Hi(Ki(Pi)),Zi.paintProperty=Hi(Ki(Vi)),Zi.layoutProperty=Hi(Ki(Ei));const Yi=Zi,Ji=Yi.light,Wi=Yi.sky,Qi=Yi.paintProperty,ts=Yi.layoutProperty;function es(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new yt(new Error(n.message))),r=!0;return r}class rs{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(a[h]=!0,s.push(i[h])):a[h]=!1;}}}}_forEachCell(t,e,r,n,i,s,a,o){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,t,e,r,n,u,s,a,o))return}}_convertFromCellCoord(t){return (t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t=0)continue;const s=t[n];i[n]=ns[r].shallow.indexOf(n)>=0?s:ls(s,e);}t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(i.$name=r),i}function us(t){if(os(t))return t;if(Array.isArray(t))return t.map(us);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=as(t)||"Object";if(!ns[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=ns[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=ns[e].shallow.indexOf(r)>=0?i:us(i);}return n}class cs{constructor(){this.first=!0;}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Hangul Syllables":t=>t>=44032&&t<=55215,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function ps(t){for(const e of t)if(xs(e.charCodeAt(0)))return !0;return !1}function fs(t){for(const e of t)if(!ms(e.charCodeAt(0)))return !1;return !0}function ds(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const ys=ds(["Arab","Dupl","Mong","Ougr","Syrc"]);function ms(t){return !ys.test(String.fromCodePoint(t))}const gs=ds(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function xs(t){return !(746!==t&&747!==t&&(t<4352||!(hs["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||hs["CJK Compatibility"](t)||hs["CJK Strokes"](t)||!(!hs["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||hs["Enclosed CJK Letters and Months"](t)||hs["Ideographic Description Characters"](t)||hs.Kanbun(t)||hs.Katakana(t)&&12540!==t||!(!hs["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!hs["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||hs["Vertical Forms"](t)||hs["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||gs.test(String.fromCodePoint(t)))))}function vs(t){return !(xs(t)||function(t){return !!(hs["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||hs["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||hs["Letterlike Symbols"](t)||hs["Number Forms"](t)||hs["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||hs["Control Pictures"](t)&&9251!==t||hs["Optical Character Recognition"](t)||hs["Enclosed Alphanumerics"](t)||hs["Geometric Shapes"](t)||hs["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||hs["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||hs["CJK Symbols and Punctuation"](t)||hs.Katakana(t)||hs["Private Use Area"](t)||hs["CJK Compatibility Forms"](t)||hs["Small Form Variants"](t)||hs["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const bs=ds(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function ws(t){return bs.test(String.fromCodePoint(t))}function _s(t,e){return !(!e&&ws(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||hs.Khmer(t))}function As(t){for(const e of t)if(ws(e.charCodeAt(0)))return !0;return !1}const Ss=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{};}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL;}getState(){return {pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(Ss.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve();}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,r){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((t=>{this.loadScriptResolve=t;}));r(e);const i=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([n,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class ks{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new cs,this.transition={});}isSupportedScript(t){return function(t,e){for(const r of t)if(!_s(r.charCodeAt(0),e))return !1;return !0}(t,"loaded"===Ss.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class Ms{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Gn(t))return new si(t,e);if(ti(t)){const r=ii(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return "color"===e.type&&"string"==typeof t?r=ke.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"numberArray"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"colorArray"!==e.type||"string"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?r=Fe.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(r=Le.parse(t)):r=Ve.parse(t):r=Be.parse(t):r=Ce.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class Is{constructor(t){this.property=t,this.value=new Ms(t,void 0);}transitioned(t,e){return new Ps(this.property,this.value,e,L({},t.transition,this.transition),t.now)}untransitioned(){return new Ps(this.property,this.value,null,{},0)}}class zs{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues);}getValue(t){return R(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].value=new Ms(this._values[t].property,null===e?void 0:R(e));}getTransition(t){return R(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Is(this._values[t].property)),this._values[t].transition=R(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new Cs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new Cs(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Ps{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(nn.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Ls{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new ks(Math.floor(e.zoom-1),e)),t.expression.evaluate(new ks(Math.floor(e.zoom),e)),t.expression.evaluate(new ks(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Os{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class Ds{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new Ms(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new Is(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({});}}}is("DataDrivenProperty",Fs),is("DataConstantProperty",Ts),is("CrossFadedDataDrivenProperty",$s),is("CrossFadedProperty",Ls),is("ColorRampProperty",Os);const js="-transition";class Rs extends mt{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Bs(e.layout)),e.paint)){this._transitionablePaint=new zs(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Es(e.paint);}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(ts,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e);}getPaintProperty(t){return t.endsWith(js)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(Qi,`layers.${this.id}.paint.${t}`,t,e,r))return !1;if(t.endsWith(js))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),j(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return (!i||!1!==i.validate)&&es(this,t.call(Yi,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:gt,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Vs&&Rn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}}const Ns={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Us{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class qs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Gs(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=Ns[t.type].BYTES_PER_ELEMENT,s=r=Zs(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Zs(r,Math.max(n,e)),alignment:e}}function Zs(t,e){return Math.ceil(t/e)*e}class Ks extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Ks.prototype.bytesPerElement=4,is("StructArrayLayout2i4",Ks);class Xs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}Xs.prototype.bytesPerElement=6,is("StructArrayLayout3i6",Xs);class Hs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Hs.prototype.bytesPerElement=8,is("StructArrayLayout4i8",Hs);class Ys extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}Ys.prototype.bytesPerElement=12,is("StructArrayLayout2i4i12",Ys);class Js extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=a,t}}Js.prototype.bytesPerElement=8,is("StructArrayLayout2i4ub8",Js);class Ws extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Ws.prototype.bytesPerElement=8,is("StructArrayLayout2f8",Ws);class Qs extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,a,o,l,u)}emplace(t,e,r,n,i,s,a,o,l,u,c){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=a,this.uint16[h+6]=o,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}Qs.prototype.bytesPerElement=20,is("StructArrayLayout10ui20",Qs);class ta extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}ta.prototype.bytesPerElement=24,is("StructArrayLayout4i4ui4i24",ta);class ea extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}ea.prototype.bytesPerElement=12,is("StructArrayLayout3f12",ea);class ra extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ra.prototype.bytesPerElement=4,is("StructArrayLayout1ul4",ra);class na extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,a,o,l)}emplace(t,e,r,n,i,s,a,o,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=a,this.uint32[h+3]=o,this.uint16[c+8]=l,this.uint16[c+9]=u,t}}na.prototype.bytesPerElement=20,is("StructArrayLayout6i1ul2ui20",na);class ia extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}ia.prototype.bytesPerElement=12,is("StructArrayLayout2i2i2i12",ia);class sa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}sa.prototype.bytesPerElement=16,is("StructArrayLayout2f1f2i16",sa);class aa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=16*t,l=4*t,u=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=a,t}}aa.prototype.bytesPerElement=16,is("StructArrayLayout2ub2f2i16",aa);class oa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}oa.prototype.bytesPerElement=6,is("StructArrayLayout3ui6",oa);class la extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=a,this.uint32[v+4]=o,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,t}}la.prototype.bytesPerElement=48,is("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",la);class ua extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k,M,I,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=a,this.int16[P+6]=o,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=A,this.uint32[C+12]=S,this.float32[C+13]=k,this.float32[C+14]=M,this.uint16[P+30]=I,this.uint16[P+31]=z,t}}ua.prototype.bytesPerElement=64,is("StructArrayLayout8i15ui1ul2f2ui64",ua);class ca extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}ca.prototype.bytesPerElement=4,is("StructArrayLayout1f4",ca);class ha extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}ha.prototype.bytesPerElement=12,is("StructArrayLayout1ui2f12",ha);class pa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}pa.prototype.bytesPerElement=8,is("StructArrayLayout1ul2ui8",pa);class fa extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}fa.prototype.bytesPerElement=4,is("StructArrayLayout2ui4",fa);class da extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}da.prototype.bytesPerElement=2,is("StructArrayLayout1ui2",da);class ya extends qs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}ya.prototype.bytesPerElement=16,is("StructArrayLayout4f16",ya);class ma extends Us{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new l(this.anchorPointX,this.anchorPointY)}}ma.prototype.size=20;class ga extends na{get(t){return new ma(this,t)}}is("CollisionBoxArray",ga);class xa extends Us{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t;}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}xa.prototype.size=48;class va extends la{get(t){return new xa(this,t)}}is("PlacedSymbolArray",va);class ba extends Us{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t;}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}ba.prototype.size=64;class wa extends ua{get(t){return new ba(this,t)}}is("SymbolInstanceArray",wa);class _a extends ca{getoffsetX(t){return this.float32[1*t+0]}}is("GlyphOffsetArray",_a);class Aa extends Xs{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}is("SymbolLineVertexArray",Aa);class Sa extends Us{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Sa.prototype.size=12;class ka extends ha{get(t){return new Sa(this,t)}}is("TextAnchorOffsetArray",ka);class Ma extends Us{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}Ma.prototype.size=8;class Ia extends pa{get(t){return new Ma(this,t)}}is("FeatureIndexArray",Ia);class za extends Ks{}class Pa extends Ks{}class Ca extends Ks{}class Ba extends Ys{}class Va extends Js{}class Ea extends Ws{}class Ta extends Qs{}class Fa extends ta{}class $a extends ea{}class La extends ra{}class Oa extends ia{}class Da extends aa{}class ja extends oa{}class Ra extends fa{}const Na=Gs([{name:"a_pos",components:2,type:"Int16"}],4),{members:Ua}=Na;class qa{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t;}prepareSegment(t,e,r,n){const i=this.segments[this.segments.length-1];return t>qa.MAX_VERTEX_ARRAY_LENGTH&&U(`Max vertices per segment is ${qa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${qa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+t>qa.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n?this.createNewSegment(e,r,n):i}createNewSegment(t,e,r){const n={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==r&&(n.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(t,e,r){return this.prepareSegment(0,t,e,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0;}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new qa([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ga(t,e){return 256*(t=F(Math.floor(t),0,255))+F(Math.floor(e),0,255)}qa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,is("SegmentVector",qa);const Za=Gs([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Ka,Xa,Ha,Ya={exports:{}},Ja={exports:{}},Wa={exports:{}},Qa=function(){if(Ha)return Ya.exports;Ha=1;var t=(Ka||(Ka=1,Ja.exports=function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Ja.exports),e=(Xa||(Xa=1,Wa.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),Wa.exports);return Ya.exports=t,Ya.exports.murmur3=t,Ya.exports.murmur2=e,Ya.exports}(),to=r(Qa);class eo{constructor(){this.ids=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(ro(t)),this.positions.push(e,r,n);}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=ro(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1;}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return no(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new eo;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function ro(t){const e=+t;return !isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:to(String(t))}function no(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;io(t,s,a),io(e,3*s,3*a),io(e,3*s+1,3*a+1),io(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r;}setUniform(t,e,r){t.set(r.constantOr(this.value));}getBinding(t,e,r){return "color"===this.type?new lo(t,e):new ao(t,e)}}class po{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1;}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr;}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i);}getBinding(t,e,r){return "u_pattern"===r.substr(0,9)?new oo(t,e):new ao(t,e)}}class fo{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,a=this.expression.evaluate(new ks(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i);}_setPaintValue(t,e,r){if("color"===this.type){const n=co(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new ks(this.zoom),e,{},n,[],i),a=this.expression.evaluate(new ks(this.zoom+1),e,{},n,[],i),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,s,a);}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=co(r),s=co(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof fo||r instanceof yo)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new go(n,e,r);this.needsUpload=!1,this._featureMap=new eo,this._bufferOffset=0;}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}function vo(t,e){return {"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function bo(t,e,r){const n={color:{source:Ws,composite:ya},number:{source:ca,composite:Ws}},i=function(t){return {"line-pattern":{source:Ta,composite:Ta},"fill-pattern":{source:Ta,composite:Ta},"fill-extrusion-pattern":{source:Ta,composite:Ta}}[t]}(t);return i&&i[r]||n[e][r]}is("ConstantBinder",ho),is("CrossFadedConstantBinder",po),is("SourceExpressionBinder",fo),is("CrossFadedCompositeBinder",mo),is("CompositeExpressionBinder",yo),is("ProgramConfiguration",go,{omit:["_buffers"]}),is("ProgramConfigurationSet",xo);const wo=Math.pow(2,14)-1,_o=-wo-1;function Ao(t){const e=z/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&U("Geometry exceeds allowed extent, reduce your vector tile buffer size");}}return r}function So(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?Ao(t):[]}}const ko=-32768;function Mo(t,e,r,n,i){t.emplaceBack(ko+8*e+n,ko+8*r+i);}class Io{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Pa,this.indexArray=new ja,this.segments=new qa,this.programConfigurations=new xo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){const n=this.layers[0],i=[];let s=null,a=!1,o="heatmap"===n.type;if("circle"===n.type){const t=n;s=t.layout.get("circle-sort-key"),a=!s.isConstant(),o=o||"map"===t.paint.get("circle-pitch-alignment");}const l=o?e.subdivisionGranularity.circle:1;for(const{feature:e,id:n,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=So(e,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),u,r))continue;const c=a?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Ao(e),patterns:{},sortKey:c};i.push(h);}a&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n,o=t[s].feature;this.addFeature(n,i,s,r,l),e.featureIndex.insert(o,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ua),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(t,e,r,n,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const a=s.length;for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=z||n<0||n>=z)continue;const i=this.segments.prepareSegment(a*a,this.layoutVertexArray,this.indexArray,t.sortKey),o=i.vertexLength;for(let t=0;t1){if(Vo(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function $o(t,e){for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function Oo(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=q(t,e,r[0]);return s!==q(t,e,r[1])||s!==q(t,e,r[2])||s!==q(t,e,r[3])}function Do(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function jo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ro(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=l.convert(e)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let e=0;eZo(t,e,r,n)))}(l,i,a,o),p=c?u*s:u;for(const t of n)for(const e of t){const t=c?e:Zo(e,i,a,o);let r=p;const n=i.projectTileCoordinates(e.x,e.y,a,o).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n/i.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=i.cameraToCenterDistance/n),Po(h,t,r))return !0}return !1}}function Zo(t,e,r,n){const i=e.projectTileCoordinates(t.x,t.y,r,n).point;return new l((.5*i.x+.5)*e.width,(.5*-i.y+.5)*e.height)}class Ko extends Io{}let Xo;is("HeatmapBucket",Ko,{omit:["layers"]});var Ho={get paint(){return Xo=Xo||new Ds({"heatmap-radius":new Fs(gt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Fs(gt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ts(gt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Os(gt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ts(gt.paint_heatmap["heatmap-opacity"])})}};function Yo(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function Jo(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Yo({},{width:e,height:r},n);Wo(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data;}function Wo(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a);};if(t.clips)for(let e=0,i=0;e0)for(let i=e;i=e;i-=n)s=El(i/n|0,t[i],t[i+1],s);return s&&Il(s,s.next)&&(Tl(s),s=s.next),s}function pl(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Il(n,n.next)&&0!==Ml(n.prev,n,n.next))n=n.next;else {if(Tl(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function fl(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=wl(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?yl(t,n,i,s):dl(t))e.push(l.i,t.i,u.i),Tl(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?fl(t=ml(pl(t),e),e,r,n,i,s,2):2===a&&gl(t,e,r,n,i,s):fl(pl(t),e,r,n,i,s,1);break}}}function dl(t){const e=t.prev,r=t,n=t.next;if(Ml(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),p=Math.max(i,s,a),f=Math.max(o,l,u);let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&Sl(i,o,s,l,a,u,d.x,d.y)&&Ml(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function yl(t,e,r,n){const i=t.prev,s=t,a=t.next;if(Ml(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=Math.min(o,l,u),d=Math.min(c,h,p),y=Math.max(o,l,u),m=Math.max(c,h,p),g=wl(f,d,e,r,n),x=wl(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Sl(o,c,l,h,u,p,v.x,v.y)&&Ml(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Sl(o,c,l,h,u,p,b.x,b.y)&&Ml(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==a&&Sl(o,c,l,h,u,p,v.x,v.y)&&Ml(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==a&&Sl(o,c,l,h,u,p,b.x,b.y)&&Ml(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function ml(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Il(n,i)&&zl(n,r,r.next,i)&&Bl(n,i)&&Bl(i,n)&&(e.push(n.i,r.i,i.i),Tl(r),Tl(r.next),r=t=i),r=r.next;}while(r!==t);return pl(r)}function gl(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&kl(a,t)){let o=Vl(a,t);return a=pl(a,a.next),o=pl(o,o.next),fl(a,e,r,n,i,s,0),void fl(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function xl(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function vl(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;if(Il(t,r))return r;do{if(Il(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&Al(is.x||r.x===s.x&&bl(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=Vl(r,t);return pl(n,n.next),pl(r,r.next)}function bl(t,e){return Ml(t.prev,t,e.prev)<0&&Ml(e.next,t,t.next)<0}function wl(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function _l(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function Sl(t,e,r,n,i,s,a,o){return !(t===a&&e===o)&&Al(t,e,r,n,i,s,a,o)}function kl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&zl(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(Bl(t,e)&&Bl(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Ml(t.prev,t,e.prev)||Ml(t,e.prev,e))||Il(t,e)&&Ml(t.prev,t,t.next)>0&&Ml(e.prev,e,e.next)>0)}function Ml(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Il(t,e){return t.x===e.x&&t.y===e.y}function zl(t,e,r,n){const i=Cl(Ml(t,e,r)),s=Cl(Ml(t,e,n)),a=Cl(Ml(r,n,t)),o=Cl(Ml(r,n,e));return i!==s&&a!==o||!(0!==i||!Pl(t,r,e))||!(0!==s||!Pl(t,n,e))||!(0!==a||!Pl(r,t,n))||!(0!==o||!Pl(r,e,n))}function Pl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Cl(t){return t>0?1:t<0?-1:0}function Bl(t,e){return Ml(t.prev,t,t.next)<0?Ml(t,e,t.next)>=0&&Ml(t,t.prev,e)>=0:Ml(t,e,t.prev)<0||Ml(t,t.next,e)<0}function Vl(t,e){const r=Fl(t.i,t.x,t.y),n=Fl(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function El(t,e,r,n){const i=Fl(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Tl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Fl(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class $l{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e;}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const r=0|Math.round(t),n=0|Math.round(e),i=this._getKey(r,n);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(r,n),s}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const r=[];for(let n=0;n0?(r.push(i),r.push(a),r.push(s)):(r.push(i),r.push(s),r.push(a));}return r}(this._vertexBuffer,t);const e=[],r=t.length;for(let n=0;n=1||v<=0)||y&&(oi)){u>=n&&u<=i&&s.push(r[(t+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(a+p*x,o+f*x));const b=a+p*Math.max(x,0),w=a+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,a,o,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(a+p*v,o+f*v)),(y||u>=n&&u<=i)&&s.push(r[(t+1)%3]),!y&&(u<=n||u>=i)&&this._generateInterEdgeVertices(s,a,o,l,u,c,h,w,n,i);}return s}_generateIntraEdgeVertices(t,e,r,n,i,s,a){const o=n-e,l=i-r,u=0===l,c=u?Math.min(e,n):Math.min(s,a),h=u?Math.max(e,n):Math.max(s,a),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?e=p;n--){const i=n*this._granularityCellSize;t.push(this._vertexToIndex(i,r+l*(i-e)/o));}}_generateInterEdgeVertices(t,e,r,n,i,s,a,o,l,u){const c=i-r,h=s-n,p=a-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=n+h*y;let x=Math.floor(Math.min(g,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,o)/this._granularityCellSize)-1,b=o=1||m<=0){const t=r-a,n=s+(e-s)*Math.min((l-a)/t,(u-a)/t);x=Math.floor(Math.min(n,o)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,o)/this._granularityCellSize)-1,b=o0?u:l;if(b)for(let e=x;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,_));else for(let e=v;e>=x;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,_));}_generateOutline(t){const e=[];for(const r of t){const t=Nl(r,this._granularity,!0),n=this._pointArrayToIndices(t),i=[];for(let t=1;ti!=(s===Ol)?(t.push(e),t.push(r),t.push(this._vertexToIndex(n,s)),t.push(r),t.push(this._vertexToIndex(i,s)),t.push(this._vertexToIndex(n,s))):(t.push(r),t.push(e),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(i,s)),t.push(r),t.push(this._vertexToIndex(n,s)));}_fillPoles(t,e,r){const n=this._vertexBuffer,i=z,s=t.length;for(let a=2;a80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return fl(s,a,r,o,l,u,0),a}(r,n),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e);}catch(t){console.error(t);}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(t,e){const r=[];for(let n=0;n0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,e=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,r=Math.abs(x-t),n=Math.abs(v-e),i=Math.abs(x-c),s=Math.abs(v-h),u=p?r/m:Number.POSITIVE_INFINITY,b=f?n/g:Number.POSITIVE_INFINITY;if((i<=r||!p)&&(s<=n||!f))break;if(u=0?a-1:s-1,i=(o+1)%s,l=t[2*e[n]],u=t[2*e[i]],c=t[2*e[a]],h=t[2*e[a]+1],p=t[2*e[o]+1];let f=!1;if(lu)f=!1;else {const r=p-h,s=-(t[2*e[o]]-c),a=h((u-c)*r+(t[2*e[i]+1]-h)*s)*a&&(f=!0);}if(f){const t=e[n],i=e[a],l=e[o];t!==i&&t!==l&&i!==l&&r.push(l,i,t),a--,a<0&&(a=s-1);}else {const t=e[i],n=e[a],l=e[o];t!==n&&t!==l&&n!==l&&r.push(l,n,t),o++,o>=s&&(o=0);}if(n===i)break}}function ql(t,e,r,n,i,s,a,o,l){const u=i.length/2,c=a&&o&&l;if(uqa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,y=!0,m=!0,g=!0,c=0);const x=Gl(a,n,s,o,p,y,u),v=Gl(a,n,s,o,f,m,u),b=Gl(a,n,s,o,d,g,u);r.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++;}}(e,r,n,i,s,t),c&&function(t,e,r,n,i,s){const a=[];for(let t=0;tqa.MAX_VERTEX_ARRAY_LENGTH&&(u=t.createNewSegment(e,r),l=o.count,d=!0,y=!0,c=0);const m=Gl(a,n,s,o,i,d,u),g=Gl(a,n,s,o,h,y,u);r.emplaceBack(c+m-l,c+g-l),u.primitiveLength++;}}}(a,r,o,i,l,t),e.forceNewSegmentOnNextPrepare(),null==a||a.forceNewSegmentOnNextPrepare();}function Gl(t,e,r,n,i,s,a){if(s){const s=n.count;return r(e[2*i],e[2*i+1]),t[i]=n.count,n.count++,a.vertexLength++,s}return t[i]}class Zl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ca,this.indexArray=new ja,this.indexArray2=new Ra,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.segments2=new qa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=ul("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=So(a,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Ao(a),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=cl("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ll),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s){for(const t of Wr(e,500)){const e=Rl(t,n,s.fill.getGranularityForZoomLevel(n.z)),r=this.layoutVertexArray;ql(((t,e)=>{r.emplaceBack(t,e);}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}}let Kl,Xl;is("FillBucket",Zl,{omit:["layers","patternFeatures"]});var Hl={get paint(){return Xl=Xl||new Ds({"fill-antialias":new Ts(gt.paint_fill["fill-antialias"]),"fill-opacity":new Fs(gt.paint_fill["fill-opacity"]),"fill-color":new Fs(gt.paint_fill["fill-color"]),"fill-outline-color":new Fs(gt.paint_fill["fill-outline-color"]),"fill-translate":new Ts(gt.paint_fill["fill-translate"]),"fill-translate-anchor":new Ts(gt.paint_fill["fill-translate-anchor"]),"fill-pattern":new $s(gt.paint_fill["fill-pattern"])})},get layout(){return Kl=Kl||new Ds({"fill-sort-key":new Fs(gt.layout_fill["fill-sort-key"])})}};class Yl extends Rs{constructor(t){super(t,Hl);}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Zl(t)}queryRadius(){return jo(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:r,pixelsToTileUnits:n}){return Co(Ro(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,n),e)}isTileClipped(){return !0}}const Jl=Gs([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Wl=Gs([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Ql}=Jl;var tu,eu,ru,nu,iu,su,au,ou={};function lu(){if(eu)return tu;eu=1;var t=s();function e(t,e,n,i,s){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=s,t.readFields(r,this,e);}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){for(var r=t.readVarint()+t.pos;t.pos>3;}if(s--,1===i||2===i)a+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(a,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return [a,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var s,a,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return ru=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},ru}function cu(){return au||(au=1,ou.VectorTile=function(){if(su)return iu;su=1;var t=uu();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return iu=function(t,r){this.layers=t.readFields(e,{},r);},iu}(),ou.VectorTileFeature=lu(),ou.VectorTileLayer=uu()),ou}var hu=r(cu());const pu=hu.VectorTileFeature.types,fu=Math.pow(2,13);function du(t,e,r,n,i,s,a,o){t.emplaceBack(e,r,2*Math.floor(n*fu)+a,i*fu*2,s*fu*2,Math.round(o));}class yu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ba,this.centroidVertexArray=new za,this.indexArray=new ja,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.features=[],this.hasPattern=ul("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=So(n,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),o,r))continue;const l={id:i,sourceLayerIndex:a,index:s,geometry:t?o.geometry:Ao(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(cl("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{},e.subdivisionGranularity),e.featureIndex.insert(n,l.geometry,s,a,this.index,!0);}}addFeatures(t,e,r){for(const n of this.features){const{geometry:i}=n;this.addFeature(n,i,n.index,e,r,t.subdivisionGranularity);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ql),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Wl.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy());}addFeature(t,e,r,n,i,s){for(const r of Wr(e,500)){const e={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(e,n,t,r,s);const a=this.layoutVertexArray.length-i,o=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t{du(u,t,e,0,0,1,1,0);}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles);}_generateSideFaces(t,e){let r=0;for(let n=1;nqa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const a=i.sub(s)._perp()._unit(),o=s.dist(i);r+o>32768&&(r=0),du(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,0,r),du(this.layoutVertexArray,i.x,i.y,a.x,a.y,0,1,r),r+=o,du(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,0,r),du(this.layoutVertexArray,s.x,s.y,a.x,a.y,0,1,r);const l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2;}}}function mu(t,e){for(let r=0;rz)||t.y===e.y&&(t.y<0||t.y>z)}function xu(t){return t.every((t=>t.x<0))||t.every((t=>t.x>z))||t.every((t=>t.y<0))||t.every((t=>t.y>z))}let vu;is("FillExtrusionBucket",yu,{omit:["layers","features"]});var bu={get paint(){return vu=vu||new Ds({"fill-extrusion-opacity":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new $s(gt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Fs(gt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ts(gt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class wu extends Rs{constructor(t){super(t,bu);}createBucket(t){return new yu(t)}queryRadius(){return jo(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s,pixelPosMatrix:a}){const o=Ro(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-i.bearingInRadians,s),u=this.paint.get("fill-extrusion-height").evaluate(e,r),c=this.paint.get("fill-extrusion-base").evaluate(e,r),h=function(t,e,r){const n=[];for(const r of t){const t=[r.x,r.y,0,1];S(t,t,e),n.push(new l(t[0]/t[3],t[1]/t[3]));}return n}(o,a),p=function(t,e,r,n){const i=[],s=[],a=n[8]*e,o=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const i of e){const e=i.x,s=i.y,y=n[0]*e+n[4]*s+n[12],m=n[1]*e+n[5]*s+n[13],g=n[2]*e+n[6]*s+n[14],x=n[3]*e+n[7]*s+n[15],v=g+u,b=x+c,w=y+h,_=m+p,A=g+f,S=x+d,k=new l((y+a)/b,(m+o)/b);k.z=v/b,t.push(k);const M=new l(w/S,_/S);M.z=A/S,r.push(M);}i.push(t),s.push(r);}return [i,s]}(n,c,u,a);return function(t,e,r){let n=1/0;Co(r,e)&&(n=Au(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new Va,this.layoutVertexArray2=new Ea,this.indexArray=new ja,this.programConfigurations=new xo(t.layers,t.zoom),this.segments=new qa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r){this.hasPattern=ul("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=So(e,t);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Ao(e),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=cl("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r);}addFeatures(t,e,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,r,t.subdivisionGranularity);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Iu)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ku),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),l=a.get("line-cap"),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n);}addLine(t,e,r,n,i,s,a,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=Nl(t,a?o.line.getGranularityForZoomLevel(a.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c0;if(w&&e>c){const t=f.dist(d);if(t>2*h){const e=f.sub(f.sub(d)._mult(h/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,m,0,0,p),d=e;}}const A=d&&y;let S=A?r:l?"butt":n;if(A&&"round"===S&&(vi&&(S="bevel"),"bevel"===S&&(v>2&&(S="flipbevel"),v100)a=g.mult(-1);else {const t=v*m.add(g).mag()/m.sub(g).mag();a._perp()._mult(t*(_?-1:1));}this.addCurrentVertex(f,a,0,0,p),this.addCurrentVertex(f,a.mult(-1),0,0,p);}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(d&&this.addCurrentVertex(f,m,e,r,p),"fakeround"===S){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*h){const e=f.add(y.sub(f)._mult(h/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,g,0,0,p),f=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i),this.distance>Cu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s));}addHalfVertex({x:t,y:e},r,n,i,s,a,o){const l=.5*(this.lineClips?this.scaledDistance*(Cu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),o.primitiveLength++),s?this.e2=u:this.e1=u;}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}let Vu,Eu;is("LineBucket",Bu,{omit:["layers","patternFeatures"]});var Tu={get paint(){return Eu=Eu||new Ds({"line-opacity":new Fs(gt.paint_line["line-opacity"]),"line-color":new Fs(gt.paint_line["line-color"]),"line-translate":new Ts(gt.paint_line["line-translate"]),"line-translate-anchor":new Ts(gt.paint_line["line-translate-anchor"]),"line-width":new Fs(gt.paint_line["line-width"]),"line-gap-width":new Fs(gt.paint_line["line-gap-width"]),"line-offset":new Fs(gt.paint_line["line-offset"]),"line-blur":new Fs(gt.paint_line["line-blur"]),"line-dasharray":new Ls(gt.paint_line["line-dasharray"]),"line-pattern":new $s(gt.paint_line["line-pattern"]),"line-gradient":new Os(gt.paint_line["line-gradient"])})},get layout(){return Vu=Vu||new Ds({"line-cap":new Ts(gt.layout_line["line-cap"]),"line-join":new Fs(gt.layout_line["line-join"]),"line-miter-limit":new Ts(gt.layout_line["line-miter-limit"]),"line-round-limit":new Ts(gt.layout_line["line-round-limit"]),"line-sort-key":new Fs(gt.layout_line["line-sort-key"])})}};class Fu extends Fs{possiblyEvaluate(t,e){return e=new ks(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=L({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let $u;class Lu extends Rs{constructor(t){super(t,Tu),this.gradientVersion=0,$u||($u=new Fu(Tu.paint.properties["line-width"].specification),$u.useIntegerZoom=!0);}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof sr,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=$u.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new Bu(t)}queryRadius(t){const e=t,r=Ou(Do("line-width",this,e),Do("line-gap-width",this,e)),n=Do("line-offset",this,e);return r/2+Math.abs(n)+jo(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:r,geometry:n,transform:i,pixelsToTileUnits:s}){const a=Ro(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-i.bearingInRadians,s),o=s/2*Ou(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),u=this.paint.get("line-offset").evaluate(e,r);return u&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Du=Gs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ju=Gs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Gs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ru=Gs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Gs([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Nu=Gs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Uu=Gs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function qu(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ss.applyArabicShaping&&(t=Ss.applyArabicShaping(t)),t}(t.text,e,r);})),t}Gs([{name:"triangle",components:3,type:"Uint16"}]),Gs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Gs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Gs([{type:"Float32",name:"offsetX"}]),Gs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Gs([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Gu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Zu,Ku,Xu,Hu=24,Yu={};function Ju(){return Zu||(Zu=1,Yu.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},Yu.write=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;}),Yu}function Wu(){if(Xu)return Ku;Xu=1,Ku=e;var t=Ju();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function v(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return a(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return a(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=s(this);for(t=t||[];this.pos127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},Ku}var Qu=r(Wu());const tc=3;function ec(t,e,r){1===t&&r.readMessage(rc,e);}function rc(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(nc,{});e.push({id:t,bitmap:new Qo({width:i+2*tc,height:s+2*tc},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}}function nc(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const ic=tc;function sc(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&dc[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new pc;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}getMaxImageSize(t){let e=0,r=0;for(let n=0;n=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function fc(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=pc.fromFeature(e,s);let g;p===t.al.vertical&&m.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=Ss;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),_c(m,c,a,r,i,d));for(const e of t){const t=new pc;t.text=e,t.sections=m.sections;for(let r=0;r=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/a,a=t;}return {x1:n,y1:i,x2:n+s,y2:i+a}}function Vc(t,e,r,n,i,s){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e];}const l=e.left*s,u=e.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-a.displaySize[0])/2,h=f+a.displaySize[0]);const d=e.top*s,y=e.bottom*s;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-a.displaySize[1])/2,p=c+a.displaySize[1]),{image:a,top:c,right:h,bottom:p,left:f,collisionPadding:o}}const Ec=255,Tc=128,Fc=Ec*Tc;function $c(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new ks(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=$c(this.zoom,r["text-size"]),this.iconSizeData=$c(this.zoom,r["icon-size"]);const n=this.layers[0].layout,i=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap="never"!==Lc(n,"text-overlap","text-allow-overlap")||"never"!==Lc(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!i.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.al[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID;}createArrays(){this.text=new Uc(new xo(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Uc(new xo(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new _a,this.lineVertexArray=new Aa,this.symbolInstances=new wa,this.textAnchorOffsets=new ka;}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=r.iconDependencies,f=r.glyphDependencies,d=r.availableImages,y=new ks(this.zoom);for(const{feature:r,id:o,index:l,sourceLayerIndex:m}of e){const e=i._featureFilter.needGeometry,g=So(r,e);if(!i._featureFilter.filter(y,g,n))continue;let x,v;if(e||(g.geometry=Ao(r)),u){const t=i.getValueAndResolveTokens("text-field",g,n,d),e=Pe.factory(t),r=this.hasRTLText=this.hasRTLText||Nc(e);(!r||"unavailable"===Ss.getRTLTextPluginStatus()||r&&Ss.isParsed())&&(x=qu(e,i,g));}if(c){const t=i.getValueAndResolveTokens("icon-image",g,n,d);v=t instanceof $e?t:$e.fromString(t);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?h.evaluate(g,{},n):void 0;if(this.features.push({id:o,text:x,icon:v,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:r.properties,type:Oc[r.type],sortKey:b}),v&&(p[v.name]=!0),x){const e=a.evaluate(g,{},n).join(","),r="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.al.vertical)>=0;for(const t of x.sections)if(t.image)p[t.image.name]=!0;else {const n=ps(x.toString()),i=t.fontStack||e,s=f[i]=f[i]||{};this.calculateGlyphDependencies(t.text,s,r,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Zc,Kc;is("SymbolBucket",Gc,{omit:["layers","collisionBoxArray","features","compareText"]}),Gc.MAX_GLYPHS=65535,Gc.addDynamicAttributes=Rc;var Xc={get paint(){return Kc=Kc||new Ds({"icon-opacity":new Fs(gt.paint_symbol["icon-opacity"]),"icon-color":new Fs(gt.paint_symbol["icon-color"]),"icon-halo-color":new Fs(gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Fs(gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Fs(gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ts(gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ts(gt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Fs(gt.paint_symbol["text-opacity"]),"text-color":new Fs(gt.paint_symbol["text-color"],{runtimeType:Lt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Fs(gt.paint_symbol["text-halo-color"]),"text-halo-width":new Fs(gt.paint_symbol["text-halo-width"]),"text-halo-blur":new Fs(gt.paint_symbol["text-halo-blur"]),"text-translate":new Ts(gt.paint_symbol["text-translate"]),"text-translate-anchor":new Ts(gt.paint_symbol["text-translate-anchor"])})},get layout(){return Zc=Zc||new Ds({"symbol-placement":new Ts(gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ts(gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ts(gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Fs(gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ts(gt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ts(gt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ts(gt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ts(gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ts(gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ts(gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Fs(gt.layout_symbol["icon-size"]),"icon-text-fit":new Ts(gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ts(gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Fs(gt.layout_symbol["icon-image"]),"icon-rotate":new Fs(gt.layout_symbol["icon-rotate"]),"icon-padding":new Fs(gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ts(gt.layout_symbol["icon-keep-upright"]),"icon-offset":new Fs(gt.layout_symbol["icon-offset"]),"icon-anchor":new Fs(gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ts(gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ts(gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ts(gt.layout_symbol["text-rotation-alignment"]),"text-field":new Fs(gt.layout_symbol["text-field"]),"text-font":new Fs(gt.layout_symbol["text-font"]),"text-size":new Fs(gt.layout_symbol["text-size"]),"text-max-width":new Fs(gt.layout_symbol["text-max-width"]),"text-line-height":new Ts(gt.layout_symbol["text-line-height"]),"text-letter-spacing":new Fs(gt.layout_symbol["text-letter-spacing"]),"text-justify":new Fs(gt.layout_symbol["text-justify"]),"text-radial-offset":new Fs(gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ts(gt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Fs(gt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Fs(gt.layout_symbol["text-anchor"]),"text-max-angle":new Ts(gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ts(gt.layout_symbol["text-writing-mode"]),"text-rotate":new Fs(gt.layout_symbol["text-rotate"]),"text-padding":new Ts(gt.layout_symbol["text-padding"]),"text-keep-upright":new Ts(gt.layout_symbol["text-keep-upright"]),"text-transform":new Fs(gt.layout_symbol["text-transform"]),"text-offset":new Fs(gt.layout_symbol["text-offset"]),"text-allow-overlap":new Ts(gt.layout_symbol["text-allow-overlap"]),"text-overlap":new Ts(gt.layout_symbol["text-overlap"]),"text-ignore-placement":new Ts(gt.layout_symbol["text-ignore-placement"]),"text-optional":new Ts(gt.layout_symbol["text-optional"])})}};class Hc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Et,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}is("FormatSectionOverride",Hc,{omit:["defaultValue"]});class Yc extends Rs{constructor(t){super(t,Xc);}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]=["horizontal"];}this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||ti(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Gc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Xc.paint.overridableProperties){if(!Yc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Hc(e),n=new Qn(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new ri("source",n):new ni("composite",n,e.value.zoomStops),this.paint._values[t]=new Vs(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&Yc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Xc.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Pe)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof Ne&&je(e.value)===Nt?s(e.value.sections):e instanceof Mr?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}}let Jc;var Wc={get paint(){return Jc=Jc||new Ds({"background-color":new Ts(gt.paint_background["background-color"]),"background-pattern":new Ls(gt.paint_background["background-pattern"]),"background-opacity":new Ts(gt.paint_background["background-opacity"])})}};class Qc extends Rs{constructor(t){super(t,Wc);}}let th;var eh={get paint(){return th=th||new Ds({"raster-opacity":new Ts(gt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ts(gt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ts(gt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ts(gt.paint_raster["raster-brightness-max"]),"raster-saturation":new Ts(gt.paint_raster["raster-saturation"]),"raster-contrast":new Ts(gt.paint_raster["raster-contrast"]),"raster-resampling":new Ts(gt.paint_raster["raster-resampling"]),"raster-fade-duration":new Ts(gt.paint_raster["raster-fade-duration"])})}};class rh extends Rs{constructor(t){super(t,eh);}}class nh extends Rs{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);},this.implementation=t;}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){throw new Error("Custom layers cannot be serialized")}}class ih{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle();}),0));}remove(){delete this._channel,this._methodToThrottle=()=>{};}}const sh={once:!0},ah=6371008.8;class oh{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new oh($(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return ah*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof oh)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new oh(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new oh(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const lh=2*Math.PI*ah;function uh(t){return lh*Math.cos(t*Math.PI/180)}function ch(t){return (180+t)/360}function hh(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function ph(t,e){return t/uh(e)}function fh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function dh(t,e){return t*uh(fh(e))}class yh{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=oh.convert(t);return new yh(ch(r.lng),hh(r.lat),ph(e,r.lat))}toLngLat(){return new oh(360*this.x-180,fh(this.y))}toAltitude(){return dh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/lh*(t=fh(this.y),1/Math.cos(t*Math.PI/180));var t;}}function mh(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class gh{constructor(t,e,r){if(!function(t,e,r){return !(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=bh(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,a=this.z,o=mh(256*(i=this.x),256*(s=Math.pow(2,a)-s-1),a),l=mh(256*(i+1),256*(s+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var i,s,a,o,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new l((t.x*e-this.x)*z,(t.y*e-this.y)*z)}toString(){return `${this.z}/${this.x}/${this.y}`}}class xh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=bh(t,e.z,e.z,e.x,e.y);}}class vh{constructor(t,e,r,n,i){if(this.terrainRttPosMatrix32f=null,t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new gh(r,+n,+i),this.key=bh(e,t,r,n,i);}clone(){return new vh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new vh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new vh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?bh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):bh(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new vh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new vh(e,this.wrap,e,r,n),new vh(e,this.wrap,e,r+1,n),new vh(e,this.wrap,e,r,n+1),new vh(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new tl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Ah{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class Sh{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new rs(z,16,0),this.grid3D=new rs(z,16,0),this.featureIndexArray=new Ia,this.promoteId=e;}insert(t,e,r,n,i,s){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const o=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new hu.VectorTile(new Qu(this.rawTileData)).layers,this.sourceLayerCoder=new _h(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params,s=z/t.tileSize/t.scale,a=ui(i.filter),o=t.queryGeometry,u=t.queryPadding*s,c=Mh(o),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=Mh(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,i)=>function(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new l(e,r),new l(e,i),new l(n,i),new l(n,r)];if(t.length>2)for(const e of s)if(Lo(t,e))return !0;for(let e=0;e(p||(p=Ao(e)),r.queryIntersectsFeature({queryGeometry:o,feature:e,featureState:n,geometry:p,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))));}return d}loadMatchingFeature(t,e,r,n,i,s,a,o,l,u,c){const h=this.bucketLayerIDs[e];if(s&&!h.some((t=>s.has(t))))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const t=So(f,!0);if(!i.filter(new ks(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new ks(this.tileID.overscaledZ),f))return;const d=this.getId(f,p);for(let e=0;e{const a=e instanceof Es?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function Mh(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {minX:e,minY:r,maxX:n,maxY:i}}function Ih(t,e){return e-t}function zh(t,e,r,n,i){const s=[];for(let a=0;a=n&&c.x>=n||(a.x>=n?a=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=n&&(c=new l(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=i&&c.y>=i||(a.y>=i?a=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y>=i&&(c=new l(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),u&&a.equals(u[u.length-1])||(u=[a],s.push(u)),u.push(c)))));}}return s}is("FeatureIndex",Sh,{omit:["rawTileData","sourceLayerCoder"]});class Ph extends l{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n);}clone(){return new Ph(this.x,this.y,this.angle,this.segment)}}function Ch(t,e,r,n,i){if(void 0===e.segment||0===r)return !0;let s=e,a=e.segment+1,o=0;for(;o>-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function Bh(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=fr.number(n.x,i.x,c),p=fr.number(n.y,i.y,c),f=new Ph(h,p,i.angleTo(n),r);return f._round(),!a||Ch(t,f,o,a,e)?f:void 0}l+=s;}}function Fh(t,e,r,n,i,s,a,o,l){const u=Vh(n,s,a),c=Eh(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new Ph(g,x,y,e);r._round(),n&&!Ch(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=$h(t,h/2,r,n,i,s,a,!0,l)),f}is("Anchor",Ph);const Lh=ac;function Oh(t,e,r,n){const i=[],s=t.image,a=s.pixelRatio,o=s.paddedRect.w-2*Lh,u=s.paddedRect.h-2*Lh;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=s.stretchX||[[0,o]],p=s.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[0],d=h.reduce(f,0),y=p.reduce(f,0),m=o-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,A=m,S=0,k=g;if(s.content&&n){const e=s.content,r=e[2]-e[0],n=e[3]-e[1];(s.textFitWidth||s.textFitHeight)&&(c=Bc(t)),x=Dh(h,0,e[0]),b=Dh(p,0,e[1]),v=Dh(h,e[0],e[2]),w=Dh(p,e[1],e[3]),_=e[0]-x,S=e[1]-b,A=r-v,k=n-w;}const M=c.x1,I=c.y1,z=c.x2-M,P=c.y2-I,C=(t,n,i,o)=>{const u=Rh(t.stretch-x,v,z,M),c=Nh(t.fixed-_,A,t.stretch,d),h=Rh(n.stretch-b,w,P,I),p=Nh(n.fixed-S,k,n.stretch,y),f=Rh(i.stretch-x,v,z,M),m=Nh(i.fixed-_,A,i.stretch,d),g=Rh(o.stretch-b,w,P,I),C=Nh(o.fixed-S,k,o.stretch,y),B=new l(u,h),V=new l(f,h),E=new l(f,g),T=new l(u,g),F=new l(c/a,p/a),$=new l(m/a,C/a),L=e*Math.PI/180;if(L){const t=Math.sin(L),e=Math.cos(L),r=[e,-t,t,e];B._matMult(r),V._matMult(r),T._matMult(r),E._matMult(r);}const O=t.stretch+t.fixed,D=n.stretch+n.fixed;return {tl:B,tr:V,bl:T,br:E,tex:{x:s.paddedRect.x+Lh+O,y:s.paddedRect.y+Lh+D,w:i.stretch+i.fixed-O,h:o.stretch+o.fixed-D},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:$,minFontScaleX:A/a/z,minFontScaleY:k/a/P,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=jh(h,m,d),e=jh(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n);}else {const u=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?Bc(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};u.y1=u.y1*a-o[0],u.y2=u.y2*a+o[2],u.x1=u.x1*a-o[3],u.x2=u.x2*a+o[1];const p=s.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const t=new l(u.x1,u.y1),e=new l(u.x2,u.y1),r=new l(u.x1,u.y2),n=new l(u.x2,u.y2),i=c*Math.PI/180;t._rotate(i),e._rotate(i),r._rotate(i),n._rotate(i),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y);}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,i);}this.boxEndIndex=t.length;}}class qh{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}function Gh(t,e=1,r=!1){let n=1/0,i=1/0,s=-1/0,a=-1/0;const o=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const u=Math.min(s-n,a-i);let c=u/2;const h=new qh([],Zh);if(0===u)return new l(n,i);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Kh(n.p.x-c,n.p.y-c,c,t)),h.push(new Kh(n.p.x+c,n.p.y-c,c,t)),h.push(new Kh(n.p.x-c,n.p.y+c,c,t)),h.push(new Kh(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Zh(t,e){return e.max-t.max}function Kh(t,e,r,n){this.p=new l(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Fo(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}var Xh;t.aB=void 0,(Xh=t.aB||(t.aB={}))[Xh.center=1]="center",Xh[Xh.left=2]="left",Xh[Xh.right=3]="right",Xh[Xh.top=4]="top",Xh[Xh.bottom=5]="bottom",Xh[Xh["top-left"]=6]="top-left",Xh[Xh["top-right"]=7]="top-right",Xh[Xh["bottom-left"]=8]="bottom-left",Xh[Xh["bottom-right"]=9]="bottom-right";const Hh=7,Yh=Number.POSITIVE_INFINITY;function Jh(t,e){return e[1]!==Yh?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case "top-right":case "top-left":case "top":i=r-Hh;break;case "bottom-right":case "bottom-left":case "bottom":i=-r+Hh;}switch(t){case "top-right":case "bottom-right":case "right":n=-e;break;case "top-left":case "bottom-left":case "left":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case "top-right":case "top-left":n=i-Hh;break;case "bottom-right":case "bottom-left":n=-i+Hh;break;case "bottom":n=-e+Hh;break;case "top":n=e-Hh;}switch(t){case "top-right":case "bottom-right":r=-i;break;case "top-left":case "bottom-left":r=i;break;case "left":r=e;break;case "right":r=-e;}return [r,n]}(t,e[0])}function Wh(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*Hu));n.startsWith("top")?i[1]-=Hh:n.startsWith("bottom")&&(i[1]+=Hh),e[r+1]=i;}return new Fe(e)}const a=i.get("text-variable-anchor");if(a){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Hu,Yh]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Hu));const s=[];for(const t of a)s.push(t,Jh(t,n));return new Fe(s)}return null}function Qh(t){switch(t){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function tp(e,r,n,i,s,a,o,l,u,c,h,p){let f=a.textMaxSize.evaluate(r,{});void 0===f&&(f=o);const d=e.layers[0].layout,y=d.get("icon-offset").evaluate(r,{},h),m=rp(n.horizontal),g=o/24,x=e.tilePixelRatio*g,v=e.tilePixelRatio*f/24,b=e.tilePixelRatio*l,w=e.tilePixelRatio*d.get("symbol-spacing"),_=d.get("text-padding")*e.tilePixelRatio,A=function(t,e,r,n=1){const i=t.get("icon-padding").evaluate(e,{},r),s=i&&i.values;return [s[0]*n,s[1]*n,s[2]*n,s[3]*n]}(d,r,h,e.tilePixelRatio),S=d.get("text-max-angle")/180*Math.PI,k="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),M="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),I=d.get("symbol-placement"),P=w/2,C=d.get("icon-text-fit");let B;i&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(B=Vc(i,n.vertical,C,d.get("icon-text-fit-padding"),y,g)),m&&(i=Vc(i,m,C,d.get("icon-text-fit-padding"),y,g)));const V=h?p.line.getGranularityForZoomLevel(h.z):1,E=(l,p)=>{p.x<0||p.x>=z||p.y<0||p.y>=z||function(e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,A,S,k){const M=e.addToLineVertexArray(r,n);let I,z,P,C,B=0,V=0,E=0,T=0,F=-1,$=-1;const L={};let O=to("");if(e.allowVerticalPlacement&&i.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},S)+90;P=new Uh(u,r,c,h,p,i.vertical,f,d,y,t),o&&(C=new Uh(u,r,c,h,p,o,g,x,y,t));}if(s){const n=l.layout.get("icon-rotate").evaluate(w,{}),i="none"!==l.layout.get("icon-text-fit"),a=Oh(s,n,A,i),f=o?Oh(o,n,A,i):void 0;z=new Uh(u,r,c,h,p,s,g,x,!1,n),B=4*a.length;const d=e.iconSizeData;let y=null;"source"===d.kind?(y=[Tc*l.layout.get("icon-size").evaluate(w,{})],y[0]>Fc&&U(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ec}. Reduce your "icon-size".`)):"composite"===d.kind&&(y=[Tc*_.compositeIconSizes[0].evaluate(w,{},S),Tc*_.compositeIconSizes[1].evaluate(w,{},S)],(y[0]>Fc||y[1]>Fc)&&U(`${e.layerIds[0]}: Value for "icon-size" is >= ${Ec}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,y,b,v,w,t.al.none,r,M.lineStartIndex,M.lineLength,-1,S),F=e.icon.placedSymbolArray.length-1,f&&(V=4*f.length,e.addSymbols(e.icon,f,y,b,v,w,t.al.vertical,r,M.lineStartIndex,M.lineLength,-1,S),$=e.icon.placedSymbolArray.length-1);}const D=Object.keys(i.horizontal);for(const n of D){const s=i.horizontal[n];if(!I){O=to(s.text);const t=l.layout.get("text-rotate").evaluate(w,{},S);I=new Uh(u,r,c,h,p,s,f,d,y,t);}const o=1===s.positionedLines.length;if(E+=ep(e,r,s,a,l,y,w,m,M,i.vertical?t.al.horizontal:t.al.horizontalOnly,o?D:[n],L,F,_,S),o)break}i.vertical&&(T+=ep(e,r,i.vertical,a,l,y,w,m,M,t.al.vertical,["vertical"],L,$,_,S));const j=I?I.boxStartIndex:e.collisionBoxArray.length,R=I?I.boxEndIndex:e.collisionBoxArray.length,N=P?P.boxStartIndex:e.collisionBoxArray.length,q=P?P.boxEndIndex:e.collisionBoxArray.length,G=z?z.boxStartIndex:e.collisionBoxArray.length,Z=z?z.boxEndIndex:e.collisionBoxArray.length,K=C?C.boxStartIndex:e.collisionBoxArray.length,X=C?C.boxEndIndex:e.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(I,H),H=Y(P,H),H=Y(z,H),H=Y(C,H);const J=H>-1?1:0;J&&(H*=k/Hu),e.glyphOffsetArray.length>=Gc.MAX_GLYPHS&&U("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const W=Wh(l,w,S),[Q,tt]=function(e,r){const n=e.length,i=null==r?void 0:r.values;if((null==i?void 0:i.length)>0)for(let r=0;r=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,F,$,O,j,R,N,q,G,Z,K,X,c,E,T,B,V,J,0,f,H,Q,tt);}(e,p,l,n,i,s,B,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,x,[_,_,_,_],k,u,b,A,M,y,r,a,c,h,o);};if("line"===I)for(const t of zh(r.geometry,0,0,z,z)){const r=Nl(t,V),s=Fh(r,w,S,n.vertical||m,i,24,v,e.overscaling,z);for(const t of s)m&&np(e,m.text,P,t)||E(r,t);}else if("line-center"===I){for(const t of r.geometry)if(t.length>1){const e=Nl(t,V),r=Th(e,S,n.vertical||m,i,24,v);r&&E(e,r);}}else if("Polygon"===r.type)for(const t of Wr(r.geometry,0)){const e=Gh(t,16);E(Nl(t[0],V,!0),new Ph(e.x,e.y,0));}else if("LineString"===r.type)for(const t of r.geometry){const e=Nl(t,V);E(e,new Ph(e[0].x,e[0].y,0));}else if("Point"===r.type)for(const t of r.geometry)for(const e of t)E([e],new Ph(e.x,e.y,0));}function ep(t,e,r,n,i,s,a,o,u,c,h,p,f,d,y){const m=function(t,e,r,n,i,s,a,o){const u=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=ic+1,p=!0,f=1,d=0;const y=(i||o)&&n.vertical,m=n.metrics.advance*n.scale/2;if(o&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Hu-n.metrics.width*n.scale)/2:(n.scale-1)*Hu)),n.imageName){const t=a[n.imageName];p=t.sdf,f=t.pixelRatio,h=ac/f;}const g=i?[n.x+m,n.y]:[0,0];let x=i?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],A=w+s.w/b*n.scale/f,S=_+s.h/b*n.scale/f,k=new l(w,_),M=new l(A,_),I=new l(w,S),z=new l(A,S);if(y){const t=new l(-m,m-cc),e=-Math.PI/2,r=Hu/2-m,i=new l(5-cc-r,-(n.imageName?r:0)),s=new l(...v);k._rotateAround(e,t)._add(i)._add(s),M._rotateAround(e,t)._add(i)._add(s),I._rotateAround(e,t)._add(i)._add(s),z._rotateAround(e,t)._add(i)._add(s);}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];k._matMult(r),M._matMult(r),I._matMult(r),z._matMult(r);}const P=new l(0,0),C=new l(0,0);c.push({tl:k,tr:M,bl:I,br:z,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0});}return c}(0,r,o,i,s,a,n,t.allowVerticalPlacement),g=t.textSizeData;let x=null;"source"===g.kind?(x=[Tc*i.layout.get("text-size").evaluate(a,{})],x[0]>Fc&&U(`${t.layerIds[0]}: Value for "text-size" is >= ${Ec}. Reduce your "text-size".`)):"composite"===g.kind&&(x=[Tc*d.compositeTextSizes[0].evaluate(a,{},y),Tc*d.compositeTextSizes[1].evaluate(a,{},y)],(x[0]>Fc||x[1]>Fc)&&U(`${t.layerIds[0]}: Value for "text-size" is >= ${Ec}. Reduce your "text-size".`)),t.addSymbols(t.text,m,x,o,s,a,c,e,u.lineStartIndex,u.lineLength,f,y);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*m.length}function rp(t){for(const e in t)return t[e];return null}function np(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=ip[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new sp(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=ip.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ap(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)cp(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];cp(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function ap(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;op(t,e,a,n,i,s),ap(t,e,r,n,a-1,1-s),ap(t,e,r,a+1,i,1-s);}function op(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);op(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(lp(t,e,n,r),e[2*i+s]>a&&lp(t,e,n,i);oa;)l--;}e[2*n+s]===a?lp(t,e,n,l):(l++,lp(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function lp(t,e,r,n){up(t,r,n),up(e,2*r,2*n),up(e,2*r+1,2*n+1);}function up(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function cp(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}var hp;t.co=void 0,(hp=t.co||(t.co={})).create="create",hp.load="load",hp.fullLoad="fullLoad";let pp=null,fp=[];const dp=1e3/60,yp="loadTime",mp="fullLoadTime",gp={mark(t){performance.mark(t);},frame(t){const e=t;null!=pp&&fp.push(e-pp),pp=e;},clearMetrics(){pp=null,fp=[],performance.clearMeasures(yp),performance.clearMeasures(mp);for(const e in t.co)performance.clearMarks(t.co[e]);},getPerformanceMetrics(){performance.measure(yp,t.co.create,t.co.load),performance.measure(mp,t.co.create,t.co.fullLoad);const e=performance.getEntriesByName(yp)[0].duration,r=performance.getEntriesByName(mp)[0].duration,n=fp.length,i=1/(fp.reduce(((t,e)=>t+e),0)/n/1e3),s=fp.filter((t=>t>dp)).reduce(((t,e)=>t+(e-dp)/dp),0);return {loadTime:e,fullLoadTime:r,fps:i,percentDroppedFrames:s/(n+s)*100,totalFrames:n}}};t.$=yh,t.A=m,t.B=fr,t.C=ks,t.D=Ts,t.E=mt,t.F=Wi,t.G=function(t){if(null==Z){const e=t.navigator?t.navigator.userAgent:null;Z=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return Z},t.H=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ih((()=>this.process())),this.subscription=W(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=G(self)?t:window;}registerMessageHandler(t,e){this.messageHandlers[t]=e;}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=e?W(e.signal,"abort",(()=>{null==s||s.unsubscribe(),delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e);}),sh):null;this.resolveRejects[i]={resolve:t=>{null==s||s.unsubscribe(),r(t);},reject:t=>{null==s||s.unsubscribe(),n(t);}};const a=[],o=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:ls(t.data,a)});this.target.postMessage(o,{transfer:a});}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(G(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e);}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e);}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(us(r.error)):e.resolve(us(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=us(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i);}catch(e){this.completeTask(t,e);}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?ls(e):null,data:ls(r,n)};this.target.postMessage(i,{transfer:n});}remove(){this.invoker.remove(),this.subscription.unsubscribe();}},t.I=oc,t.J=ot,t.K=function(){var t=new m(16);return m!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.L=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*y+o*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=s*y+u*m+f*g+e[14],t[15]=a*y+c*m+d*g+e[15]),t},t.M=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.N=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*o+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*s+b*u+w*f+_*g,t[3]=v*a+b*c+w*d+_*x,t[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*s+b*u+w*f+_*g,t[7]=v*a+b*c+w*d+_*x,t[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*s+b*u+w*f+_*g,t[11]=v*a+b*c+w*d+_*x,t[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*s+b*u+w*f+_*g,t[15]=v*a+b*c+w*d+_*x,t},t.O=function(t,e){const r={};for(let n=0;n{const e=window.document.createElement("video");return e.muted=!0,new Promise((r=>{e.onloadstart=()=>{r(e);};for(const r of t){const t=window.document.createElement("source");ht(r)||(e.crossOrigin="Anonymous"),t.src=r,e.appendChild(t);}}))},t.a3=Pt,t.a4=function(){return O++},t.a5=ga,t.a6=Gc,t.a7=ui,t.a8=So,t.a9=Ah,t.aA=function(t,e,r,n,i=!1){if(!r[0]&&!r[1])return [0,0];const s=i?"map"===n?-t.bearingInRadians:0:"viewport"===n?t.bearingInRadians:0;if(s){const t=Math.sin(s),e=Math.cos(s);r=[r[0]*e-r[1]*t,r[0]*t+r[1]*e];}return [i?r[0]:P(e,r[0],t.zoom),i?r[1]:P(e,r[1],t.zoom)]},t.aC=Lc,t.aD=Qh,t.aE=Ac,t.aF=sp,t.aG=Gs,t.aH=Ll,t.aI=za,t.aJ=qa,t.aK=ja,t.aL=$,t.aM=tt,t.aN=dh,t.aO=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},t.aP=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},t.aQ=function(t){var e=new m(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.aR=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},t.aS=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},t.aT=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},t.aU=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},t.aV=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.aW=xh,t.aX=bh,t.aY=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.aZ=function(t){var e=new m(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.a_=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],a=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i+u*n,t[1]=a*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-s*n,t[5]=c*i-a*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},t.aa=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e},t.ab=Q,t.ac=function(t){return Math.pow(2,t)},t.ad=x,t.ae=F,t.af=85.051129,t.ag=ph,t.ah=function(t){return Math.log(t)/Math.LN2},t.ai=function(t){var e=t[0],r=t[1];return e*e+r*r},t.aj=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.ak=function(t,e){let r=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:i,minZoom:s,maxZoom:a}=t,o=i?F(hr.interpolationFactor(i,e,s,a),0,1):0;"camera"===t.kind?n=fr.number(t.minSize,t.maxSize,o):r=o;}return {uSizeT:r,uSize:n}},t.am=function(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/Tc:"composite"===t.kind?fr.number(n/Tc,i/Tc,r):e},t.an=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],y=e[13],m=e[14],g=e[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,A=i*u-s*l,S=c*y-h*d,k=c*m-p*d,M=c*g-f*d,I=h*m-p*y,z=h*g-f*y,P=p*g-f*m,C=x*P-v*z+b*I+w*M-_*k+A*S;return C?(t[0]=(o*P-l*z+u*I)*(C=1/C),t[1]=(i*z-n*P-s*I)*C,t[2]=(y*A-m*_+g*w)*C,t[3]=(p*_-h*A-f*w)*C,t[4]=(l*M-a*P-u*k)*C,t[5]=(r*P-i*M+s*k)*C,t[6]=(m*b-d*A-g*v)*C,t[7]=(c*A-p*b+f*v)*C,t[8]=(a*z-o*M+u*S)*C,t[9]=(n*M-r*z-s*S)*C,t[10]=(d*_-y*b+g*x)*C,t[11]=(h*b-c*_-f*x)*C,t[12]=(o*k-a*I-l*S)*C,t[13]=(r*I-n*k+i*S)*C,t[14]=(y*v-d*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null},t.ao=M,t.ap=function(t){return Math.hypot(t[0],t[1])},t.aq=function(t){return t[0]=0,t[1]=0,t},t.ar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},t.as=Rc,t.at=S,t.au=function(t,e,r,n){const i=e.y-t.y,s=e.x-t.x,a=n.y-r.y,o=n.x-r.x,u=a*s-o*i;if(0===u)return null;const c=(o*(t.y-r.y)-a*(t.x-r.x))/u;return new l(t.x+c*s,t.y+c*i)},t.av=zh,t.aw=zo,t.ax=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return [e,r,n,i]},t.ay=Hu,t.az=P,t.b=K,t.b$=class extends da{},t.b0=function(){const t=new Float32Array(16);return x(t),t},t.b1=function(){const t=new Float64Array(16);return x(t),t},t.b2=function(){return new Float64Array(16)},t.b3=function(t,e,r){const n=new Float64Array(4);return function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u;}(n,t,e-90,r),n},t.b4=function(t,e,r,n){var i,s,a,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],m=r[2],g=r[3];return (s=u*f+c*d+h*m+p*g)<0&&(s=-s,f=-f,d=-d,m=-m,g=-g),1-s>y?(i=Math.acos(s),a=Math.sin(i),o=Math.sin((1-n)*i)/a,l=Math.sin(n*i)/a):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*m,t[3]=o*p+l*g,t},t.b5=function(t){const e=new Float64Array(9);var r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v;h=(i=(n=t)[0])*(l=i+i),p=(s=n[1])*l,d=(a=n[2])*l,y=a*(u=s+s),g=(o=n[3])*l,x=o*u,v=o*(c=a+a),(r=e)[0]=1-(f=s*u)-(m=a*c),r[3]=p-v,r[6]=d+x,r[1]=p+v,r[4]=1-h-m,r[7]=y-g,r[2]=d-x,r[5]=y+g,r[8]=1-h-f;const b=tt(-Math.asin(F(e[2],-1,1)));let w,_;return Math.hypot(e[5],e[8])<.001?(w=0,_=-tt(Math.atan2(e[3],e[4]))):(w=tt(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),_=tt(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:w,pitch:b+90,bearing:_}},t.b6=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.b7=ke,t.b8=ao,t.b9=Ol,t.bA=function(t){if("custom"===t.type)return new nh(t);switch(t.type){case "background":return new Qc(t);case "circle":return new Go(t);case "fill":return new Yl(t);case "fill-extrusion":return new wu(t);case "heatmap":return new nl(t);case "hillshade":return new al(t);case "line":return new Lu(t);case "raster":return new rh(t);case "symbol":return new Yc(t)}},t.bB=R,t.bC=function(t,e){if(!t)return [{command:"setStyle",args:[e]}];let r=[];try{if(!bt(t.version,e.version))return [{command:"setStyle",args:[e]}];bt(t.center,e.center)||r.push({command:"setCenter",args:[e.center]}),bt(t.state,e.state)||r.push({command:"setGlobalState",args:[e.state]}),bt(t.centerAltitude,e.centerAltitude)||r.push({command:"setCenterAltitude",args:[e.centerAltitude]}),bt(t.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),bt(t.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),bt(t.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),bt(t.roll,e.roll)||r.push({command:"setRoll",args:[e.roll]}),bt(t.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),bt(t.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),bt(t.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),bt(t.light,e.light)||r.push({command:"setLight",args:[e.light]}),bt(t.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),bt(t.sky,e.sky)||r.push({command:"setSky",args:[e.sky]}),bt(t.projection,e.projection)||r.push({command:"setProjection",args:[e.projection]});const n={},i=[];!function(t,e,r,n){let i;for(i in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,i)&&(Object.prototype.hasOwnProperty.call(e,i)||At(i,r,n));for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&(Object.prototype.hasOwnProperty.call(t,i)?bt(t[i],e[i])||("geojson"===t[i].type&&"geojson"===e[i].type&&kt(t,e,i)?wt(r,{command:"setGeoJSONSourceData",args:[i,e[i].data]}):St(i,e,r,n)):_t(i,e,r));}(t.sources,e.sources,i,n);const s=[];t.layers&&t.layers.forEach((t=>{"source"in t&&n[t.source]?r.push({command:"removeLayer",args:[t.id]}):s.push(t);})),r=r.concat(i),function(t,e,r){e=e||[];const n=(t=t||[]).map(It),i=e.map(It),s=t.reduce(zt,{}),a=e.reduce(zt,{}),o=n.slice(),l=Object.create(null);let u,c,h,p,f;for(let t=0,e=0;tr?i-360:i+360;return Math.abs(i)0?a:-a},t.bt=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bu=ah,t.bv=function(t,e){const r=C(t,2*Math.PI),n=C(e,2*Math.PI);return Math.min(Math.abs(r-n),Math.abs(r-n+2*Math.PI),Math.abs(r-n-2*Math.PI))},t.bw=function(){const t={},e=gt.$version;for(const r in gt.$root){const n=gt.$root[r];if(n.required){let i=null;i="version"===r?e:"array"===n.type?[]:{},null!=i&&(t[r]=i);}}return t},t.bx=cs,t.by=ut,t.bz=function(t){t=t.slice();const e=Object.create(null);for(let r=0;r"symbol"===t.type,t.c4=t=>"circle"===t.type,t.c5=t=>"heatmap"===t.type,t.c6=t=>"line"===t.type,t.c7=t=>"fill"===t.type,t.c8=t=>"fill-extrusion"===t.type,t.c9=t=>"hillshade"===t.type,t.cA=Zl,t.cB=yu,t.cC=hu,t.cD=Qu,t.cE=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start);}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.cF=function(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if(d())try{return yield H(t,r,n,i,s)}catch(t){}return function(t,e,r,n,i){const s=t.width,a=t.height;Y&&J||(Y=new OffscreenCanvas(s,a),J=Y.getContext("2d",{willReadFrequently:!0})),Y.width=s,Y.height=a,J.drawImage(t,0,0,s,a);const o=J.getImageData(e,r,n,i);return J.clearRect(0,0,s,a),o.data}(t,r,n,i,s)}))},t.cG=wh,t.cH=r,t.cI=s,t.cJ=cu,t.cK=Wu,t.cL=ei,t.cM=Ss,t.ca=t=>"raster"===t.type,t.cb=t=>"background"===t.type,t.cc=t=>"custom"===t.type,t.cd=E,t.ce=function(t,e,r){const n=I(e.x-r.x,e.y-r.y),i=I(t.x-r.x,t.y-r.y);var s,a;return tt(Math.atan2(n[0]*i[1]-n[1]*i[0],(s=n)[0]*(a=i)[0]+s[1]*a[1]))},t.cf=T,t.cg=function(t,e){return rt[e]&&(t instanceof MouseEvent||t instanceof WheelEvent)},t.ch=function(t,e){return et[e]&&"touches"in t},t.ci=function(t){return et[t]||rt[t]},t.cj=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},t.ck=function(t,e){const{x:r,y:n}=yh.fromLngLat(e);return !(t<0||t>25||n<0||n>=1||r<0||r>=1)},t.cl=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cm=class extends Xs{},t.cn=gp,t.cp=function(t){return t.message===nt},t.cq=lt,t.cr=function(t,e){st.REGISTERED_PROTOCOLS[t]=e;},t.cs=function(t){delete st.REGISTERED_PROTOCOLS[t];},t.ct=function(t,e){const r={};for(let n=0;nt*Hu));}let v=o?"center":n.get("text-justify").evaluate(i,{},e.canonical);const b="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(i,{},e.canonical)*Hu:1/0,w=()=>{e.bucket.allowVerticalPlacement&&ps(s)&&(d.vertical=fc(y,e.glyphMap,e.glyphPositions,e.imagePositions,c,b,a,m,"left",f,g,t.al.vertical,!0,p,h));};if(!o&&x){const r=new Set;if("auto"===v)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.g=at,t.h=t=>new Promise(((e,r)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>{n.src=X;}));},n.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const i=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(i):X;})),t.i=G,t.j=(t,e)=>ct(L(t,{type:"json"}),e),t.k=yt,t.l=dt,t.m=ct,t.n=(t,e)=>ct(L(t,{type:"arrayBuffer"}),e),t.o=function(t){return new Qu(t).readFields(ec,[])},t.p=sc,t.q=Qo,t.r=Ds,t.s=W,t.t=Ji,t.u=hs,t.v=gt,t.w=U,t.x=es,t.y=Yi,t.z=function([t,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(r),y:t*Math.sin(e)*Math.sin(r),z:t*Math.cos(r)}};})); -define("worker",["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const o of t){this._layerConfigs[o.id]=o;const t=this._layers[o.id]=e.aA(o);t._featureFilter=e.a7(t.filter),this.keyCache[o.id]&&delete this.keyCache[o.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=e.bk(Object.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let s=this.familiesBySource[i];s||(s=this.familiesBySource[i]={});const r=o.sourceLayer||"_geojsonTileLayer";let n=s[r];n||(n=s[r]=[]),n.push(t);}}}class o{constructor(t){const o={},i=[];for(const e in t){const s=t[e],r=o[e]={};for(const e in s){const t=s[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};i.push(o),r[e]={rect:o,metrics:t.metrics};}}const{w:s,h:r}=e.p(i),n=new e.o({width:s||1,height:r||1});for(const i in t){const s=t[i];for(const t in s){const r=s[+t];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const a=o[i][t].rect;e.o.copy(r.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},r.bitmap);}}this.image=n,this.positions=o;}}e.bl("GlyphAtlas",o);class i{constructor(t){this.tileID=new e.S(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,i,r,n){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a5;const a=new e.bm(Object.keys(t.layers).sort()),l=new e.bn(this.tileID,this.promoteId);l.bucketLayerIDs=[];const c={},u={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:r},h=i.familiesBySource[this.source];for(const o in h){const i=t.layers[o];if(!i)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=a.encode(o),d=[];for(let e=0;e=o.maxzoom||"none"!==o.visibility&&(s(t,this.zoom,r),(c[o.id]=o.createBucket({index:l.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(d,u,this.tileID.canonical),l.bucketLayerIDs.push(t.map((e=>e.id))));}}const d=e.aF(u.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(d).length){const e=new AbortController;this.inFlightDependencies.push(e),f=n.sendAsync({type:"GG",data:{stacks:d,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const g=Object.keys(u.iconDependencies);let p=Promise.resolve({});if(g.length){const e=new AbortController;this.inFlightDependencies.push(e),p=n.sendAsync({type:"GI",data:{icons:g,source:this.source,tileID:this.tileID,type:"icons"}},e);}const m=Object.keys(u.patternDependencies);let y=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),y=n.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const[v,w,x]=yield Promise.all([f,p,y]),b=new o(v),S=new e.bo(w,x);for(const t in c){const o=c[t];o instanceof e.a6?(s(o.layers,this.zoom,r),e.bp({bucket:o,glyphMap:v,glyphPositions:b.positions,imageMap:w,imagePositions:S.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):o.hasPattern&&(o instanceof e.bq||o instanceof e.br||o instanceof e.bs)&&(s(o.layers,this.zoom,r),o.addFeatures(u,this.tileID.canonical,S.patternPositions));}return this.status="done",{buckets:Object.values(c).filter((e=>!e.isEmpty())),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:S,glyphMap:this.returnDependencies?v:null,iconMap:this.returnDependencies?w:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function s(t,o,i){const s=new e.z(o);for(const e of t)e.recalculate(s,i);}class r{constructor(e,t,o){this.actor=e,this.layerIndex=t,this.availableImages=o,this.fetching={},this.loading={},this.loaded={};}loadVectorTile(t,o){return e._(this,void 0,void 0,(function*(){const i=yield e.l(t.request,o);try{return {vectorTile:new e.bt.VectorTile(new e.bu(i.data)),rawData:i.data,cacheControl:i.cacheControl,expires:i.expires}}catch(e){const o=new Uint8Array(i.data);let s=`Unable to parse the tile at ${t.request.url}, `;throw s+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(s)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid,s=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.bv(t.request),r=new i(t);this.loading[o]=r;const n=new AbortController;r.abort=n;try{const i=yield this.loadVectorTile(t,n);if(delete this.loading[o],!i)return null;const a=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(s){const e=s.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}r.vectorTile=i.vectorTile;const u=r.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[o]=r,this.fetching[o]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[o];}}catch(e){throw delete this.loading[o],r.status="done",this.loaded[o]=r,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid;if(!this.loaded||!this.loaded[o])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const i=this.loaded[o];if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const t=yield i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor);let s;if(this.fetching[o]){const{rawTileData:i,cacheControl:r,resourceTiming:n}=this.fetching[o];delete this.fetching[o],s=e.e({rawTileData:i.slice(0)},t,r,n);}else s=t;return s}if("done"===i.status&&i.vectorTile)return i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){const e=this.loading,o=t.uid;e&&e[o]&&e[o].abort&&(e[o].abort.abort(),delete e[o]);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid];}))}}class n{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:i,rawImageData:s,redFactor:r,greenFactor:n,blueFactor:a,baseShift:l}=t,c=s.width+2,u=s.height+2,h=e.b(s)?new e.R({width:c,height:u},yield e.bw(s,-1,-1,c,u)):s,d=new e.bx(o,h,i,r,n,a,l);return this.loaded=this.loaded||{},this.loaded[o]=d,d}))}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}function a(e,t){if(0!==e.length){l(e[0],t);for(var o=1;o=Math.abs(a)?o-l+a:a-l+o,o=l;}o+i>=0!=!!t&&e.reverse();}var c=e.by((function e(t,o){var i,s=t&&t.type;if("FeatureCollection"===s)for(i=0;i>31}function I(e,t){for(var o=e.loadGeometry(),i=e.type,s=0,r=0,n=o.length,a=0;ae},D=Math.fround||(C=new Float32Array(1),e=>(C[0]=+e,C[0]));var C;const L=3,O=5,F=6;class z{constructor(e){this.options=Object.assign(Object.create(T),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const s=`prepare ${e.length} points`;t&&console.time(s),this.points=e;const r=[];for(let t=0;t=o;e--){const o=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let s=180===e[2]?180:((e[2]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,s=180;else if(o>s){const e=this.getClusters([o,i,180,r],t),n=this.getClusters([-180,i,s,r],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(G(o),j(r),G(s),j(i)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+O]>1?A(l,t,this.clusterProps):this.points[l[t+L]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",s=this.trees[o];if(!s)throw new Error(i);const r=s.data;if(t*this.stride>=r.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=s.within(r[t*this.stride],r[t*this.stride+1],n),l=[];for(const t of a){const o=t*this.stride;r[o+4]===e&&l.push(r[o+O]>1?A(r,o,this.clusterProps):this.points[r[o+L]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],s=Math.pow(2,e),{extent:r,radius:n}=this.options,a=n/r,l=(o-a)/s,c=(o+1+a)/s,u={features:[]};return this._addTileFeatures(i.range((t-a)/s,l,(t+1+a)/s,c),i.data,t,o,s,u),0===t&&this._addTileFeatures(i.range(1-a/s,l,1,c),i.data,s,o,s,u),t===s-1&&this._addTileFeatures(i.range(0,l,a/s,c),i.data,-1,o,s,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,s){const r=this.getChildren(t);for(const t of r){const r=t.properties;if(r&&r.cluster?s+r.point_count<=i?s+=r.point_count:s=this._appendLeaves(e,r.cluster_id,o,i,s):s1;let l,c,u;if(a)l=E(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+L]];l=o.properties;const[i,s]=o.geometry.coordinates;c=G(i),u=j(s);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*s-o)),Math.round(this.options.extent*(u*s-i))]],tags:l};let d;d=a||this.options.generateId?t[e+L]:this.points[t[e+L]].id,void 0!==d&&(h.id=d),r.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:s,minPoints:r}=this.options,n=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+O]);}if(f>d&&f>=r){let e,r=i*d,n=u*d,g=-1;const p=((o/c|0)<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+O];r+=a[l]*u,n+=a[l+1]*u,a[l+4]=p,s&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),s(e,this._map(a,l)));}a[o+4]=p,l.push(r/f,n/f,1/0,p,-1,f),s&&l.push(g);}else {for(let e=0;e1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+O]>1){const i=this.clusterProps[e[t+F]];return o?Object.assign({},i):i}const i=this.points[e[t+L]].properties,s=this.options.map(i);return o&&s===i?Object.assign({},s):s}}function A(e,t,o){return {type:"Feature",id:e[t+L],properties:E(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),R(e[t+1])]}};var i;}function E(e,t,o){const i=e[t+O],s=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,r=e[t+F],n=-1===r?{}:Object.assign({},o[r]);return Object.assign(n,{cluster:!0,cluster_id:e[t+L],point_count:i,point_count_abbreviated:s})}function G(e){return e/360+.5}function j(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function R(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function Z(e,t,o,i){let s=i;const r=t+(o-t>>1);let n,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;is)n=i,s=t;else if(t===s){const e=Math.abs(i-r);ei&&(n-t>3&&Z(e,t,n,i),e[n+2]=s,o-n>3&&Z(e,n,o,i));}function N(e,t,o,i,s,r){let n=s-o,a=r-i;if(0!==n||0!==a){const l=((e-o)*n+(t-i)*a)/(n*n+a*a);l>1?(o=s,i=r):l>0&&(o+=n*l,i+=a*l);}return n=e-o,a=t-i,n*n+a*a}function J(e,t,o,i){const s={id:null==e?null:e,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)W(s,o);else if("Polygon"===t)W(s,o[0]);else if("MultiLineString"===t)for(const e of o)W(s,e);else if("MultiPolygon"===t)for(const e of o)W(s,e[0]);return s}function W(e,t){for(let o=0;o0&&(n+=i?(s*l-a*r)/2:Math.sqrt(Math.pow(a-s,2)+Math.pow(l-r,2))),s=a,r=l;}const a=t.length-3;t[2]=1,Z(t,0,a,o),t[a+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function q(e,t,o,i){for(let s=0;s1?1:o}function U(e,t,o,i,s,r,n,a){if(i/=t,r>=(o/=t)&&n=i)return null;const l=[];for(const t of e){const e=t.geometry;let r=t.type;const n=0===s?t.minX:t.minY,c=0===s?t.maxX:t.maxY;if(n>=o&&c=i)continue;let u=[];if("Point"===r||"MultiPoint"===r)$(e,u,o,i,s);else if("LineString"===r)K(e,u,o,i,s,!1,a.lineMetrics);else if("MultiLineString"===r)ee(e,u,o,i,s,!1);else if("Polygon"===r)ee(e,u,o,i,s,!0);else if("MultiPolygon"===r)for(const t of e){const e=[];ee(t,e,o,i,s,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===r){for(const e of u)l.push(J(t.id,r,e,t.tags));continue}"LineString"!==r&&"MultiLineString"!==r||(1===u.length?(r="LineString",u=u[0]):r="MultiLineString"),"Point"!==r&&"MultiPoint"!==r||(r=3===u.length?"Point":"MultiPoint"),l.push(J(t.id,r,u,t.tags));}}return l.length?l:null}function $(e,t,o,i,s){for(let r=0;r=o&&n<=i&&te(t,e[r],e[r+1],e[r+2]);}}function K(e,t,o,i,s,r,n){let a=Q(e);const l=0===s?oe:ie;let c,u,h=e.start;for(let d=0;do&&(u=l(a,f,g,m,y,o),n&&(a.start=h+c*u)):v>i?w=o&&(u=l(a,f,g,m,y,o),x=!0),w>i&&v<=i&&(u=l(a,f,g,m,y,i),x=!0),!r&&x&&(n&&(a.end=h+c*u),t.push(a),a=Q(e)),n&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===s?f:g;p>=o&&p<=i&&te(a,f,g,e[d+2]),d=a.length-3,r&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&te(a,a[0],a[1],a[2]),a.length&&t.push(a);}function Q(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ee(e,t,o,i,s,r){for(const n of e)K(n,t,o,i,s,r,!1);}function te(e,t,o,i){e.push(t,o,i);}function oe(e,t,o,i,s,r){const n=(r-t)/(i-t);return te(e,r,o+(s-o)*n,1),n}function ie(e,t,o,i,s,r){const n=(r-o)/(s-o);return te(e,t+(i-t)*n,r,1),n}function se(e,t){const o=[];for(let i=0;i0&&t.size<(s?n:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;en)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;s&&function(e,t){let o=0;for(let t=0,i=e.length,s=i-2;t0===t)for(let t=0,o=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=le(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==s){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===s)continue;if(null!=s){const e=s-t;if(o!==r>>e||i!==n>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,v=null,w=null,x=null,b=U(e,u,o-f,o+p,0,d.minX,d.maxX,l),S=U(e,u,o+g,o+m,0,d.minX,d.maxX,l);e=null,b&&(y=U(b,u,i-f,i+p,1,d.minY,d.maxY,l),v=U(b,u,i+g,i+m,1,d.minY,d.maxY,l),b=null),S&&(w=U(S,u,i-f,i+p,1,d.minY,d.maxY,l),x=U(S,u,i+g,i+m,1,d.minY,d.maxY,l),S=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(v||[],t+1,2*o,2*i+1),a.push(w||[],t+1,2*o+1,2*i),a.push(x||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:s,debug:r}=i;if(e<0||e>24)return null;const n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[fe(c,u,h)];return l&&l.source?(r>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),r>1&&console.timeEnd("drilling down"),this.tiles[a]?ne(this.tiles[a],s):null):null}}function fe(e,t,o){return 32*((1<{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(r,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)r.accumulated=e[t],e[t]=s[t].evaluate(r,n);},t}(t)).load((yield this._pendingData).features):(s=yield this._pendingData,new de(s,t.geojsonVtOptions)),this.loaded={};const o={};if(i){const e=i.finish();e&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}return o}catch(t){if(delete this._pendingRequest,e.bB(t))return {abandoned:!0};throw t}var s;}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){let i=yield this.loadGeoJSON(t,o);if(delete this._pendingRequest,"object"!=typeof i)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(c(i,!0),t.filter){const o=e.bC(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const s=i.features.filter((e=>o.value.evaluate({zoom:0},e)));i={type:"FeatureCollection",features:s};}return i}))}loadGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){const{promoteId:i}=t;if(t.request){const s=yield e.h(t.request,o);return this._dataUpdateable=pe(s.data,i)?me(s.data,i):void 0,s.data}if("string"==typeof t.data)try{const e=JSON.parse(t.data);return this._dataUpdateable=pe(e,i)?me(e,i):void 0,e}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return function(e,t,o){var i,s,r,n;if(t.removeAll&&e.clear(),t.remove)for(const o of t.remove)e.delete(o);if(t.add)for(const i of t.add){const t=ge(i,o);null!=t&&e.set(t,i);}if(t.update)for(const o of t.update){let t=e.get(o.id);if(null==t)continue;const a=!o.removeAllProperties&&((null===(i=o.removeProperties)||void 0===i?void 0:i.length)>0||(null===(s=o.addOrUpdateProperties)||void 0===s?void 0:s.length)>0);if((o.newGeometry||o.removeAllProperties||a)&&(t=Object.assign({},t),e.set(o.id,t),a&&(t.properties=Object.assign({},t.properties))),o.newGeometry&&(t.geometry=o.newGeometry),o.removeAllProperties)t.properties={};else if((null===(r=o.removeProperties)||void 0===r?void 0:r.length)>0)for(const e of o.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:i}of o.addOrUpdateProperties)t.properties[e]=i;}}(this._dataUpdateable,t.dataDiff,i),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class ve{constructor(t){this.self=t,this.actor=new e.F(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.bi,this.self.removeProtocol=e.bj,this.self.registerRTLTextPlugin=t=>{if(e.bD.isParsed())throw new Error("RTL text plugin already registered.");e.bD.setMethods(t);},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,o)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,o.source).removeTile(o);})))),this.actor.registerMessageHandler("GCEZ",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterExpansionZoom(o)})))),this.actor.registerMessageHandler("GCC",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterChildren(o)})))),this.actor.registerMessageHandler("GCL",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterLeaves(o)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,o)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][o.type]||!this.workerSources[t][o.type][o.source])return;const e=this.workerSources[t][o.type][o.source];delete this.workerSources[t][o.type][o.source],void 0!==e.removeSource&&e.removeSource(o);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t];})))),this.actor.registerMessageHandler("SR",((t,o)=>e._(this,void 0,void 0,(function*(){this.referrer=o;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,o)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(o);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(o.layers,o.removedIds);})))),this.actor.registerMessageHandler("SL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(o);}))));}_setImages(t,o){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=o;for(const e in this.workerSources[t]){const i=this.workerSources[t][e];for(const e in i)i[e].availableImages=o;}}))}_syncRTLPluginState(t,o){return e._(this,void 0,void 0,(function*(){if(e.bD.isParsed())return e.bD.getState();if("loading"!==o.pluginStatus)return e.bD.setState(o),o;const t=o.pluginURL;if(this.self.importScripts(t),e.bD.isParsed()){const o={pluginStatus:"loaded",pluginURL:t};return e.bD.setState(o),o}throw e.bD.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let o=this.layerIndexes[e];return o||(o=this.layerIndexes[e]=new t),o}_getWorkerSource(e,t,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][o]){const i={sendAsync:(t,o)=>(t.targetMapId=e,this.actor.sendAsync(t,o))};switch(t){case"vector":this.workerSources[e][t][o]=new r(i,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][o]=new ye(i,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][o]=new this.externalWorkerSourceTypes[t](i,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][o]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ve(self)),ve})); +define("worker",["./shared"],(function(e){"use strict";class t{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const o of t){this._layerConfigs[o.id]=o;const t=this._layers[o.id]=e.bA(o);t._featureFilter=e.a7(t.filter),this.keyCache[o.id]&&delete this.keyCache[o.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=e.ct(Object.values(this._layerConfigs),this.keyCache);for(const e of i){const t=e.map((e=>this._layers[e.id])),o=t[0];if("none"===o.visibility)continue;const i=o.source||"";let r=this.familiesBySource[i];r||(r=this.familiesBySource[i]={});const s=o.sourceLayer||"_geojsonTileLayer";let n=r[s];n||(n=r[s]=[]),n.push(t);}}}class o{constructor(t){const o={},i=[];for(const e in t){const r=t[e],s=o[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const o={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};i.push(o),s[e]={rect:o,metrics:t.metrics};}}const{w:r,h:s}=e.p(i),n=new e.q({width:r||1,height:s||1});for(const i in t){const r=t[i];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const a=o[i][t].rect;e.q.copy(s.bitmap,n,{x:0,y:0},{x:a.x+1,y:a.y+1},s.bitmap);}}this.image=n,this.positions=o;}}e.cu("GlyphAtlas",o);class i{constructor(t){this.tileID=new e.Y(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[];}parse(t,i,s,n,a){return e._(this,void 0,void 0,(function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a5;const l=new e.cv(Object.keys(t.layers).sort()),c=new e.cw(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:s,subdivisionGranularity:a},d=i.familiesBySource[this.source];for(const o in d){const i=t.layers[o];if(!i)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${o}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const n=l.encode(o),a=[];for(let e=0;e=o.maxzoom||"none"!==o.visibility&&(r(t,this.zoom,s),(u[o.id]=o.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:n,sourceID:this.source})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map((e=>e.id))));}}const f=e.bF(h.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let g=Promise.resolve({});if(Object.keys(f).length){const e=new AbortController;this.inFlightDependencies.push(e),g=n.sendAsync({type:"GG",data:{stacks:f,source:this.source,tileID:this.tileID,type:"glyphs"}},e);}const p=Object.keys(h.iconDependencies);let m=Promise.resolve({});if(p.length){const e=new AbortController;this.inFlightDependencies.push(e),m=n.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},e);}const y=Object.keys(h.patternDependencies);let v=Promise.resolve({});if(y.length){const e=new AbortController;this.inFlightDependencies.push(e),v=n.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},e);}const[w,x,_]=yield Promise.all([g,m,v]),b=new o(w),M=new e.cx(x,_);for(const t in u){const o=u[t];o instanceof e.a6?(r(o.layers,this.zoom,s),e.cy({bucket:o,glyphMap:w,glyphPositions:b.positions,imageMap:x,imagePositions:M.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):o.hasPattern&&(o instanceof e.cz||o instanceof e.cA||o instanceof e.cB)&&(r(o.layers,this.zoom,s),o.addFeatures(h,this.tileID.canonical,M.patternPositions));}return this.status="done",{buckets:Object.values(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:M,glyphMap:this.returnDependencies?w:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function r(t,o,i){const r=new e.C(o);for(const e of t)e.recalculate(r,i);}class s{constructor(e,t,o){this.actor=e,this.layerIndex=t,this.availableImages=o,this.fetching={},this.loading={},this.loaded={};}loadVectorTile(t,o){return e._(this,void 0,void 0,(function*(){const i=yield e.n(t.request,o);try{return {vectorTile:new e.cC.VectorTile(new e.cD(i.data)),rawData:i.data,cacheControl:i.cacheControl,expires:i.expires}}catch(e){const o=new Uint8Array(i.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===o[0]&&139===o[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}}))}loadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cE(t.request),s=new i(t);this.loading[o]=s;const n=new AbortController;s.abort=n;try{const i=yield this.loadVectorTile(t,n);if(delete this.loading[o],!i)return null;const a=i.rawData,l={};i.expires&&(l.expires=i.expires),i.cacheControl&&(l.cacheControl=i.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)));}s.vectorTile=i.vectorTile;const u=s.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[o]=s,this.fetching[o]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[o];}}catch(e){throw delete this.loading[o],s.status="done",this.loaded[o]=s,e}}))}reloadTile(t){return e._(this,void 0,void 0,(function*(){const o=t.uid;if(!this.loaded||!this.loaded[o])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const i=this.loaded[o];if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=yield i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let s;if(this.fetching[o]){const{rawTileData:t,cacheControl:i,resourceTiming:n}=this.fetching[o];delete this.fetching[o],s=e.e({rawTileData:t.slice(0)},r,i,n);}else s=r;return s}if("done"===i.status&&i.vectorTile)return i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){const e=this.loading,o=t.uid;e&&e[o]&&e[o].abort&&(e[o].abort.abort(),delete e[o]);}))}removeTile(t){return e._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid];}))}}class n{constructor(){this.loaded={};}loadTile(t){return e._(this,void 0,void 0,(function*(){const{uid:o,encoding:i,rawImageData:r,redFactor:s,greenFactor:n,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cF(r,-1,-1,c,u)):r,d=new e.cG(o,h,i,s,n,a,l);return this.loaded=this.loaded||{},this.loaded[o]=d,d}))}removeTile(e){const t=this.loaded,o=e.uid;t&&t[o]&&delete t[o];}}var a,l,c=function(){if(l)return a;function e(e,o){if(0!==e.length){t(e[0],o);for(var i=1;i=Math.abs(a)?o-l+a:a-l+o,o=l;}o+i>=0!=!!t&&e.reverse();}return l=1,a=function t(o,i){var r,s=o&&o.type;if("FeatureCollection"===s)for(r=0;r>31}function c(e,t){for(var o=e.loadGeometry(),i=e.type,r=0,s=0,n=o.length,c=0;ce},_=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;const M=3,S=5,I=6;class P{constructor(e){this.options=Object.assign(Object.create(x),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:o,maxZoom:i}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const s=[];for(let t=0;t=o;e--){const o=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-o);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let o=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)o=-180,r=180;else if(o>r){const e=this.getClusters([o,i,180,s],t),n=this.getClusters([-180,i,r,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(D(o),C(s),D(r),C(i)),l=n.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+S]>1?k(l,t,this.clusterProps):this.points[l[t+M]]);}return c}getChildren(e){const t=this._getOriginId(e),o=this._getOriginZoom(e),i="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(i);const s=r.data;if(t*this.stride>=s.length)throw new Error(i);const n=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=r.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const o=t*this.stride;s[o+4]===e&&l.push(s[o+S]>1?k(s,o,this.clusterProps):this.points[s[o+M]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,o){const i=[];return this._appendLeaves(i,e,t=t||10,o=o||0,0),i}getTile(e,t,o){const i=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(o-a)/r,c=(o+1+a)/r,u={features:[]};return this._addTileFeatures(i.range((t-a)/r,l,(t+1+a)/r,c),i.data,t,o,r,u),0===t&&this._addTileFeatures(i.range(1-a/r,l,1,c),i.data,r,o,r,u),t===r-1&&this._addTileFeatures(i.range(0,l,a/r,c),i.data,-1,o,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const o=this.getChildren(e);if(t++,1!==o.length)break;e=o[0].properties.cluster_id;}return t}_appendLeaves(e,t,o,i,r){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?r+s.point_count<=i?r+=s.point_count:r=this._appendLeaves(e,s.cluster_id,o,i,r):r1;let l,c,u;if(a)l=T(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const o=this.points[t[e+M]];l=o.properties;const[i,r]=o.geometry.coordinates;c=D(i),u=C(r);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-o)),Math.round(this.options.extent*(u*r-i))]],tags:l};let d;d=a||this.options.generateId?t[e+M]:this.points[t[e+M]].id,void 0!==d&&(h.id=d),s.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:o,extent:i,reduce:r,minPoints:s}=this.options,n=o/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let o=0;ot&&(f+=a[o+S]);}if(f>d&&f>=s){let e,s=i*d,n=u*d,g=-1;const p=((o/c|0)<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+S];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=p,r&&(e||(e=this._map(a,o,!0),g=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)));}a[o+4]=p,l.push(s/f,n/f,1/0,p,-1,f),r&&l.push(g);}else {for(let e=0;e1)for(const e of h){const o=e*c;if(!(a[o+2]<=t)){a[o+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,o){if(e[t+S]>1){const i=this.clusterProps[e[t+I]];return o?Object.assign({},i):i}const i=this.points[e[t+M]].properties,r=this.options.map(i);return o&&r===i?Object.assign({},r):r}}function k(e,t,o){return {type:"Feature",id:e[t+M],properties:T(e,t,o),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),O(e[t+1])]}};var i;}function T(e,t,o){const i=e[t+S],r=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,s=e[t+I],n=-1===s?{}:Object.assign({},o[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+M],point_count:i,point_count_abbreviated:r})}function D(e){return e/360+.5}function C(e){const t=Math.sin(e*Math.PI/180),o=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return o<0?0:o>1?1:o}function O(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function L(e,t,o,i){let r=i;const s=t+(o-t>>1);let n,a=o-t;const l=e[t],c=e[t+1],u=e[o],h=e[o+1];for(let i=t+3;ir)n=i,r=t;else if(t===r){const e=Math.abs(i-s);ei&&(n-t>3&&L(e,t,n,i),e[n+2]=r,o-n>3&&L(e,n,o,i));}function F(e,t,o,i,r,s){let n=r-o,a=s-i;if(0!==n||0!==a){const l=((e-o)*n+(t-i)*a)/(n*n+a*a);l>1?(o=r,i=s):l>0&&(o+=n*l,i+=a*l);}return n=e-o,a=t-i,n*n+a*a}function G(e,t,o,i){const r={id:null==e?null:e,type:t,geometry:o,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)z(r,o);else if("Polygon"===t)z(r,o[0]);else if("MultiLineString"===t)for(const e of o)z(r,e);else if("MultiPolygon"===t)for(const e of o)z(r,e[0]);return r}function z(e,t){for(let o=0;o0&&(n+=i?(r*l-a*s)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-s,2))),r=a,s=l;}const a=t.length-3;t[2]=1,L(t,0,a,o),t[a+2]=1,t.size=Math.abs(n),t.start=0,t.end=t.size;}function Z(e,t,o,i){for(let r=0;r1?1:o}function W(e,t,o,i,r,s,n,a){if(i/=t,s>=(o/=t)&&n=i)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const n=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(n>=o&&c=i)continue;let u=[];if("Point"===s||"MultiPoint"===s)R(e,u,o,i,r);else if("LineString"===s)Y(e,u,o,i,r,!1,a.lineMetrics);else if("MultiLineString"===s)q(e,u,o,i,r,!1);else if("Polygon"===s)q(e,u,o,i,r,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];q(t,e,o,i,r,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===s){for(const e of u)l.push(G(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===u.length?(s="LineString",u=u[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===u.length?"Point":"MultiPoint"),l.push(G(t.id,s,u,t.tags));}}return l.length?l:null}function R(e,t,o,i,r){for(let s=0;s=o&&n<=i&&H(t,e[s],e[s+1],e[s+2]);}}function Y(e,t,o,i,r,s,n){let a=V(e);const l=0===r?X:B;let c,u,h=e.start;for(let d=0;do&&(u=l(a,f,g,m,y,o),n&&(a.start=h+c*u)):v>i?w=o&&(u=l(a,f,g,m,y,o),x=!0),w>i&&v<=i&&(u=l(a,f,g,m,y,i),x=!0),!s&&x&&(n&&(a.end=h+c*u),t.push(a),a=V(e)),n&&(h+=c);}let d=e.length-3;const f=e[d],g=e[d+1],p=0===r?f:g;p>=o&&p<=i&&H(a,f,g,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&H(a,a[0],a[1],a[2]),a.length&&t.push(a);}function V(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function q(e,t,o,i,r,s){for(const n of e)Y(n,t,o,i,r,s,!1);}function H(e,t,o,i){e.push(t,o,i);}function X(e,t,o,i,r,s){const n=(s-t)/(i-t);return H(e,s,o+(r-o)*n,1),n}function B(e,t,o,i,r,s){const n=(s-o)/(r-o);return H(e,t+(i-t)*n,s,1),n}function $(e,t){const o=[];for(let i=0;i0&&t.size<(r?n:i))return void(o.numPoints+=t.length/3);const a=[];for(let e=0;en)&&(o.numSimplified++,a.push(t[e],t[e+1])),o.numPoints++;r&&function(e,t){let o=0;for(let t=0,i=e.length,r=i-2;t0===t)for(let t=0,o=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const o=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=ee(e,t,o,i,l),this.tileCoords.push({z:t,x:o,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,o,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(o!==s>>e||i!==n>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,g=.5-f,p=.5+f,m=1+f;let y=null,v=null,w=null,x=null,_=W(e,u,o-f,o+p,0,d.minX,d.maxX,l),b=W(e,u,o+g,o+m,0,d.minX,d.maxX,l);e=null,_&&(y=W(_,u,i-f,i+p,1,d.minY,d.maxY,l),v=W(_,u,i+g,i+m,1,d.minY,d.maxY,l),_=null),b&&(w=W(b,u,i-f,i+p,1,d.minY,d.maxY,l),x=W(b,u,i+g,i+m,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*o,2*i),a.push(v||[],t+1,2*o,2*i+1),a.push(w||[],t+1,2*o+1,2*i),a.push(x||[],t+1,2*o+1,2*i+1);}}getTile(e,t,o){e=+e,t=+t,o=+o;const i=this.options,{extent:r,debug:s}=i;if(e<0||e>24)return null;const n=1<1&&console.log("drilling down to z%d-%d-%d",e,t,o);let l,c=e,u=t,h=o;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[se(c,u,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,o),s>1&&console.timeEnd("drilling down"),this.tiles[a]?K(this.tiles[a],r):null):null}}function se(e,t,o){return 32*((1<{n.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=r[t].evaluate(s,n);},t}(t)).load((yield this._pendingData).features):(r=yield this._pendingData,new re(r,t.geojsonVtOptions)),this.loaded={};const o={};if(i){const e=i.finish();e&&(o.resourceTiming={},o.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)));}return o}catch(t){if(delete this._pendingRequest,e.cp(t))return {abandoned:!0};throw t}var r;}))}getData(){return e._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){let i=yield this.loadGeoJSON(t,o);if(delete this._pendingRequest,"object"!=typeof i)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(i,!0),t.filter){const o=e.cL(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const r=i.features.filter((e=>o.value.evaluate({zoom:0},e)));i={type:"FeatureCollection",features:r};}return i}))}loadGeoJSON(t,o){return e._(this,void 0,void 0,(function*(){const{promoteId:i}=t;if(t.request){const r=yield e.j(t.request,o);return this._dataUpdateable=ae(r.data,i)?le(r.data,i):void 0,r.data}if("string"==typeof t.data)try{const e=JSON.parse(t.data);return this._dataUpdateable=ae(e,i)?le(e,i):void 0,e}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return function(e,t,o){var i,r,s,n;if(t.removeAll&&e.clear(),t.remove)for(const o of t.remove)e.delete(o);if(t.add)for(const i of t.add){const t=ne(i,o);null!=t&&e.set(t,i);}if(t.update)for(const o of t.update){let t=e.get(o.id);if(null==t)continue;const a=!o.removeAllProperties&&((null===(i=o.removeProperties)||void 0===i?void 0:i.length)>0||(null===(r=o.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((o.newGeometry||o.removeAllProperties||a)&&(t=Object.assign({},t),e.set(o.id,t),a&&(t.properties=Object.assign({},t.properties))),o.newGeometry&&(t.geometry=o.newGeometry),o.removeAllProperties)t.properties={};else if((null===(s=o.removeProperties)||void 0===s?void 0:s.length)>0)for(const e of o.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0)for(const{key:e,value:i}of o.addOrUpdateProperties)t.properties[e]=i;}}(this._dataUpdateable,t.dataDiff,i),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(t){return e._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort();}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class ue{constructor(t){this.self=t,this.actor=new e.H(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t;},this.self.addProtocol=e.cr,this.self.removeProtocol=e.cs,this.self.registerRTLTextPlugin=t=>{e.cM.setMethods(t);},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,o)=>e._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,o.source).removeTile(o);})))),this.actor.registerMessageHandler("GCEZ",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterExpansionZoom(o)})))),this.actor.registerMessageHandler("GCC",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterChildren(o)})))),this.actor.registerMessageHandler("GCL",((t,o)=>e._(this,void 0,void 0,(function*(){return this._getWorkerSource(t,o.type,o.source).getClusterLeaves(o)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,o)=>e._(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][o.type]||!this.workerSources[t][o.type][o.source])return;const e=this.workerSources[t][o.type][o.source];delete this.workerSources[t][o.type][o.source],void 0!==e.removeSource&&e.removeSource(o);})))),this.actor.registerMessageHandler("RM",(t=>e._(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t];})))),this.actor.registerMessageHandler("SR",((t,o)=>e._(this,void 0,void 0,(function*(){this.referrer=o;})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,o)=>e._(this,void 0,void 0,(function*(){this.self.importScripts(o);})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(o.layers,o.removedIds);})))),this.actor.registerMessageHandler("SL",((t,o)=>e._(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(o);}))));}_setImages(t,o){return e._(this,void 0,void 0,(function*(){this.availableImages[t]=o;for(const e in this.workerSources[t]){const i=this.workerSources[t][e];for(const e in i)i[e].availableImages=o;}}))}_syncRTLPluginState(t,o){return e._(this,void 0,void 0,(function*(){return yield e.cM.syncState(o,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let o=this.layerIndexes[e];return o||(o=this.layerIndexes[e]=new t),o}_getWorkerSource(e,t,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][o]){const i={sendAsync:(t,o)=>(t.targetMapId=e,this.actor.sendAsync(t,o))};switch(t){case "vector":this.workerSources[e][t][o]=new s(i,this._getLayerIndex(e),this._getAvailableImages(e));break;case "geojson":this.workerSources[e][t][o]=new ce(i,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][o]=new this.externalWorkerSourceTypes[t](i,this._getLayerIndex(e),this._getAvailableImages(e));}}return this.workerSources[e][t][o]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue})); -define("index",["exports","./shared"],(function(t,e){"use strict";var i="4.7.1";let a,s;const o={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:t=>new Promise(((i,a)=>{const s=requestAnimationFrame(i);t.signal.addEventListener("abort",(()=>{cancelAnimationFrame(s),a(e.c());}));})),getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>(a||(a=document.createElement("a")),a.href=t,a.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==s&&(s=matchMedia("(prefers-reduced-motion: reduce)")),s.matches)}};class r{static testProp(t){if(!r.docStyle)return t[0];for(let e=0;e{window.removeEventListener("click",r.suppressClickInternal,!0);}),0);}static getScale(t){const e=t.getBoundingClientRect();return {x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}static getPoint(t,i,a){const s=i.boundingClientRect;return new e.P((a.clientX-s.left)/i.x-t.clientLeft,(a.clientY-s.top)/i.y-t.clientTop)}static mousePos(t,e){const i=r.getScale(t);return r.getPoint(t,i,e)}static touchPos(t,e){const i=[],a=r.getScale(t);for(let s=0;s{l&&d(l),l=null,u=!0;},h.onerror=()=>{c=!0,l=null;},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(t){let i,a,s,o;t.resetRequestQueue=()=>{i=[],a=0,s=0,o={};},t.addThrottleControl=t=>{const e=s++;return o[e]=t,e},t.removeThrottleControl=t=>{delete o[t],l();},t.getImage=(t,a,s=!0)=>new Promise(((o,r)=>{n.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),e.e(t,{type:"image"}),i.push({abortController:a,requestParameters:t,supportImageRefresh:s,state:"queued",onError:t=>{r(t);},onSuccess:t=>{o(t);}}),l();}));const r=t=>e._(this,void 0,void 0,(function*(){t.state="running";const{requestParameters:i,supportImageRefresh:s,onError:o,onSuccess:r,abortController:n}=t,c=!1===s&&!e.i(self)&&!e.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((t,e)=>t&&"accept"===e),!0));a++;const u=c?h(i,n):e.m(i,n);try{const i=yield u;delete t.abortController,t.state="completed",i.data instanceof HTMLImageElement||e.b(i.data)?r(i):i.data&&r({data:yield(d=i.data,"function"==typeof createImageBitmap?e.d(d):e.f(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(e){delete t.abortController,o(e);}finally{a--,l();}var d;})),l=()=>{const t=(()=>{for(const t of Object.keys(o))if(o[t]())return !0;return !1})()?e.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:e.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let e=a;e0;e++){const t=i.shift();t.abortController.signal.aborted?e--:r(t);}},h=(t,i)=>new Promise(((a,s)=>{const o=new Image,r=t.url,n=t.credentials;n&&"include"===n?o.crossOrigin="use-credentials":(n&&"same-origin"===n||!e.s(r))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{o.src="",s(e.c());})),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,a({data:o});},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||s(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},o.src=r;}));}(_||(_={})),_.resetRequestQueue();class p{constructor(t){this._transformRequestFn=t;}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t;}}function m(t){var i=new e.A(3);return i[0]=t[0],i[1]=t[1],i[2]=t[2],i}var f,g=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t};f=new e.A(3),e.A!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0);var v=function(t){var e=t[0],i=t[1];return e*e+i*i};function x(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const i=[];for(const{id:a,url:s}of t){const t=`${a}${s}`;-1===i.indexOf(t)&&(i.push(t),e.push({id:a,url:s}));}}return e}function y(t,e,i){const a=t.split("?");return a[0]+=`${e}${i}`,a.join("?")}!function(){var t=new e.A(2);e.A!=Float32Array&&(t[0]=0,t[1]=0);}();class b{constructor(t,e,i,a){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,a);}update(t,i,a){const{width:s,height:o}=t,r=!(this.size&&this.size[0]===s&&this.size[1]===o||a),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),r)this.size=[s,o],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,t):l.texImage2D(l.TEXTURE_2D,0,this.format,s,o,0,this.format,l.UNSIGNED_BYTE,t.data);else {const{x:i,y:r}=a||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texSubImage2D(l.TEXTURE_2D,0,i,r,l.RGBA,l.UNSIGNED_BYTE,t):l.texSubImage2D(l.TEXTURE_2D,0,i,r,s,o,l.RGBA,l.UNSIGNED_BYTE,t.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D);}bind(t,e,i){const{context:a}=this,{gl:s}=a;s.bindTexture(s.TEXTURE_2D,this.texture),i!==s.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=s.LINEAR),t!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,e),this.wrap=e);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}}function w(t){const{userImage:e}=t;return !!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class T extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[];}}getImage(t){const i=this.images[t];if(i&&!i.data&&i.spriteData){const t=i.spriteData;i.data=new e.R({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),i.spriteData=null;}return i}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e);}_validate(t,i){let a=!0;const s=i.data||i.spriteData;return this._validateStretch(i.stretchX,s&&s.width)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "stretchX" value`))),a=!1),this._validateStretch(i.stretchY,s&&s.height)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "stretchY" value`))),a=!1),this._validateContent(i.content,i)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "content" value`))),a=!1),a}_validateStretch(t,e){if(!t)return !0;let i=0;for(const a of t){if(a[0]{let a=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(a=!1);this.isLoaded()||a?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e});}))}_getImagesForIds(t){const i={};for(const a of t){let t=this.getImage(a);t||(this.fire(new e.k("styleimagemissing",{id:a})),t=this.getImage(a)),t?i[a]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${a}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return i}getPixelSize(){const{width:t,height:e}=this.atlasImage;return {width:t,height:e}}getPattern(t){const i=this.patterns[t],a=this.getImage(t);if(!a)return null;if(i&&i.position.version===a.version)return i.position;if(i)i.position.version=a.version;else {const i={w:a.data.width+2,h:a.data.height+2,x:0,y:0},s=new e.I(i,a);this.patterns[t]={bin:i,position:s};}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new b(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE);}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:i,h:a}=e.p(t),s=this.atlasImage;s.resize({width:i||1,height:a||1});for(const t in this.patterns){const{bin:i}=this.patterns[t],a=i.x+1,o=i.y+1,r=this.getImage(t).data,n=r.width,l=r.height;e.R.copy(r,s,{x:0,y:0},{x:a,y:o},{width:n,height:l}),e.R.copy(r,s,{x:0,y:l-1},{x:a,y:o-1},{width:n,height:1}),e.R.copy(r,s,{x:0,y:0},{x:a,y:o+l},{width:n,height:1}),e.R.copy(r,s,{x:n-1,y:0},{x:a-1,y:o},{width:1,height:l}),e.R.copy(r,s,{x:0,y:0},{x:a+n,y:o},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(t){for(const i of t){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const t=this.getImage(i);t||e.w(`Image with ID: "${i}" was not found`),w(t)&&this.updateImage(i,t);}}}const I=1e20;function E(t,e,i,a,s,o,r,n,l){for(let h=e;h-1);l++,o[l]=n,r[l]=h,r[l+1]=I;}for(let n=0,l=0;n65535)throw new Error("glyphs > 65535 not supported");if(e.ranges[s])return {stack:t,id:i,glyph:a};if(!this.url)throw new Error("glyphsUrl is not set");if(!e.requests[s]){const i=C.loadGlyphRange(t,s,this.url,this.requestManager);e.requests[s]=i;}const o=yield e.requests[s];for(const t in o)this._doesCharSupportLocalGlyph(+t)||(e.glyphs[+t]=o[+t]);return e.ranges[s]=!0,{stack:t,id:i,glyph:o[i]||null}}))}_doesCharSupportLocalGlyph(t){return !!this.localIdeographFontFamily&&/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(t))}_tinySDF(t,i,a){const s=this.localIdeographFontFamily;if(!s)return;if(!this._doesCharSupportLocalGlyph(a))return;let o=t.tinySDF;if(!o){let e="400";/bold/i.test(i)?e="900":/medium/i.test(i)?e="500":/light/i.test(i)&&(e="200"),o=t.tinySDF=new C.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:s,fontWeight:e});}const r=o.draw(String.fromCharCode(a));return {id:a,bitmap:new e.o({width:r.width||60,height:r.height||60},r.data),metrics:{width:r.glyphWidth/2||24,height:r.glyphHeight/2||24,left:r.glyphLeft/2+.5||0,top:r.glyphTop/2-27.5||-8,advance:r.glyphAdvance/2||24,isDoubleResolution:!0}}}}C.loadGlyphRange=function(t,i,a,s){return e._(this,void 0,void 0,(function*(){const o=256*i,r=o+255,n=s.transformRequest(a.replace("{fontstack}",t).replace("{range}",`${o}-${r}`),"Glyphs"),l=yield e.l(n,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${r}`);const h={};for(const t of e.n(l.data))h[t.id]=t;return h}))},C.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:a=.25,fontFamily:s="sans-serif",fontWeight:o="normal",fontStyle:r="normal"}={}){this.buffer=e,this.cutoff=a,this.radius=i;const n=this.size=t+4*e,l=this._createCanvas(n),h=this.ctx=l.getContext("2d",{willReadFrequently:!0});h.font=`${r} ${o} ${t}px ${s}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:a,actualBoundingBoxLeft:s,actualBoundingBoxRight:o}=this.ctx.measureText(t),r=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-s))),l=Math.min(this.size-this.buffer,r+Math.ceil(a)),h=n+2*this.buffer,c=l+2*this.buffer,u=Math.max(h*c,0),d=new Uint8ClampedArray(u),_={data:d,width:h,height:c,glyphWidth:n,glyphHeight:l,glyphTop:r,glyphLeft:0,glyphAdvance:e};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(t,m,m+r);const v=p.getImageData(m,m,n,l);g.fill(I,0,u),f.fill(0,0,u);for(let t=0;t0?t*t:0,f[a]=t<0?t*t:0;}}E(g,0,0,h,c,h,this.f,this.v,this.z),E(f,m,m,n,l,h,this.f,this.v,this.z);for(let t=0;t1&&(r=t[++o]);const l=Math.abs(n-r.left),h=Math.abs(n-r.right),c=Math.min(l,h);let u;const d=e/i*(a+1);if(r.isDash){const t=a-Math.abs(d);u=Math.sqrt(c*c+t*t);}else u=a-Math.sqrt(c*c+d*d);this.data[s+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],a=t[e+1];i.zeroLength?t.splice(e,1):a&&a.isDash===i.isDash&&(a.left=i.left,t.splice(e,1));}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const a=this.width*this.nextRow;let s=0,o=t[s];for(let e=0;e1&&(o=t[++s]);const i=Math.abs(e-o.left),r=Math.abs(e-o.right),n=Math.min(i,r);this.data[a+e]=Math.max(0,Math.min(255,(o.isDash?n:-n)+128));}}addDash(t,i){const a=i?7:0,s=2*a+1;if(this.nextRow+s>this.height)return e.w("LineAtlas out of space"),null;let o=0;for(let e=0;e{t.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[k]}numActive(){return Object.keys(this.active).length}}const F=Math.floor(o.hardwareConcurrency/2);let B,O;function N(){return B||(B=new L),B}L.workerCount=e.C(globalThis)?Math.max(Math.min(F,3),1):1;class U{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=i;const a=this.workerPool.acquire(i);for(let t=0;t{t.remove();})),this.actors=[],t&&this.workerPool.release(this.id);}registerMessageHandler(t,e){for(const i of this.actors)i.registerMessageHandler(t,e);}}function j(){return O||(O=new U(N(),e.G),O.registerMessageHandler("GR",((t,i,a)=>e.m(i,a)))),O}function Z(t,i){const a=e.H();return e.J(a,a,[1,1,0]),e.K(a,a,[.5*t.width,.5*t.height,1]),e.L(a,a,t.calculatePosMatrix(i.toUnwrapped()))}function q(t,e,i,a,s,o){const r=function(t,e,i){if(t)for(const a of t){const t=e[a];if(t&&t.source===i&&"fill-extrusion"===t.type)return !0}else for(const t in e){const a=e[t];if(a.source===i&&"fill-extrusion"===a.type)return !0}return !1}(s&&s.layers,e,t.id),n=o.maxPitchScaleFactor(),l=t.tilesIn(a,n,r);l.sort(V);const h=[];for(const a of l)h.push({wrappedTileID:a.tileID.wrapped().key,queryResults:a.tile.queryRenderedFeatures(e,i,t._state,a.queryGeometry,a.cameraQueryGeometry,a.scale,s,o,n,Z(t.transform,a.tileID))});const c=function(t){const e={},i={};for(const a of t){const t=a.queryResults,s=a.wrappedTileID,o=i[s]=i[s]||{};for(const i in t){const a=t[i],s=o[i]=o[i]||{},r=e[i]=e[i]||[];for(const t of a)s[t.featureIndex]||(s[t.featureIndex]=!0,r.push(t));}}return e}(h);for(const e in c)c[e].forEach((e=>{const i=e.feature,a=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=a;}));return c}function V(t,e){const i=t.tileID,a=e.tileID;return i.overscaledZ-a.overscaledZ||i.canonical.y-a.canonical.y||i.wrap-a.wrap||i.canonical.x-a.canonical.x}function G(t,i,a){return e._(this,void 0,void 0,(function*(){let s=t;if(t.url?s=(yield e.h(i.transformRequest(t.url,"Source"),a)).data:yield o.frameAsync(a),!s)return null;const r=e.M(e.e(s,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in s&&s.vector_layers&&(r.vectorLayerIds=s.vector_layers.map((t=>t.id))),r}))}class H{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])));}setNorthEast(t){return this._ne=t instanceof e.N?new e.N(t.lng,t.lat):e.N.convert(t),this}setSouthWest(t){return this._sw=t instanceof e.N?new e.N(t.lng,t.lat):e.N.convert(t),this}extend(t){const i=this._sw,a=this._ne;let s,o;if(t instanceof e.N)s=t,o=t;else {if(!(t instanceof H))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(H.convert(t)):this.extend(e.N.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(e.N.convert(t)):this;if(s=t._sw,o=t._ne,!s||!o)return this}return i||a?(i.lng=Math.min(s.lng,i.lng),i.lat=Math.min(s.lat,i.lat),a.lng=Math.max(o.lng,a.lng),a.lat=Math.max(o.lat,a.lat)):(this._sw=new e.N(s.lng,s.lat),this._ne=new e.N(o.lng,o.lat)),this}getCenter(){return new e.N((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new e.N(this.getWest(),this.getNorth())}getSouthEast(){return new e.N(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(t){const{lng:i,lat:a}=e.N.convert(t);let s=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&s}static convert(t){return t instanceof H?t:t?new H(t):t}static fromLngLat(t,i=0){const a=360*i/40075017,s=a/Math.cos(Math.PI/180*t.lat);return new H(new e.N(t.lng-s,t.lat-a),new e.N(t.lng+s,t.lat+a))}adjustAntiMeridian(){const t=new e.N(this._sw.lng,this._sw.lat),i=new e.N(this._ne.lng,this._ne.lat);return new H(t,t.lng>i.lng?new e.N(i.lng+360,i.lat):i)}}class W{constructor(t,e,i){this.bounds=H.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24;}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),a=Math.floor(e.O(this.bounds.getWest())*i),s=Math.floor(e.Q(this.bounds.getNorth())*i),o=Math.ceil(e.O(this.bounds.getEast())*i),r=Math.ceil(e.Q(this.bounds.getSouth())*i);return t.x>=a&&t.x=s&&t.y{this._options.tiles=t;})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return e.e({},this._options)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(e,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};i.request.collectResourceTiming=this._collectResourceTiming;let a="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise(((e,i)=>{t.reloadPromise={resolve:e,reject:i};}))}else t.actor=this.dispatcher.getActor(),a="LT";t.abortController=new AbortController;try{const e=yield t.actor.sendAsync({type:a,data:i},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e);}catch(e){if(delete t.abortController,t.aborted)return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null);}}))}_afterTileLoadWorkerResponse(t,e){if(e&&e.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.loadVectorData(e,this.map.painter),t.reloadPromise){const e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject);}}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}));}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class X extends e.E{constructor(t,i,a,s){super(),this.id=t,this.dispatcher=a,this.setEventedParent(s),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},i),e.e(this,e.M(i,["url","scheme","tileSize"]));}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield G(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,t&&(e.e(this,t),t.bounds&&(this.tileBounds=new W(t.bounds,this.minzoom,this.maxzoom)),this.fire(new e.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.k("data",{dataType:"source",sourceDataType:"content"})));}catch(t){this._tileJSONRequest=null,this.fire(new e.j(t));}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load();}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t;})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t;})),this}serialize(){return e.e({},this._options)}hasTile(t){return !this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const i=yield _.getImage(this.map._requestManager.transformRequest(e,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const e=this.map.painter.context,a=e.gl,s=i.data;t.texture=this.map.painter.getTileTexture(s.width),t.texture?t.texture.update(s,{useMipmap:!0}):(t.texture=new b(e,s,a.RGBA,{useMipmap:!0}),t.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST)),t.state="loaded";}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController);}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture);}))}hasTransition(){return !1}}class K extends X{constructor(t,i,a,s){super(t,i,a,s),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(t){return e._(this,void 0,void 0,(function*(){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),a=this.map._requestManager.transformRequest(i,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const i=yield _.getImage(a,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){const a=i.data;this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const s=e.b(a)&&e.U()?a:yield this.readImageNow(a),o={type:this.type,uid:t.uid,source:this.id,rawImageData:s,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||"expired"===t.state){t.actor=this.dispatcher.getActor();const e=yield t.actor.sendAsync({type:"LDT",data:o});t.dem=e,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded";}}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}readImageNow(t){return e._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&e.V()){const i=t.width+2,a=t.height+2;try{return new e.R({width:i,height:a},yield e.W(t,-1,-1,i,a))}catch(t){}}return o.getImageData(t,1)}))}_getNeighboringTiles(t){const i=t.canonical,a=Math.pow(2,i.z),s=(i.x-1+a)%a,o=0===i.x?t.wrap-1:t.wrap,r=(i.x+1+a)%a,n=i.x+1===a?t.wrap+1:t.wrap,l={};return l[new e.S(t.overscaledZ,o,i.z,s,i.y).key]={backfilled:!1},l[new e.S(t.overscaledZ,n,i.z,r,i.y).key]={backfilled:!1},i.y>0&&(l[new e.S(t.overscaledZ,o,i.z,s,i.y-1).key]={backfilled:!1},l[new e.S(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.S(t.overscaledZ,n,i.z,r,i.y-1).key]={backfilled:!1}),i.y+10&&e.e(s,{resourceTiming:a}),this.fire(new e.k("data",Object.assign(Object.assign({},s),{sourceDataType:"metadata"}))),this.fire(new e.k("data",Object.assign(Object.assign({},s),{sourceDataType:"content"})));}catch(t){if(this._pendingLoads--,this._removed)return void this.fire(new e.k("dataabort",{dataType:"source"}));this.fire(new e.j(t));}}))}loaded(){return 0===this._pendingLoads}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.actor?"RT":"LT";t.actor=this.actor;const i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.abortController=new AbortController;const a=yield this.actor.sendAsync({type:e,data:i},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(a,this.map.painter,"RT"===e);}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0;}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}}var Y=e.Y([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Q extends e.E{constructor(t,e,i,a){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(a),this.options=e;}load(t){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const e=yield _.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,e&&e.data&&(this.image=e.data,t&&(this.coordinates=t),this._finishLoading());}catch(t){this._request=null,this._loaded=!0,this.fire(new e.j(t));}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.k("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(t){this.map=t,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(t){this.coordinates=t;const i=t.map(e.Z.fromLngLat);this.tileID=function(t){let i=1/0,a=1/0,s=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),a=Math.min(a,e.y),s=Math.max(s,e.x),o=Math.max(o,e.y);const r=Math.max(s-i,o-a),n=Math.max(0,Math.floor(-Math.log(r)/Math.LN2)),l=Math.pow(2,n);return new e.a1(n,Math.floor((i+s)/2*l),Math.floor((a+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z;const a=i.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new e.$,this._boundsArray.emplaceBack(a[0].x,a[0].y,0,0),this._boundsArray.emplaceBack(a[1].x,a[1].y,e.X,0),this._boundsArray.emplaceBack(a[3].x,a[3].y,0,e.X),this._boundsArray.emplaceBack(a[2].x,a[2].y,e.X,e.X),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new e.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,Y.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture||(this.texture=new b(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let a=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,a=!0);}a&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(t){return e._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}}class tt extends Q{constructor(t,e,i,a){super(t,e,i,a),this.roundZoom=!0,this.type="video",this.options=e;}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,"Source").url);try{const t=yield e.a3(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading();}catch(t){this.fire(new e.j(t));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.j(new e.a2(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,Y.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new b(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let a=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,a=!0);}a&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class et extends Q{constructor(t,i,a,s){super(t,i,a,s),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new e.j(new e.a2(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.j(new e.a2(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.j(new e.a2(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.j(new e.a2(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.j(new e.a2(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,a=i.gl;this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,Y.members)),this.boundsSegments||(this.boundsSegments=e.a0.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new b(i,this.canvas,a.RGBA,{premultiply:!0});let s=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,s=!0);}s&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of [this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return !0;return !1}}const it={},at=t=>{switch(t){case"geojson":return J;case"image":return Q;case"raster":return X;case"raster-dem":return K;case"vector":return $;case"video":return tt;case"canvas":return et}return it[t]},st="RTLPluginLoaded";class ot extends e.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=j();}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((t=>{throw this.status="error",t}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(t){return e._(this,arguments,void 0,(function*(t,e=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=o.resolveURL(t),!this.url)throw new Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return e._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new e.k(st));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let rt=null;function nt(){return rt||(rt=new ot),rt}class lt{constructor(t,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=e.a4(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){a.layers=t,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=a;}}return i}(t.buckets,i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.a6){if(this.hasSymbolBuckets=!0,!a)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.a6&&i.hasRTLText){this.hasRTLText=!0,nt().lazyLoad();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e));}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage);}else this.collisionBoxArray=new e.a5;}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t);}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new b(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new b(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null);}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture);}queryRenderedFeatures(t,e,i,a,s,o,r,n,l,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:a,cameraQueryGeometry:s,scale:o,tileSize:this.tileSize,pixelPosMatrix:h,transform:n,params:r,queryPadding:this.queryPadding*l},t,e,i):{}}querySourceFeatures(t,i){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const s=a.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",r=s._geojsonTileLayer||s[o];if(!r)return;const n=e.a7(i&&i.filter),{z:l,x:h,y:c}=this.tileID.canonical,u={z:l,x:h,y:c};for(let i=0;it)e=!1;else if(i)if(this.expirationTime{this.remove(t,s);}),i)),this.data[a].push(s),this.order.push(a),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,a=void 0===e?0:this.data[i].indexOf(e),s=this.data[i][a];return this.data[i].splice(a,1),s.timeout&&clearTimeout(s.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}filter(t){const e=[];for(const i in this.data)for(const a of this.data[i])t(a.value)||e.push(a);for(const t of e)this.remove(t.value.tileID,t);}}class ct{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(t,i,a){const s=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][s]=this.stateChanges[t][s]||{},e.e(this.stateChanges[t][s],a),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==s&&(this.deletedStates[t][e]=null);}else if(this.deletedStates[t]&&null===this.deletedStates[t][s]){this.deletedStates[t][s]={};for(const e in this.state[t][s])a[e]||(this.deletedStates[t][s][e]=null);}else for(const e in a)this.deletedStates[t]&&this.deletedStates[t][s]&&null===this.deletedStates[t][s][e]&&delete this.deletedStates[t][s][e];}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const a=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][a]&&(this.deletedStates[t][a]=this.deletedStates[t][a]||{},this.deletedStates[t][a][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][a])for(i in this.deletedStates[t][a]={},this.stateChanges[t][a])this.deletedStates[t][a][i]=null;else this.deletedStates[t][a]=null;else this.deletedStates[t]=null;}getState(t,i){const a=String(i),s=e.e({},(this.state[t]||{})[a],(this.stateChanges[t]||{})[a]);if(null===this.deletedStates[t])return {};if(this.deletedStates[t]){const e=this.deletedStates[t][i];if(null===e)return {};for(const t in e)delete s[t];}return s}initializeTileState(t,e){t.setFeatureState(this.state,e);}coalesceChanges(t,i){const a={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const a in this.stateChanges[t])this.state[t][a]||(this.state[t][a]={}),e.e(this.state[t][a],this.stateChanges[t][a]),i[a]=this.state[t][a];a[t]=i;}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e];}a[t]=a[t]||{},e.e(a[t],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(a).length)for(const e in t)t[e].setFeatureState(a,i);}}class ut extends e.E{constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>this._dataHandler(t))),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((t,e,i,a)=>{const s=new(at(e.type))(t,e,i,a);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return s})(t,e,i,this),this._tiles={},this._cache=new ht(0,(t=>this._unloadTile(t))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ct,this._didEmitContent=!1,this._updated=!1;}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t);}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(t,i,a){return e._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,i,a);}catch(i){t.state="errored",404!==i.status?this._source.fire(new e.j(i,{tile:t})):this.update(this.transform,this.terrain);}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t);}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new e.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(dt).map((t=>t.key))}getRenderableIds(t){const i=[];for(const e in this._tiles)this._isIdRenderable(e,t)&&i.push(this._tiles[e]);return t?i.sort(((t,i)=>{const a=t.tileID,s=i.tileID,o=new e.P(a.canonical.x,a.canonical.y)._rotate(this.transform.angle),r=new e.P(s.canonical.x,s.canonical.y)._rotate(this.transform.angle);return a.overscaledZ-s.overscaledZ||r.y-o.y||r.x-o.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(dt).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return !!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading");}}_reloadTile(t,i){return e._(this,void 0,void 0,(function*(){const e=this._tiles[t];e&&("loading"!==e.state&&(e.state=i),yield this._loadTile(e,t,i));}))}_tileLoaded(t,i,a){t.timeAdded=o.now(),"expired"===a&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new e.k("data",{dataType:"source",tile:t,coord:t.tileID}));}_backfillDEM(t){const e=this.getRenderableIds();for(let a=0;a1||(Math.abs(i)>1&&(1===Math.abs(i+s)?i+=s:1===Math.abs(i-s)&&(i-=s)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,a),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)));}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,a){for(const s in this._tiles){let o=this._tiles[s];if(a[s]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>i)continue;let r=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(r=t);}let n=r;for(;n.overscaledZ>e;)if(n=n.scaledTo(n.overscaledZ-1),t[n.key]){a[r.key]=r;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),a=this._getLoadedTile(e);if(a)return a}}findLoadedSibling(t){return this._getLoadedTile(t)}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const i=Math.ceil(t.width/this._source.tileSize)+1,a=Math.ceil(t.height/this._source.tileSize)+1,s=Math.floor(i*a*(null===this._maxTileCacheZoomLevels?e.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(o);}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const a=this._tiles[i];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+e),t[a.tileID.key]=a;}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(t,this._tiles[t]);}}_updateCoveredAndRetainedTiles(t,e,i,a,s,r){const n={},l={},h=Object.keys(t),c=o.now();for(const i of h){const a=t[i],s=this._tiles[i];if(!s||0!==s.fadeEndTime&&s.fadeEndTime<=c)continue;const o=this.findLoadedParent(a,e),r=this.findLoadedSibling(a),h=o||r||null;h&&(this._addTile(h.tileID),n[h.tileID.key]=h.tileID),l[i]=a;}this._retainLoadedChildren(l,a,i,t);for(const e in n)t[e]||(this._coveredTiles[e]=!0,t[e]=n[e]);if(r){const e={},i={};for(const t of s)this._tiles[t.key].hasData()?e[t.key]=t:i[t.key]=t;for(const a in i){const s=i[a].children(this._source.maxzoom);this._tiles[s[0].key]&&this._tiles[s[1].key]&&this._tiles[s[2].key]&&this._tiles[s[3].key]&&(e[s[0].key]=t[s[0].key]=s[0],e[s[1].key]=t[s[1].key]=s[1],e[s[2].key]=t[s[2].key]=s[2],e[s[3].key]=t[s[3].key]=s[3],delete i[a]);}for(const a in i){const s=i[a],o=this.findLoadedParent(s,this._source.minzoom),r=this.findLoadedSibling(s),n=o||r||null;if(n){e[n.tileID.key]=t[n.tileID.key]=n.tileID;for(const t in e)e[t].isChildOf(n.tileID)&&delete e[t];}}for(const t in this._tiles)e[t]||(this._coveredTiles[t]=!0);}}update(t,i){if(!this._sourceLoaded||this._paused)return;let a;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.S(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(a=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i}),this._source.hasTile&&(a=a.filter((t=>this._source.hasTile(t))))):a=[];const s=t.coveringZoomLevel(this._source),o=Math.max(s-ut.maxOverzooming,this._source.minzoom),r=Math.max(s+ut.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of a)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const a=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[a.key]=a;}a=a.concat(Object.values(t));}const n=0===a.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new e.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(a,s);_t(this._source.type)&&this._updateCoveredAndRetainedTiles(l,o,r,s,a,i);for(const t in l)this._tiles[t].clearFadeHold();const h=e.ab(this._tiles,l);for(const t of h){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t);}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache();}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t);}_updateRetainedTiles(t,e){var i;const a={},s={},o=Math.max(e-ut.maxOverzooming,this._source.minzoom),r=Math.max(e+ut.maxUnderzooming,this._source.minzoom),n={};for(const i of t){const t=this._addTile(i);a[i.key]=i,t.hasData()||ethis._source.maxzoom){const t=r.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){a[t.key]=t;continue}}else {const t=r.children(this._source.maxzoom);if(a[t[0].key]&&a[t[1].key]&&a[t[2].key]&&a[t[3].key])continue}let n=t.wasRequested();for(let e=r.overscaledZ-1;e>=o;--e){const o=r.scaledTo(e);if(s[o.key])break;if(s[o.key]=!0,t=this.getTile(o),!t&&n&&(t=this._addTile(o)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(a[o.key]=o),n=t.wasRequested(),e)break}}}return a}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,a=this._tiles[t].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){i=this._loadedParentTiles[a.key];break}e.push(a.key);const t=a.scaledTo(a.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;a=t;}for(const t of e)this._loadedParentTiles[t]=i;}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const t in this._tiles){const e=this._tiles[t].tileID,i=this._getLoadedTile(e);this._loadedSiblingTiles[e.key]=i;}}_addTile(t){let i=this._tiles[t.key];if(i)return i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const a=i;return i||(i=new lt(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state)),i.uses++,this._tiles[t.key]=i,a||this._source.fire(new e.k("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t];}),i));}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))));}_dataHandler(t){const e=t.sourceDataType;"source"===t.dataType&&"metadata"===e&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===e&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset();}tilesIn(t,i,a){const s=[],o=this.transform;if(!o)return s;const r=a?o.getCameraQueryGeometry(t):t,n=t.map((t=>o.pointCoordinate(t,this.terrain))),l=r.map((t=>o.pointCoordinate(t,this.terrain))),h=this.getIds();let c=1/0,u=1/0,d=-1/0,_=-1/0;for(const t of l)c=Math.min(c,t.x),u=Math.min(u,t.y),d=Math.max(d,t.x),_=Math.max(_,t.y);for(let t=0;t=0&&f[1].y+m>=0){const t=n.map((t=>r.getTilePoint(t))),e=l.map((t=>r.getTilePoint(t)));s.push({tile:a,tileID:r,queryGeometry:t,cameraQueryGeometry:e,scale:p});}}return s}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.posMatrix=this.transform.calculatePosMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return !0;if(_t(this._source.type)){const t=o.now();for(const e in this._tiles)if(this._tiles[e].fadeEndTime>=t)return !0}return !1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i);}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i);}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const a=this._tiles[t];a&&a.setDependencies(e,i);}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)));}}function dt(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),a=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||a-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function _t(t){return "raster"===t||"image"===t||"video"===t}ut.maxOverzooming=10,ut.maxUnderzooming=3;class pt{constructor(t,e){this.reset(t,e);}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t0?(s-r)/n:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function mt(t,e){let i=!0;return "always"===t||"never"!==t&&"never"!==e||(i=!1),i}class ft{constructor(t,e,i){const a=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;tthis.width||a<0||e>this.height)return [];const n=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=a){if(s)return [{key:null,x1:t,y1:e,x2:i,y2:a}];for(let t=0;t0}hitTestCircle(t,e,i,a,s){const o=t-i,r=t+i,n=e-i,l=e+i;if(r<0||o>this.width||l<0||n>this.height)return !1;const h=[];return this._forEachCell(o,n,r,l,this._queryCellCircle,h,{hitTest:!0,overlapMode:a,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},s),h.length>0}_queryCell(t,e,i,a,s,o,r,n){const{seenUids:l,hitTest:h,overlapMode:c}=r,u=this.boxCells[s];if(null!==u){const s=this.bboxes;for(const r of u)if(!l.box[r]){l.box[r]=!0;const u=4*r,d=this.boxKeys[r];if(t<=s[u+2]&&e<=s[u+3]&&i>=s[u+0]&&a>=s[u+1]&&(!n||n(d))&&(!h||!mt(c,d.overlapMode))&&(o.push({key:d,x1:s[u],y1:s[u+1],x2:s[u+2],y2:s[u+3]}),h))return !0}}const d=this.circleCells[s];if(null!==d){const s=this.circles;for(const r of d)if(!l.circle[r]){l.circle[r]=!0;const u=3*r,d=this.circleKeys[r];if(this._circleAndRectCollide(s[u],s[u+1],s[u+2],t,e,i,a)&&(!n||n(d))&&(!h||!mt(c,d.overlapMode))){const t=s[u],e=s[u+1],i=s[u+2];if(o.push({key:d,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),h)return !0}}}return !1}_queryCellCircle(t,e,i,a,s,o,r,n){const{circle:l,seenUids:h,overlapMode:c}=r,u=this.boxCells[s];if(null!==u){const t=this.bboxes;for(const e of u)if(!h.box[e]){h.box[e]=!0;const i=4*e,a=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!n||n(a))&&!mt(c,a.overlapMode))return o.push(!0),!0}}const d=this.circleCells[s];if(null!==d){const t=this.circles;for(const e of d)if(!h.circle[e]){h.circle[e]=!0;const i=3*e,a=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!n||n(a))&&!mt(c,a.overlapMode))return o.push(!0),!0}}}_forEachCell(t,e,i,a,s,o,r,n){const l=this._convertToXCellCoord(t),h=this._convertToYCellCoord(e),c=this._convertToXCellCoord(i),u=this._convertToYCellCoord(a);for(let d=l;d<=c;d++)for(let l=h;l<=u;l++)if(s.call(this,t,e,i,a,this.xCellCount*l+d,o,r,n))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,a,s,o){const r=a-t,n=s-e,l=i+o;return l*l>r*r+n*n}_circleAndRectCollide(t,e,i,a,s,o,r){const n=(o-a)/2,l=Math.abs(t-(a+n));if(l>n+i)return !1;const h=(r-s)/2,c=Math.abs(e-(s+h));if(c>h+i)return !1;if(l<=n||c<=h)return !0;const u=l-n,d=c-h;return u*u+d*d<=i*i}}function gt(t,i,a,s,o){const r=e.H();return i?(e.K(r,r,[1/o,1/o,1]),a||e.ad(r,r,s.angle)):e.L(r,s.labelPlaneMatrix,t),r}function vt(t,i,a,s,o){if(i){const i=e.ae(t);return e.K(i,i,[o,o,1]),a||e.ad(i,i,-s.angle),i}return s.glCoordMatrix}function xt(t,i,a,s){let o;s?(o=[t,i,s(t,i),1],e.af(o,o,a)):(o=[t,i,0,1],kt(o,o,a));const r=o[3];return {point:new e.P(o[0]/r,o[1]/r),signedDistanceFromCamera:r,isOccluded:!1}}function yt(t,e){return .5+t/e*.5}function bt(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function wt(t,i,a,s,o,r,n,l,h,c,u,d,_,p,m){const f=s?t.textSizeData:t.iconSizeData,g=e.ag(f,a.transform.zoom),v=[256/a.width*2+1,256/a.height*2+1],x=s?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;x.clear();const y=t.lineVertexArray,b=s?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=a.transform.width/a.transform.height;let T=!1;for(let s=0;sMath.abs(a.x-i.x)*s?{useVertical:!0}:(t===e.ah.vertical?i.ya.x)?{needsFlipping:!0}:null}function Et(t,i,a,s,o,r,n,l,h,c,u){const d=a/24,_=i.lineOffsetX*d,p=i.lineOffsetY*d;let m;if(i.numGlyphs>1){const e=i.glyphStartIndex+i.numGlyphs,a=i.lineStartIndex,r=i.lineStartIndex+i.lineLength,h=Tt(d,l,_,p,s,i,u,t);if(!h)return {notEnoughRoom:!0};const f=xt(h.first.point.x,h.first.point.y,n,t.getElevation).point,g=xt(h.last.point.x,h.last.point.y,n,t.getElevation).point;if(o&&!s){const t=It(i.writingMode,f,g,c);if(t)return t}m=[h.first];for(let o=i.glyphStartIndex+1;o0?n.point:function(t,e,i,a,s,o){return Pt(t,e,i,1,s,o)}(t.tileAnchorPoint,o,a,0,r,t),h=It(i.writingMode,a,l,c);if(h)return h}const a=Mt(d*l.getoffsetX(i.glyphStartIndex),_,p,s,i.segment,i.lineStartIndex,i.lineStartIndex+i.lineLength,t,u);if(!a||t.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[a];}for(const t of m)e.aj(h,t.point,t.angle);return {}}function Pt(t,e,i,a,s,o){const r=t.add(t.sub(e)._unit()),n=void 0!==s?xt(r.x,r.y,s,o.getElevation).point:St(r.x,r.y,o).point,l=i.sub(n);return i.add(l._mult(a/l.mag()))}function Ct(t,i,a){const s=i.projectionCache;if(s.projections[t])return s.projections[t];const o=new e.P(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),r=St(o.x,o.y,i);if(r.signedDistanceFromCamera>0)return s.projections[t]=r.point,s.anyProjectionOccluded=s.anyProjectionOccluded||r.isOccluded,r.point;const n=t-a.direction;return function(t,e,i,a,s){return Pt(t,e,i,a,void 0,s)}(0===a.distanceFromAnchor?i.tileAnchorPoint:new e.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),o,a.previousVertex,a.absOffsetX-a.distanceFromAnchor+1,i)}function St(t,e,i){const a=t+i.translation[0],s=e+i.translation[1];let o;return !i.pitchWithMap&&i.projection.useSpecialProjectionForSymbols?(o=i.projection.projectTileCoordinates(a,s,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height):(o=xt(a,s,i.labelPlaneMatrix,i.getElevation),o.isOccluded=!1),o}function zt(t,e,i){return t._unit()._perp()._mult(e*i)}function Dt(t,i,a,s,o,r,n,l,h){if(l.projectionCache.offsets[t])return l.projectionCache.offsets[t];const c=a.add(i);if(t+h.direction=o)return l.projectionCache.offsets[t]=c,c;const u=Ct(t+h.direction,l,h),d=zt(u.sub(a),n,h.direction),_=a.add(d),p=u.add(d);return l.projectionCache.offsets[t]=e.ak(r,c,_,p)||c,l.projectionCache.offsets[t]}function Mt(t,e,i,a,s,o,r,n,l){const h=a?t-e:t+e;let c=h>0?1:-1,u=0;a&&(c*=-1,u=Math.PI),c<0&&(u+=Math.PI);let d,_=c>0?o+s:o+s+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=St(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const y=Math.abs(h),b=[];let w;for(;v+x<=y;){if(_+=c,_=r)return null;v+=x,g=f,m=p;const t={absOffsetX:y,direction:c,distanceFromAnchor:v,previousVertex:g};if(f=Ct(_,n,t),0===i)b.push(g),w=f.sub(g);else {let e;const a=f.sub(g);e=0===a.mag()?zt(Ct(_+c,n,t).sub(f),i,c):zt(a,i,c),m||(m=g.add(e)),p=Dt(_,e,f,o,r,m,i,n,t),b.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((y-v)/x)._add(m||g),I=u+Math.atan2(f.y-g.y,f.x-g.x);return b.push(T),{point:T,angle:l?I:0,path:b}}const At=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Rt(t,e){for(let i=0;i=1;t--)l.push(r.path[t]);for(let t=1;tt.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point));}let m=[];if(l.length>0){const t=l[0].clone(),i=l[0].clone();for(let e=1;e=a.x&&i.x<=s.x&&t.y>=a.y&&i.y<=s.y?[l]:i.xs.x||i.ys.y?[]:e.al([l],a.x,a.y,s.x,s.y);}for(const e of m){o.reset(e,.25*i);let a=0;a=o.length<=.5*i?1:Math.ceil(o.paddedLength/u)+1;for(let e=0;ext(t.x,t.y,i,e.getElevation)))}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let a=1/0,s=1/0,o=-1/0,r=-1/0;for(const n of t){const t=new e.P(n.x+Lt,n.y+Lt);a=Math.min(a,t.x),s=Math.min(s,t.y),o=Math.max(o,t.x),r=Math.max(r,t.y),i.push(t);}const n=this.grid.query(a,s,o,r).concat(this.ignoredGrid.query(a,s,o,r)),l={},h={};for(const t of n){const a=t.key;if(void 0===l[a.bucketInstanceId]&&(l[a.bucketInstanceId]={}),l[a.bucketInstanceId][a.featureIndex])continue;const s=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.am(i,s)&&(l[a.bucketInstanceId][a.featureIndex]=!0,void 0===h[a.bucketInstanceId]&&(h[a.bucketInstanceId]=[]),h[a.bucketInstanceId].push(a.featureIndex));}return h}insertCollisionBox(t,e,i,a,s,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:a,featureIndex:s,collisionGroupID:o,overlapMode:e},t[0],t[1],t[2],t[3]);}insertCollisionCircles(t,e,i,a,s,o){const r=i?this.ignoredGrid:this.grid,n={bucketInstanceId:a,featureIndex:s,collisionGroupID:o,overlapMode:e};for(let e=0;e=this.screenRightBoundary||athis.screenBottomBoundary}isInsideGrid(t,e,i,a){return i>=0&&t=0&&ethis.projectAndGetPerspectiveRatio(a,t.x,t.y,s,h)));I=t.some((t=>!t.isOccluded)),T=t.map((t=>t.point));}else I=!0;return {box:e.ao(T),allPointsOccluded:!I}}}function Bt(t,i,a){return i*(e.X/(t.tileSize*Math.pow(2,a-t.tileID.overscaledZ)))}class Ot{constructor(t,e,i,a){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):a&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Nt{constructor(t,e,i,a,s){this.text=new Ot(t?t.text:null,e,i,s),this.icon=new Ot(t?t.icon:null,e,a,s);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Ut{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i;}}class jt{constructor(){this.invProjMatrix=e.H(),this.viewportMatrix=e.H(),this.circles=[];}}class Zt{constructor(t,e,i,a,s){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=a,this.tileID=s;}}class qt{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={};}get(t){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e};}return this.collisionGroups[t]}}function Vt(t,i,a,s,o){const{horizontalAlign:r,verticalAlign:n}=e.au(t);return new e.P(-(r-.5)*i+s[0]*o,-(n-.5)*a+s[1]*o)}class Gt{constructor(t,e,i,a,s,o){this.transform=t.clone(),this.terrain=i,this.collisionIndex=new Ft(this.transform,e),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new qt(s),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(t){const e=this.terrain;return e?(i,a)=>e.getElevation(t,i,a):null}getBucketParts(t,i,a,s){const o=a.getBucket(i),r=a.latestFeatureIndex;if(!o||!r||i.id!==o.layerIds[0])return;const n=a.collisionBoxArray,l=o.layers[0].layout,h=o.layers[0].paint,c=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),u=a.tileSize/e.X,d=a.tileID.toUnwrapped(),_=this.transform.calculatePosMatrix(d),p="map"===l.get("text-pitch-alignment"),m="map"===l.get("text-rotation-alignment"),f=Bt(a,1,this.transform.zoom),g=this.collisionIndex.mapProjection.translatePosition(this.transform,a,h.get("text-translate"),h.get("text-translate-anchor")),v=this.collisionIndex.mapProjection.translatePosition(this.transform,a,h.get("icon-translate"),h.get("icon-translate-anchor")),x=gt(_,p,m,this.transform,f);let y=null;if(p){const t=vt(_,p,m,this.transform,f);y=e.L([],this.transform.labelPlaneMatrix,t);}this.retainedQueryData[o.bucketInstanceId]=new Zt(o.bucketInstanceId,r,o.sourceLayerIndex,o.index,a.tileID);const b={bucket:o,layout:l,translationText:g,translationIcon:v,posMatrix:_,unwrappedTileID:d,textLabelPlaneMatrix:x,labelToScreenMatrix:y,scale:c,textPixelRatio:u,holdingForFade:a.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:e.ag(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(s)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:a,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:a,symbolInstanceEnd:s,parameters:b});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:b});}attemptAnchorPlacement(t,i,a,s,o,r,n,l,h,c,u,d,_,p,m,f,g,v,x){const y=e.aq[t.textAnchor],b=[t.textOffset0,t.textOffset1],w=Vt(y,a,s,b,o),T=this.collisionIndex.placeCollisionBox(i,d,l,h,c,n,r,f,u.predicate,x,w);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,h,c,n,r,g,u.predicate,x,w).placeable)&&T.placeable){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID].text&&(t=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:b,width:a,height:s,anchor:y,textBoxScale:o,prevAnchor:t},this.markUsedJustification(p,y,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,a){const{bucket:s,layout:o,translationText:r,translationIcon:n,posMatrix:l,unwrappedTileID:h,textLabelPlaneMatrix:c,labelToScreenMatrix:u,textPixelRatio:d,holdingForFade:_,collisionBoxArray:p,partiallyEvaluatedTextSize:m,collisionGroup:f}=t.parameters,g=o.get("text-optional"),v=o.get("icon-optional"),x=e.ar(o,"text-overlap","text-allow-overlap"),y="always"===x,b=e.ar(o,"icon-overlap","icon-allow-overlap"),w="always"===b,T="map"===o.get("text-rotation-alignment"),I="map"===o.get("text-pitch-alignment"),E="none"!==o.get("icon-text-fit"),P="viewport-y"===o.get("symbol-z-order"),C=y&&(w||!s.hasIconData()||v),S=w&&(y||!s.hasTextData()||g);!s.collisionArrays&&p&&s.deserializeCollisionBoxes(p);const z=this._getTerrainElevationFunc(this.retainedQueryData[s.bucketInstanceId].tileID),D=(t,p,w)=>{var P,D;if(i[t.crossTileID])return;if(_)return void(this.placements[t.crossTileID]=new Ut(!1,!1,!1));let M=!1,A=!1,R=!0,k=null,L={box:null,placeable:!1,offscreen:null},F={box:null,placeable:!1,offscreen:null},B=null,O=null,N=null,U=0,j=0,Z=0;p.textFeatureIndex?U=p.textFeatureIndex:t.useRuntimeCollisionCircles&&(U=t.featureIndex),p.verticalTextFeatureIndex&&(j=p.verticalTextFeatureIndex);const q=p.textBox;if(q){const i=i=>{let a=e.ah.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,a=e,this.markUsedOrientation(s,a,t));}return a},o=(i,a)=>{if(s.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&p.verticalTextBox){for(const t of s.writingModes)if(t===e.ah.vertical?(L=a(),F=L):L=i(),L&&L.placeable)break}else L=i();},c=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===c){const a=(e,i)=>{const a=this.collisionIndex.placeCollisionBox(e,x,d,l,h,I,T,r,f.predicate,z);return a&&a.placeable&&(this.markUsedOrientation(s,i,t),this.placedOrientations[t.crossTileID]=i),a};o((()=>a(q,e.ah.horizontal)),(()=>{const i=p.verticalTextBox;return s.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?a(i,e.ah.vertical):{box:null,offscreen:null}})),i(L&&L.placeable);}else {let _=e.aq[null===(D=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[t.crossTileID])||void 0===D?void 0:D.anchor];const m=(i,o,p)=>{const m=i.x2-i.x1,g=i.y2-i.y1,v=t.textBoxScale,y=E&&"never"===b?o:null;let w=null,P="never"===x?1:2,C="never";_&&P++;for(let e=0;em(q,p.iconBox,e.ah.horizontal)),(()=>{const i=p.verticalTextBox;return s.allowVerticalPlacement&&(!L||!L.placeable)&&t.numVerticalGlyphVertices>0&&i?m(i,p.verticalIconBox,e.ah.vertical):{box:null,occluded:!0,offscreen:null}})),L&&(M=L.placeable,R=L.offscreen);const g=i(L&&L.placeable);if(!M&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(s,e.anchor,t,g));}}}if(B=L,M=B&&B.placeable,R=B&&B.offscreen,t.useRuntimeCollisionCircles){const i=s.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),n=e.ai(s.textSizeData,m,i),d=o.get("text-padding");O=this.collisionIndex.placeCollisionCircles(x,i,s.lineVertexArray,s.glyphOffsetArray,n,l,h,c,u,a,I,f.predicate,t.collisionCircleDiameter,d,r,z),O.circles.length&&O.collisionDetected&&!a&&e.w("Collisions detected, but collision boxes are not shown"),M=y||O.circles.length>0&&!O.collisionDetected,R=R&&O.offscreen;}if(p.iconFeatureIndex&&(Z=p.iconFeatureIndex),p.iconBox){const t=t=>this.collisionIndex.placeCollisionBox(t,b,d,l,h,I,T,n,f.predicate,z,E&&k?k:void 0);F&&F.placeable&&p.verticalIconBox?(N=t(p.verticalIconBox),A=N.placeable):(N=t(p.iconBox),A=N.placeable),R=R&&N.offscreen;}const V=g||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,G=v||0===t.numIconVertices;V||G?G?V||(A=A&&M):M=A&&M:A=M=A&&M;const H=A&&N.placeable;if(M&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,x,o.get("text-ignore-placement"),s.bucketInstanceId,F&&F.placeable&&j?j:U,f.ID),H&&this.collisionIndex.insertCollisionBox(N.box,b,o.get("icon-ignore-placement"),s.bucketInstanceId,Z,f.ID),O&&M&&this.collisionIndex.insertCollisionCircles(O.circles,x,o.get("text-ignore-placement"),s.bucketInstanceId,U,f.ID),a&&this.storeCollisionData(s.bucketInstanceId,w,p,B,N,O),0===t.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===s.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new Ut(M||C,A||S,R||s.justReloaded),i[t.crossTileID]=!0;};if(P){if(0!==t.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const e=s.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const i=e[t];D(s.symbolInstances.get(i),s.collisionArrays[i],i);}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:a.crossTileID);}markUsedOrientation(t,i,a){const s=i===e.ah.horizontal||i===e.ah.horizontalOnly?i:0,o=i===e.ah.vertical?i:0,r=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const e of r)t.text.placedSymbolArray.get(e).placedOrientation=s;a.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=o);}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const a=e?e.symbolFadeChange(t):1,s=e?e.opacities:{},o=e?e.variableOffsets:{},r=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],o=s[t];o?(this.opacities[t]=new Nt(o,a,e.text,e.icon),i=i||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new Nt(null,a,e.text,e.icon,e.skipFade),i=i||e.text||e.icon);}for(const t in s){const e=s[t];if(!this.opacities[t]){const s=new Nt(e,a,!1,!1);s.isHidden()||(this.opacities[t]=s,i=i||e.text.placed||e.icon.placed);}}for(const t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(const t in r)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=r[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t);}updateLayerOpacities(t,e){const i={};for(const a of e){const e=a.getBucket(t);e&&a.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,a.tileID,i,a.collisionBoxArray);}}updateBucketOpacities(t,i,a,s){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const o=t.layers[0],r=o.layout,n=new Nt(null,0,!1,!1,!0),l=r.get("text-allow-overlap"),h=r.get("icon-allow-overlap"),c=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===r.get("text-rotation-alignment"),d="map"===r.get("text-pitch-alignment"),_="none"!==r.get("icon-text-fit"),p=new Nt(null,0,l&&(h||!t.hasIconData()||r.get("icon-optional")),h&&(l||!t.hasTextData()||r.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const m=(t,e,i)=>{for(let a=0;a0,v=this.placedOrientations[s.crossTileID],x=v===e.ah.vertical,y=v===e.ah.horizontal||v===e.ah.horizontalOnly;if(o>0||r>0){const e=te(h.text);m(t.text,o,x?ee:e),m(t.text,r,y?ee:e);const i=h.text.isHidden();[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||x?1:0);})),s.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).hidden=i||y?1:0);const a=this.variableOffsets[s.crossTileID];a&&this.markUsedJustification(t,a.anchor,s,v);const n=this.placedOrientations[s.crossTileID];n&&(this.markUsedJustification(t,"left",s,n),this.markUsedOrientation(t,n,s));}if(g){const e=te(h.icon),i=!(_&&s.verticalPlacedIconSymbolIndex&&x);s.placedIconSymbolIndex>=0&&(m(t.icon,s.numIconVertices,i?e:ee),t.icon.placedSymbolArray.get(s.placedIconSymbolIndex).hidden=h.icon.isHidden()),s.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,s.numVerticalIconVertices,i?ee:e),t.icon.placedSymbolArray.get(s.verticalPlacedIconSymbolIndex).hidden=h.icon.isHidden());}const b=f&&f.has(i)?f.get(i):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const a=t.collisionArrays[i];if(a){let i=new e.P(0,0);if(a.textBox||a.verticalTextBox){let e=!0;if(c){const t=this.variableOffsets[l];t?(i=Vt(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),u&&i._rotate(d?this.transform.angle:-this.transform.angle)):e=!1;}if(a.textBox||a.verticalTextBox){let s;a.textBox&&(s=x),a.verticalTextBox&&(s=y),Ht(t.textCollisionBox.collisionVertexArray,h.text.placed,!e||s,b.text,i.x,i.y);}}if(a.iconBox||a.verticalIconBox){const e=Boolean(!y&&a.verticalIconBox);let s;a.iconBox&&(s=e),a.verticalIconBox&&(s=!e),Ht(t.iconCollisionBox.collisionVertexArray,h.icon.placed,s,b.icon,_?i.x:0,_?i.y:0);}}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId];}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0;}}function Ht(t,e,i,a,s,o){a&&0!==a.length||(a=[0,0,0,0]);const r=a[0]-Lt,n=a[1]-Lt,l=a[2]-Lt,h=a[3]-Lt;t.emplaceBack(e?1:0,i?1:0,s||0,o||0,r,n),t.emplaceBack(e?1:0,i?1:0,s||0,o||0,l,n),t.emplaceBack(e?1:0,i?1:0,s||0,o||0,l,h),t.emplaceBack(e?1:0,i?1:0,s||0,o||0,r,h);}const Wt=Math.pow(2,25),$t=Math.pow(2,24),Xt=Math.pow(2,17),Kt=Math.pow(2,16),Jt=Math.pow(2,9),Yt=Math.pow(2,8),Qt=Math.pow(2,1);function te(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Wt+e*$t+i*Xt+e*Kt+i*Jt+e*Yt+i*Qt+e}const ee=0;function ie(){return {isOccluded:(t,e,i)=>!1,getPitchedTextCorrection:(t,e,i)=>1,get useSpecialProjectionForSymbols(){return !1},projectTileCoordinates(t,e,i,a){throw new Error("Not implemented.")},translatePosition:(t,e,i,a)=>function(t,e,i,a,s=!1){if(!i[0]&&!i[1])return [0,0];const o=s?"map"===a?t.angle:0:"viewport"===a?-t.angle:0;if(o){const t=Math.sin(o),e=Math.cos(o);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e];}return [s?i[0]:Bt(e,i[0],t.zoom),s?i[1]:Bt(e,i[1],t.zoom)]}(t,e,i,a),getCircleRadiusCorrection:t=>1}}class ae{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(t,e,i,a,s){const o=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex!this._forceFullPlacement&&o.now()-a>2;for(;this._currentPlacementIndex>=0;){const a=e[t[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===a.type&&(!a.minzoom||a.minzoom<=o)&&(!a.maxzoom||a.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new ae(a)),this._inProgressLayer.continuePlacement(i[a.source],this.placement,this._showCollisionBoxes,a,s))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(t){return this.placement.commit(t),this.placement}}const oe=512/e.X/2;class re{constructor(t,i,a){this.tileID=t,this.bucketInstanceId=a,this._symbolsByKey={};const s=new Map;for(let t=0;t({x:Math.floor(t.anchorX*oe),y:Math.floor(t.anchorY*oe)}))),crossTileIDs:i.map((t=>t.crossTileID))};if(a.positions.length>128){const t=new e.av(a.positions.length,16,Uint16Array);for(const{x:e,y:i}of a.positions)t.add(e,i);t.finish(),delete a.positions,a.index=t;}this._symbolsByKey[t]=a;}}getScaledCoordinates(t,i){const{x:a,y:s,z:o}=this.tileID.canonical,{x:r,y:n,z:l}=i.canonical,h=oe/Math.pow(2,l-o),c=(n*e.X+t.anchorY)*h,u=s*e.X*oe;return {x:Math.floor((r*e.X+t.anchorX)*h-a*e.X*oe),y:Math.floor(c-u)}}findMatches(t,e,i){const a=this.tileID.canonical.zt))}}class ne{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class le{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],a={};for(const t in i){const s=i[t];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+e),a[s.tileID.key]=s;}this.indexes[t]=a;}this.lng=t;}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key]);}for(let t=0;tt.overscaledZ)for(const i in s){const o=s[i];o.tileID.isChildOf(t)&&o.findMatches(e.symbolInstances,t,a);}else {const o=s[t.scaledTo(Number(i)).key];o&&o.findMatches(e.symbolInstances,t,a);}}for(let t=0;t{e[t]=!0;}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t];}}const ce=(t,i)=>e.t(t,i&&i.filter((t=>"source.canvas"!==t.identifier))),ue=e.aw();class de extends e.E{constructor(t,i={}){super(),this._rtlPluginLoaded=()=>{for(const t in this.sourceCaches){const e=this.sourceCaches[t].getSource().type;"vector"!==e&&"geojson"!==e||this.sourceCaches[t].reload();}},this.map=t,this.dispatcher=new U(N(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.imageManager=new T,this.imageManager.setEventedParent(this),this.glyphManager=new C(t._requestManager,i.localIdeographFontFamily),this.lineAtlas=new R(256,512),this.crossTileSymbolIndex=new he,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new e.ax,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",e.ay()),nt().on(st,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e);}}));}loadURL(t,i={},a){this.fire(new e.k("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const s=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;e.h(s,this._loadStyleRequest).then((t=>{this._loadStyleRequest=null,this._load(t.data,i,a);})).catch((t=>{this._loadStyleRequest=null,t&&!o.signal.aborted&&this.fire(new e.j(t));}));}loadJSON(t,i={},a){this.fire(new e.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,o.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(t,i,a);})).catch((()=>{}));}loadEmpty(){this.fire(new e.k("dataloading",{dataType:"style"})),this._load(ue,{validate:!1});}_load(t,i,a){var s;const o=i.transformStyle?i.transformStyle(a,t):t;if(!i.validate||!ce(this,e.u(o))){this._loaded=!0,this.stylesheet=o;for(const t in o.sources)this.addSource(t,o.sources[t],{validate:!1});o.sprite?this._loadSprite(o.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(o.glyphs),this._createLayers(),this.light=new D(this.stylesheet.light),this.sky=new A(this.stylesheet.sky),this.map.setTerrain(null!==(s=this.stylesheet.terrain)&&void 0!==s?s:null),this.fire(new e.k("data",{dataType:"style"})),this.fire(new e.k("style.load"));}}_createLayers(){const t=e.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const i of t){const t=e.aA(i);t.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=t;}}_loadSprite(t,i=!1,a=void 0){let s;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(t,i,a,s){return e._(this,void 0,void 0,(function*(){const r=x(t),n=a>1?"@2x":"",l={},h={};for(const{id:t,url:a}of r){const o=i.transformRequest(y(a,n,".json"),"SpriteJSON");l[t]=e.h(o,s);const r=i.transformRequest(y(a,n,".png"),"SpriteImage");h[t]=_.getImage(r,s);}return yield Promise.all([...Object.values(l),...Object.values(h)]),function(t,i){return e._(this,void 0,void 0,(function*(){const e={};for(const a in t){e[a]={};const s=o.getImageCanvasContext((yield i[a]).data),r=(yield t[a]).data;for(const t in r){const{width:i,height:o,x:n,y:l,sdf:h,pixelRatio:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=r[t];e[a][t]={data:null,pixelRatio:c,sdf:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:o,x:n,y:l,context:s}};}}return e}))}(l,h)}))}(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((t=>{if(this._spriteRequest=null,t)for(const e in t){this._spritesImagesIds[e]=[];const a=this._spritesImagesIds[e]?this._spritesImagesIds[e].filter((e=>!(e in t))):[];for(const t of a)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const a in t[e]){const s="default"===e?a:`${e}:${a}`;this._spritesImagesIds[e].push(s),s in this.imageManager.images?this.imageManager.updateImage(s,t[e][a],!1):this.imageManager.addImage(s,t[e][a]),i&&(this._changedImages[s]=!0);}}})).catch((t=>{this._spriteRequest=null,s=t,this.fire(new e.j(s));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"})),a&&a(s);}));}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}));}_validateLayer(t){const i=this.sourceCaches[t.source];if(!i)return;const a=t.sourceLayer;if(!a)return;const s=i.getSource();("geojson"===s.type||s.vectorLayerIds&&-1===s.vectorLayerIds.indexOf(a))&&this.fire(new e.j(new Error(`Source layer "${a}" does not exist on source "${s.id}" as specified by style layer "${t.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(t,i=!1){const a=this._serializedAllLayers();if(!t||0===t.length)return Object.values(i?e.aB(a):a);const s=[];for(const o of t)if(a[o]){const t=i?e.aB(a[o]):a[o];s.push(t);}return s}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const i of e){const e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize());}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return !0;if(this.sky&&this.sky.hasTransition())return !0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return !0;for(const t in this._layers)if(this._layers[t].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const i=this._changed;if(i){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else {if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates();}const a={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];a[t]=e.used,e.used=!1;}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const t in a){const i=this.sourceCaches[t];!!a[t]!=!!i.used&&i.fire(new e.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}));}this.light.recalculate(t),this.sky.recalculate(t),this.z=t.zoom,i&&this.fire(new e.k("data",{dataType:"style"}));}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:e});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(t,i={}){var a;this._checkLoaded();const s=this.serialize();if(t=i.transformStyle?i.transformStyle(s,t):t,(null===(a=i.validate)||void 0===a||a)&&ce(this,e.u(t)))return !1;(t=e.aB(t)).layers=e.az(t.layers);const o=e.aC(s,t),r=this._getOperationsToPerform(o);if(r.unimplemented.length>0)throw new Error(`Unimplemented: ${r.unimplemented.join(", ")}.`);if(0===r.operations.length)return !1;for(const t of r.operations)t();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const e=[],i=[];for(const a of t)switch(a.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":e.push((()=>this.addLayer.apply(this,a.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,a.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,a.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,a.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,a.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,a.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,a.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,a.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,a.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,a.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,a.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,a.args)));break;case"setSky":e.push((()=>this.setSky.apply(this,a.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,a.args)));break;case"setTransition":e.push((()=>{}));break;default:i.push(a.command);}return {operations:e,unimplemented:i}}addImage(t,i){if(this.getImage(t))return this.fire(new e.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,i),this._afterImageUpdated(t);}updateImage(t,e){this.imageManager.updateImage(t,e);}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new e.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t);}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,i,a={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(e.u.source,`sources.${t}`,i,null,a))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const s=this.sourceCaches[t]=new ut(t,i,this.dispatcher);s.style=this,s.setEventedParent(this,(()=>({isSourceLoaded:s.loaded(),source:s.serialize(),sourceId:t}))),s.onAdd(this.map),this._changed=!0;}removeSource(t){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.j(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],i.fire(new e.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const i=this.sourceCaches[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0;}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,i,a={}){this._checkLoaded();const s=t.id;if(this.getLayer(s))return void this.fire(new e.j(new Error(`Layer "${s}" already exists on this map.`)));let o;if("custom"===t.type){if(ce(this,e.aD(t)))return;o=e.aA(t);}else {if("source"in t&&"object"==typeof t.source&&(this.addSource(s,t.source),t=e.aB(t),t=e.e(t,{source:s})),this._validate(e.u.layer,`layers.${s}`,t,{arrayIndex:-1},a))return;o=e.aA(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:s}});}const r=i?this._order.indexOf(i):this._order.length;if(i&&-1===r)this.fire(new e.j(new Error(`Cannot add layer "${s}" before non-existing layer "${i}".`)));else {if(this._order.splice(r,0,s),this._layerOrderChanged=!0,this._layers[s]=o,this._removedLayers[s]&&o.source&&"custom"!==o.type){const t=this._removedLayers[s];delete this._removedLayers[s],t.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause());}this._updateLayer(o),o.onAdd&&o.onAdd(this.map);}}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const a=this._order.indexOf(t);this._order.splice(a,1);const s=i?this._order.indexOf(i):this._order.length;i&&-1===s?this.fire(new e.j(new Error(`Cannot move layer "${t}" before non-existing layer "${i}".`))):(this._order.splice(s,0,t),this._layerOrderChanged=!0);}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.j(new Error(`Cannot remove non-existing layer "${t}".`)));i.setEventedParent(null);const a=this._order.indexOf(t);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.onRemove(this.map);}getLayer(t){return this._layers[t]}getLayersOrder(){return [...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,i,a){this._checkLoaded();const s=this.getLayer(t);s?s.minzoom===i&&s.maxzoom===a||(null!=i&&(s.minzoom=i),null!=a&&(s.maxzoom=a),this._updateLayer(s)):this.fire(new e.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)));}setFilter(t,i,a={}){this._checkLoaded();const s=this.getLayer(t);if(s){if(!e.aE(s.filter,i))return null==i?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(e.u.filter,`layers.${s.id}.filter`,i,null,a)||(s.filter=e.aB(i),this._updateLayer(s)))}else this.fire(new e.j(new Error(`Cannot filter non-existing layer "${t}".`)));}getFilter(t){return e.aB(this.getLayer(t).filter)}setLayoutProperty(t,i,a,s={}){this._checkLoaded();const o=this.getLayer(t);o?e.aE(o.getLayoutProperty(i),a)||(o.setLayoutProperty(i,a,s),this._updateLayer(o)):this.fire(new e.j(new Error(`Cannot style non-existing layer "${t}".`)));}getLayoutProperty(t,i){const a=this.getLayer(t);if(a)return a.getLayoutProperty(i);this.fire(new e.j(new Error(`Cannot get style of non-existing layer "${t}".`)));}setPaintProperty(t,i,a,s={}){this._checkLoaded();const o=this.getLayer(t);o?e.aE(o.getPaintProperty(i),a)||(o.setPaintProperty(i,a,s)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new e.j(new Error(`Cannot style non-existing layer "${t}".`)));}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,i){this._checkLoaded();const a=t.source,s=t.sourceLayer,o=this.sourceCaches[a];if(void 0===o)return void this.fire(new e.j(new Error(`The source '${a}' does not exist in the map's style.`)));const r=o.getSource().type;"geojson"===r&&s?this.fire(new e.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==r||s?(void 0===t.id&&this.fire(new e.j(new Error("The feature id parameter must be provided."))),o.setFeatureState(s,t.id,i)):this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(t,i){this._checkLoaded();const a=t.source,s=this.sourceCaches[a];if(void 0===s)return void this.fire(new e.j(new Error(`The source '${a}' does not exist in the map's style.`)));const o=s.getSource().type,r="vector"===o?t.sourceLayer:void 0;"vector"!==o||r?i&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new e.j(new Error("A feature id is required to remove its specific state property."))):s.removeFeatureState(r,t.id,i):this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(t){this._checkLoaded();const i=t.source,a=t.sourceLayer,s=this.sourceCaches[i];if(void 0!==s)return "vector"!==s.getSource().type||a?(void 0===t.id&&this.fire(new e.j(new Error("The feature id parameter must be provided."))),s.getFeatureState(a,t.id)):void this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new e.j(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return e.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=e.aF(this.sourceCaches,(t=>t.serialize())),i=this._serializeByIds(this._order,!0),a=this.map.getTerrain()||void 0,s=this.stylesheet;return e.aG({version:s.version,name:s.name,metadata:s.metadata,light:s.light,sky:s.sky,center:s.center,zoom:s.zoom,bearing:s.bearing,pitch:s.pitch,sprite:s.sprite,glyphs:s.glyphs,transition:s.transition,sources:t,layers:i,terrain:a},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},a=[];for(let s=this._order.length-1;s>=0;s--){const o=this._order[s];if(e(o)){i[o]=s;for(const e of t){const t=e[o];if(t)for(const e of t)a.push(e);}}}a.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const s=[];for(let o=this._order.length-1;o>=0;o--){const r=this._order[o];if(e(r))for(let t=a.length-1;t>=0;t--){const e=a[t].feature;if(i[e.layer.id]{const a=i.featureSortOrder;if(a){const i=a.indexOf(t.featureIndex);return a.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of s)e.push(t);}}for(const e in n)n[e].forEach((a=>{const s=a.feature,o=i[t[e].source].getFeatureState(s.layer["source-layer"],s.id);s.source=s.layer.source,s.layer["source-layer"]&&(s.sourceLayer=s.layer["source-layer"]),s.state=o;}));return n}(this._layers,r,this.sourceCaches,t,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,i){i&&i.filter&&this._validate(e.u.filter,"querySourceFeatures.filter",i.filter,null,i);const a=this.sourceCaches[t];return a?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),a=[],s={};for(let t=0;tt.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)));}const a=this.crossTileSymbolIndex.addLayer(i,l[i.source],t.center.lng);r=r||a;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((s=s||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(o.now(),t.zoom))&&(this.pauseablePlacement=new se(t,this.map.terrain,this._order,s,e,i,a,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(o.now()),n=!0),r&&this.pauseablePlacement.placement.setStale()),n||r)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(o.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles();}getImages(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const e=this.sourceCaches[i.source];return e&&e.setDependencies(i.tileID.key,i.type,i.icons),t}))}getGlyphs(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.glyphManager.getGlyphs(i.stacks),e=this.sourceCaches[i.source];return e&&e.setDependencies(i.tileID.key,i.type,[""]),t}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,i={}){this._checkLoaded(),t&&this._validate(e.u.glyphs,"glyphs",t,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t));}addSprite(t,i,a={},s){this._checkLoaded();const o=[{id:t,url:i}],r=[...x(this.stylesheet.sprite),...o];this._validate(e.u.sprite,"sprite",r,null,a)||(this.stylesheet.sprite=r,this._loadSprite(o,!0,s));}removeSprite(t){this._checkLoaded();const i=x(this.stylesheet.sprite);if(i.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;i.splice(i.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}));}else this.fire(new e.j(new Error(`Sprite "${t}" doesn't exists on this map.`)));}getSprite(){return x(this.stylesheet.sprite)}setSprite(t,i={},a){this._checkLoaded(),t&&this._validate(e.u.sprite,"sprite",t,null,i)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,a):(this._unloadSprite(),a&&a(null)));}}var _e=e.Y([{name:"a_pos",type:"Int16",components:2}]);const pe={prelude:me("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:me("uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:me("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:me("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:me("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:me("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,get_elevation(floor(a_pos*0.5)),1);gl_Position=u_matrix*pos;}"),heatmapTexture:me("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:me("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_anchor_pos;attribute vec2 a_placed;attribute vec2 a_box_real;uniform mat4 u_matrix;uniform vec2 u_pixel_extrude_scale;varying float v_placed;varying float v_notUsed;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:me("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:me("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:me("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}"),fillOutline:me("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillOutlinePattern:me("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillPattern:me("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:me("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:me("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:me("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:me("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:me("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:me("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:me("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:me("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:me("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:me("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_tex;varying float v_fade_opacity;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:me("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:me("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:me("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;varying vec2 v_texture_pos;varying float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture2D(u_texture,v_texture_pos);if (v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);gl_FragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {gl_FragColor=surface_color;}}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform mat4 u_fog_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:me("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:me("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=u_matrix*vec4(a_pos3d.xy,ele-ele_delta,1.0);}"),sky:me("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform float u_horizon;uniform float u_sky_horizon_blend;void main() {float y=gl_FragCoord.y;if (y > u_horizon) {float blend=y-u_horizon;if (blend < u_sky_horizon_blend) {gl_FragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {gl_FragColor=u_sky_color;}}}","attribute vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function me(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,a=e.match(/attribute ([\w]+) ([\w]+)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),r=o?o.concat(s):s,n={};return {fragmentSource:t=t.replace(i,((t,e,i,a,s)=>(n[s]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nvarying ${i} ${a} ${s};\n#else\nuniform ${i} ${a} u_${s};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${s}\n ${i} ${a} ${s} = u_${s};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,a,s)=>{const o="float"===a?"vec2":"vec4",r=s.match(/color/)?"color":o;return n[s]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${o} a_${s};\nvarying ${i} ${a} ${s};\n#else\nuniform ${i} ${a} u_${s};\n#endif\n`:"vec4"===r?`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = a_${s};\n#else\n ${i} ${a} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = unpack_mix_${r}(a_${s}, u_${s}_t);\n#else\n ${i} ${a} ${s} = u_${s};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${o} a_${s};\n#else\nuniform ${i} ${a} u_${s};\n#endif\n`:"vec4"===r?`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${a} ${s} = a_${s};\n#else\n ${i} ${a} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${a} ${s} = unpack_mix_${r}(a_${s}, u_${s}_t);\n#else\n ${i} ${a} ${s} = u_${s};\n#endif\n`})),staticAttributes:a,staticUniforms:r}}class fe{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(t,e,i,a,s,o,r,n,l){this.context=t;let h=this.boundPaintVertexBuffers.length!==a.length;for(let t=0;!h&&t({u_matrix:t,u_texture:0,u_ele_delta:i,u_fog_matrix:a,u_fog_color:s?s.properties.get("fog-color"):e.aM.white,u_fog_ground_blend:s?s.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:s?s.calculateFogBlendOpacity(o):0,u_horizon_color:s?s.properties.get("horizon-color"):e.aM.white,u_horizon_fog_blend:s?s.properties.get("horizon-fog-blend"):1});function ve(t){const e=[];for(let i=0;i({u_depth:new e.aH(t,i.u_depth),u_terrain:new e.aH(t,i.u_terrain),u_terrain_dim:new e.aI(t,i.u_terrain_dim),u_terrain_matrix:new e.aJ(t,i.u_terrain_matrix),u_terrain_unpack:new e.aK(t,i.u_terrain_unpack),u_terrain_exaggeration:new e.aI(t,i.u_terrain_exaggeration)}))(t,b),this.binderUniforms=a?a.getUniforms(t,b):[];}draw(t,e,i,a,s,o,r,n,l,h,c,u,d,_,p,m,f,g){const v=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(a),t.setColorMode(s),t.setCullFace(o),n){t.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,n.depthTexture),t.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,n.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(n[t]);}for(const t in this.fixedUniforms)this.fixedUniforms[t].set(r[t]);p&&p.setUniforms(t,this.binderUniforms,d,{zoom:_});let x=0;switch(e){case v.LINES:x=2;break;case v.TRIANGLES:x=3;break;case v.LINE_STRIP:x=1;}for(const i of u.get()){const a=i.vaos||(i.vaos={});(a[l]||(a[l]=new fe)).bind(t,this,h,p?p.getPaintVertexBuffers():[],c,i.vertexOffset,m,f,g),v.drawElements(e,i.primitiveLength*x,v.UNSIGNED_SHORT,i.primitiveOffset*x*2);}}}function ye(t,e,i){const a=1/Bt(i,1,e.transform.tileZoom),s=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,e.transform.tileZoom)/s,r=o*(i.tileID.canonical.x+i.tileID.wrap*s),n=o*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[a,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[r>>16,n>>16],u_pixel_coord_lower:[65535&r,65535&n]}}const be=(t,i,a,s)=>{const o=i.style.light,r=o.properties.get("position"),n=[r.x,r.y,r.z],l=function(){var t=new e.A(9);return e.A!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}();"viewport"===o.properties.get("anchor")&&function(t,e){var i=Math.sin(e),a=Math.cos(e);t[0]=a,t[1]=i,t[2]=0,t[3]=-i,t[4]=a,t[5]=0,t[6]=0,t[7]=0,t[8]=1;}(l,-i.transform.angle),function(t,e,i){var a=e[0],s=e[1],o=e[2];t[0]=a*i[0]+s*i[3]+o*i[6],t[1]=a*i[1]+s*i[4]+o*i[7],t[2]=a*i[2]+s*i[5]+o*i[8];}(n,n,l);const h=o.properties.get("color");return {u_matrix:t,u_lightpos:n,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+a,u_opacity:s}},we=(t,i,a,s,o,r,n)=>e.e(be(t,i,a,s),ye(r,i,n),{u_height_factor:-Math.pow(2,o.overscaledZ)/n.tileSize/8}),Te=t=>({u_matrix:t}),Ie=(t,i,a,s)=>e.e(Te(t),ye(a,i,s)),Ee=(t,e)=>({u_matrix:t,u_world:e}),Pe=(t,i,a,s,o)=>e.e(Ie(t,i,a,s),{u_world:o}),Ce=(t,e,i,a)=>{const s=t.transform;let o,r;if("map"===a.paint.get("circle-pitch-alignment")){const t=Bt(i,1,s.zoom);o=!0,r=[t,t];}else o=!1,r=s.pixelsToGLUnits;return {u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===a.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+o,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:r}},Se=(t,e,i)=>({u_matrix:t,u_inv_matrix:e,u_camera_to_center_distance:i.cameraToCenterDistance,u_viewport_size:[i.width,i.height]}),ze=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),De=t=>({u_matrix:t}),Me=(t,e,i,a)=>({u_matrix:t,u_extrude_scale:Bt(e,1,i),u_intensity:a}),Ae=(t,i,a,s)=>{const o=e.H();e.aP(o,0,t.width,t.height,0,0,1);const r=t.context.gl;return {u_matrix:o,u_world:[r.drawingBufferWidth,r.drawingBufferHeight],u_image:a,u_color_ramp:s,u_opacity:i.paint.get("heatmap-opacity")}};function Re(t,i){const a=Math.pow(2,i.canonical.z),s=i.canonical.y;return [new e.Z(0,s/a).toLngLat().lat,new e.Z(0,(s+1)/a).toLngLat().lat]}const ke=(t,e,i,a)=>{const s=t.transform;return {u_matrix:Ne(t,e,i,a),u_ratio:1/Bt(e,1,s.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Le=(t,i,a,s,o)=>e.e(ke(t,i,a,o),{u_image:0,u_image_height:s}),Fe=(t,e,i,a,s)=>{const o=t.transform,r=Oe(e,o);return {u_matrix:Ne(t,e,i,s),u_texsize:e.imageAtlasTexture.size,u_ratio:1/Bt(e,1,o.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[r,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Be=(t,i,a,s,o,r)=>{const n=t.lineAtlas,l=Oe(i,t.transform),h="round"===a.layout.get("line-cap"),c=n.getDash(s.from,h),u=n.getDash(s.to,h),d=c.width*o.fromScale,_=u.width*o.toScale;return e.e(ke(t,i,a,r),{u_patternscale_a:[l/d,-c.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*t.pixelRatio)/2,u_image:0,u_tex_y_a:c.y,u_tex_y_b:u.y,u_mix:o.t})};function Oe(t,e){return 1/Bt(t,1,e.tileZoom)}function Ne(t,e,i,a){return t.translatePosMatrix(a?a.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Ue=(t,e,i,a,s)=>{return {u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*s.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:s.paint.get("raster-brightness-min"),u_brightness_high:s.paint.get("raster-brightness-max"),u_saturation_factor:(r=s.paint.get("raster-saturation"),r>0?1-1/(1.001-r):-r),u_contrast_factor:(o=s.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:je(s.paint.get("raster-hue-rotate"))};var o,r;};function je(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return [(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Ze=(t,e,i,a,s,o,r,n,l,h,c,u,d,_)=>{const p=r.transform;return {u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:r.options.fadeDuration?r.symbolFadeChange:1,u_matrix:n,u_label_plane_matrix:l,u_coord_matrix:h,u_is_text:+u,u_pitch_with_map:+a,u_is_along_line:s,u_is_variable_anchor:o,u_texsize:d,u_texture:0,u_translation:c,u_pitched_scale:_}},qe=(t,i,a,s,o,r,n,l,h,c,u,d,_,p,m)=>{const f=n.transform;return e.e(Ze(t,i,a,s,o,r,n,l,h,c,u,d,_,m),{u_gamma_scale:s?Math.cos(f._pitch)*f.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:+p})},Ve=(t,i,a,s,o,r,n,l,h,c,u,d,_,p)=>e.e(qe(t,i,a,s,o,r,n,l,h,c,u,!0,d,!0,p),{u_texsize_icon:_,u_texture_icon:1}),Ge=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),He=(t,i,a,s,o,r)=>e.e(function(t,e,i,a){const s=i.imageManager.getPattern(t.from.toString()),o=i.imageManager.getPattern(t.to.toString()),{width:r,height:n}=i.imageManager.getPixelSize(),l=Math.pow(2,a.tileID.overscaledZ),h=a.tileSize*Math.pow(2,i.transform.tileZoom)/l,c=h*(a.tileID.canonical.x+a.tileID.wrap*l),u=h*a.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[r,n],u_mix:e.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/Bt(a,1,i.transform.tileZoom),u_pixel_coord_upper:[c>>16,u>>16],u_pixel_coord_lower:[65535&c,65535&u]}}(s,r,a,o),{u_matrix:t,u_opacity:i}),We={fillExtrusion:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_lightpos:new e.aN(t,i.u_lightpos),u_lightintensity:new e.aI(t,i.u_lightintensity),u_lightcolor:new e.aN(t,i.u_lightcolor),u_vertical_gradient:new e.aI(t,i.u_vertical_gradient),u_opacity:new e.aI(t,i.u_opacity)}),fillExtrusionPattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_lightpos:new e.aN(t,i.u_lightpos),u_lightintensity:new e.aI(t,i.u_lightintensity),u_lightcolor:new e.aN(t,i.u_lightcolor),u_vertical_gradient:new e.aI(t,i.u_vertical_gradient),u_height_factor:new e.aI(t,i.u_height_factor),u_image:new e.aH(t,i.u_image),u_texsize:new e.aO(t,i.u_texsize),u_pixel_coord_upper:new e.aO(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aO(t,i.u_pixel_coord_lower),u_scale:new e.aN(t,i.u_scale),u_fade:new e.aI(t,i.u_fade),u_opacity:new e.aI(t,i.u_opacity)}),fill:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix)}),fillPattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_image:new e.aH(t,i.u_image),u_texsize:new e.aO(t,i.u_texsize),u_pixel_coord_upper:new e.aO(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aO(t,i.u_pixel_coord_lower),u_scale:new e.aN(t,i.u_scale),u_fade:new e.aI(t,i.u_fade)}),fillOutline:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_world:new e.aO(t,i.u_world)}),fillOutlinePattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_world:new e.aO(t,i.u_world),u_image:new e.aH(t,i.u_image),u_texsize:new e.aO(t,i.u_texsize),u_pixel_coord_upper:new e.aO(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aO(t,i.u_pixel_coord_lower),u_scale:new e.aN(t,i.u_scale),u_fade:new e.aI(t,i.u_fade)}),circle:(t,i)=>({u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_scale_with_map:new e.aH(t,i.u_scale_with_map),u_pitch_with_map:new e.aH(t,i.u_pitch_with_map),u_extrude_scale:new e.aO(t,i.u_extrude_scale),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_matrix:new e.aJ(t,i.u_matrix)}),collisionBox:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_pixel_extrude_scale:new e.aO(t,i.u_pixel_extrude_scale)}),collisionCircle:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_inv_matrix:new e.aJ(t,i.u_inv_matrix),u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_viewport_size:new e.aO(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.aL(t,i.u_color),u_matrix:new e.aJ(t,i.u_matrix),u_overlay:new e.aH(t,i.u_overlay),u_overlay_scale:new e.aI(t,i.u_overlay_scale)}),clippingMask:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix)}),heatmap:(t,i)=>({u_extrude_scale:new e.aI(t,i.u_extrude_scale),u_intensity:new e.aI(t,i.u_intensity),u_matrix:new e.aJ(t,i.u_matrix)}),heatmapTexture:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_world:new e.aO(t,i.u_world),u_image:new e.aH(t,i.u_image),u_color_ramp:new e.aH(t,i.u_color_ramp),u_opacity:new e.aI(t,i.u_opacity)}),hillshade:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_image:new e.aH(t,i.u_image),u_latrange:new e.aO(t,i.u_latrange),u_light:new e.aO(t,i.u_light),u_shadow:new e.aL(t,i.u_shadow),u_highlight:new e.aL(t,i.u_highlight),u_accent:new e.aL(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_image:new e.aH(t,i.u_image),u_dimension:new e.aO(t,i.u_dimension),u_zoom:new e.aI(t,i.u_zoom),u_unpack:new e.aK(t,i.u_unpack)}),line:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_ratio:new e.aI(t,i.u_ratio),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aO(t,i.u_units_to_pixels)}),lineGradient:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_ratio:new e.aI(t,i.u_ratio),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aO(t,i.u_units_to_pixels),u_image:new e.aH(t,i.u_image),u_image_height:new e.aI(t,i.u_image_height)}),linePattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_texsize:new e.aO(t,i.u_texsize),u_ratio:new e.aI(t,i.u_ratio),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_image:new e.aH(t,i.u_image),u_units_to_pixels:new e.aO(t,i.u_units_to_pixels),u_scale:new e.aN(t,i.u_scale),u_fade:new e.aI(t,i.u_fade)}),lineSDF:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_ratio:new e.aI(t,i.u_ratio),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aO(t,i.u_units_to_pixels),u_patternscale_a:new e.aO(t,i.u_patternscale_a),u_patternscale_b:new e.aO(t,i.u_patternscale_b),u_sdfgamma:new e.aI(t,i.u_sdfgamma),u_image:new e.aH(t,i.u_image),u_tex_y_a:new e.aI(t,i.u_tex_y_a),u_tex_y_b:new e.aI(t,i.u_tex_y_b),u_mix:new e.aI(t,i.u_mix)}),raster:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_tl_parent:new e.aO(t,i.u_tl_parent),u_scale_parent:new e.aI(t,i.u_scale_parent),u_buffer_scale:new e.aI(t,i.u_buffer_scale),u_fade_t:new e.aI(t,i.u_fade_t),u_opacity:new e.aI(t,i.u_opacity),u_image0:new e.aH(t,i.u_image0),u_image1:new e.aH(t,i.u_image1),u_brightness_low:new e.aI(t,i.u_brightness_low),u_brightness_high:new e.aI(t,i.u_brightness_high),u_saturation_factor:new e.aI(t,i.u_saturation_factor),u_contrast_factor:new e.aI(t,i.u_contrast_factor),u_spin_weights:new e.aN(t,i.u_spin_weights)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.aH(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aH(t,i.u_is_size_feature_constant),u_size_t:new e.aI(t,i.u_size_t),u_size:new e.aI(t,i.u_size),u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_pitch:new e.aI(t,i.u_pitch),u_rotate_symbol:new e.aH(t,i.u_rotate_symbol),u_aspect_ratio:new e.aI(t,i.u_aspect_ratio),u_fade_change:new e.aI(t,i.u_fade_change),u_matrix:new e.aJ(t,i.u_matrix),u_label_plane_matrix:new e.aJ(t,i.u_label_plane_matrix),u_coord_matrix:new e.aJ(t,i.u_coord_matrix),u_is_text:new e.aH(t,i.u_is_text),u_pitch_with_map:new e.aH(t,i.u_pitch_with_map),u_is_along_line:new e.aH(t,i.u_is_along_line),u_is_variable_anchor:new e.aH(t,i.u_is_variable_anchor),u_texsize:new e.aO(t,i.u_texsize),u_texture:new e.aH(t,i.u_texture),u_translation:new e.aO(t,i.u_translation),u_pitched_scale:new e.aI(t,i.u_pitched_scale)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.aH(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aH(t,i.u_is_size_feature_constant),u_size_t:new e.aI(t,i.u_size_t),u_size:new e.aI(t,i.u_size),u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_pitch:new e.aI(t,i.u_pitch),u_rotate_symbol:new e.aH(t,i.u_rotate_symbol),u_aspect_ratio:new e.aI(t,i.u_aspect_ratio),u_fade_change:new e.aI(t,i.u_fade_change),u_matrix:new e.aJ(t,i.u_matrix),u_label_plane_matrix:new e.aJ(t,i.u_label_plane_matrix),u_coord_matrix:new e.aJ(t,i.u_coord_matrix),u_is_text:new e.aH(t,i.u_is_text),u_pitch_with_map:new e.aH(t,i.u_pitch_with_map),u_is_along_line:new e.aH(t,i.u_is_along_line),u_is_variable_anchor:new e.aH(t,i.u_is_variable_anchor),u_texsize:new e.aO(t,i.u_texsize),u_texture:new e.aH(t,i.u_texture),u_gamma_scale:new e.aI(t,i.u_gamma_scale),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_is_halo:new e.aH(t,i.u_is_halo),u_translation:new e.aO(t,i.u_translation),u_pitched_scale:new e.aI(t,i.u_pitched_scale)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.aH(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aH(t,i.u_is_size_feature_constant),u_size_t:new e.aI(t,i.u_size_t),u_size:new e.aI(t,i.u_size),u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_pitch:new e.aI(t,i.u_pitch),u_rotate_symbol:new e.aH(t,i.u_rotate_symbol),u_aspect_ratio:new e.aI(t,i.u_aspect_ratio),u_fade_change:new e.aI(t,i.u_fade_change),u_matrix:new e.aJ(t,i.u_matrix),u_label_plane_matrix:new e.aJ(t,i.u_label_plane_matrix),u_coord_matrix:new e.aJ(t,i.u_coord_matrix),u_is_text:new e.aH(t,i.u_is_text),u_pitch_with_map:new e.aH(t,i.u_pitch_with_map),u_is_along_line:new e.aH(t,i.u_is_along_line),u_is_variable_anchor:new e.aH(t,i.u_is_variable_anchor),u_texsize:new e.aO(t,i.u_texsize),u_texsize_icon:new e.aO(t,i.u_texsize_icon),u_texture:new e.aH(t,i.u_texture),u_texture_icon:new e.aH(t,i.u_texture_icon),u_gamma_scale:new e.aI(t,i.u_gamma_scale),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_is_halo:new e.aH(t,i.u_is_halo),u_translation:new e.aO(t,i.u_translation),u_pitched_scale:new e.aI(t,i.u_pitched_scale)}),background:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_opacity:new e.aI(t,i.u_opacity),u_color:new e.aL(t,i.u_color)}),backgroundPattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_opacity:new e.aI(t,i.u_opacity),u_image:new e.aH(t,i.u_image),u_pattern_tl_a:new e.aO(t,i.u_pattern_tl_a),u_pattern_br_a:new e.aO(t,i.u_pattern_br_a),u_pattern_tl_b:new e.aO(t,i.u_pattern_tl_b),u_pattern_br_b:new e.aO(t,i.u_pattern_br_b),u_texsize:new e.aO(t,i.u_texsize),u_mix:new e.aI(t,i.u_mix),u_pattern_size_a:new e.aO(t,i.u_pattern_size_a),u_pattern_size_b:new e.aO(t,i.u_pattern_size_b),u_scale_a:new e.aI(t,i.u_scale_a),u_scale_b:new e.aI(t,i.u_scale_b),u_pixel_coord_upper:new e.aO(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aO(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.aI(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_texture:new e.aH(t,i.u_texture),u_ele_delta:new e.aI(t,i.u_ele_delta),u_fog_matrix:new e.aJ(t,i.u_fog_matrix),u_fog_color:new e.aL(t,i.u_fog_color),u_fog_ground_blend:new e.aI(t,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new e.aI(t,i.u_fog_ground_blend_opacity),u_horizon_color:new e.aL(t,i.u_horizon_color),u_horizon_fog_blend:new e.aI(t,i.u_horizon_fog_blend)}),terrainDepth:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_ele_delta:new e.aI(t,i.u_ele_delta)}),terrainCoords:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_texture:new e.aH(t,i.u_texture),u_terrain_coords_id:new e.aI(t,i.u_terrain_coords_id),u_ele_delta:new e.aI(t,i.u_ele_delta)}),sky:(t,i)=>({u_sky_color:new e.aL(t,i.u_sky_color),u_horizon_color:new e.aL(t,i.u_horizon_color),u_horizon:new e.aI(t,i.u_horizon),u_sky_horizon_blend:new e.aI(t,i.u_sky_horizon_blend)})};class $e{constructor(t,e,i){this.context=t;const a=t.gl;this.buffer=a.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const Xe={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ke{constructor(t,e,i,a){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=a,this.context=t;const s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer);}enableAttributes(t,e){for(let i=0;i0){const i=e.H();e.aQ(i,m.placementInvProjMatrix,t.transform.glCoordMatrix),e.aQ(i,i,m.placementViewportMatrix),h.push({circleArray:g,circleOffset:u,transform:p.posMatrix,invTransform:i,coord:p}),c+=g.length/4,u=c;}f&&l.draw(r,n.LINES,Oi.disabled,Ui.disabled,t.colorModeForRenderPass(),ji.disabled,{u_matrix:p.posMatrix,u_pixel_extrude_scale:[1/(d=t.transform).width,1/d.height]},t.style.map.terrain&&t.style.map.terrain.getTerrainData(p),a.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,null,t.transform.zoom,null,null,f.collisionVertexBuffer);}var d;if(!o||!h.length)return;const _=t.useProgram("collisionCircle"),p=new e.aR;p.resize(4*c),p._trim();let m=0;for(const t of h)for(let e=0;e=0&&(v[x.associatedIconIndex]={shiftedAnchor:D,angle:M});}else Rt(x.numGlyphs,f);}if(c){g.clear();const i=t.icon.placedSymbolArray;for(let t=0;tt.style.map.terrain.getElevation(l,e,i):null,i="map"===a.layout.get("text-rotation-alignment");wt(h,l.posMatrix,t,o,U,Z,v,c,i,f,l.toUnwrapped(),m.width,m.height,q,e);}const H=l.posMatrix,W=o&&E||G,$=x||W?Vi:U,X=j,K=_&&0!==a.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let J;J=_?h.iconsInText?Ve(I.kind,D,y,v,x,W,t,H,$,X,q,A,F,C):qe(I.kind,D,y,v,x,W,t,H,$,X,q,o,A,!0,C):Ze(I.kind,D,y,v,x,W,t,H,$,X,q,o,A,C);const Y={program:z,buffers:u,uniformValues:J,atlasTexture:R,atlasTextureIcon:B,atlasInterpolation:k,atlasInterpolationIcon:L,isSDF:_,hasHalo:K};if(w&&h.canOverlap){T=!0;const t=u.segments.get();for(const i of t)P.push({segments:new e.a0([i]),sortKey:i.sortKey,state:Y,terrainData:M});}else P.push({segments:u.segments,sortKey:0,state:Y,terrainData:M});}T&&P.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of P){const i=e.state;if(_.activeTexture.set(p.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,p.CLAMP_TO_EDGE),i.atlasTextureIcon&&(_.activeTexture.set(p.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),i.isSDF){const s=i.uniformValues;i.hasHalo&&(s.u_is_halo=1,Ki(i.buffers,e.segments,a,t,i.program,I,u,d,s,e.terrainData)),s.u_is_halo=0;}Ki(i.buffers,e.segments,a,t,i.program,I,u,d,i.uniformValues,e.terrainData);}}function Ki(t,e,i,a,s,o,r,n,l,h){const c=a.context;s.draw(c,c.gl.TRIANGLES,o,r,n,ji.disabled,l,h,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,a.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer);}function Ji(t,i,a,s){const o=t.context,r=o.gl,n=Ui.disabled,l=new Fi([r.ONE,r.ONE],e.aM.transparent,[!0,!0,!0,!0]),h=i.getBucket(a);if(!h)return;const c=s.key;let u=a.heatmapFbos.get(c);u||(u=Qi(o,i.tileSize,i.tileSize),a.heatmapFbos.set(c,u)),o.bindFramebuffer.set(u.framebuffer),o.viewport.set([0,0,i.tileSize,i.tileSize]),o.clear({color:e.aM.transparent});const d=h.programConfigurations.get(a.id),_=t.useProgram("heatmap",d),p=t.style.map.terrain.getTerrainData(s);_.draw(o,r.TRIANGLES,Oi.disabled,n,l,ji.disabled,Me(s.posMatrix,i,t.transform.zoom,a.paint.get("heatmap-intensity")),p,a.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,a.paint,t.transform.zoom,d);}function Yi(t,e,i){const a=t.context,s=a.gl;a.setColorMode(t.colorModeForRenderPass());const o=ta(a,e),r=i.key,n=e.heatmapFbos.get(r);n&&(a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,n.colorAttachment.get()),a.activeTexture.set(s.TEXTURE1),o.bind(s.LINEAR,s.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(a,s.TRIANGLES,Oi.disabled,Ui.disabled,t.colorModeForRenderPass(),ji.disabled,Ae(t,e,0,1),null,e.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,e.paint,t.transform.zoom),n.destroy(),e.heatmapFbos.delete(r));}function Qi(t,e,i){var a,s;const o=t.gl,r=o.createTexture();o.bindTexture(o.TEXTURE_2D,r),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),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const n=null!==(a=t.HALF_FLOAT)&&void 0!==a?a:o.UNSIGNED_BYTE,l=null!==(s=t.RGBA16F)&&void 0!==s?s:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,e,i,0,o.RGBA,n,null);const h=t.createFramebuffer(e,i,!1,!1);return h.colorAttachment.set(r),h}function ta(t,e){return e.colorRampTexture||(e.colorRampTexture=new b(t,e.colorRamp,t.gl.RGBA)),e.colorRampTexture}function ea(t,e,i,a,s){if(!i||!a||!a.imageAtlas)return;const o=a.imageAtlas.patternPositions;let r=o[i.to.toString()],n=o[i.from.toString()];if(!r&&n&&(r=n),!n&&r&&(n=r),!r||!n){const t=s.getPaintProperty(e);r=o[t],n=o[t];}r&&n&&t.setConstantPatternPositions(r,n);}function ia(t,e,i,a,s,o,r){const n=t.context.gl,l="fill-pattern",h=i.paint.get(l),c=h&&h.constantOr(1),u=i.getCrossfadeParameters();let d,_,p,m,f;r?(_=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",d=n.LINES):(_=c?"fillPattern":"fill",d=n.TRIANGLES);const g=h.constantOr(null);for(const h of a){const a=e.getTile(h);if(c&&!a.patternsLoaded())continue;const v=a.getBucket(i);if(!v)continue;const x=v.programConfigurations.get(i.id),y=t.useProgram(_,x),b=t.style.map.terrain&&t.style.map.terrain.getTerrainData(h);c&&(t.context.activeTexture.set(n.TEXTURE0),a.imageAtlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),x.updatePaintBuffers(u)),ea(x,l,g,a,i);const w=b?h:null,T=t.translatePosMatrix(w?w.posMatrix:h.posMatrix,a,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(r){m=v.indexBuffer2,f=v.segments2;const e=[n.drawingBufferWidth,n.drawingBufferHeight];p="fillOutlinePattern"===_&&c?Pe(T,t,u,a,e):Ee(T,e);}else m=v.indexBuffer,f=v.segments,p=c?Ie(T,t,u,a):Te(T);y.draw(t.context,d,s,t.stencilModeForClipping(h),o,ji.disabled,p,b,i.id,v.layoutVertexBuffer,m,f,i.paint,t.transform.zoom,x);}}function aa(t,e,i,a,s,o,r){const n=t.context,l=n.gl,h="fill-extrusion-pattern",c=i.paint.get(h),u=c.constantOr(1),d=i.getCrossfadeParameters(),_=i.paint.get("fill-extrusion-opacity"),p=c.constantOr(null);for(const c of a){const a=e.getTile(c),m=a.getBucket(i);if(!m)continue;const f=t.style.map.terrain&&t.style.map.terrain.getTerrainData(c),g=m.programConfigurations.get(i.id),v=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",g);u&&(t.context.activeTexture.set(l.TEXTURE0),a.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),g.updatePaintBuffers(d)),ea(g,h,p,a,i);const x=t.translatePosMatrix(c.posMatrix,a,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),y=i.paint.get("fill-extrusion-vertical-gradient"),b=u?we(x,t,y,_,c,d,a):be(x,t,y,_);v.draw(n,n.gl.TRIANGLES,s,o,r,ji.backCCW,b,f,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,g,t.style.map.terrain&&m.centroidVertexBuffer);}}function sa(t,e,i,a,s,o,r){const n=t.context,l=n.gl,h=i.fbo;if(!h)return;const c=t.useProgram("hillshade"),u=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);n.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,h.colorAttachment.get()),c.draw(n,l.TRIANGLES,s,o,r,ji.disabled,((t,e,i,a)=>{const s=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),r=i.paint.get("hillshade-accent-color");let n=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(n-=t.transform.angle);const l=!t.options.moving;return {u_matrix:a?a.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:Re(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),n],u_shadow:s,u_highlight:o,u_accent:r}})(t,i,a,u?e:null),u,a.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments);}function oa(t,i,a,s,o,r){const n=t.context,l=n.gl,h=i.dem;if(h&&h.data){const c=h.dim,u=h.stride,d=h.getPixels();if(n.activeTexture.set(l.TEXTURE1),n.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(u),i.demTexture){const t=i.demTexture;t.update(d,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE);}else i.demTexture=new b(n,d,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);n.activeTexture.set(l.TEXTURE0);let _=i.fbo;if(!_){const t=new b(n,{width:c,height:c,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),_=i.fbo=n.createFramebuffer(c,c,!0,!1),_.colorAttachment.set(t.texture);}n.bindFramebuffer.set(_.framebuffer),n.viewport.set([0,0,c,c]),t.useProgram("hillshadePrepare").draw(n,l.TRIANGLES,s,o,r,ji.disabled,((t,i)=>{const a=i.stride,s=e.H();return e.aP(s,0,e.X,-e.X,0,0,1),e.J(s,s,[0,-e.X,0]),{u_matrix:s,u_image:1,u_dimension:[a,a],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}})(i.tileID,h),null,a.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1;}}function ra(t,i,a,s,r,n){const l=s.paint.get("raster-fade-duration");if(!n&&l>0){const s=o.now(),n=(s-t.timeAdded)/l,h=i?(s-i.timeAdded)/l:-1,c=a.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),_=d&&t.refreshedUponExpiration?1:e.ac(d?n:1-h,0,1);return t.refreshedUponExpiration&&n>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-_}:{opacity:_,mix:0}}return {opacity:1,mix:0}}const na=new e.aM(1,0,0,1),la=new e.aM(0,1,0,1),ha=new e.aM(0,0,1,1),ca=new e.aM(1,0,1,1),ua=new e.aM(0,1,1,1);function da(t,e,i,a){pa(t,0,e+i/2,t.transform.width,i,a);}function _a(t,e,i,a){pa(t,e-i/2,0,i,t.transform.height,a);}function pa(t,e,i,a,s,o){const r=t.context,n=r.gl;n.enable(n.SCISSOR_TEST),n.scissor(e*t.pixelRatio,i*t.pixelRatio,a*t.pixelRatio,s*t.pixelRatio),r.clear({color:o}),n.disable(n.SCISSOR_TEST);}function ma(t,i,a){const s=t.context,o=s.gl,r=a.posMatrix,n=t.useProgram("debug"),l=Oi.disabled,h=Ui.disabled,c=t.colorModeForRenderPass(),u="$debug",d=t.style.map.terrain&&t.style.map.terrain.getTerrainData(a);s.activeTexture.set(o.TEXTURE0);const _=i.getTileByID(a.key).latestRawTileData,p=Math.floor((_&&_.byteLength||0)/1024),m=i.getTile(a).tileSize,f=512/Math.min(m,512)*(a.overscaledZ/t.transform.zoom)*.5;let g=a.canonical.toString();a.overscaledZ!==a.canonical.z&&(g+=` => ${a.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,a=t.context.gl,s=t.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,i.width,i.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(e,5,5),s.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE);}(t,`${g} ${p}kB`),n.draw(s,o.TRIANGLES,l,h,Fi.alphaBlended,ji.disabled,ze(r,e.aM.transparent,f),null,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),n.draw(s,o.LINE_STRIP,l,h,c,ji.disabled,ze(r,e.aM.red),d,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments);}function fa(t,e,i){const a=t.context,s=a.gl,o=t.colorModeForRenderPass(),r=new Oi(s.LEQUAL,Oi.ReadWrite,t.depthRangeFor3D),n=t.useProgram("terrain"),l=e.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,t.width,t.height]);for(const h of i){const i=t.renderToTexture.getTexture(h),c=e.getTerrainData(h.tileID);a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,i.texture);const u=t.transform.calculatePosMatrix(h.tileID.toUnwrapped()),d=e.getMeshFrameDelta(t.transform.zoom),_=t.transform.calculateFogMatrix(h.tileID.toUnwrapped()),p=ge(u,d,_,t.style.sky,t.transform.pitch);n.draw(a,s.TRIANGLES,r,Ui.disabled,o,ji.backCCW,p,c,"terrain",l.vertexBuffer,l.indexBuffer,l.segments);}}class ga{constructor(t,e,i){this.vertexBuffer=t,this.indexBuffer=e,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}class va{constructor(t,i){this.context=new Bi(t),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ut.maxUnderzooming+ut.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new he;}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize();}setup(){const t=this.context,i=new e.aX;i.emplaceBack(0,0),i.emplaceBack(e.X,0),i.emplaceBack(0,e.X),i.emplaceBack(e.X,e.X),this.tileExtentBuffer=t.createVertexBuffer(i,_e.members),this.tileExtentSegments=e.a0.simpleSegment(0,0,4,2);const a=new e.aX;a.emplaceBack(0,0),a.emplaceBack(e.X,0),a.emplaceBack(0,e.X),a.emplaceBack(e.X,e.X),this.debugBuffer=t.createVertexBuffer(a,_e.members),this.debugSegments=e.a0.simpleSegment(0,0,4,5);const s=new e.$;s.emplaceBack(0,0,0,0),s.emplaceBack(e.X,0,e.X,0),s.emplaceBack(0,e.X,0,e.X),s.emplaceBack(e.X,e.X,e.X,e.X),this.rasterBoundsBuffer=t.createVertexBuffer(s,Y.members),this.rasterBoundsSegments=e.a0.simpleSegment(0,0,4,2);const o=new e.aX;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(o,_e.members),this.viewportSegments=e.a0.simpleSegment(0,0,4,2);const r=new e.aZ;r.emplaceBack(0),r.emplaceBack(1),r.emplaceBack(3),r.emplaceBack(2),r.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(r);const n=new e.aY;n.emplaceBack(0,1,2),n.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(n);const l=this.context.gl;this.stencilClearMode=new Ui({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO);}clearStencil(){const t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=e.H();e.aP(a,0,this.width,this.height,0,0,1),e.K(a,a,[i.drawingBufferWidth,i.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,i.TRIANGLES,Oi.disabled,this.stencilClearMode,Fi.disabled,ji.disabled,De(a),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;const i=this.context,a=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(Fi.disabled),i.setDepthMode(Oi.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,o=this.style.map.terrain&&this.style.map.terrain.getTerrainData(t);s.draw(i,a.TRIANGLES,Oi.disabled,new Ui({func:a.ALWAYS,mask:0},e,255,a.KEEP,a.KEEP,a.REPLACE),Fi.disabled,ji.disabled,De(t.posMatrix),o,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new Ui({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new Ui({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),a=i[i.length-1].overscaledZ,s=i[0].overscaledZ-a+1;if(s>1){this.currentStencilSource=void 0,this.nextStencilID+s>256&&this.clearStencil();const t={};for(let i=0;i({u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:(e.height/2+e.getHorizon())*i,u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*i}))(i,t.style.map.transform,t.pixelRatio),r=new Oi(s.LEQUAL,Oi.ReadWrite,[0,1]),n=Ui.disabled,l=t.colorModeForRenderPass(),h=t.useProgram("sky");if(!i.mesh){const t=new e.aX;t.emplaceBack(-1,-1),t.emplaceBack(1,-1),t.emplaceBack(1,1),t.emplaceBack(-1,1);const s=new e.aY;s.emplaceBack(0,1,2),s.emplaceBack(0,2,3),i.mesh=new ga(a.createVertexBuffer(t,_e.members),a.createIndexBuffer(s),e.a0.simpleSegment(0,0,t.length,s.length));}h.draw(a,s.TRIANGLES,r,n,l,ji.disabled,o,void 0,"sky",i.mesh.vertexBuffer,i.mesh.indexBuffer,i.mesh.segments);}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[a[this.currentLayer]],e=s[t.source],i=r[t.source];this._renderTileClippingMasks(t,i),this.renderLayer(this,e,t,i);}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayeri.source&&!i.isHidden(e)?[t.sourceCaches[i.source]]:[])),s=a.filter((t=>"vector"===t.getSource().type)),o=a.filter((t=>"vector"!==t.getSource().type)),r=t=>{(!i||i.getSource().maxzoomr(t))),i||o.forEach((t=>r(t))),i}(this.style,this.transform.zoom);t&&function(t,e,i){for(let a=0;a0),s&&(e.b0(i,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,i){const a=t.context,s=a.gl,o=Fi.unblended,r=new Oi(s.LEQUAL,Oi.ReadWrite,[0,1]),n=i.getTerrainMesh(),l=i.sourceCache.getRenderableTiles(),h=t.useProgram("terrainDepth");a.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),a.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),a.clear({color:e.aM.transparent,depth:1});for(const e of l){const l=i.getTerrainData(e.tileID),c={u_matrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped()),u_ele_delta:i.getMeshFrameDelta(t.transform.zoom)};h.draw(a,s.TRIANGLES,r,Ui.disabled,o,ji.backCCW,c,l,"terrain",n.vertexBuffer,n.indexBuffer,n.segments);}a.bindFramebuffer.set(null),a.viewport.set([0,0,t.width,t.height]);}(this,this.style.map.terrain),function(t,i){const a=t.context,s=a.gl,o=Fi.unblended,r=new Oi(s.LEQUAL,Oi.ReadWrite,[0,1]),n=i.getTerrainMesh(),l=i.getCoordsTexture(),h=i.sourceCache.getRenderableTiles(),c=t.useProgram("terrainCoords");a.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),a.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),a.clear({color:e.aM.transparent,depth:1}),i.coordsIndex=[];for(const e of h){const h=i.getTerrainData(e.tileID);a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,l.texture);const u={u_matrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped()),u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(t.transform.zoom)};c.draw(a,s.TRIANGLES,r,Ui.disabled,o,ji.backCCW,u,h,"terrain",n.vertexBuffer,n.indexBuffer,n.segments),i.coordsIndex.push(e.tileID.key);}a.bindFramebuffer.set(null),a.viewport.set([0,0,t.width,t.height]);}(this,this.style.map.terrain));}renderLayer(t,i,a,s){if(!a.isHidden(this.transform.zoom)&&("background"===a.type||"custom"===a.type||(s||[]).length))switch(this.id=a.id,a.type){case"symbol":!function(t,i,a,s,o){if("translucent"!==t.renderPass)return;const r=Ui.disabled,n=t.colorModeForRenderPass();(a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,a,s,o,r,n,l,h){const c=i.transform,u=ie(),d="map"===o,_="map"===r;for(const o of t){const t=s.getTile(o),r=t.getBucket(a);if(!r||!r.text||!r.text.segments.get().length)continue;const p=e.ag(r.textSizeData,c.zoom),m=Bt(t,1,i.transform.zoom),f=gt(o.posMatrix,_,d,i.transform,m),g="none"!==a.layout.get("icon-text-fit")&&r.hasIconData();if(p){const e=Math.pow(2,c.zoom-t.tileID.overscaledZ),a=i.style.map.terrain?(t,e)=>i.style.map.terrain.getElevation(o,t,e):null,s=u.translatePosition(c,t,n,l);Wi(r,d,_,h,c,f,o.posMatrix,e,p,g,u,s,o.toUnwrapped(),a);}}}(s,t,a,i,a.layout.get("text-rotation-alignment"),a.layout.get("text-pitch-alignment"),a.paint.get("text-translate"),a.paint.get("text-translate-anchor"),o),0!==a.paint.get("icon-opacity").constantOr(1)&&Xi(t,i,a,s,!1,a.paint.get("icon-translate"),a.paint.get("icon-translate-anchor"),a.layout.get("icon-rotation-alignment"),a.layout.get("icon-pitch-alignment"),a.layout.get("icon-keep-upright"),r,n),0!==a.paint.get("text-opacity").constantOr(1)&&Xi(t,i,a,s,!0,a.paint.get("text-translate"),a.paint.get("text-translate-anchor"),a.layout.get("text-rotation-alignment"),a.layout.get("text-pitch-alignment"),a.layout.get("text-keep-upright"),r,n),i.map.showCollisionBoxes&&(qi(t,i,a,s,!0),qi(t,i,a,s,!1));}(t,i,a,s,this.style.placement.variableOffsets);break;case"circle":!function(t,i,a,s){if("translucent"!==t.renderPass)return;const o=a.paint.get("circle-opacity"),r=a.paint.get("circle-stroke-width"),n=a.paint.get("circle-stroke-opacity"),l=!a.layout.get("circle-sort-key").isConstant();if(0===o.constantOr(1)&&(0===r.constantOr(1)||0===n.constantOr(1)))return;const h=t.context,c=h.gl,u=t.depthModeForSublayer(0,Oi.ReadOnly),d=Ui.disabled,_=t.colorModeForRenderPass(),p=[];for(let o=0;ot.sortKey-e.sortKey));for(const e of p){const{programConfiguration:i,program:s,layoutVertexBuffer:o,indexBuffer:r,uniformValues:n,terrainData:l}=e.state;s.draw(h,c.TRIANGLES,u,d,_,ji.disabled,n,l,a.id,o,r,e.segments,a.paint,t.transform.zoom,i);}}(t,i,a,s);break;case"heatmap":!function(t,i,a,s){if(0===a.paint.get("heatmap-opacity"))return;const o=t.context;if(t.style.map.terrain){for(const e of s){const s=i.getTile(e);i.hasRenderableParent(e)||("offscreen"===t.renderPass?Ji(t,s,a,e):"translucent"===t.renderPass&&Yi(t,a,e));}o.viewport.set([0,0,t.width,t.height]);}else "offscreen"===t.renderPass?function(t,i,a,s){const o=t.context,r=o.gl,n=Ui.disabled,l=new Fi([r.ONE,r.ONE],e.aM.transparent,[!0,!0,!0,!0]);((function(t,i,a){const s=t.gl;t.activeTexture.set(s.TEXTURE1),t.viewport.set([0,0,i.width/4,i.height/4]);let o=a.heatmapFbos.get(e.aU);o?(s.bindTexture(s.TEXTURE_2D,o.colorAttachment.get()),t.bindFramebuffer.set(o.framebuffer)):(o=Qi(t,i.width/4,i.height/4),a.heatmapFbos.set(e.aU,o));}))(o,t,a),o.clear({color:e.aM.transparent});for(let e=0;e20&&o.texParameterf(o.TEXTURE_2D,s.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,s.extTextureFilterAnisotropicMax);const y=t.style.map.terrain&&t.style.map.terrain.getTerrainData(a),b=y?a:null,w=b?b.posMatrix:t.transform.calculatePosMatrix(a.toUnwrapped(),d),T=Ue(w,v||[0,0],g||1,f,i);r instanceof Q?n.draw(s,o.TRIANGLES,c,Ui.disabled,l,ji.disabled,T,y,i.id,r.boundsBuffer,t.quadTriangleIndexBuffer,r.boundsSegments):n.draw(s,o.TRIANGLES,c,h[a.overscaledZ],l,ji.disabled,T,y,i.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments);}}(t,i,a,s);break;case"background":!function(t,e,i,a){const s=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;const r=t.context,n=r.gl,l=t.transform,h=l.tileSize,c=i.paint.get("background-pattern");if(t.isPatternMissing(c))return;const u=!c&&1===s.a&&1===o&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==u)return;const d=Ui.disabled,_=t.depthModeForSublayer(0,"opaque"===u?Oi.ReadWrite:Oi.ReadOnly),p=t.colorModeForRenderPass(),m=t.useProgram(c?"backgroundPattern":"background"),f=a||l.coveringTiles({tileSize:h,terrain:t.style.map.terrain});c&&(r.activeTexture.set(n.TEXTURE0),t.imageManager.bind(t.context));const g=i.getCrossfadeParameters();for(const e of f){const l=a?e.posMatrix:t.transform.calculatePosMatrix(e.toUnwrapped()),u=c?He(l,o,t,c,{tileID:e,tileSize:h},g):Ge(l,o,s),f=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);m.draw(r,n.TRIANGLES,_,d,p,ji.disabled,u,f,i.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments);}}(t,0,a,s);break;case"custom":!function(t,e,i){const a=t.context,s=i.implementation;if("offscreen"===t.renderPass){const e=s.prerender;e&&(t.setCustomLayerDefaults(),a.setColorMode(t.colorModeForRenderPass()),e.call(s,a.gl,t.transform.customLayerMatrix()),a.setDirty(),t.setBaseState());}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),a.setColorMode(t.colorModeForRenderPass()),a.setStencilMode(Ui.disabled);const e="3d"===s.renderingMode?new Oi(t.context.gl.LEQUAL,Oi.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Oi.ReadOnly);a.setDepthMode(e),s.render(a.gl,t.transform.customLayerMatrix(),{farZ:t.transform.farZ,nearZ:t.transform.nearZ,fov:t.transform._fov,modelViewProjectionMatrix:t.transform.modelViewProjectionMatrix,projectionMatrix:t.transform.projectionMatrix}),a.setDirty(),t.setBaseState(),a.bindFramebuffer.set(null);}}(t,0,a);}}translatePosMatrix(t,i,a,s,o){if(!a[0]&&!a[1])return t;const r=o?"map"===s?this.transform.angle:0:"viewport"===s?-this.transform.angle:0;if(r){const t=Math.sin(r),e=Math.cos(r);a=[a[0]*e-a[1]*t,a[0]*t+a[1]*e];}const n=[o?a[0]:Bt(i,a[0],this.transform.zoom),o?a[1]:Bt(i,a[1],this.transform.zoom),0],l=new Float32Array(16);return e.J(l,t,n),l}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t];}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return !1;if(!t.from||!t.to)return !0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return !e||!i}useProgram(t,e){this.cache=this.cache||{};const i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new xe(this.context,pe[t],e,We[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[i]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new b(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}class xa{constructor(t,e){this.points=t,this.planes=e;}static fromInvProjectionMatrix(t,i,a){const s=Math.pow(2,a),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((a=>{const o=1/(a=e.af([],a,t))[3]/i*s;return e.b1(a,a,[o,o,1/a[3],o])})),r=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=function(t,e){var i=e[0],a=e[1],s=e[2],o=i*i+a*a+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}([],function(t,e,i){var a=e[0],s=e[1],o=e[2],r=i[0],n=i[1],l=i[2];return t[0]=s*l-o*n,t[1]=o*r-a*l,t[2]=a*n-s*r,t}([],g([],o[t[0]],o[t[1]]),g([],o[t[2]],o[t[1]]))),i=-((a=e)[0]*(s=o[t[1]])[0]+a[1]*s[1]+a[2]*s[2]);var a,s;return e.concat(i)}));return new xa(o,r)}}class ya{constructor(t,e){this.min=t,this.max=e,this.center=function(t,e,i){return t[0]=.5*e[0],t[1]=.5*e[1],t[2]=.5*e[2],t}([],function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}([],this.min,this.max));}quadrant(t){const e=[t%2==0,t<2],i=m(this.min),a=m(this.max);for(let t=0;t=0&&r++;if(0===r)return 0;r!==i.length&&(a=!1);}if(a)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,a=-Number.MAX_VALUE;for(let s=0;sthis.max[e]-this.min[e])return 0}return 1}}class ba{constructor(t=0,e=0,i=0,a=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(a)||a<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=a;}interpolate(t,i,a){return null!=i.top&&null!=t.top&&(this.top=e.y.number(t.top,i.top,a)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.y.number(t.bottom,i.bottom,a)),null!=i.left&&null!=t.left&&(this.left=e.y.number(t.left,i.left,a)),null!=i.right&&null!=t.right&&(this.right=e.y.number(t.right,i.right,a)),this}getCenter(t,i){const a=e.ac((this.left+t-this.right)/2,0,t),s=e.ac((this.top+i-this.bottom)/2,0,i);return new e.P(a,s)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new ba(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const wa=85.051129;class Ta{constructor(t,i,a,s,o){this.tileSize=512,this._renderWorldCopies=void 0===o||!!o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=null==a?0:a,this._maxPitch=null==s?60:s,this.setMaxBounds(),this.width=0,this.height=0,this._center=new e.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new ba,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0;}clone(){const t=new Ta(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.lngRange=t.lngRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices();}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t));}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t));}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t));}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t));}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t;}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return -this.angle/Math.PI*180}set bearing(t){const i=-e.b3(t,-180,180)*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=function(){var t=new e.A(4);return e.A!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}(),function(t,e,i){var a=e[0],s=e[1],o=e[2],r=e[3],n=Math.sin(i),l=Math.cos(i);t[0]=a*l+o*n,t[1]=s*l+r*n,t[2]=a*-n+o*l,t[3]=s*-n+r*l;}(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices());}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices());}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.tileZoom=Math.max(0,Math.floor(e)),this.scale=this.zoomScale(e),this._constrain(),this._calcMatrices());}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices();}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(t){const i=[new e.b4(0,t)];if(this._renderWorldCopies){const a=this.pointCoordinate(new e.P(0,0)),s=this.pointCoordinate(new e.P(this.width,0)),o=this.pointCoordinate(new e.P(this.width,this.height)),r=this.pointCoordinate(new e.P(0,this.height)),n=Math.floor(Math.min(a.x,s.x,o.x,r.x)),l=Math.floor(Math.max(a.x,s.x,o.x,r.x)),h=1;for(let a=n-h;a<=l+h;a++)0!==a&&i.push(new e.b4(a,t));}return i}coveringTiles(t){var i,a;let s=this.coveringZoomLevel(t);const o=s;if(void 0!==t.minzoom&&st.maxzoom&&(s=t.maxzoom);const r=this.pointCoordinate(this.getCameraPoint()),n=e.Z.fromLngLat(this.center),l=Math.pow(2,s),h=[l*r.x,l*r.y,0],c=[l*n.x,l*n.y,0],u=xa.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,s);let d=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(d=s);const _=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,p=t=>({aabb:new ya([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),m=[],f=[],g=s,x=t.reparseOverscaled?o:s;if(this._renderWorldCopies)for(let t=1;t<=3;t++)m.push(p(-t)),m.push(p(t));for(m.push(p(0));m.length>0;){const s=m.pop(),o=s.x,r=s.y;let n=s.fullyVisible;if(!n){const t=s.aabb.intersects(u);if(0===t)continue;n=2===t;}const l=t.terrain?h:c,p=s.aabb.distanceX(l),y=s.aabb.distanceY(l),b=Math.max(Math.abs(p),Math.abs(y));if(s.zoom===g||b>_+(1<=d){const t=g-s.zoom,i=h[0]-.5-(o<>1),u=s.zoom+1;let d=s.aabb.quadrant(l);if(t.terrain){const o=new e.S(u,s.wrap,u,h,c),r=t.terrain.getMinMaxElevation(o),n=null!==(i=r.minElevation)&&void 0!==i?i:this.elevation,l=null!==(a=r.maxElevation)&&void 0!==a?a:this.elevation;d=new ya([d.min[0],d.min[1],n],[d.max[0],d.max[1],l]);}m.push({aabb:d,zoom:u,x:h,y:c,wrap:s.wrap,fullyVisible:n});}}return f.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const i=e.ac(t.lat,-85.051129,wa);return new e.P(e.O(t.lng)*this.worldSize,e.Q(i)*this.worldSize)}unproject(t){return new e.Z(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return {lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const i=this.elevation,a=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,s=this.pointLocation(this.centerPoint,t),o=t.getElevationForLngLatZoom(s,this.tileZoom);if(!(this.elevation-o))return;const r=a+i-o,n=Math.cos(this._pitch)*this.cameraToCenterDistance/r/e.b5(1,s.lat),l=this.scaleZoom(n/this.tileSize);this._elevation=o,this._center=s,this.zoom=l;}setLocationAtPoint(t,i){const a=this.pointCoordinate(i),s=this.pointCoordinate(this.centerPoint),o=this.locationCoordinate(t),r=new e.Z(o.x-(a.x-s.x),o.y-(a.y-s.y));this.center=this.coordinateLocation(r),this._renderWorldCopies&&(this.center=this.center.wrap());}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),e.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return e.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,i){if(i){const e=i.pointCoordinate(t);if(null!=e)return e}const a=[t.x,t.y,0,1],s=[t.x,t.y,1,1];e.af(a,a,this.pixelMatrixInverse),e.af(s,s,this.pixelMatrixInverse);const o=a[3],r=s[3],n=a[1]/o,l=s[1]/r,h=a[2]/o,c=s[2]/r,u=h===c?0:(0-h)/(c-h);return new e.Z(e.y.number(a[0]/o,s[0]/r,u)/this.worldSize,e.y.number(n,l,u)/this.worldSize)}coordinatePoint(t,i=0,a=this.pixelMatrix){const s=[t.x*this.worldSize,t.y*this.worldSize,i,1];return e.af(s,s,a),new e.P(s[0]/s[3],s[1]/s[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return (new H).extend(this.pointLocation(new e.P(0,t))).extend(this.pointLocation(new e.P(this.width,t))).extend(this.pointLocation(new e.P(this.width,this.height))).extend(this.pointLocation(new e.P(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new H([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,wa]);}calculateTileMatrix(t){const i=t.canonical,a=this.worldSize/this.zoomScale(i.z),s=i.x+Math.pow(2,i.z)*t.wrap,o=e.an(new Float64Array(16));return e.J(o,o,[s*a,i.y*a,0]),e.K(o,o,[a/e.X,a/e.X,1]),o}calculatePosMatrix(t,i=!1){const a=t.key,s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s[a])return s[a];const o=this.calculateTileMatrix(t);return e.L(o,i?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,o),s[a]=new Float32Array(o),s[a]}calculateFogMatrix(t){const i=t.key,a=this._fogMatrixCache;if(a[i])return a[i];const s=this.calculateTileMatrix(t);return e.L(s,this.fogMatrix,s),a[i]=new Float32Array(s),a[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,i){i=e.ac(+i,this.minZoom,this.maxZoom);const a={center:new e.N(t.lng,t.lat),zoom:i};let s=this.lngRange;if(!this._renderWorldCopies&&null===s){const t=180-1e-10;s=[-t,t];}const o=this.tileSize*this.zoomScale(a.zoom);let r=0,n=o,l=0,h=o,c=0,u=0;const{x:d,y:_}=this.size;if(this.latRange){const t=this.latRange;r=e.Q(t[1])*o,n=e.Q(t[0])*o,n-r<_&&(c=_/(n-r));}s&&(l=e.b3(e.O(s[0])*o,0,o),h=e.b3(e.O(s[1])*o,0,o),hn&&(g=n-t);}if(s){const t=(l+h)/2;let i=p;this._renderWorldCopies&&(i=e.b3(p,t-o/2,t+o/2));const a=d/2;i-ah&&(f=h-a);}if(void 0!==f||void 0!==g){const t=new e.P(null!=f?f:p,null!=g?g:m);a.center=this.unproject.call({worldSize:o},t).wrap();}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:e,zoom:i}=this.getConstrained(this.center,this.zoom);this.center=e,this.zoom=i,this._unmodified=t,this._constraining=!1;}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,i=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=e.b5(1,this.center.lat)*this.worldSize;let s=e.an(new Float64Array(16));e.K(s,s,[this.width/2,-this.height/2,1]),e.J(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=e.an(new Float64Array(16)),e.K(s,s,[1,-1,1]),e.J(s,s,[-1,-1,0]),e.K(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s;const o=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),r=Math.min(this.elevation,this.minElevationForCurrentTile),n=o-r*this._pixelPerMeter/Math.cos(this._pitch),l=r<0?n:o,h=Math.PI/2+this._pitch,c=this._fov*(.5+t.y/this.height),u=Math.sin(c)*l/Math.sin(e.ac(Math.PI-h-c,.01,Math.PI-.01)),d=this.getHorizon(),_=2*Math.atan(d/this.cameraToCenterDistance)*(.5+t.y/(2*d)),p=Math.sin(_)*l/Math.sin(e.ac(Math.PI-h-_,.01,Math.PI-.01)),m=Math.min(u,p);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*m+l),this.nearZ=this.height/50,s=new Float64Array(16),e.b6(s,this._fov,this.width/this.height,this.nearZ,this.farZ),s[8]=2*-t.x/this.width,s[9]=2*t.y/this.height,this.projectionMatrix=e.ae(s),e.K(s,s,[1,-1,1]),e.J(s,s,[0,0,-this.cameraToCenterDistance]),e.b7(s,s,this._pitch),e.ad(s,s,this.angle),e.J(s,s,[-i,-a,0]),this.mercatorMatrix=e.K([],s,[this.worldSize,this.worldSize,this.worldSize]),e.K(s,s,[1,1,this._pixelPerMeter]),this.pixelMatrix=e.L(new Float64Array(16),this.labelPlaneMatrix,s),e.J(s,s,[0,0,-this.elevation]),this.modelViewProjectionMatrix=s,this.invModelViewProjectionMatrix=e.as([],s),this.fogMatrix=new Float64Array(16),e.b6(this.fogMatrix,this._fov,this.width/this.height,o,this.farZ),this.fogMatrix[8]=2*-t.x/this.width,this.fogMatrix[9]=2*t.y/this.height,e.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),e.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),e.b7(this.fogMatrix,this.fogMatrix,this._pitch),e.ad(this.fogMatrix,this.fogMatrix,this.angle),e.J(this.fogMatrix,this.fogMatrix,[-i,-a,0]),e.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),e.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=e.L(new Float64Array(16),this.labelPlaneMatrix,s);const f=this.width%2/2,g=this.height%2/2,v=Math.cos(this.angle),x=Math.sin(this.angle),y=i-Math.round(i)+v*f+x*g,b=a-Math.round(a)+v*g+x*f,w=new Float64Array(s);if(e.J(w,w,[y>.5?y-1:y,b>.5?b-1:b,0]),this.alignedModelViewProjectionMatrix=w,s=e.as(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");this.pixelMatrixInverse=s,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={};}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new e.P(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.af(i,i,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}getCameraQueryGeometry(t){const i=this.getCameraPoint();if(1===t.length)return [t[0],i];{let a=i.x,s=i.y,o=i.x,r=i.y;for(const e of t)a=Math.min(a,e.x),s=Math.min(s,e.y),o=Math.max(o,e.x),r=Math.max(r,e.y);return [new e.P(a,s),new e.P(o,s),new e.P(o,r),new e.P(a,r),new e.P(a,s)]}}lngLatToCameraDepth(t,i){const a=this.locationCoordinate(t),s=[a.x*this.worldSize,a.y*this.worldSize,i,1];return e.af(s,s,this.modelViewProjectionMatrix),s[2]/s[3]}}function Ia(t,e){let i,a=!1,s=null,o=null;const r=()=>{s=null,a&&(t.apply(o,i),s=setTimeout(r,e),a=!1);};return (...t)=>(a=!0,o=this,i=t,s||r(),s)}class Ea{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t);})),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return !1},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t);},this._removeHash=()=>{const t=this._getCurrentHash();if(0===t.length)return;const e=t.join("/");let i=e;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${e}`);let a=window.location.hash.replace(i,"");a.startsWith("#&")?a=a.slice(0,1)+a.slice(2):"#"===a&&(a="");let s=window.location.href.replace(/(#.+)?$/,a);s=s.replace("&&","&"),window.history.replaceState(window.history.state,null,s);},this._updateHash=Ia(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t);}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,a=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,a),o=Math.round(e.lng*s)/s,r=Math.round(e.lat*s)/s,n=this._map.getBearing(),l=this._map.getPitch();let h="";if(h+=t?`/${o}/${r}/${i}`:`${i}/${r}/${o}`,(n||l)&&(h+="/"+Math.round(10*n)/10),l&&(h+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const a=i.split("=")[0];return a===t?(e=!0,`${a}=${h}`):i})).filter((t=>t));return e||i.push(`${t}=${h}`),`#${i.join("&")}`}return `#${h}`}}const Pa={linearity:.3,easing:e.b8(0,0,.3,1)},Ca=e.e({deceleration:2500,maxSpeed:1400},Pa),Sa=e.e({deceleration:20,maxSpeed:1400},Pa),za=e.e({deceleration:1e3,maxSpeed:360},Pa),Da=e.e({deceleration:1e3,maxSpeed:90},Pa);class Ma{constructor(t){this._map=t,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:o.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=o.now();for(;t.length>0&&e-t[0].time>160;)t.shift();}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,s={};if(i.pan.mag()){const o=Ra(i.pan.mag(),a,e.e({},Ca,t||{}));s.offset=i.pan.mult(o.amount/i.pan.mag()),s.center=this._map.transform.center,Aa(s,o);}if(i.zoom){const t=Ra(i.zoom,a,Sa);s.zoom=this._map.transform.zoom+t.amount,Aa(s,t);}if(i.bearing){const t=Ra(i.bearing,a,za);s.bearing=this._map.transform.bearing+e.ac(t.amount,-179,179),Aa(s,t);}if(i.pitch){const t=Ra(i.pitch,a,Da);s.pitch=this._map.transform.pitch+t.amount,Aa(s,t);}if(s.zoom||s.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;s.around=t?this._map.unproject(t):this._map.getCenter();}return this.clear(),e.e(s,{noMoveStart:!0})}}function Aa(t,e){(!t.duration||t.durationi.unproject(t))),l=o.reduce(((t,e,i,a)=>t.add(e.div(a.length))),new e.P(0,0));super(t,{points:o,point:l,lngLats:n,lngLat:i.unproject(l),originalEvent:a}),this._defaultPrevented=!1;}}class Fa extends e.k{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1;}}class Ba{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance;}reset(){delete this._mousedownPos;}wheel(t){return this._firePreventable(new Fa(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new ka(t.type,this._map,t))}mouseup(t){this._map.fire(new ka(t.type,this._map,t));}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new ka(t.type,this._map,t));}dblclick(t){return this._firePreventable(new ka(t.type,this._map,t))}mouseover(t){this._map.fire(new ka(t.type,this._map,t));}mouseout(t){this._map.fire(new ka(t.type,this._map,t));}touchstart(t){return this._firePreventable(new La(t.type,this._map,t))}touchmove(t){this._map.fire(new La(t.type,this._map,t));}touchend(t){this._map.fire(new La(t.type,this._map,t));}touchcancel(t){this._map.fire(new La(t.type,this._map,t));}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Oa{constructor(t){this._map=t;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(t){this._map.fire(new ka(t.type,this._map,t));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ka("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new ka(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Na{constructor(t){this._map=t;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(e.P.convert(t),this._map.terrain)}}class Ua{constructor(t,e){this._map=t,this._tr=new Na(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(r.disableDrag(),this._startPos=this._lastPos=e,this._active=!0);}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)t.fitScreenCoordinates(a,s,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t);}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(r.remove(this._box),this._box=null),r.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.k(t,{originalEvent:i}))}}function ja(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),a.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=ja(a,i)));}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const a=ja(i,e);for(const t in this.touches){const e=a[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0);}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class qa{constructor(t){this.singleTap=new Za(t),this.numTaps=t.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(t,e,i){this.singleTap.touchstart(t,e,i);}touchmove(t,e,i){this.singleTap.touchmove(t,e,i);}touchend(t,e,i){const a=this.singleTap.touchend(t,e,i);if(a){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(a)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class Va{constructor(t){this._tr=new Na(t),this._zoomIn=new qa({numTouches:1,numTaps:2}),this._zoomOut=new qa({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i);}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i);}touchend(t,e,i){const a=this._zoomIn.touchend(t,e,i),s=this._zoomOut.touchend(t,e,i),o=this._tr;return a?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(a)},{originalEvent:t})}):s?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:o.zoom-1,around:o.unproject(s)},{originalEvent:t})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Ga{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset();}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t);}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=e.length?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(t,e){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const a=e.length?e[0]:e;return !this._moved&&a.dist(i){t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault();};},Ka=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>{const a=new Wa({checkCorrectEvent:t=>0===r.mouseButton(t)&&t.ctrlKey||2===r.mouseButton(t)});return new Ga({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:a,enable:t,assignEvents:Xa})},Ja=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>{const a=new Wa({checkCorrectEvent:t=>0===r.mouseButton(t)&&t.ctrlKey||2===r.mouseButton(t)});return new Ga({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:a,enable:t,assignEvents:Xa})};class Ya{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0);}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active){if(!this._shouldBePrevented(i.length))return t.preventDefault(),this._calculateTransform(t,e,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t);}}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(t,i,a){a.length>0&&(this._active=!0);const s=ja(a,i),o=new e.P(0,0),r=new e.P(0,0);let n=0;for(const t in s){const e=s[t],i=this._touches[t];i&&(o._add(e),r._add(e.sub(i)),n++,s[t]=e);}if(this._touches=s,this._shouldBePrevented(n)||!r.mag())return;const l=r.div(n);return this._sum._add(l),this._sum.mag()Math.abs(t.x)}class rs extends Qa{constructor(t){super(),this._currentTouchCount=0,this._map=t;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length;}_start(t){this._lastPoints=t,os(t[0].sub(t[1]))&&(this._valid=!1);}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const a=t[0].sub(this._lastPoints[0]),s=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(a,s,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(a.y+s.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const a=t.mag()>=2,s=e.mag()>=2;if(!a&&!s)return;if(!a||!s)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=t.y>0==e.y>0;return os(t)&&os(e)&&o}}const ns={panStep:100,bearingStep:15,pitchStep:10};class ls{constructor(t){this._tr=new Na(t);const e=ns;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,a=0,s=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),s=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),s=1);break;case 38:t.shiftKey?a=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?a=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,a=0),{cameraAnimation:r=>{const n=this._tr;r.easeTo({duration:300,easeId:"keyboardHandler",easing:hs,zoom:e?Math.round(n.zoom)+e*(t.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+a*this._pitchStep,offset:[-s*this._panStep,-o*this._panStep],center:n.center},{originalEvent:t});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function hs(t){return t*(2-t)}const cs=4.000244140625;class us{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t);},this._map=t,this._tr=new Na(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(t){this._defaultZoomRate=t;}setWheelZoomRate(t){this._wheelZoomRate=t;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(t){return !!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=o.now(),a=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%cs==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":a>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(a*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault();}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=r.mousePos(this._map.getCanvas(),t),a=this._tr;this._around=i.y>a.transform.height/2-a.transform.getHorizon()?e.N.convert(this._aroundCenter?a.center:a.unproject(i)):e.N.convert(a.center),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._tr.transform;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>cs?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);const a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*i))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"==typeof this._targetZoom?this._targetZoom:t.zoom,a=this._startZoom,s=this._easing;let r,n=!1;const l=o.now()-this._lastWheelEventTime;if("wheel"===this._type&&a&&s&&l){const t=Math.min(l/200,1),o=s(t);r=e.y.number(a,i,o),t<1?this._frameId||(this._frameId=!0):n=!0;}else r=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;}),200)),{noInertia:!0,needsRenderFrame:!n,zoomDelta:r-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.b9;if(this._prevEase){const t=this._prevEase,a=(o.now()-t.start)/t.duration,s=t.easing(a+.01)-t.easing(a),r=.27/Math.sqrt(s*s+1e-4)*.01,n=Math.sqrt(.0729-r*r);i=e.b8(r,n,.25,1);}return this._prevEase={start:o.now(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class ds{constructor(t,e){this._clickZoom=t,this._tapZoom=e;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class _s{constructor(t){this._tr=new Na(t),this.reset();}reset(){this._active=!1;}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ps{constructor(){this._tap=new qa({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(t,e,i){if(!this._swipePoint)if(this._tapTime){const a=e[0],s=t.timeStamp-this._tapTime<500,o=this._tapPoint.dist(a)<30;s&&o?i.length>0&&(this._swipePoint=a,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(t,e,i);}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const a=e[0],s=a.y-this._swipePoint.y;return this._swipePoint=a,t.preventDefault(),this._active=!0,{zoomDelta:s/128}}}else this._tap.touchmove(t,e,i);}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const a=this._tap.touchend(t,e,i);a&&(this._tapTime=t.timeStamp,this._tapPoint=a);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ms{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i;}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class fs{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class gs{constructor(t,e,i,a){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=a,this._rotationDisabled=!1,this._enabled=!0;}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class vs{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=r.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),a=document.createElement("div");a.className="maplibregl-desktop-message",a.textContent=e,this._container.appendChild(a);const s=document.createElement("div");s.className="maplibregl-mobile-message",s.textContent=i,this._container.appendChild(s),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(r.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,i){this._enabled&&(this._map.fire(new e.k("cooperativegestureprevented",{gestureType:t,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const xs=t=>t.zoom||t.drag||t.pitch||t.rotate;class ys extends e.k{}function bs(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class ws{constructor(t,e){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`);},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===t.type?void 0:t,a={needsRenderFrame:!1},s={},o={},n=t.touches,l=n?this._getMapTouches(n):void 0,h=l?r.touchPos(this._map.getCanvas(),l):r.mousePos(this._map.getCanvas(),t);for(const{handlerName:r,handler:n,allowed:c}of this._handlers){if(!n.isEnabled())continue;let u;this._blockedByActive(o,c,r)?n.reset():n[e||t.type]&&(u=n[e||t.type](t,h,l),this.mergeHandlerResult(a,s,u,r,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||n.isActive())&&(o[r]=n);}const c={};for(const t in this._previousActiveHandlers)o[t]||(c[t]=i);this._previousActiveHandlers=o,(Object.keys(c).length||bs(a))&&(this._changes.push([a,s,c]),this._triggerRenderFrame()),(Object.keys(o).length||bs(a))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=a;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map));},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ma(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,i]of this._listeners)r.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[t,e,i]of this._listeners)r.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new Ba(e,t));const a=e.boxZoom=new Ua(e,t);this._add("boxZoom",a),t.interactive&&t.boxZoom&&a.enable();const s=e.cooperativeGestures=new vs(e,t.cooperativeGestures);this._add("cooperativeGestures",s),t.cooperativeGestures&&s.enable();const o=new Va(e),n=new _s(e);e.doubleClickZoom=new ds(n,o),this._add("tapZoom",o),this._add("clickZoom",n),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();const l=new ps;this._add("tapDragZoom",l);const h=e.touchPitch=new rs(e);this._add("touchPitch",h),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);const c=Ka(t),u=Ja(t);e.dragRotate=new fs(t,c,u),this._add("mouseRotate",c,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();const d=(({enable:t,clickTolerance:e})=>{const i=new Wa({checkCorrectEvent:t=>0===r.mouseButton(t)&&!t.ctrlKey});return new Ga({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:i,enable:t,assignEvents:Xa})})(t),_=new Ya(t,e);e.dragPan=new ms(i,d,_),this._add("mousePan",d),this._add("touchPan",_,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);const p=new ss,m=new is;e.touchZoomRotate=new gs(i,m,p,l),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",m,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate);const f=e.scrollZoom=new us(e,(()=>this._triggerRenderFrame()));this._add("scrollZoom",f,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);const g=e.keyboard=new ls(e);this._add("keyboard",g),t.interactive&&t.keyboard&&e.keyboard.enable(),this._add("blockableMapEvent",new Oa(e));}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e;}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[];}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(xs(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const a in t)if(a!==i&&(!e||e.indexOf(a)<0))return !0;return !1}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,i,a,s,o){if(!a)return;e.e(t,a);const r={handlerName:s,originalEvent:a.originalEvent||o};void 0!==a.zoomDelta&&(i.zoom=r),void 0!==a.panDelta&&(i.drag=r),void 0!==a.pitchDelta&&(i.pitch=r),void 0!==a.bearingDelta&&(i.rotate=r);}_applyChanges(){const t={},i={},a={};for(const[s,o,r]of this._changes)s.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(s.panDelta)),s.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+s.zoomDelta),s.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+s.bearingDelta),s.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+s.pitchDelta),void 0!==s.around&&(t.around=s.around),void 0!==s.pinchAround&&(t.pinchAround=s.pinchAround),s.noInertia&&(t.noInertia=s.noInertia),e.e(i,o),e.e(a,r);this._updateMapTransform(t,i,a),this._changes=[];}_updateMapTransform(t,e,i){const a=this._map,s=a._getTransformForUpdate(),o=a.terrain;if(!(bs(t)||o&&this._terrainMovement))return this._fireEvents(e,i,!0);let{panDelta:r,zoomDelta:n,bearingDelta:l,pitchDelta:h,around:c,pinchAround:u}=t;void 0!==u&&(c=u),a._stop(!0),c=c||a.transform.centerPoint;const d=s.pointLocation(r?c.sub(r):c);l&&(s.bearing+=l),h&&(s.pitch+=h),n&&(s.zoom+=n),o?this._terrainMovement||!e.drag&&!e.zoom?e.drag&&this._terrainMovement?s.center=s.pointLocation(s.centerPoint.sub(r)):s.setLocationAtPoint(d,c):(this._terrainMovement=!0,this._map._elevationFreeze=!0,s.setLocationAtPoint(d,c)):s.setLocationAtPoint(d,c),a._applyUpdatedTransform(s),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0);}_fireEvents(t,i,a){const s=xs(this._eventsInProgress),r=xs(t),n={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!s&&r&&this._fireEvent("movestart",r.originalEvent);for(const t in n)this._fireEvent(t,n[t]);r&&this._fireEvent("move",r.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const l={};let h;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:a}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],h=i[e]||a,l[`${t}end`]=h);}for(const t in l)this._fireEvent(t,l[t]);const c=xs(this._eventsInProgress),u=(s||r)&&!c;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const t=this._map._getTransformForUpdate();t.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(t);}if(a&&u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ys("renderFrame",{timeStamp:t})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class Ts extends e.E{constructor(t,e){super(),this._renderFrameCallback=()=>{const t=Math.min((o.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState;}));}getCenter(){return new e.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,i,a){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),a)}panTo(t,i,a){return this.easeTo(e.e({center:t},i),a)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,i,a){return this.easeTo(e.e({zoom:t},i),a)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,i,a){return this.easeTo(e.e({bearing:t},i),a)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(t,e){return Math.abs(this.getBearing()){if(this._zooming&&(s.zoom=e.y.number(r,g,a)),this._rotating&&(s.bearing=e.y.number(n,c,a)),this._pitching&&(s.pitch=e.y.number(l,u,a)),this._padding&&(s.interpolatePadding(h,d,a),p=s.centerPoint.add(_)),this.terrain&&!t.freezeElevation&&this._updateElevation(a),b)s.setLocationAtPoint(b,w);else {const t=s.zoomScale(s.zoom-r),e=g>r?Math.min(2,y):Math.max(.5,y),i=Math.pow(e,1-a),o=s.unproject(v.add(x.mult(a*i)).mult(t));s.setLocationAtPoint(s.renderWorldCopies?o.wrap():o,p);}this._applyUpdatedTransform(s),this._fireMoveEvents(i);}),(e=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i,e);}),t),this}_prepareEase(t,i,a={}){this._moving=!0,i||a.moving||this.fire(new e.k("movestart",t)),this._zooming&&!a.zooming&&this.fire(new e.k("zoomstart",t)),this._rotating&&!a.rotating&&this.fire(new e.k("rotatestart",t)),this._pitching&&!a.pitching&&this.fire(new e.k("pitchstart",t));}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&i!==this._elevationTarget){const e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i;}this.transform.elevation=e.y.number(this._elevationStart,this._elevationTarget,t);}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){const e=t.getCameraPosition(),i=this.terrain.getElevationForLngLatZoom(e.lngLat,t.zoom);if(e.altitudethis._elevateCameraIfInsideTerrain(t))),this.transformCameraUpdate&&e.push((t=>this.transformCameraUpdate(t))),!e.length)return;const i=t.clone();for(const t of e){const e=i.clone(),{center:a,zoom:s,pitch:o,bearing:r,elevation:n}=t(e);a&&(e.center=a),void 0!==s&&(e.zoom=s),void 0!==o&&(e.pitch=o),void 0!==r&&(e.bearing=r),void 0!==n&&(e.elevation=n),i.apply(e);}this.transform.apply(i);}_fireMoveEvents(t){this.fire(new e.k("move",t)),this._zooming&&this.fire(new e.k("zoom",t)),this._rotating&&this.fire(new e.k("rotate",t)),this._pitching&&this.fire(new e.k("pitch",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const a=this._zooming,s=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new e.k("zoomend",t)),s&&this.fire(new e.k("rotateend",t)),o&&this.fire(new e.k("pitchend",t)),this.fire(new e.k("moveend",t));}flyTo(t,i){var a;if(!t.essential&&o.prefersReducedMotion){const a=e.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(a,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.b9},t);const s=this._getTransformForUpdate(),r=s.zoom,n=s.bearing,l=s.pitch,h=s.padding,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,u="pitch"in t?+t.pitch:l,d="padding"in t?t.padding:s.padding,_=e.P.convert(t.offset);let p=s.centerPoint.add(_);const m=s.pointLocation(p),{center:f,zoom:g}=s.getConstrained(e.N.convert(t.center||m),null!==(a=t.zoom)&&void 0!==a?a:r);this._normalizeCenter(f,s);const v=s.zoomScale(g-r),x=s.project(m),y=s.project(f).sub(x);let b=t.curve;const w=Math.max(s.width,s.height),T=w/v,I=y.mag();if("minZoom"in t){const i=e.ac(Math.min(t.minZoom,r,g),s.minZoom,s.maxZoom),a=w/s.zoomScale(i-r);b=Math.sqrt(a/I*2);}const E=b*b;function P(t){const e=(T*T-w*w+(t?-1:1)*E*E*I*I)/(2*(t?T:w)*E*I);return Math.log(Math.sqrt(e*e+1)-e)}function C(t){return (Math.exp(t)-Math.exp(-t))/2}function S(t){return (Math.exp(t)+Math.exp(-t))/2}const z=P(!1);let D=function(t){return S(z)/S(z+b*t)},M=function(t){return w*((S(z)*(C(e=z+b*t)/S(e))-C(z))/E)/I;var e;},A=(P(!0)-z)/b;if(Math.abs(I)<1e-6||!isFinite(A)){if(Math.abs(w-T)<1e-6)return this.easeTo(t,i);const e=T0,D=t=>Math.exp(e*b*t);}return t.duration="duration"in t?+t.duration:1e3*A/("screenSpeed"in t?+t.screenSpeed/b:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=n!==c,this._pitching=u!==l,this._padding=!s.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f),this._ease((a=>{const o=a*A,m=1/D(o);s.zoom=1===a?g:r+s.scaleZoom(m),this._rotating&&(s.bearing=e.y.number(n,c,a)),this._pitching&&(s.pitch=e.y.number(l,u,a)),this._padding&&(s.interpolatePadding(h,d,a),p=s.centerPoint.add(_)),this.terrain&&!t.freezeElevation&&this._updateElevation(a);const v=1===a?f:s.unproject(x.add(y.mult(M(o))).mult(m));s.setLocationAtPoint(s.renderWorldCopies?v.wrap():v,p),this._applyUpdatedTransform(s),this._fireMoveEvents(i);}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),t),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(t,e){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e);}return t||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=o.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(t,i){t=e.b3(t,-180,180);const a=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0;}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(e.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const Is={compact:!0,customAttribution:'MapLibre'};class Es{constructor(t=Is){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=t;}getDefaultPosition(){return "bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=r.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=r.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=r.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){r.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0;}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id;}const e=this._map.style.sourceCaches;for(const i in e){const a=e[i];if(a.used||a.usedForTerrain){const e=a.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution);}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let a=i+1;a=0)return !1;return !0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class Ps{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact");}},this.options=t;}getDefaultPosition(){return "bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=r.create("div","maplibregl-ctrl");const e=r.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){r.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class Cs{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var Ss=e.Y([{name:"a_pos3d",type:"Int16",components:3}]);class zs extends e.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(t,i){this.sourceCache.update(t,i),this._renderableTilesKeys=[];const a={};for(const s of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i}))a[s.key]=!0,this._renderableTilesKeys.push(s.key),this._tiles[s.key]||(s.posMatrix=new Float64Array(16),e.aP(s.posMatrix,0,e.X,0,e.X,0,1),this._tiles[s.key]=new lt(s,this.tileSize));for(const t in this._tiles)a[t]||delete this._tiles[t];}freeRtt(t){for(const e in this._tiles){const i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const i={};for(const a of this._renderableTilesKeys){const s=this._tiles[a].tileID;if(s.canonical.equals(t.canonical)){const s=t.clone();s.posMatrix=new Float64Array(16),e.aP(s.posMatrix,0,e.X,0,e.X,0,1),i[a]=s;}else if(s.canonical.isChildOf(t.canonical)){const o=t.clone();o.posMatrix=new Float64Array(16);const r=s.canonical.z-t.canonical.z,n=s.canonical.x-(s.canonical.x>>r<>r<>r;e.aP(o.posMatrix,0,h,0,h,0,1),e.J(o.posMatrix,o.posMatrix,[-n*h,-l*h,0]),i[a]=o;}else if(t.canonical.isChildOf(s.canonical)){const o=t.clone();o.posMatrix=new Float64Array(16);const r=t.canonical.z-s.canonical.z,n=t.canonical.x-(t.canonical.x>>r<>r<>r;e.aP(o.posMatrix,0,e.X,0,e.X,0,1),e.J(o.posMatrix,o.posMatrix,[n*h,l*h,0]),e.K(o.posMatrix,o.posMatrix,[1/2**r,1/2**r,0]),i[a]=o;}}return i}getSourceTile(t,e){const i=this.sourceCache._source;let a=t.overscaledZ-this.deltaZoom;if(a>i.maxzoom&&(a=i.maxzoom),a=i.minzoom&&(!s||!s.dem);)s=this.sourceCache.getTileByID(t.scaledTo(a--).key);return s}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeAdded>=t))}}class Ds{constructor(t,e,i){this.painter=t,this.sourceCache=new zs(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(t,i,a,s=e.X){var o;if(!(i>=0&&i=0&&at.canonical.z&&(t.canonical.z>=a?s=t.canonical.z-a:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=t.canonical.x-(t.canonical.x>>s<>s<>8<<4|t>>8,i[e+3]=0;const a=new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),s=new b(t,a,t.gl.RGBA,{premultiply:!1});return s.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=s,s}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),a=this.painter.context,s=a.gl,o=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),r=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),s.readPixels(o,n-r-1,1,1,s.RGBA,s.UNSIGNED_BYTE,i),a.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),h=i[1]+((15&i[2])<<8),c=this.coordsIndex[255-i[3]],u=c&&this.sourceCache.getTileByID(c);if(!u)return null;const d=this._coordsTextureSize,_=(1<t.id!==e)),this._recentlyUsed.push(t.id);}stampObject(t){t.stamp=++this._stamp;}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1;}freeAllObjects(){for(const t of this._objects)this.freeObject(t);}isFull(){return !(this._objects.length!t.inUse))}}const As={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Rs{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new Ms(t.context,30,e.sourceCache.tileSize*e.qualityFactor);}destruct(){this.pool.destruct();}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e))),this._coordsDescendingInv={};for(const e in t.sourceCaches){this._coordsDescendingInv[e]={};const i=t.sourceCaches[e].getVisibleCoordinates();for(const t of i){const i=this.terrain.sourceCache.getTerrainCoords(t);for(const t in i)this._coordsDescendingInv[e][t]||(this._coordsDescendingInv[e][t]=[]),this._coordsDescendingInv[e][t].push(i[t]);}}this._coordsDescendingInvStr={};for(const e of t._order){const i=t._layers[e],a=i.source;if(As[i.type]&&!this._coordsDescendingInvStr[a]){this._coordsDescendingInvStr[a]={};for(const t in this._coordsDescendingInv[a])this._coordsDescendingInvStr[a][t]=this._coordsDescendingInv[a][t].map((t=>t.key)).sort().join();}}for(const t of this._renderableTiles)for(const e in this._coordsDescendingInvStr){const i=this._coordsDescendingInvStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[]);}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return !1;const i=t.type,a=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(As[i]&&(this._prevType&&As[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(t.id),!s))return !0;if(As[this._prevType]||As[i]&&s){this._prevType=i;const t=this._stacks.length-1,s=this._stacks[t]||[];for(const i of this._renderableTiles){if(this.pool.isFull()&&(fa(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[t]){const e=this.pool.getObjectForId(i.rtt[t].id);if(e.stamp===i.rtt[t].stamp){this.pool.useObject(e);continue}}const o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),i.rtt[t]={id:o.id,stamp:o.stamp},a.context.bindFramebuffer.set(o.fbo.framebuffer),a.context.clear({color:e.aM.transparent,stencil:0}),a.currentStencilSource=void 0;for(let t=0;t{t.touchstart=t.dragStart,t.touchmoveWindow=t.dragMove,t.touchend=t.dragEnd;},Os={showCompass:!0,showZoom:!0,visualizePitch:!1};class Ns{constructor(t,i,a=!1){this.mousedown=t=>{this.startMouse(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),r.mousePos(this.element,t)),r.addEventListener(window,"mousemove",this.mousemove),r.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=t=>{this.moveMouse(t,r.mousePos(this.element,t));},this.mouseup=t=>{this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp();},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=r.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),r.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),r.addEventListener(window,"touchend",this.touchend));},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=r.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos));},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10;const s=t.dragRotate._mouseRotate.getClickTolerance(),o=t.dragRotate._mousePitch.getClickTolerance();this.element=i,this.mouseRotate=Ka({clickTolerance:s,enable:!0}),this.touchRotate=(({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>{const a=new $a;return new Ga({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:a,enable:t,assignEvents:Bs})})({clickTolerance:s,enable:!0}),this.map=t,a&&(this.mousePitch=Ja({clickTolerance:o,enable:!0}),this.touchPitch=(({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>{const a=new $a;return new Ga({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:a,enable:t,assignEvents:Bs})})({clickTolerance:o,enable:!0})),r.addEventListener(i,"mousedown",this.mousedown),r.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),r.addEventListener(i,"touchcancel",this.reset);}startMouse(t,e){this.mouseRotate.dragStart(t,e),this.mousePitch&&this.mousePitch.dragStart(t,e),r.disableDrag();}startTouch(t,e){this.touchRotate.dragStart(t,e),this.touchPitch&&this.touchPitch.dragStart(t,e),r.disableDrag();}moveMouse(t,e){const i=this.map,{bearingDelta:a}=this.mouseRotate.dragMove(t,e)||{};if(a&&i.setBearing(i.getBearing()+a),this.mousePitch){const{pitchDelta:a}=this.mousePitch.dragMove(t,e)||{};a&&i.setPitch(i.getPitch()+a);}}moveTouch(t,e){const i=this.map,{bearingDelta:a}=this.touchRotate.dragMove(t,e)||{};if(a&&i.setBearing(i.getBearing()+a),this.touchPitch){const{pitchDelta:a}=this.touchPitch.dragMove(t,e)||{};a&&i.setPitch(i.getPitch()+a);}}off(){const t=this.element;r.removeEventListener(t,"mousedown",this.mousedown),r.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),r.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),r.removeEventListener(window,"touchend",this.touchend),r.removeEventListener(t,"touchcancel",this.reset),this.offTemp();}offTemp(){r.enableDrag(),r.removeEventListener(window,"mousemove",this.mousemove),r.removeEventListener(window,"mouseup",this.mouseup),r.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),r.removeEventListener(window,"touchend",this.touchend);}}let Us;function js(t,i,a){const s=new e.N(t.lng,t.lat);if(t=new e.N(t.lng,t.lat),i){const s=new e.N(t.lng-360,t.lat),o=new e.N(t.lng+360,t.lat),r=a.locationPoint(t).distSqr(i);a.locationPoint(s).distSqr(i)180;){const e=a.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=a.width&&e.y<=a.height)break;t.lng>a.center.lng?t.lng-=360:t.lng+=360;}return t.lng!==s.lng&&a.locationPoint(t).y>a.height/2-a.getHorizon()?t:s}const Zs={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function qs(t,e,i){const a=t.classList;for(const t in Zs)a.remove(`maplibregl-${i}-anchor-${t}`);a.add(`maplibregl-${i}-anchor-${e}`);}class Vs extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=t=>{const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup();},this._update=t=>{var e;if(!this._map)return;const i=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!i)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?js(this._lngLat,this._flatPos,this._map.transform):null===(e=this._lngLat)||void 0===e?void 0:e.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let a="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?a=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(a=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let s="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?s="rotateX(0deg)":"map"===this._pitchAlignment&&(s=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||t&&"moveend"!==t.type||(this._pos=this._pos.round()),r.setTransform(this._element,`${Zs[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${s} ${a}`),o.frameAsync(new AbortController).then((()=>{this._updateOpacity(t&&"moveend"===t.type);})).catch((()=>{}));},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e;}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.k("dragstart"))),this.fire(new e.k("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new e.k("dragend")),this._state="inactive";},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._subpixelPositioning=t&&t.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else {this._defaultMarker=!0,this._element=r.create("div");const i=r.createNS("http://www.w3.org/2000/svg","svg"),a=41,s=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${a}px`),i.setAttributeNS(null,"width",`${s}px`),i.setAttributeNS(null,"viewBox",`0 0 ${s} ${a}`);const o=r.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const n=r.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"fill-rule","nonzero");const l=r.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const h=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of h){const e=r.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),l.appendChild(e);}const c=r.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const u=r.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(u);const d=r.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=r.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=r.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=r.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=r.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=r.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),n.appendChild(l),n.appendChild(c),n.appendChild(d),n.appendChild(p),n.appendChild(m),i.appendChild(n),i.setAttributeNS(null,"height",a*this._scale+"px"),i.setAttributeNS(null,"width",s*this._scale+"px"),this._element.appendChild(i),this._offset=e.P.convert(t&&t.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault();})),this._element.addEventListener("mousedown",(t=>{t.preventDefault();})),qs(this._element,this._anchor,"marker"),t&&t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null;}addTo(t){return this.remove(),this._map=t,this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),r.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.N.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,a=Math.abs(i)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[a,-1*(e-i+a)],"bottom-right":[-a,-1*(e-i+a)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset;}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var i,a;if(!(null===(i=this._map)||void 0===i?void 0:i.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const s=this._map,o=s.terrain.depthAtPoint(this._pos),r=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,r)-o<.006)return void(this._element.style.opacity=this._opacity);const n=-this._offset.y/s.transform._pixelPerMeter,l=Math.sin(s.getPitch()*Math.PI/180)*n,h=s.terrain.depthAtPoint(new e.P(this._pos.x,this._pos.y-this._offset.y)),c=s.transform.lngLatToCameraDepth(this._lngLat,r+l)-h>.006;(null===(a=this._popup)||void 0===a?void 0:a.isOpen())&&c&&this._popup.remove(),this._element.style.opacity=c?this._opacityWhenCovered:this._opacity;}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t);}removeClassName(t){this._element.classList.remove(t);}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return void 0===t&&void 0===e&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}const Gs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Hs=0,Ws=!1;const $s={maxWidth:100,unit:"metric"};function Xs(t,e,i){const a=i&&i.maxWidth||100,s=t._container.clientHeight/2,o=t.unproject([0,s]),r=t.unproject([a,s]),n=o.distanceTo(r);if(i&&"imperial"===i.unit){const i=3.2808*n;i>5280?Ks(e,a,i/5280,t._getUIString("ScaleControl.Miles")):Ks(e,a,i,t._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?Ks(e,a,n/1852,t._getUIString("ScaleControl.NauticalMiles")):n>=1e3?Ks(e,a,n/1e3,t._getUIString("ScaleControl.Kilometers")):Ks(e,a,n,t._getUIString("ScaleControl.Meters"));}function Ks(t,e,i,a){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(s/i)+"px",t.innerHTML=`${s} ${a}`;}const Js={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Ys=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Qs(t){if(t){if("number"==typeof t){const i=Math.round(Math.abs(t)/Math.SQRT2);return {center:new e.P(0,0),top:new e.P(0,t),"top-left":new e.P(i,i),"top-right":new e.P(-i,i),bottom:new e.P(0,-t),"bottom-left":new e.P(i,-i),"bottom-right":new e.P(-i,-i),left:new e.P(t,0),right:new e.P(-t,0)}}if(t instanceof e.P||Array.isArray(t)){const i=e.P.convert(t);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:e.P.convert(t.center||[0,0]),top:e.P.convert(t.top||[0,0]),"top-left":e.P.convert(t["top-left"]||[0,0]),"top-right":e.P.convert(t["top-right"]||[0,0]),bottom:e.P.convert(t.bottom||[0,0]),"bottom-left":e.P.convert(t["bottom-left"]||[0,0]),"bottom-right":e.P.convert(t["bottom-right"]||[0,0]),left:e.P.convert(t.left||[0,0]),right:e.P.convert(t.right||[0,0])}}return Qs(new e.P(0,0))}const to=i;t.AJAXError=e.bh,t.Evented=e.E,t.LngLat=e.N,t.MercatorCoordinate=e.Z,t.Point=e.P,t.addProtocol=e.bi,t.config=e.a,t.removeProtocol=e.bj,t.AttributionControl=Es,t.BoxZoomHandler=Ua,t.CanvasSource=et,t.CooperativeGesturesHandler=vs,t.DoubleClickZoomHandler=ds,t.DragPanHandler=ms,t.DragRotateHandler=fs,t.EdgeInsets=ba,t.FullscreenControl=class extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(t=null==e?void 0:e.shadowRoot)||void 0===t?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=r.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){r.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const t=this._fullscreenButton=r.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);r.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new e.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},t.GeoJSONSource=J,t.GeolocateControl=class extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.k("geolocate",t)),this._finish();}},this._updateCamera=t=>{const i=new e.N(t.coords.longitude,t.coords.latitude),a=t.coords.accuracy,s=this._map.getBearing(),o=e.e({bearing:s},this.options.fitBoundsOptions),r=H.fromLngLat(i,a);this._map.fitBounds(r,o,{geolocateSource:!0});},this._updateMarker=t=>{if(t){const i=new e.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===t.code&&Ws)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.k("error",t)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=r.create("button","maplibregl-ctrl-geolocate",this._container),r.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=t=>{if(this._map){if(!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t);}else {const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=r.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Vs({element:this._dotElement}),this._circleElement=r.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Vs({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.k("trackuserlocationend")),this.fire(new e.k("userlocationlostfocus")));}));}},this.options=e.e({},Gs,t);}onAdd(t){return this._map=t,this._container=r.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return e._(this,arguments,void 0,(function*(t=!1){if(void 0!==Us&&!t)return Us;if(void 0===window.navigator.permissions)return Us=!!window.navigator.geolocation,Us;try{const t=yield window.navigator.permissions.query({name:"geolocation"});Us="denied"!==t.state;}catch(t){Us=!!window.navigator.geolocation;}return Us}))}().then((t=>this._finishSetupUI(t))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),r.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Hs=0,Ws=!1;}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitudee.getEast()||i.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const t=this._map.getBounds(),e=t.getSouthEast(),i=t.getNorthEast(),a=e.distanceTo(i),s=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`;}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Hs--,Ws=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new e.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.k("trackuserlocationstart")),this.fire(new e.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Hs++,Hs>1?(t={maximumAge:6e5,timeout:0},Ws=!0):(t=this.options.positionOptions,Ws=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},t.Hash=Ea,t.ImageSource=Q,t.KeyboardHandler=ls,t.LngLatBounds=H,t.LogoControl=Ps,t.Map=class extends Ts{constructor(t){e.bf.mark(e.bg.create);const i=Object.assign(Object.assign({},Fs),t);if(null!=i.minZoom&&null!=i.maxZoom&&i.minZoom>i.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=i.minPitch&&null!=i.maxPitch&&i.minPitch>i.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=i.minPitch&&i.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=i.maxPitch&&i.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Ta(i.minZoom,i.maxZoom,i.minPitch,i.maxPitch,i.renderWorldCopies),{bearingSnap:i.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Cs,this._controls=[],this._mapId=e.a4(),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new e.k("webglcontextlost",{originalEvent:t}));},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new e.k("webglcontextrestored",{originalEvent:t}));},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=i.interactive,this._maxTileCacheSize=i.maxTileCacheSize,this._maxTileCacheZoomLevels=i.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=!0===i.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=!0===i.preserveDrawingBuffer,this._antialias=!0===i.antialias,this._trackResize=!0===i.trackResize,this._bearingSnap=i.bearingSnap,this._refreshExpiredTiles=!0===i.refreshExpiredTiles,this._fadeDuration=i.fadeDuration,this._crossSourceCollisions=!0===i.crossSourceCollisions,this._collectResourceTiming=!0===i.collectResourceTiming,this._locale=Object.assign(Object.assign({},ks),i.locale),this._clickTolerance=i.clickTolerance,this._overridePixelRatio=i.pixelRatio,this._maxCanvasSize=i.maxCanvasSize,this.transformCameraUpdate=i.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===i.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=_.addThrottleControl((()=>this.isMoving())),this._requestManager=new p(i.transformRequest),"string"==typeof i.container){if(this._container=document.getElementById(i.container),!this._container)throw new Error(`Container '${i.container}' not found.`)}else {if(!(i.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=i.container;}if(i.maxBounds&&this.setMaxBounds(i.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))).on("moveend",(()=>this._update(!1))).on("zoom",(()=>this._update(!0))).on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})).once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1;const e=Ia((t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw());}),50);this._resizeObserver=new ResizeObserver((i=>{t?e(i):t=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new ws(this,i),this._hash=i.hash&&new Ea("string"==typeof i.hash&&i.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch}),i.bounds&&(this.resize(),this.fitBounds(i.bounds,e.e({},i.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=i.localIdeographFontFamily,this._validateStyle=i.validateStyle,i.style&&this.setStyle(i.style,{localIdeographFontFamily:i.localIdeographFontFamily}),i.attributionControl&&this.addControl(new Es("boolean"==typeof i.attributionControl?void 0:i.attributionControl)),i.maplibreLogo&&this.addControl(new Ps,i.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet);})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.k(`${t.dataType}data`,t));})),this.on("dataloading",(t=>{this.fire(new e.k(`${t.dataType}dataloading`,t));})),this.on("dataabort",(t=>{this.fire(new e.k("sourcedataabort",t));}));}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const a=t.onAdd(this);this._controls.push(t);const s=this._controlPositions[i];return -1!==i.indexOf("bottom")?s.insertBefore(a,s.firstChild):s.appendChild(a),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,a){return null==a&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,i,a)}resize(t){var i;const a=this._containerDimensions(),s=a[0],o=a[1],r=this._getClampedPixelRatio(s,o);if(this._resizeCanvas(s,o,r),this.painter.resize(s,o,r),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const e=this._getClampedPixelRatio(s,o);this._resizeCanvas(s,o,e),this.painter.resize(s,o,e);}this.transform.resize(s,o),null===(i=this._requestedCameraState)||void 0===i||i.resize(s,o);const n=!this._moving;return n&&(this.stop(),this.fire(new e.k("movestart",t)).fire(new e.k("move",t))),this.fire(new e.k("resize",t)),n&&this.fire(new e.k("moveend",t)),this}_getClampedPixelRatio(t,e){const{0:i,1:a}=this._maxCanvasSize,s=this.getPixelRatio(),o=t*s,r=e*s;return Math.min(o>i?i/o:1,r>a?a/r:1)*s}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(H.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}project(t){return this.transform.locationPoint(e.N.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.pointLocation(e.P.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let a=!1;const s=s=>{const o=e.filter((t=>this.getLayer(t))),r=0!==o.length?this.queryRenderedFeatures(s.point,{layers:o}):[];r.length?a||(a=!0,i.call(this,new ka(t,this,s.originalEvent,{features:r}))):a=!1;};return {layers:e,listener:i,delegates:{mousemove:s,mouseout:()=>{a=!1;}}}}if("mouseleave"===t||"mouseout"===t){let a=!1;const s=s=>{const o=e.filter((t=>this.getLayer(t)));(0!==o.length?this.queryRenderedFeatures(s.point,{layers:o}):[]).length?a=!0:a&&(a=!1,i.call(this,new ka(t,this,s.originalEvent)));},o=e=>{a&&(a=!1,i.call(this,new ka(t,this,e.originalEvent)));};return {layers:e,listener:i,delegates:{mousemove:s,mouseout:o}}}{const a=t=>{const a=e.filter((t=>this.getLayer(t))),s=0!==a.length?this.queryRenderedFeatures(t.point,{layers:a}):[];s.length&&(t.features=s,i.call(this,t),delete t.features);};return {layers:e,listener:i,delegates:{[t]:a}}}}_saveDelegatedListener(t,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(e);}_removeDelegatedListener(t,e,i){if(!this._delegatedListeners||!this._delegatedListeners[t])return;const a=this._delegatedListeners[t];for(let t=0;te.includes(t)))){for(const t in s.delegates)this.off(t,s.delegates[t]);return void a.splice(t,1)}}}on(t,e,i){if(void 0===i)return super.on(t,e);const a=this._createDelegatedListener(t,"string"==typeof e?[e]:e,i);this._saveDelegatedListener(t,a);for(const t in a.delegates)this.on(t,a.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);const a="string"==typeof e?[e]:e,s=this._createDelegatedListener(t,a,i);for(const e in s.delegates){const o=s.delegates[e];s.delegates[e]=(...e)=>{this._removeDelegatedListener(t,a,i),o(...e);};}this._saveDelegatedListener(t,s);for(const t in s.delegates)this.once(t,s.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._removeDelegatedListener(t,"string"==typeof e?[e]:e,i),this)}queryRenderedFeatures(t,i){if(!this.style)return [];let a;const s=t instanceof e.P||Array.isArray(t),o=s?t:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(s?{}:t)||{},o instanceof e.P||"number"==typeof o[0])a=[e.P.convert(o)];else {const t=e.P.convert(o[0]),i=e.P.convert(o[1]);a=[t,new e.P(i.x,t.y),i,new e.P(t.x,i.y),t];}return this.style.queryRenderedFeatures(a,i,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,i){return !1!==(i=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(t,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(t,e)));const i=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new de(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,i):this.style.loadJSON(t,e,i),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new de(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(t,i){if("string"==typeof t){const a=this._requestManager.transformRequest(t,"Style");e.h(a,new AbortController).then((t=>{this._updateDiff(t.data,i);})).catch((t=>{t&&this.fire(new e.j(t));}));}else "object"==typeof t&&this._updateDiff(t,i);}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0);}catch(a){e.w(`Unable to perform style diff: ${a.message||a.error||a}. Rebuilding the style from scratch.`),this._updateStyle(t,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){const i=this.style&&this.style.sourceCaches[t];if(void 0!==i)return i.loaded();this.fire(new e.j(new Error(`There is no source with ID '${t}'`)));}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const i=this.style.sourceCaches[t.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const a=this.style._layers[i];"hillshade"===a.type&&a.source===t.source&&e.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new Ds(this.painter,i,t),this.painter.renderToTexture=new Rs(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=e=>{"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(e.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new e.k("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return !1}}return !0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,i,a={}){const{pixelRatio:s=1,sdf:r=!1,stretchX:n,stretchY:l,content:h,textFitWidth:c,textFitHeight:u}=a;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||e.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new e.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:a,height:o,data:d}=i,_=i;return this.style.addImage(t,{data:new e.R({width:a,height:o},new Uint8Array(d)),pixelRatio:s,stretchX:n,stretchY:l,content:h,textFitWidth:c,textFitHeight:u,sdf:r,version:0,userImage:_}),_.onAdd&&_.onAdd(this,t),this}}{const{width:a,height:d,data:_}=o.getImageData(i);this.style.addImage(t,{data:new e.R({width:a,height:d},_),pixelRatio:s,stretchX:n,stretchY:l,content:h,textFitWidth:c,textFitHeight:u,sdf:r,version:0});}}updateImage(t,i){const a=this.style.getImage(t);if(!a)return this.fire(new e.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=i instanceof HTMLImageElement||e.b(i)?o.getImageData(i):i,{width:r,height:n,data:l}=s;if(void 0===r||void 0===n)return this.fire(new e.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(r!==a.data.width||n!==a.data.height)return this.fire(new e.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const h=!(i instanceof HTMLImageElement||e.b(i));return a.data.replace(l,h),this.style.updateImage(t,a),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.j(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t);}loadImage(t){return _.getImage(this._requestManager.transformRequest(t,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,a={}){return this.style.setPaintProperty(t,e,i,a),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,a={}){return this.style.setLayoutProperty(t,e,i,a),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,(t=>{t||this._update(!0);})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0);})),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(t){return this._lazyInitEmptyStyle(),this.style.setSky(t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=r.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=r.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),a=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],a);const s=this._controlContainer=r.create("div","maplibregl-control-container",t),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{o[t]=r.create("div",`maplibregl-ctrl-${t} `,s);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`;}_setupPainter(){const t={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type);}),{once:!0});const i=this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t);if(!i){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new va(i,this.transform),n.testSupport(i);}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t);}_render(t){const i=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let a=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,s=o.now();this.style.zoomHistory.update(t,s);const r=new e.z(t,{now:s,fadeDuration:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(a=!0,this._crossFadingFactor=n),this.style.update(r);}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,i,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:i,showPadding:this.showPadding}),this.fire(new e.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.bf.mark(e.bg.load),this.fire(new e.k("load"))),this.style&&(this.style.hasTransitions()||a)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const s=this._sourcesDirty||this._styleDirty||this._placementDirty;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.k("idle")),!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0,e.bf.mark(e.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),_.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),r.remove(this._canvasContainer),r.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),e.bf.clearMetrics(),this._removed=!0,this.fire(new e.k("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,o.frameAsync(this._frameRequest).then((t=>{e.bf.frame(t),this._frameRequest=null,this._render(t);})).catch((()=>{})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update());}get showPadding(){return !!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update());}get repaint(){return !!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(t){this._vertices=t,this._update();}get version(){return Ls}getCameraTargetElevation(){return this.transform.elevation}},t.MapMouseEvent=ka,t.MapTouchEvent=La,t.MapWheelEvent=Fa,t.Marker=Vs,t.NavigationControl=class{constructor(t){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t;},this._setButtonTitle=(t,e)=>{const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i);},this.options=e.e({},Os,t),this._container=r.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),r.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),r.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t});})),this._compassIcon=r.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ns(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){r.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(t,e){const i=r.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},t.Popup=class extends e.E{constructor(t){super(),this.remove=()=>(this._content&&r.remove(this._content),this._container&&(r.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new e.k("close"))),this),this._onMouseUp=t=>{this._update(t.point);},this._onMouseMove=t=>{this._update(t.point);},this._onDrag=t=>{this._update(t.point);},this._update=t=>{var e;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=r.create("div","maplibregl-popup",this._map.getContainer()),this._tip=r.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?js(this._lngLat,this._flatPos,this._map.transform):null===(e=this._lngLat)||void 0===e?void 0:e.wrap(),this._trackPointer&&!t)return;const i=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let a=this.options.anchor;const s=Qs(this.options.offset);if(!a){const t=this._container.offsetWidth,e=this._container.offsetHeight;let o;o=i.y+s.bottom.ythis._map.transform.height-e?["bottom"]:[],i.xthis._map.transform.width-t/2&&o.push("right"),a=0===o.length?"bottom":o.join("-");}let o=i.add(s[a]);this.options.subpixelPositioning||(o=o.round()),r.setTransform(this._container,`${Zs[a]} translate(${o.x}px,${o.y}px)`),qs(this._container,a,"popup");},this._onClose=()=>{this.remove();},this.options=e.e(Object.create(Js),t);}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new e.k("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.N.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let a;for(i.innerHTML=t;a=i.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=r.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t;}_createCloseButton(){this.options.closeButton&&(this._closeButton=r.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(Ys);t&&t.focus();}},t.RasterDEMTileSource=K,t.RasterTileSource=X,t.ScaleControl=class{constructor(t){this._onMove=()=>{Xs(this._map,this._container,this.options);},this.setUnit=t=>{this.options.unit=t,Xs(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},$s),t);}getDefaultPosition(){return "bottom-left"}onAdd(t){return this._map=t,this._container=r.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){r.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},t.ScrollZoomHandler=us,t.Style=de,t.TerrainControl=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=t;}onAdd(t){return this._map=t,this._container=r.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=r.create("button","maplibregl-ctrl-terrain",this._container),r.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){r.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},t.TwoFingersTouchPitchHandler=rs,t.TwoFingersTouchRotateHandler=ss,t.TwoFingersTouchZoomHandler=is,t.TwoFingersTouchZoomRotateHandler=gs,t.VectorTileSource=$,t.VideoSource=tt,t.addSourceType=(t,i)=>e._(void 0,void 0,void 0,(function*(){if(at(t))throw new Error(`A source type called "${t}" already exists.`);((t,e)=>{it[t]=e;})(t,i);})),t.clearPrewarmedResources=function(){const t=B;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(k),B=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},t.getMaxParallelImageRequests=function(){return e.a.MAX_PARALLEL_IMAGE_REQUESTS},t.getRTLTextPluginStatus=function(){return nt().getRTLTextPluginStatus()},t.getVersion=function(){return to},t.getWorkerCount=function(){return L.workerCount},t.getWorkerUrl=function(){return e.a.WORKER_URL},t.importScriptInWorkers=function(t){return j().broadcast("IS",t)},t.prewarm=function(){N().acquire(k);},t.setMaxParallelImageRequests=function(t){e.a.MAX_PARALLEL_IMAGE_REQUESTS=t;},t.setRTLTextPlugin=function(t,e){return nt().setRTLTextPlugin(t,e)},t.setWorkerCount=function(t){L.workerCount=t;},t.setWorkerUrl=function(t){e.a.WORKER_URL=t;};})); +define("index",["exports","./shared"],(function(e,t){"use strict";var i="5.5.0";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let o,a;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,i,r){const o=requestAnimationFrame((e=>{a(),i(e);})),{unsubscribe:a}=t.s(e.signal,"abort",(()=>{a(),cancelAnimationFrame(o),r(t.c());}),!1);},frameAsync(e){return new Promise(((t,i)=>{this.frame(e,t,i);}))},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(o||(o=document.createElement("a")),o.href=e,o.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return !!matchMedia&&(null==a&&(a=matchMedia("(prefers-reduced-motion: reduce)")),a.matches)}};class n{static testProp(e){if(!n.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",n.suppressClickInternal,!0);}),0);}static getScale(e){const t=e.getBoundingClientRect();return {x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const o=i.boundingClientRect;return new t.P((r.clientX-o.left)/i.x-e.clientLeft,(r.clientY-o.top)/i.y-e.clientTop)}static mousePos(e,t){const i=n.getScale(e);return n.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=n.getScale(e);for(let o=0;o{c&&_(c),c=null,d=!0;},h.onerror=()=>{u=!0,c=null;},h.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,r,o,a;e.resetRequestQueue=()=>{i=[],r=0,o=0,a={};},e.addThrottleControl=e=>{const t=o++;return a[t]=e,t},e.removeThrottleControl=e=>{delete a[e],n();},e.getImage=(e,r,o=!0)=>new Promise(((a,s)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:o,state:"queued",onError:e=>{s(e);},onSuccess:e=>{a(e);}}),n();}));const s=e=>t._(this,void 0,void 0,(function*(){e.state="running";const{requestParameters:i,supportImageRefresh:o,onError:a,onSuccess:s,abortController:l}=e,h=!1===o&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((e,t)=>e&&"accept"===t),!0));r++;const u=h?c(i,l):t.m(i,l);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires});}catch(t){delete e.abortController,a(t);}finally{r--,n();}var d;})),n=()=>{const e=(()=>{for(const e of Object.keys(a))if(a[e]())return !0;return !1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e);}},c=(e,i)=>new Promise(((r,o)=>{const a=new Image,s=e.url,n=e.credentials;n&&"include"===n?a.crossOrigin="use-credentials":(n&&"same-origin"===n||!t.d(s))&&(a.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{a.src="",o(t.c());})),a.fetchPriority="high",a.onload=()=>{a.onerror=a.onload=null,r({data:a});},a.onerror=()=>{a.onerror=a.onload=null,i.signal.aborted||o(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));},a.src=s;}));}(p||(p={})),p.resetRequestQueue();class m{constructor(e){this._transformRequestFn=e;}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e;}}function f(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:o}of e){const e=`${r}${o}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:o}));}}return t}function g(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}class v{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:o,height:a}=e,s=!(this.size&&this.size[0]===o&&this.size[1]===a||r),{context:n}=this,{gl:l}=n;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),s)this.size=[o,a],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,e):l.texImage2D(l.TEXTURE_2D,0,this.format,o,a,0,this.format,l.UNSIGNED_BYTE,e.data);else {const{x:i,y:s}=r||{x:0,y:0};e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||t.b(e)?l.texSubImage2D(l.TEXTURE_2D,0,i,s,l.RGBA,l.UNSIGNED_BYTE,e):l.texSubImage2D(l.TEXTURE_2D,0,i,s,o,a,l.RGBA,l.UNSIGNED_BYTE,e.data);}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D),n.pixelStoreUnpackFlipY.setDefault(),n.pixelStoreUnpack.setDefault(),n.pixelStoreUnpackPremultiplyAlpha.setDefault();}bind(e,t,i){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),i!==o.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=o.LINEAR),e!==this.filter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,t),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,t),this.wrap=t);}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[];}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null;}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t);}_validate(e,i){let r=!0;const o=i.data||i.spriteData;return this._validateStretch(i.stretchX,o&&o.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,o&&o.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return !0;let i=0;for(const r of e){if(r[0]{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t});}))}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.l("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return {width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else {const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},o=new t.I(i,r);this.patterns[e]={bin:i,position:o};}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const t=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new v(e,this.atlasImage,t.RGBA),this.atlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE);}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),o=this.atlasImage;o.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,a=i.y+1,s=this.getImage(e).data,n=s.width,l=s.height;t.R.copy(s,o,{x:0,y:0},{x:r,y:a},{width:n,height:l}),t.R.copy(s,o,{x:0,y:l-1},{x:r,y:a-1},{width:n,height:1}),t.R.copy(s,o,{x:0,y:0},{x:r,y:a+l},{width:n,height:1}),t.R.copy(s,o,{x:n-1,y:0},{x:r-1,y:a},{width:1,height:l}),t.R.copy(s,o,{x:0,y:0},{x:r+n,y:a},{width:1,height:l});}this.dirty=!0;}beginFrame(){this.callbackDispatchedThisFrame={};}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e);}}}const y=1e20;function w(e,t,i,r,o,a,s,n,l){for(let c=t;c-1);l++,a[l]=n,s[l]=c,s[l+1]=y;}for(let n=0,l=0;n65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[o])return {stack:e,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[o]){const i=P.loadGlyphRange(e,o,this.url,this.requestManager);t.requests[o]=i;}const a=yield t.requests[o];for(const e in a)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=a[+e]);return t.ranges[o]=!0,{stack:e,id:i,glyph:a[i]||null}}))}_doesCharSupportLocalGlyph(e){return !!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||t.u["CJK Unified Ideographs"](e)||t.u["Hangul Syllables"](e)||t.u.Hiragana(e)||t.u.Katakana(e)||t.u["CJK Symbols and Punctuation"](e)||t.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,i,r){const o=this.localIdeographFontFamily;if(!o)return;if(!this._doesCharSupportLocalGlyph(r))return;let a=e.tinySDF;if(!a){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),a=e.tinySDF=new P.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:o,fontWeight:t});}const s=a.draw(String.fromCharCode(r));return {id:r,bitmap:new t.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}P.loadGlyphRange=function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=256*i,s=a+255,n=o.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${a}-${s}`),"Glyphs"),l=yield t.n(n,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${a}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c}))},P.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:a="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const n=this.size=e+4*t,l=this._createCanvas(n),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${a} ${e}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(n*n),this.gridInner=new Float64Array(n*n),this.f=new Float64Array(n),this.z=new Float64Array(n+1),this.v=new Uint16Array(n);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:a}=this.ctx.measureText(e),s=Math.ceil(i),n=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-o))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=n+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),_={data:d,width:c,height:h,glyphWidth:n,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===n||0===l)return _;const{ctx:p,buffer:m,gridInner:f,gridOuter:g}=this;p.clearRect(m,m,n,l),p.fillText(e,m,m+s);const v=p.getImageData(m,m,n,l);g.fill(y,0,u),f.fill(0,0,u);for(let e=0;e0?e*e:0,f[r]=e<0?e*e:0;}}w(g,0,0,c,h,c,this.f,this.v,this.z),w(f,m,m,n,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++a]);const l=Math.abs(n-s.left),c=Math.abs(n-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.data[o+n]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let o=0,a=e[o];for(let t=0;t1&&(a=e[++o]);const i=Math.abs(t-a.left),s=Math.abs(t-a.right),n=Math.min(i,s);this.data[r+t]=Math.max(0,Math.min(255,(a.isDash?n:-n)+128));}}addDash(e,i){const r=i?7:0,o=2*r+1;if(this.nextRow+o>this.height)return t.w("LineAtlas out of space"),null;let a=0;for(let t=0;t{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[z]}numActive(){return Object.keys(this.active).length}}const A=Math.floor(s.hardwareConcurrency/2);let L,k;function F(){return L||(L=new D),L}D.workerCount=t.G(globalThis)?Math.max(Math.min(A,3),1):1;class B{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let e=0;e{e.remove();})),this.actors=[],e&&this.workerPool.release(this.id);}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t);}}function O(){return k||(k=new B(F(),t.J),k.registerMessageHandler("GR",((e,i,r)=>t.m(i,r)))),k}function j(e,i){const r=t.K();return t.L(r,r,[1,1,0]),t.M(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.N(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function Z(e,t,i,r,o,a,s){var n;const l=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return !0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return !0}return !1}(null!==(n=null==o?void 0:o.layers)&&void 0!==n?n:null,t,e.id),c=a.maxPitchScaleFactor(),h=e.tilesIn(r,c,l);h.sort(N);const u=[];for(const r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,o,a,c,j(e.transform,r.tileID),s?(e,t)=>s(r.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const r of e[i])U(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,o=r.wrappedTileID,a=i[o]=i[o]||{};for(const i in e){const r=e[i],o=a[i]=a[i]||{},s=t[i]=t[i]||[];for(const e of r)o[e.featureIndex]||(o[e.featureIndex]=!0,s.push(e));}}return t}(u),e)}function N(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function U(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r;}function G(e,i,r){return t._(this,void 0,void 0,(function*(){let o=e;if(e.url?o=(yield t.j(i.transformRequest(e.url,"Source"),r)).data:yield s.frameAsync(r),!o)return null;const a=t.O(t.e(o,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return "vector_layers"in o&&o.vector_layers&&(a.vectorLayerIds=o.vector_layers.map((e=>e.id))),a}))}class V{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])));}setNorthEast(e){return this._ne=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.Q?new t.Q(e.lng,e.lat):t.Q.convert(e),this}extend(e){const i=this._sw,r=this._ne;let o,a;if(e instanceof t.Q)o=e,a=e;else {if(!(e instanceof V))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(V.convert(e)):this.extend(t.Q.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.Q.convert(e)):this;if(o=e._sw,a=e._ne,!o||!a)return this}return i||r?(i.lng=Math.min(o.lng,i.lng),i.lat=Math.min(o.lat,i.lat),r.lng=Math.max(a.lng,r.lng),r.lat=Math.max(a.lat,r.lat)):(this._sw=new t.Q(o.lng,o.lat),this._ne=new t.Q(a.lng,a.lat)),this}getCenter(){return new t.Q((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new t.Q(this.getWest(),this.getNorth())}getSouthEast(){return new t.Q(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:i,lat:r}=t.Q.convert(e);let o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&o}static convert(e){return e instanceof V?e:e?new V(e):e}static fromLngLat(e,i=0){const r=360*i/40075017,o=r/Math.cos(Math.PI/180*e.lat);return new V(new t.Q(e.lng-o,e.lat-r),new t.Q(e.lng+o,e.lat+r))}adjustAntiMeridian(){const e=new t.Q(this._sw.lng,this._sw.lat),i=new t.Q(this._ne.lng,this._ne.lat);return new V(e,e.lng>i.lng?new t.Q(i.lng+360,i.lat):i)}}class q{constructor(e,t,i){this.bounds=V.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.U(this.bounds.getWest())*i),o=Math.floor(t.S(this.bounds.getNorth())*i),a=Math.ceil(t.U(this.bounds.getEast())*i),s=Math.ceil(t.S(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise(((t,i)=>{e.reloadPromise={resolve:t,reject:i};}))}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null);}}))}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject);}}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}));}))}hasTransition(){return !1}}class H extends t.E{constructor(e,i,r,o){super(),this.id=e,this.dispatcher=r,this.setEventedParent(o),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.O(i,["url","scheme","tileSize"]));}load(){return t._(this,arguments,void 0,(function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield G(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})));}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e));}}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null);}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0);}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}serialize(){return t.e({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const i=yield p.getImage(this.map._requestManager.transformRequest(t,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const t=this.map.painter.context,r=t.gl,o=i.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new v(t,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded";}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController);}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.texture&&this.map.painter.saveTileTexture(e.texture);}))}hasTransition(){return !1}}class $ extends H{constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift;}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield p.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const o=t.b(r)&&t.V()?r:yield this.readImageNow(r),a={type:this.type,uid:e.uid,source:this.id,rawImageData:o,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:a});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded";}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}}))}readImageNow(e){return t._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&t.W()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.X(e,-1,-1,i,r))}catch(e){}}return s.getImageData(e,1)}))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,a=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,n=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.Y(e.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.Y(e.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.Y(e.overscaledZ,n,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates)).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return t._(this,void 0,void 0,(function*(){const e=new V,t=yield this.getData();let i;switch(t.type){case "FeatureCollection":i=t.features.map((e=>this.getCoordinatesFromGeometry(e.geometry))).flat(1/0);break;case "Feature":i=this.getCoordinatesFromGeometry(t.geometry);break;default:i=this.getCoordinatesFromGeometry(t);}if(0==i.length)return e;for(let t=0;t0&&t.e(o,{resourceTiming:r}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content"})));}catch(e){if(this._pendingLoads--,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e));}}))}loaded(){return 0===this._pendingLoads}loadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t);}))}abortTile(e){return t._(this,void 0,void 0,(function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0;}))}unloadTile(e){return t._(this,void 0,void 0,(function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}});}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}});}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}}class K extends t.E{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t;}load(e){return t._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield p.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading());}catch(e){this._request=null,this._loaded=!0,this.fire(new t.k(e));}}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally((()=>{this.texture=null;})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._request&&(this._request.abort(),this._request=null);}setCoordinates(e){this.coordinates=e;const i=e.map(t.$.fromLngLat);var r;return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s=Math.max(o-i,a-r),n=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,n);return new t.a1(n,Math.floor((i+o)/2*l),Math.floor((r+a)/2*l))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((e=>this.tileID.getTilePoint(e)._round())),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new v(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}loadTile(e){return t._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored";}))}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}_getOverlappingTileRanges(e){let i=1/0,r=1/0,o=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),a=Math.max(a,t.y);const s={};for(let e=0;e<=t.a0;e++){const t=Math.pow(2,e),n=Math.floor(i*t),l=Math.floor(r*t),c=Math.floor(o*t),h=Math.floor(a*t);s[e]={minTileX:n,minTileY:l,maxTileX:c,maxTileY:h};}return s}}class Q extends K{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a2(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading();}catch(e){this.fire(new t.k(e));}}))}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.a3(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new v(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0);}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Y extends K{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.a3(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.a3(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.k(new t.a3(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){return t._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}))}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new v(i,this.canvas,r.RGBA,{premultiply:!0});let o=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,o=!0);}o&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}));}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}}const J={},ee=e=>{switch(e){case "geojson":return X;case "image":return K;case "raster":return H;case "raster-dem":return $;case "vector":return W;case "video":return Q;case "canvas":return Y}return J[e]},te="RTLPluginLoaded";class ie extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=O();}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch((e=>{throw this.status="error",e}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null;}setRTLTextPlugin(e){return t._(this,arguments,void 0,(function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status);}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return t._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(te));}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport();}}let re=null;function oe(){return re||(re=new ie),re}class ae{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a4(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading";}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.id]=r;}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a6&&i.hasRTLText){this.hasRTLText=!0,oe().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t));}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage);}else this.collisionBoxArray=new t.a5;}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded";}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new v(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new v(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null);}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture);}queryRenderedFeatures(e,t,i,r,o,a,s,n,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:o,scale:a,tileSize:this.tileSize,pixelPosMatrix:c,transform:n,params:s,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const o=r.loadVTLayers(),a=i&&i.sourceLayer?i.sourceLayer:"",s=o._geojsonTileLayer||o[a];if(!s)return;const n=t.a7(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,o);}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class ne{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,i,r){const o=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},t.e(this.stateChanges[e][o],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])r[t]||(this.deletedStates[e][o][t]=null);}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,i){const r=String(i),o=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return {};for(const e in t)delete o[e];}return o}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,i){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),t.e(this.state[e][r],this.stateChanges[e][r]),i[r]=this.state[e][r];r[e]=i;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t];}r[e]=r[e]||{},t.e(r[e],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i);}}const le=89.25;function ce(e,i){const r=t.ae(i.lat,-85.051129,t.af);return new t.P(t.U(i.lng)*e,t.S(r)*e)}function he(e,i){return new t.$(i.x/e,i.y/e).toLngLat()}function ue(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.ab(90-e.pitch)),Math.tan(t.ab(le-e.pitch)))}function de(e,i){const r=e.canonical,o=i/t.ac(r.z),a=r.x+Math.pow(2,r.z)*e.wrap,s=t.ad(new Float64Array(16));return t.L(s,s,[a*o,r.y*o,0]),t.M(s,s,[o/t.Z,o/t.Z,1]),s}function _e(e,i,r,o,a){const s=t.$.fromLngLat(e,i),n=a*t.ag(1,e.lat),l=n*Math.cos(t.ab(r)),c=Math.sqrt(n*n-l*l),h=c*Math.sin(t.ab(-o)),u=c*Math.cos(t.ab(-o));return new t.$(s.x+h,s.y+u,s.z+l)}function pe(e,t,i){const r=t.intersectsFrustum(e);if(!i)return r;const o=t.intersectsPlane(i);return 0===r||0===o?0:2===r&&2===o?2:1}function me(e,t,i){let r=0;const o=(i-t)/10;for(let a=0;a<10;a++)r+=o*Math.pow(Math.cos(t+(a+.5)/10*(i-t)),e);return r}function fe(e,i){return function(r,o,a,s,n){const l=2*((e-1)/t.ah(Math.cos(t.ab(le-n))/Math.cos(t.ab(le)))-1),c=Math.acos(a/s),h=2*me(l-1,0,t.ab(n/2)),u=Math.min(t.ab(le),c+t.ab(n/2)),d=me(l-1,Math.min(u,c-t.ab(n/2)),u),_=Math.atan(o/a),p=Math.hypot(o,a);let m=r;return m+=t.ah(s/p/Math.max(.5,Math.cos(t.ab(n/2)))),m+=l*t.ah(Math.cos(_))/2,m-=t.ah(Math.max(1,d/h/i))/2,m}}const ge=fe(9.314,3);function ve(e,i){const r=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ah(e.tileSize/i.tileSize));return Math.max(0,r)}function xe(e,i){const r=e.getCameraFrustum(),o=e.getClippingPlane(),a=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.$.fromLngLat(e.center,e.elevation);a.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const n=e.getCoveringTilesDetailsProvider(),l=n.allowVariableZoom(e,i),c=ve(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),_=Math.pow(2,d),p=[_*a.x,_*a.y,0],m=[_*s.x,_*s.y,0],f=Math.hypot(s.x-a.x,s.y-a.y),g=Math.abs(s.z-a.z),v=Math.hypot(f,g),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),b=[],y=[];if(e.renderWorldCopies&&n.allowWorldCopies())for(let e=1;e<=3;e++)b.push(x(-e)),b.push(x(e));for(b.push(x(0));b.length>0;){const _=b.pop(),f=_.x,x=_.y;let w=_.fullyVisible;const T={x:f,y:x,z:_.zoom},P=n.getTileAABB(T,_.wrap,e.elevation,i);if(!w){const e=pe(r,P,o);if(0===e)continue;w=2===e;}const C=n.distanceToTile2d(a.x,a.y,T,P);let M=c;l&&(M=(i.calculateTileZoom||ge)(e.zoom+t.ah(e.tileSize/i.tileSize),C,g,v,e.fov)),M=(i.roundZoom?Math.round:Math.floor)(M),M=Math.max(0,M);const I=Math.min(M,u);if(_.wrap=n.getWrap(s,T,_.wrap),_.zoom>=I){if(_.zoom>1),wrap:_.wrap,fullyVisible:w});}return y.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}class be extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",(e=>this._dataHandler(e))),this.on("dataloading",(()=>{this._sourceErrored=!1;})),this.on("error",(()=>{this._sourceErrored=this._source.loaded();})),this._source=((e,t,i,r)=>{const o=new(ee(t.type))(e,t,i,r);if(o.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${o.id}`);return o})(e,t,i,this),this._tiles={},this._cache=new se(0,(e=>this._unloadTile(e))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ne,this._didEmitContent=!1,this._updated=!1;}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e);}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e);}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return !0;if(!this._updated)return !1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain);}_loadTile(e,i,r){return t._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,r);}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain);}}))}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e);}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}));}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager);}}getIds(){return Object.values(this._tiles).map((e=>e.tileID)).sort(ye).map((e=>e.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,o=i.tileID,a=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(o.canonical.x,o.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-o.overscaledZ||s.y-a.y||s.x-a.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(ye).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)(e||"errored"!==this._tiles[t].state)&&this._reloadTile(t,"reloading");}}_reloadTile(e,i){return t._(this,void 0,void 0,(function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i));}))}_tileLoaded(e,i,r){e.timeAdded=s.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[a]&&(e.neighboringTiles[a].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const o in this._tiles){let a=this._tiles[o];if(r[o]||!a.hasData()||a.tileID.overscaledZ<=t||a.tileID.overscaledZ>i)continue;let s=a.tileID;for(;a&&a.tileID.overscaledZ>t+1;){const e=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[e.key],a&&a.hasData()&&(s=e);}let n=s;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]||e[n.canonical.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,o=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e]);}}_updateCoveredAndRetainedTiles(e,t,i,r,o,a){const n={},l={},c=Object.keys(e),h=s.now();for(const i of c){const r=e[i],o=this._tiles[i];if(!o||0!==o.fadeEndTime&&o.fadeEndTime<=h)continue;const a=this.findLoadedParent(r,t),s=this.findLoadedSibling(r),c=a||s||null;c&&(this._addTile(c.tileID),n[c.tileID.key]=c.tileID),l[i]=r;}this._retainLoadedChildren(l,r,i,e);for(const t in n)e[t]||(this._coveredTiles[t]=!0,e[t]=n[t]);if(a){const t={},i={};for(const e of o)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const r in i){const o=i[r].children(this._source.maxzoom);this._tiles[o[0].key]&&this._tiles[o[1].key]&&this._tiles[o[2].key]&&this._tiles[o[3].key]&&(t[o[0].key]=e[o[0].key]=o[0],t[o[1].key]=e[o[1].key]=o[1],t[o[2].key]=e[o[2].key]=o[2],t[o[3].key]=e[o[3].key]=o[3],delete i[r]);}for(const r in i){const o=i[r],a=this.findLoadedParent(o,this._source.minzoom),s=this.findLoadedSibling(o),n=a||s||null;if(n){t[n.tileID.key]=e[n.tileID.key]=n.tileID;for(const e in t)t[e].isChildOf(n.tileID)&&delete t[e];}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0);}}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.Y(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=xe(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter((e=>this._source.hasTile(e))))):r=[];const o=ve(e,this._source),a=Math.max(o-be.maxOverzooming,this._source.minzoom),s=Math.max(o+be.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of r)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const r=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[r.key]=r;}r=r.concat(Object.values(e));}const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,o);we(this._source.type)&&this._updateCoveredAndRetainedTiles(l,a,s,o,r,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.aj(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e);}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e);}_updateRetainedTiles(e,t){var i;const r={},o={},a=Math.max(t-be.maxOverzooming,this._source.minzoom),s=Math.max(t+be.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);r[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=s.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){r[e.key]=e;continue}}else {const e=s.children(this._source.maxzoom);if(r[e[0].key]&&r[e[1].key]&&r[e[2].key]&&r[e[3].key])continue}let n=e.wasRequested();for(let t=s.overscaledZ-1;t>=a;--t){const a=s.scaledTo(t);if(o[a.key])break;if(o[a.key]=!0,e=this.getTile(a),!e&&n&&(e=this._addTile(a)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=e.wasRequested(),t)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i;}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new ae(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}refreshTiles(e){for(const t in this._tiles)this._isIdRenderable(t)&&e.some((e=>e.equals(this._tiles[t].tileID.canonical)))&&this._reloadTile(t,"expired");}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0);}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset();}tilesIn(e,i,r){const o=[],a=this.transform;if(!a)return o;const s=r?a.getCameraQueryGeometry(e):e,n=e.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),l=s.map((e=>a.screenPointToMercatorCoordinate(e,this.terrain))),c=this.getIds();let h=1/0,u=1/0,d=-1/0,_=-1/0;for(const e of l)h=Math.min(h,e.x),u=Math.min(u,e.y),d=Math.max(d,e.x),_=Math.max(_,e.y);for(let e=0;e=0&&f[1].y+m>=0){const e=n.map((e=>s.getTilePoint(e))),t=l.map((e=>s.getTilePoint(e)));o.push({tile:r,tileID:s,queryGeometry:e,cameraQueryGeometry:t,scale:p});}}return o}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return !0;if(we(this._source.type)){const e=s.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}}function ye(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function we(e){return "raster"===e||"image"===e||"video"===e}be.maxOverzooming=10,be.maxUnderzooming=3;class Te{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(o-s)/n:0;return this.points[a].mult(1-l).add(this.points[i].mult(l))}}function Pe(e,t){let i=!0;return "always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Ce{constructor(e,t,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return [];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(o)return [{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e0}hitTestCircle(e,t,i,r,o){const a=e-i,s=e+i,n=t-i,l=t+i;if(s<0||a>this.width||l<0||n>this.height)return !1;const c=[];return this._forEachCell(a,n,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},o),c.length>0}_queryCell(e,t,i,r,o,a,s,n){const{seenUids:l,hitTest:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const o=this.bboxes;for(const s of u)if(!l.box[s]){l.box[s]=!0;const u=4*s,d=this.boxKeys[s];if(e<=o[u+2]&&t<=o[u+3]&&i>=o[u+0]&&r>=o[u+1]&&(!n||n(d))&&(!c||!Pe(h,d.overlapMode))&&(a.push({key:d,x1:o[u],y1:o[u+1],x2:o[u+2],y2:o[u+3]}),c))return !0}}const d=this.circleCells[o];if(null!==d){const o=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const u=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],e,t,i,r)&&(!n||n(d))&&(!c||!Pe(h,d.overlapMode))){const e=o[u],t=o[u+1],i=o[u+2];if(a.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return !0}}}return !1}_queryCellCircle(e,t,i,r,o,a,s,n){const{circle:l,seenUids:c,overlapMode:h}=s,u=this.boxCells[o];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!n||n(r))&&!Pe(h,r.overlapMode))return a.push(!0),!0}}const d=this.circleCells[o];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!n||n(r))&&!Pe(h,r.overlapMode))return a.push(!0),!0}}}_forEachCell(e,t,i,r,o,a,s,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(o.call(this,e,t,i,r,this.xCellCount*l+d,a,s,n))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,o,a){const s=r-e,n=o-t,l=i+a;return l*l>s*s+n*n}_circleAndRectCollide(e,t,i,r,o,a,s){const n=(a-r)/2,l=Math.abs(e-(r+n));if(l>n+i)return !1;const c=(s-o)/2,h=Math.abs(t-(o+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}function Me(e,i,o){const a=t.K();if(!e){const{vecSouth:e,vecEast:t}=Ee(i),o=r();o[0]=t[0],o[1]=t[1],o[2]=e[0],o[3]=e[1],s=o,(d=(l=(n=o)[0])*(u=n[3])-(h=n[2])*(c=n[1]))&&(s[0]=u*(d=1/d),s[1]=-c*d,s[2]=-h*d,s[3]=l*d),a[0]=o[0],a[1]=o[1],a[4]=o[2],a[5]=o[3];}var s,n,l,c,h,u,d;return t.M(a,a,[1/o,1/o,1]),a}function Ie(e,i,r,o){if(e){const e=t.K();if(!i){const{vecSouth:t,vecEast:i}=Ee(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1];}return t.M(e,e,[o,o,1]),e}return r.pixelsToClipSpaceMatrix}function Ee(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),o=Math.cos(e.pitchInRadians),a=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),n=t.ao();n[0]=-a*o*r-s*i,n[1]=-s*o*r+a*i;const l=t.ap(n);l<1e-9?t.aq(n):t.ar(n,n,1/l);const c=t.ao();c[0]=a*o*i-s*r,c[1]=s*o*i+a*r;const h=t.ap(c);return h<1e-9?t.aq(c):t.ar(c,c,1/h),{vecEast:c,vecSouth:n}}function Se(e,i,r,o){let a;o?(a=[e,i,o(e,i),1],t.at(a,a,r)):(a=[e,i,0,1],We(a,a,r));const s=a[3];return {point:new t.P(a[0]/s,a[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Re(e,t){return .5+e/t*.5}function ze(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function De(e,i,r,o,a,s,n,l,c,h,u,d,_){const p=r?e.textSizeData:e.iconSizeData,m=t.ak(p,i.transform.zoom),f=[256/i.width*2+1,256/i.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();const v=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,b=i.transform.width/i.transform.height;let y=!1;for(let r=0;rMath.abs(r.x-i.x)*o?{useVertical:!0}:(e===t.al.vertical?i.yr.x)?{needsFlipping:!0}:null}function ke(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:o,fontSize:a,flip:s,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=a/24,_=o.lineOffsetX*d,p=o.lineOffsetY*d;let m;if(o.numGlyphs>1){const e=o.glyphStartIndex+o.numGlyphs,t=o.lineStartIndex,a=o.lineStartIndex+o.lineLength,c=Ae(d,l,_,p,s,o,u,i);if(!c)return {notEnoughRoom:!0};const f=je(c.first.point.x,c.first.point.y,i,r),g=je(c.last.point.x,c.last.point.y,i,r);if(n&&!s){const e=Le(o.writingMode,f,g,h);if(e)return e}m=[c.first];for(let r=o.glyphStartIndex+1;r0?n.point:Fe(i.tileAnchorPoint,s,e,1,i),c=je(e.x,e.y,i,r),u=je(l.x,l.y,i,r),d=Le(o.writingMode,c,u,h);if(d)return d}const e=Ge(d*l.getoffsetX(o.glyphStartIndex),_,p,s,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return {notEnoughRoom:!0};m=[e];}for(const e of m)t.as(c,e.point,e.angle);return {}}function Fe(e,t,i,r,o){const a=e.add(e.sub(t)._unit()),s=Oe(a.x,a.y,o).point,n=i.sub(s);return i.add(n._mult(r/n.mag()))}function Be(e,i,r){const o=i.projectionCache;if(o.projections[e])return o.projections[e];const a=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Oe(a.x,a.y,i);if(s.signedDistanceFromCamera>0)return o.projections[e]=s.point,o.anyProjectionOccluded=o.anyProjectionOccluded||s.isOccluded,s.point;const n=e-r.direction;return Fe(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),a,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Oe(e,t,i){const r=e+i.translation[0],o=t+i.translation[1];let a;return i.pitchWithMap?(a=Se(r,o,i.pitchedLabelPlaneMatrix,i.getElevation),a.isOccluded=!1):(a=i.transform.projectTileCoordinates(r,o,i.unwrappedTileID,i.getElevation),a.point.x=(.5*a.point.x+.5)*i.width,a.point.y=(.5*-a.point.y+.5)*i.height),a}function je(e,i,r,o){if(r.pitchWithMap){const a=[e,i,0,1];return t.at(a,a,o),r.transform.projectTileCoordinates(a[0]/a[3],a[1]/a[3],r.unwrappedTileID,r.getElevation).point}return {x:e/r.width*2-1,y:i/r.height*2-1}}function Ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ne(e,t,i){return e._unit()._perp()._mult(t*i)}function Ue(e,i,r,o,a,s,n,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=r.add(i);if(e+c.direction=a)return l.projectionCache.offsets[e]=h,h;const u=Be(e+c.direction,l,c),d=Ne(u.sub(r),n,c.direction),_=r.add(d),p=u.add(d);return l.projectionCache.offsets[e]=t.au(s,h,_,p)||h,l.projectionCache.offsets[e]}function Ge(e,t,i,r,o,a,s,n,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,_=h>0?a+o:a+o+1;n.projectionCache.cachedAnchorPoint?d=n.projectionCache.cachedAnchorPoint:(d=Oe(n.tileAnchorPoint.x,n.tileAnchorPoint.y,n).point,n.projectionCache.cachedAnchorPoint=d);let p,m,f=d,g=d,v=0,x=0;const b=Math.abs(c),y=[];let w;for(;v+x<=b;){if(_+=h,_=s)return null;v+=x,g=f,m=p;const e={absOffsetX:b,direction:h,distanceFromAnchor:v,previousVertex:g};if(f=Be(_,n,e),0===i)y.push(g),w=f.sub(g);else {let t;const r=f.sub(g);t=0===r.mag()?Ne(Be(_+h,n,e).sub(f),i,h):Ne(r,i,h),m||(m=g.add(t)),p=Ue(_,t,f,a,s,m,i,n,e),y.push(m),w=p.sub(m);}x=w.mag();}const T=w._mult((b-v)/x)._add(m||g),P=u+Math.atan2(f.y-g.y,f.x-g.x);return y.push(T),{point:T,angle:l?P:0,path:y}}const Ve=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function qe(e,t){for(let i=0;i=1;e--)_.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let f=[];if(_.length>0){const e=_[0].clone(),i=_[0].clone();for(let t=1;t<_.length;t++)e.x=Math.min(e.x,_[t].x),e.y=Math.min(e.y,_[t].y),i.x=Math.max(i.x,_[t].x),i.y=Math.max(i.y,_[t].y);f=e.x>=r.x&&i.x<=o.x&&e.y>=r.y&&i.y<=o.y?[_]:i.xo.x||i.yo.y?[]:t.av([_],r.x,r.y,o.x,o.y);}for(const t of f){a.reset(t,.25*i);let r=0;r=a.length<=.5*i?1:Math.ceil(a.paddedLength/p)+1;for(let t=0;t{const t=Se(e.x,e.y,r,i.getElevation),o=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height,o}))}(e,i);return function(e){let t=0,i=0,r=0,o=0;for(let a=0;ai&&(i=o,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let r=1/0,o=1/0,a=-1/0,s=-1/0;for(const n of e){const e=new t.P(n.x+He,n.y+He);r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y),i.push(e);}const n=this.grid.query(r,o,a,s).concat(this.ignoredGrid.query(r,o,a,s)),l={},c={};for(const e of n){const r=e.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const o=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aw(i,o)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex));}return c}insertCollisionBox(e,t,i,r,o,a){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,r,o,a){const s=i?this.ignoredGrid:this.grid,n={bucketInstanceId:r,featureIndex:o,collisionGroupID:a,overlapMode:t};for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,o,c,u)));S=e.some((e=>!e.isOccluded)),E=e.map((e=>new t.P(e.x,e.y)));}else S=!0;return {box:t.ax(E),allPointsOccluded:!S}}}class Xe{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class Ke{constructor(e,t,i,r,o){this.text=new Xe(e?e.text:null,t,i,o),this.icon=new Xe(e?e.icon:null,t,r,o);}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Qe{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i;}}class Ye{constructor(e,t,i,r,o){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=o;}}class Je{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function et(e,i,r,o,a){const{horizontalAlign:s,verticalAlign:n}=t.aE(e);return new t.P(-(s-.5)*i+o[0]*a,-(n-.5)*r+o[1]*a)}class tt{constructor(e,t,i,r,o){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new $e(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Je(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,o){const a=r.getBucket(i),s=r.latestFeatureIndex;if(!a||!s||i.id!==a.layerIds[0])return;const n=r.collisionBoxArray,l=a.layers[0].layout,c=a.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.Z,d=r.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=t.az(r,1,this.transform.zoom),m=t.aA(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),f=t.aA(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),g=Me(_,this.transform,p);this.retainedQueryData[a.bucketInstanceId]=new Ye(a.bucketInstanceId,s,a.sourceLayerIndex,a.index,r.tileID);const v={bucket:a,layout:l,translationText:m,translationIcon:f,unwrappedTileID:d,pitchedLabelPlaneMatrix:g,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:t.ak(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(o)for(const t of a.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:v});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:v});}attemptAnchorPlacement(e,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v,x,b){const y=t.aB[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=et(y,r,o,w,a),P=this.collisionIndex.placeCollisionBox(i,d,l,c,h,n,s,f,u.predicate,x,T,b);if((!v||this.collisionIndex.placeCollisionBox(v,d,l,c,h,n,s,g,u.predicate,x,T,b).placeable)&&P.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID]&&this.prevPlacement.placements[_.crossTileID].text&&(e=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:w,width:r,height:o,anchor:y,textBoxScale:a,prevAnchor:e},this.markUsedJustification(p,y,_,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,_),this.placedOrientations[_.crossTileID]=m),{shift:T,placedGlyphBoxes:P}}}placeLayerBucketPart(e,i,r){const{bucket:o,layout:a,translationText:s,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=e.parameters,m=a.get("text-optional"),f=a.get("icon-optional"),g=t.aC(a,"text-overlap","text-allow-overlap"),v="always"===g,x=t.aC(a,"icon-overlap","icon-allow-overlap"),b="always"===x,y="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),T="none"!==a.get("icon-text-fit"),P="viewport-y"===a.get("symbol-z-order"),C=v&&(b||!o.hasIconData()||f),M=b&&(v||!o.hasTextData()||m);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d);const I=this.retainedQueryData[o.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(I),S=this.transform.getFastPathSimpleProjectionMatrix(I),R=(e,d,b)=>{var P,R;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new Qe(!1,!1,!1));let z=!1,D=!1,A=!0,L=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,j=null,Z=0,N=0,U=0;d.textFeatureIndex?Z=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(Z=e.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let r=t.al.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(o,r,e));}return r},a=(i,r)=>{if(o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of o.writingModes)if(e===t.al.vertical?(k=r(),F=k):k=i(),k&&k.placeable)break}else k=i();},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,h,I,l,w,y,s,p.predicate,E,void 0,S);return r&&r.placeable&&(this.markUsedOrientation(o,i,e),this.placedOrientations[e.crossTileID]=i),r};a((()=>r(G,t.al.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.al.vertical):{box:null,offscreen:null}})),i(k&&k.placeable);}else {let _=t.aB[null===(R=null===(P=this.prevPlacement)||void 0===P?void 0:P.variableOffsets[e.crossTileID])||void 0===R?void 0:R.anchor];const m=(t,i,a)=>{const d=t.x2-t.x1,m=t.y2-t.y1,f=e.textBoxScale,v=T&&"never"===x?i:null;let b=null,P="never"===g?1:2,C="never";_&&P++;for(let i=0;im(G,d.iconBox,t.al.horizontal)),(()=>{const i=d.verticalTextBox;return o.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.al.vertical):{box:null,occluded:!0,offscreen:null}})),k&&(z=k.placeable,A=k.offscreen);const f=i(k&&k.placeable);if(!z&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(o,t.anchor,e,f));}}}if(B=k,z=B&&B.placeable,A=B&&B.offscreen,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),n=t.am(o.textSizeData,_,i),h=a.get("text-padding");O=this.collisionIndex.placeCollisionCircles(g,i,o.lineVertexArray,o.glyphOffsetArray,n,l,c,r,w,p.predicate,e.collisionCircleDiameter,h,s,E),O.circles.length&&O.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),z=v||O.circles.length>0&&!O.collisionDetected,A=A&&O.offscreen;}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,I,l,w,y,n,p.predicate,E,T&&L?L:void 0,S);F&&F.placeable&&d.verticalIconBox?(j=e(d.verticalIconBox),D=j.placeable):(j=e(d.iconBox),D=j.placeable),A=A&&j.offscreen;}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,q=f||0===e.numIconVertices;V||q?q?V||(D=D&&z):z=D&&z:D=z=D&&z;const W=D&&j.placeable;if(z&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,g,a.get("text-ignore-placement"),o.bucketInstanceId,F&&F.placeable&&N?N:Z,p.ID),W&&this.collisionIndex.insertCollisionBox(j.box,x,a.get("icon-ignore-placement"),o.bucketInstanceId,U,p.ID),O&&z&&this.collisionIndex.insertCollisionCircles(O.circles,g,a.get("text-ignore-placement"),o.bucketInstanceId,Z,p.ID),r&&this.storeCollisionData(o.bucketInstanceId,b,d,B,j,O),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===o.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Qe((z||C)&&!(null==B?void 0:B.occluded),(D||M)&&!(null==j?void 0:j.occluded),A||o.justReloaded),i[e.crossTileID]=!0;};if(P){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=o.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];R(o.symbolInstances.get(i),o.collisionArrays[i],i);}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID);}markUsedOrientation(e,i,r){const o=i===t.al.horizontal||i===t.al.horizontalOnly?i:0,a=i===t.al.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,o=t?t.opacities:{},a=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],a=o[e];a?(this.opacities[e]=new Ke(a,r,t.text,t.icon),i=i||t.text!==a.text.placed||t.icon!==a.icon.placed):(this.opacities[e]=new Ke(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon);}for(const e in o){const t=o[e];if(!this.opacities[e]){const o=new Ke(t,r,!1,!1);o.isHidden()||(this.opacities[e]=o,i=i||t.text.placed||t.icon.placed);}}for(const e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray);}}updateBucketOpacities(e,i,r,o){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const a=e.layers[0],s=a.layout,n=new Ke(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),h=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),_="none"!==s.get("icon-text-fit"),p=new Ke(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&o&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(o);const m=(e,t,i)=>{for(let r=0;r0,v=this.placedOrientations[o.crossTileID],x=v===t.al.vertical,b=v===t.al.horizontal||v===t.al.horizontalOnly;if(a>0||s>0){const t=ht(c.text);m(e.text,a,x?ut:t),m(e.text,s,b?ut:t);const i=c.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||x?1:0);})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||b?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o));}if(g){const t=ht(c.icon),i=!(_&&o.verticalPlacedIconSymbolIndex&&x);o.placedIconSymbolIndex>=0&&(m(e.icon,o.numIconVertices,i?t:ut),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=c.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,o.numVerticalIconVertices,i?ut:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden());}const y=f&&f.has(i)?f.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const r=e.collisionArrays[i];if(r){let i=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[l];e?(i=et(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1;}if(r.textBox||r.verticalTextBox){let o;r.textBox&&(o=x),r.verticalTextBox&&(o=b),it(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||o,y.text,i.x,i.y);}}if(r.iconBox||r.verticalIconBox){const t=Boolean(!b&&r.verticalIconBox);let o;r.iconBox&&(o=t),r.verticalIconBox&&(o=!t),it(e.iconCollisionBox.collisionVertexArray,c.icon.placed,o,y.icon,_?i.x:0,_?i.y:0);}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId]);}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0;}}function it(e,t,i,r,o,a){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-He,n=r[1]-He,l=r[2]-He,c=r[3]-He;e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,n),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,l,c),e.emplaceBack(t?1:0,i?1:0,o||0,a||0,s,c);}const rt=Math.pow(2,25),ot=Math.pow(2,24),at=Math.pow(2,17),st=Math.pow(2,16),nt=Math.pow(2,9),lt=Math.pow(2,8),ct=Math.pow(2,1);function ht(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*rt+t*ot+i*at+t*st+i*nt+t*lt+i*ct+t}const ut=0;class dt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[];}continuePlacement(e,t,i,r,o){const a=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex!this._forceFullPlacement&&s.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=a)&&(!r.maxzoom||r.maxzoom>a)){if(this._inProgressLayer||(this._inProgressLayer=new dt(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const pt=512/t.Z/2;class mt{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const o=new Map;for(let e=0;e({x:Math.floor(e.anchorX*pt),y:Math.floor(e.anchorY*pt)}))),crossTileIDs:i.map((e=>e.crossTileID))};if(r.positions.length>128){const e=new t.aF(r.positions.length,16,Uint16Array);for(const{x:t,y:i}of r.positions)e.add(t,i);e.finish(),delete r.positions,r.index=e;}this._symbolsByKey[e]=r;}}getScaledCoordinates(e,i){const{x:r,y:o,z:a}=this.tileID.canonical,{x:s,y:n,z:l}=i.canonical,c=pt/Math.pow(2,l-a),h=(n*t.Z+e.anchorY)*c,u=o*t.Z*pt;return {x:Math.floor((s*t.Z+e.anchorX)*c-r*t.Z*pt),y:Math.floor(h-u)}}findMatches(e,t,i){const r=this.tileID.canonical.ze))}}class ft{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class gt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const o=i[e];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),r[o.tileID.key]=o;}this.indexes[e]=r;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in o){const a=o[i];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,r);}else {const a=o[e.scaledTo(Number(i)).key];a&&a.findMatches(t.symbolInstances,e,r);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var xt="void main() {fragColor=vec4(1.0);}";const bt={prelude:yt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:yt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:yt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:yt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:yt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:yt("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:yt(xt,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:yt("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:yt("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:yt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:yt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:yt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:yt(xt,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:yt("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:yt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:yt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:yt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:yt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:yt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;switch(u_method){case BASIC:\nbasic_hillshade(deriv);break;case COMBINED:\ncombined_hillshade(deriv);break;case IGOR:\nigor_hillshade(deriv);break;case MULTIDIRECTIONAL:\nmultidirectional_hillshade(deriv);break;case STANDARD:\ndefault:\nstandard_hillshade(deriv);break;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:yt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:yt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:yt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:yt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:yt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:yt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:yt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:yt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:yt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:yt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:yt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:yt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:yt("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:yt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function yt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),o=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=a?a.concat(o):o,n={};return {fragmentSource:e=e.replace(i,((e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,i,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\nout ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:r,staticUniforms:s}}class wt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i;}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null;}}var Tt=t.aG([{name:"a_pos",type:"Int16",components:2}]);const Pt="#define PROJECTION_MERCATOR",Ct="mercator";class Mt{constructor(){this._cachedMesh=null;}get name(){return "mercator"}get useSubdivision(){return !1}get shaderVariantName(){return Ct}get shaderDefine(){return Pt}get shaderPreludeCode(){return bt.projectionMercator}get vertexShaderPreludeCode(){return bt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aH.noSubdivision}get useGlobeControls(){return !1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,o,a){if(this._cachedMesh)return this._cachedMesh;const s=new t.aI;s.emplaceBack(0,0),s.emplaceBack(t.Z,0),s.emplaceBack(0,t.Z),s.emplaceBack(t.Z,t.Z);const n=e.createVertexBuffer(s,Tt.members),l=t.aJ.simpleSegment(0,0,4,2),c=new t.aK;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new wt(n,h,l),this._cachedMesh}recalculate(){}hasTransition(){return !1}setErrorQueryLatitudeDegrees(e){}}class It{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r;}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.B.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.B.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.B.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.B.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.ae((this.left+e-this.right)/2,0,e),o=t.ae((this.top+i-this.bottom)/2,0,i);return new t.P(r,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new It(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Et(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0;}function St(e){return Math.max(0,Math.floor(e))}class Rt{constructor(e,i,r,o,a,s){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=r||22,this._minPitch=null==o?0:o,this._maxPitch=null==a?60:a,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.Q(0,0),this._elevation=0,this._zoom=0,this._tileZoom=St(this._zoom),this._scale=t.ac(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new It,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0;}apply(e,i,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=St(this._zoom),this._scale=t.ac(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new It(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices();}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e;}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom));}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)));}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)));}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aL(e,-180,180)*Math.PI/180;var o,a,s,n,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),o=this._rotationMatrix,s=-this._bearingInRadians,n=(a=this._rotationMatrix)[0],l=a[1],c=a[2],h=a[3],u=Math.sin(s),d=Math.cos(s),o[0]=n*d+c*u,o[1]=l*d+h*u,o[2]=n*-u+c*d,o[3]=l*-u+h*d);}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ae(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices());}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices());}get fovInRadians(){return this._fovInRadians}get fov(){return t.aM(this._fovInRadians)}setFov(e){e=t.ae(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ab(e),this._calcMatrices());}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.ac(i),this._constrain(),this._calcMatrices());}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices());}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices());}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices();}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices();}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices();}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new V([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-85.051129,t.af]);}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return [i[0],e];{let r=e.x,o=e.y,a=e.x,s=e.y;for(const e of i)r=Math.min(r,e.x),o=Math.min(o,e.y),a=Math.max(a,e.x),s=Math.max(s,e.y);return [new t.P(r,o),new t.P(a,o),new t.P(a,s),new t.P(r,s),new t.P(r,o)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1;}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ad(new Float64Array(16));t.M(e,e,[this._width/2,-this._height/2,1]),t.L(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ad(new Float64Array(16)),t.M(e,e,[1,-1,1]),t.L(e,e,[-1,-1,0]),t.M(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height;}this._callbacks.calcMatrices();}calculateCenterFromCameraLngLatAlt(e,i,r,o){const a=void 0!==r?r:this.bearing,s=o=void 0!==o?o:this.pitch,n=t.$.fromLngLat(e,i),l=-Math.cos(t.ab(s)),c=Math.sin(t.ab(s)),h=c*Math.sin(t.ab(a)),u=-c*Math.cos(t.ab(a));let d=this.elevation;const _=i-d;let p;l*_>=0||Math.abs(l)<.1?(p=1e4,d=i+p*l):p=-_/l;let m,f,g=t.aN(1,n.y),v=0;do{if(v+=1,v>10)break;f=p/g,m=new t.$(n.x+h*f,n.y+u*f),g=1/m.meterInMercatorCoordinateUnits();}while(Math.abs(p-f*g)>1e-12);return {center:m.toLngLat(),elevation:d,zoom:t.ah(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.ag(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,o=t.$.fromLngLat(this.center,this.elevation),a=_e(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(a.toLngLat(),t.aN(a.z,o.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom);}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.ag(1,this.center.lat)*this.worldSize;return _e(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return [0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class Dt{distanceToTile2d(e,t,i,r){const o=r.distanceX([e,t]),a=r.distanceY([e,t]);return Math.hypot(o,a)}getWrap(e,t,i){return i}getTileAABB(e,i,r,o){var a,s;let n=r,l=r;if(o.terrain){const c=new t.Y(e.z,i,e.z,e.x,e.y),h=o.terrain.getMinMaxElevation(c);n=null!==(a=h.minElevation)&&void 0!==a?a:r,l=null!==(s=h.maxElevation)&&void 0!==s?s:r;}const c=1<o}allowWorldCopies(){return !0}recalculateCache(){}}class At{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i;}static fromInvProjectionMatrix(e,i=1,r=0){const o=Math.pow(2,r),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const a=1/(r=t.at([],r,e))[3]/i*o;return t.aR(r,r,[a,a,1/r[3],a])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.aS([],a[e[0]],a[e[1]]),r=t.aS([],a[e[2]],a[e[1]]),o=t.aT([],t.aU([],i,r)),s=-t.aV(o,a[e[1]]);return o.concat(s)})),n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],l=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of a)for(let t=0;t<3;t++)n[t]=Math.min(n[t],e[t]),l[t]=Math.max(l[t],e[t]);return new At(a,s,new zt(n,l))}}class Lt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,r,o){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,r,o),this._coveringTilesDetailsProvider=new Dt;}clone(){const e=new Lt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i);}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.aW(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),n=Math.floor(Math.min(r.x,o.x,a.x,s.x)),l=Math.floor(Math.max(r.x,o.x,a.x,s.x)),c=1;for(let r=n-c;r<=l+c;r++)0!==r&&i.push(new t.aW(r,e));}return i}getCameraFrustum(){return At.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i);}setLocationAtPoint(e,i){const r=t.ag(this.elevation,this.center.lat),o=this.screenPointToMercatorCoordinateAtZ(i,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),s=t.$.fromLngLat(e),n=new t.$(s.x-(o.x-a.x),s.y-(o.y-a.y));this.setCenter(null==n?void 0:n.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap());}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.$.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.$.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,o=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.at(o,o,this._pixelMatrixInverse),t.at(a,a,this._pixelMatrixInverse);const s=o[3],n=a[3],l=o[1]/s,c=a[1]/n,h=o[2]/s,u=a[2]/n,d=h===u?0:(r-h)/(u-h);return new t.$(t.B.number(o[0]/s,a[0]/n,d)/this.worldSize,t.B.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.at(o,o,r),new t.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this._helper._height/2-ue(this));return (new V).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-ue(this)}calculatePosMatrix(e,i=!1,r){var o;const a=null!==(o=e.key)&&void 0!==o?o:t.aX(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(a)){const e=s.get(a);return r?e.f32:e.f64}const n=de(e,this.worldSize);t.N(n,i?this._alignedProjMatrix:this._viewProjMatrix,n);const l={f64:n,f32:new Float32Array(n)};return s.set(a,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const o=de(e,this.worldSize);return t.N(o,this._fogMatrix,o),r.set(i,new Float32Array(o)),r.get(i)}getConstrained(e,i){i=t.ae(+i,this.minZoom,this.maxZoom);const r={center:new t.Q(e.lng,e.lat),zoom:i};let o=this._helper._lngRange;this._helper._renderWorldCopies||null!==o||(o=[-179.9999999999,180-1e-10]);const a=this.tileSize*t.ac(r.zoom);let s=0,n=a,l=0,c=a,h=0,u=0;const{x:d,y:_}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.S(e[1])*a,n=t.S(e[0])*a,n-s<_&&(h=_/(n-s));}o&&(l=t.aL(t.U(o[0])*a,0,a),c=t.aL(t.U(o[1])*a,0,a),cn&&(g=n-e);}if(o){const e=(l+c)/2;let i=p;this._helper._renderWorldCopies&&(i=t.aL(p,e-a/2,e+a/2));const r=d/2;i-rc&&(f=c-r);}if(void 0!==f||void 0!==g){const e=new t.P(null!=f?f:p,null!=g?g:m);r.center=he(a,e).wrap();}return r}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const o=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-o*this._helper._pixelPerMeter/Math.cos(i),s=o<0?a:e,n=Math.PI/2+this.pitchInRadians,l=t.ab(this.fov)*(Math.abs(Math.cos(t.ab(this.roll)))*this.height+Math.abs(Math.sin(t.ab(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*s/Math.sin(t.ae(Math.PI-n-l,.01,Math.PI-.01)),h=ue(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.ab(.75),_=u>d?2*u*(.5+r.y/(2*h)):d,p=Math.sin(_)*s/Math.sin(t.ae(Math.PI-n-_,.01,Math.PI-.01)),m=Math.min(c,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50;}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=ce(this.worldSize,this.center),r=i.x,o=i.y;this._helper._pixelPerMeter=t.ag(1,this.center.lat)*this.worldSize;const a=t.ab(Math.min(this.pitch,le)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a));let n;this._calculateNearFarZIfNeeded(s,a,e),n=new Float64Array(16),t.aY(n,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.an(this._invProjMatrix,n),n[8]=2*-e.x/this._helper._width,n[9]=2*e.y/this._helper._height,this._projectionMatrix=t.aZ(n),t.M(n,n,[1,-1,1]),t.L(n,n,[0,0,-this._helper.cameraToCenterDistance]),t.a_(n,n,-this.rollInRadians),t.a$(n,n,this.pitchInRadians),t.a_(n,n,-this.bearingInRadians),t.L(n,n,[-r,-o,0]),this._mercatorMatrix=t.M([],n,[this.worldSize,this.worldSize,this.worldSize]),t.M(n,n,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n),t.L(n,n,[0,0,-this.elevation]),this._viewProjMatrix=n,this._invViewProjMatrix=t.an([],n);const l=[0,0,-1,1];t.at(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.aY(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.M(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.a_(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.a$(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.a_(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.L(this._fogMatrix,this._fogMatrix,[-r,-o,0]),t.M(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.L(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.N(new Float64Array(16),this.clipSpaceToPixelsMatrix,n);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),_=r-Math.round(r)+u*c+d*h,p=o-Math.round(o)+u*h+d*c,m=new Float64Array(n);if(t.L(m,m,[_>.5?_-1:_,p>.5?p-1:p,0]),this._alignedProjMatrix=m,n=t.an(new Float64Array(16),this._pixelMatrix),!n)throw new Error("failed to invert matrix");this._pixelMatrixInverse=n,this._clearMatrixCaches();}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear();}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.at(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.ag(1,this.center.lat)*this.worldSize;return _e(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.$.fromLngLat(e),o=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.at(o,o,this._viewProjMatrix),o[2]/o[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:o}=e,a=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;let n;return n=i&&i.terrainRttPosMatrix32f&&o?i.terrainRttPosMatrix32f:s||t.b0(),{mainMatrix:n,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n}}isLocationOccluded(e){return !1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aQ(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,o){const a=this.calculatePosMatrix(r);let s;o?(s=[e,i,o(e,i),1],t.at(s,s,a)):(s=[e,i,0,1],We(s,s,a));const n=s[3];return {point:new t.P(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t);}getMatrixForModel(e,i){const r=t.$.fromLngLat(e,i),o=r.meterInMercatorCoordinateUnits(),a=t.b1();return t.L(a,a,[r.x,r.y,r.z]),t.a_(a,a,Math.PI),t.a$(a,a,Math.PI/2),t.M(a,a,[-o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=new t.Y(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),o=de(i,this.worldSize);t.N(o,this._viewProjMatrix,o),r.tileMercatorCoords=[0,0,1,1];const a=[t.Z,t.Z,this.worldSize/this._helper.pixelsPerMeter],s=t.b2();return t.M(s,o,a),r.fallbackMatrix=s,r.mainMatrix=s,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function kt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");}function Ft(e){if(e.useSlerp)if(e.k<1){const i=t.b3(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.b3(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),o=new Float64Array(4);t.b4(o,i,r,e.k);const a=t.b5(o);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing);}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.B.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.B.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.B.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k));}function Bt(e,i,r,o,a){const s=a.padding,n=ce(a.worldSize,r.getNorthWest()),l=ce(a.worldSize,r.getNorthEast()),c=ce(a.worldSize,r.getSouthEast()),h=ce(a.worldSize,r.getSouthWest()),u=t.ab(-o),d=n.rotate(u),_=l.rotate(u),p=c.rotate(u),m=h.rotate(u),f=new t.P(Math.max(d.x,_.x,m.x,p.x),Math.max(d.y,_.y,m.y,p.y)),g=new t.P(Math.min(d.x,_.x,m.x,p.x),Math.min(d.y,_.y,m.y,p.y)),v=f.sub(g),x=(a.width-(s.left+s.right+i.left+i.right))/v.x,b=(a.height-(s.top+s.bottom+i.top+i.bottom))/v.y;if(b<0||x<0)return void kt();const y=Math.min(t.ah(a.scale*Math.min(x,b)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ab(o)),P=w.add(T).mult(a.scale/t.ac(y));return {center:he(a.worldSize,n.add(c).div(2).sub(P)),zoom:y,bearing:o}}class Ot{get useGlobeControls(){return !1}handlePanInertia(e,t){return {easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta);}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around);}cameraForBoxAndBearing(e,t,i,r,o){return Bt(e,t,i,r,o)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.Q.convert(i.center));}handleEaseTo(e,i){const r=e.zoom,o=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},n=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=n?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:_,zoom:p}=e.getConstrained(t.Q.convert(i.center||d),null!=h?h:r);Et(e,_);const m=ce(e.worldSize,d),f=ce(e.worldSize,_).sub(m),g=t.ac(p-r);return c=p!==r,{easeFunc:n=>{if(c&&e.setZoom(t.B.number(r,p,n)),t.b6(a,s)||Ft({startEulerAngles:a,endEulerAngles:s,tr:e,k:n,useSlerp:a.roll!=s.roll}),l&&(e.interpolatePadding(o,i.padding,n),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else {const i=t.ac(e.zoom-r),o=p>r?Math.min(2,g):Math.max(.5,g),a=Math.pow(o,1-n),s=he(e.worldSize,m.add(f.mult(n*a)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,u);}},isZooming:c,elevationCenter:_}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.zoom,a=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),r?+i.zoom:o),s=a.center,n=a.zoom;Et(e,s);const l=ce(e.worldSize,i.locationAtOffset),c=ce(e.worldSize,s).sub(l),h=c.mag(),u=t.ac(n-o);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,o,n),a=e.getConstrained(s,r).zoom;d=t.ac(a-o);}return {easeFunc:(i,r,a,h)=>{e.setZoom(1===i?n:o+t.ah(r));const u=1===i?s:he(e.worldSize,l.add(c.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h);},scaleOfZoom:u,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:h}}}class jt{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i;}}jt.Replace=[1,0],jt.disabled=new jt(jt.Replace,t.b7.transparent,[!1,!1,!1,!1]),jt.unblended=new jt(jt.Replace,t.b7.transparent,[!0,!0,!0,!0]),jt.alphaBlended=new jt([1,771],t.b7.transparent,[!0,!0,!0,!0]);const Zt=2305;class Nt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Nt.disabled=new Nt(!1,1029,Zt),Nt.backCCW=new Nt(!0,1029,Zt),Nt.frontCCW=new Nt(!0,1028,Zt);class Ut{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Ut.ReadOnly=!1,Ut.ReadWrite=!0,Ut.disabled=new Ut(519,Ut.ReadOnly,[0,1]);const Gt=7680;class Vt{constructor(e,t,i,r,o,a){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=o,this.pass=a;}}Vt.disabled=new Vt({func:519,mask:0},0,0,Gt,Gt,Gt);const qt=new WeakMap;function Wt(e){var t;if(qt.has(e))return qt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return qt.set(e,i),i}}class Ht{get awaitingQuery(){return !!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const o=new t.aI;o.emplaceBack(-1,-1),o.emplaceBack(2,-1),o.emplaceBack(-1,2);const a=new t.aK;a.emplaceBack(0,1,2),this._fullscreenTriangle=new wt(i.createVertexBuffer(o,Tt.members),i.createIndexBuffer(a),t.aJ.simpleSegment(0,0,o.length,a.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Wt(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null));}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null;}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer);}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,o=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.b7.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,o.TRIANGLES,Ut.disabled,Vt.disabled,jt.unblended,Nt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Wt(o)){o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.readBuffer(o.COLOR_ATTACHMENT0),o.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const e=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);o.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e};}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null};}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Wt(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Ht._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount;}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const $t=t.Z/128;function Xt(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,o=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=o+1,n=a+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=r+(e.generateBorders?1:0),u=r+(e.generateBorders||e.extendToSouthPole?1:0),d=s*n,_=o*a*6,p=s*n>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,f=new Int16Array(2*d);let g=0;for(let i=c;i<=u;i++)for(let o=l;o<=h;o++){let a=o/r*t.Z;-1===o&&(a=-64),o===r+1&&(a=t.Z+$t);let s=i/r*t.Z;-1===i&&(s=e.extendToNorthPole?t.b9:-64),i===r+1&&(s=e.extendToSouthPole?t.ba:t.Z+$t),f[g++]=a,f[g++]=s;}const v=m?new Uint32Array(_):new Uint16Array(_);let x=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return "globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy();}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e);}getMeshFromTileID(e,t,i,r,o){return this.currentProjection.getMeshFromTileID(e,t,i,r,o)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator");}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e);}}function ei(e){const t=ri(e.worldSize,e.center.lat);return 2*Math.PI*t}function ti(e,i,r,o,a){const s=1/(1<1e-6){const o=e[0]/r,a=Math.acos(e[2]/r),s=(o>0?a:-a)/Math.PI*180;return new t.Q(t.aL(s,-180,180),i)}return new t.Q(0,i)}function ai(e){return Math.cos(e*Math.PI/180)}function si(e,i){const r=ai(e),o=ai(i);return t.ah(o/r)}function ni(e,i){const r=e.rotate(i.bearingInRadians),o=i.zoom+si(i.center.lat,0),a=t.bc(1/ai(i.center.lat),1/ai(Math.min(Math.abs(i.center.lat),60)),t.bf(o,7,3,0,1)),s=360/ei({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.Q(i.center.lng-r.x*s*a,t.ae(i.center.lat+r.y*s,-85.051129,t.af))}function li(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function ci(e,i,r,o){const a=e.lat+r*o;if(Math.abs(r)>1){const s=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,n=Math.abs(e.lat+r)*Math.PI/180,l=li(s+o*(n-s)),c=li(s),h=li(n);return new t.Q(e.lng+i*((l-c)/(h-c)),a)}return new t.Q(e.lng+i*o,a)}class hi{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._aabbFactory=e;}recalculateCache(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1;}getTileAABB(e,t,i,r){const o=`${e.z}_${e.x}_${e.y}`,a=this._cache.get(o);if(a)return a;const s=this._cachePrevious.get(o);if(s)return this._cache.set(o,s),s;const n=this._aabbFactory(e,t,i,r);return this._cache.set(o,n),this._hadAnyChanges=!0,n}}function ui(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function di(e,t,i,r,o){const a=e-i;let s;return s=a<0?Math.min(-a,1+a-o):a>1?Math.min(Math.max(a-o,0),1-a):0,Math.max(s,ui(t,r,o))}class _i{constructor(){this._aabbCache=new hi(this._computeTileAABB);}recalculateCache(){this._aabbCache.recalculateCache();}distanceToTile2d(e,t,i,r){const o=1<4}allowWorldCopies(){return !1}getTileAABB(e,t,i,r){return this._aabbCache.getTileAABB(e,t,i,r)}_computeTileAABB(e,i,r,o){if(e.z<=0)return new zt([-1,-1,-1],[1,1,1]);if(1===e.z)return new zt([0===e.x?-1:0,0===e.y?0:-1,-1],[0===e.x?0:1,0===e.y?1:0,1]);{const i=[ti(0,0,e.x,e.y,e.z),ti(t.Z,0,e.x,e.y,e.z),ti(t.Z,t.Z,e.x,e.y,e.z),ti(0,t.Z,e.x,e.y,e.z)],r=[1,1,1],o=[-1,-1,-1];for(const e of i)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);if(0===e.y||e.y===(1<{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new _i;}clone(){const e=new pi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e);}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bh();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return {mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,o=Math.sin(i)*r,a=Math.cos(i)*r+1,s=1/Math.sqrt(o*o+a*a)*1;let n=-o,l=a;const c=Math.sqrt(n*n+l*l);n/=c,l/=c;const h=[0,n,l];t.bl(h,h,[0,0,0],-this.bearingInRadians),t.bm(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bn(h,h,[0,0,0],this.center.lng*Math.PI/180);const u=1/t.bo(h);return t.aO(h,h,u),[...h,-s*u]}isLocationOccluded(e){return !this.isSurfacePointVisible(ii(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,o=Math.cos(r),a=[Math.sin(i)*o,Math.sin(r),Math.cos(i)*o],s=[a[2],0,-a[0]],n=[0,0,0];t.aU(n,s,a),t.aT(s,s),t.aT(n,n);const l=[0,0,0];return t.aT(l,[s[0]*e[0]+n[0]*e[1]+a[0]*e[2],s[1]*e[0]+n[1]*e[1]+a[1]*e[2],s[2]*e[0]+n[2]*e[1]+a[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const o=function(e,i,r){const o=1/(1<a&&(a=i),rn&&(n=r);}const h=[c.lng+s,c.lat+l,c.lng+a,c.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new V(h)}getConstrained(e,i){const r=t.ae(e.lat,-85.051129,t.af),o=t.ae(+i,this.minZoom+si(0,r),this.maxZoom);return {center:new t.Q(e.lng,r),zoom:o}}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=ii(this.unprojectScreenPoint(i)),o=ii(e),a=t.bh();t.br(a);const s=t.bh();t.bn(s,r,a,-this.center.lng*Math.PI/180),t.bm(s,s,a,this.center.lat*Math.PI/180);const n=o[0]*o[0]+o[2]*o[2],l=s[0]*s[0];if(n=-g&&p<=g,x=f>=-g&&f<=g;let b,y;if(v&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bv(u,e)+t.bv(p,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return !1;const i=t.bk();return t.at(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.aV(e,i),o=t.bh(),a=t.bh();t.aO(a,i,r),t.aS(o,e,a);const s=1-t.aV(o,o);if(s<0)return null;const n=t.aV(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(s),c=n/l,h=l;return {tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),o=this.rayPlanetIntersection(i,r);if(o){const e=t.bh();t.aP(e,i,[r[0]*o.tMin,r[1]*o.tMin,r[2]*o.tMin]);const a=t.bh();return t.aT(a,e),oi(a)}const a=this._cachedClippingPlane,s=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],n=-t.bt(a,i)/s,l=t.bh();if(n>0)t.aP(l,i,[r[0]*n,r[1]*n,r[2]*n]);else {const e=t.bh();t.aP(e,i,[2*r[0],2*r[1],2*r[2]]);const o=t.bt(this._cachedClippingPlane,e);t.aS(l,e,[this._cachedClippingPlane[0]*o,this._cachedClippingPlane[1]*o,this._cachedClippingPlane[2]*o]);}const c=function(e){const i=t.bh();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(a);return oi(function(e,i,r){const o=t.bh();t.aS(o,r,e);const a=t.bh();return t.bi(a,e,o,i/t.bj(o)),a}(c.center,c.radius,l))}getMatrixForModel(e,i){const r=t.Q.convert(e),o=1/t.bu,a=t.b1();return t.bp(a,a,r.lng/180*Math.PI),t.a$(a,a,-r.lat/180*Math.PI),t.L(a,a,[0,0,1+i/t.bu]),t.a$(a,a,.5*Math.PI),t.M(a,a,[o,o,o]),a}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.Y(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class mi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e);}setMaxZoom(e){this._helper.setMaxZoom(e);}setMinPitch(e){this._helper.setMinPitch(e);}setMaxPitch(e){this._helper.setMaxPitch(e);}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e);}setBearing(e){this._helper.setBearing(e);}setPitch(e){this._helper.setPitch(e);}setRoll(e){this._helper.setRoll(e);}setFov(e){this._helper.setFov(e);}setZoom(e){this._helper.setZoom(e);}setCenter(e){this._helper.setCenter(e);}setElevation(e){this._helper.setElevation(e);}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e);}setPadding(e){this._helper.setPadding(e);}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i);}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e);}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t);}clearNearFarZOverride(){this._helper.clearNearFarZOverride();}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().recalculateCache(),this._mercatorTransform.getCoveringTilesDetailsProvider().recalculateCache();}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Rt({calcMatrices:()=>{this._calcMatrices();},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Lt,this._verticalPerspectiveTransform=new pi;}clone(){const e=new mi;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians);}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return {mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bc(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bc(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const o=this._mercatorTransform.getPitchedTextCorrection(e,i,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.bc(o,a,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ);}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e);}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e);}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform);}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class fi{get useGlobeControls(){return !0}handlePanInertia(e,i){const r=ni(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,o=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const a=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-a;if(0===s)return;const n=t.bq(i.center.lng,o.lng),l=n/(Math.abs(n/180)+1),c=t.bq(i.center.lat,o.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*t.aV(u,h),_=t.bh();t.aP(_,u,[h[0]*d,h[1]*d,h[2]*d]);const p=t.bo(_)-1,m=Math.exp(.5*-Math.max(p-.3,0)),f=ri(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=t.bf(f,.9,.5,1,.25),v=(1-t.ac(-s))*Math.min(m,g),x=i.center.lat,b=i.zoom,y=new t.Q(i.center.lng+l*v,t.ae(i.center.lat+c*v,-85.051129,t.af));i.setLocationAtPoint(o,r);const w=i.center,T=t.bf(Math.abs(n),45,85,0,1),P=t.bf(f,.75,.35,0,1),C=Math.pow(Math.max(T,P),.25),M=t.bq(w.lng,y.lng),I=t.bq(w.lat,y.lat);i.setCenter(new t.Q(w.lng+M*C,w.lat+I*C).wrap()),i.setZoom(b+si(x,i.center.lat));}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,o=t.zoom;t.setCenter(ni(e.panDelta,t).wrap()),t.setZoom(o+si(r,t.center.lat));}cameraForBoxAndBearing(e,i,r,o,a){const s=Bt(e,i,r,o,a),n=i.left/a.width*2-1,l=(a.width-i.right)/a.width*2-1,c=i.top/a.height*-2+1,h=(a.height-i.bottom)/a.height*-2+1,u=t.bq(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),_=u?r.getWest():r.getEast(),p=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),f=d+.5*t.bq(d,_),g=p+.5*t.bq(p,m),v=a.clone();v.setCenter(s.center),v.setBearing(s.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(s.zoom);const x=v.modelViewProjectionMatrix,b=[ii(r.getNorthWest()),ii(r.getNorthEast()),ii(r.getSouthWest()),ii(r.getSouthEast()),ii(new t.Q(_,g)),ii(new t.Q(d,g)),ii(new t.Q(f,p)),ii(new t.Q(f,m))],y=ii(s.center);let w=Number.POSITIVE_INFINITY;for(const e of b)n<0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"x",n))),l>0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"x",l))),c>0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"y",c))),h<0&&(w=fi.getLesserNonNegativeNonNull(w,fi.solveVectorScale(e,y,x,"y",h)));if(Number.isFinite(w)&&0!==w)return s.zoom=v.zoom+t.ah(w),s;kt();}handleJumpToCenterZoom(e,i){const r=e.center.lat,o=e.getConstrained(i.center?t.Q.convert(i.center):e.center,e.zoom).center;e.setCenter(o.wrap());const a=void 0!==i.zoom?+i.zoom:e.zoom+si(r,o.lat);e.zoom!==a&&e.setZoom(a);}handleEaseTo(e,i){const r=e.zoom,o=e.center,a=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},n={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.Q.convert(i.center):o,d=e.getConstrained(u,r).center;Et(e,d);const _=e.clone();_.setCenter(d),_.setZoom(l?+i.zoom:r+si(o.lat,u.lat)),_.setBearing(i.bearing);const p=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));_.setLocationAtPoint(d,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,f=l?+i.zoom:r+si(o.lat,m.lat),g=r+si(o.lat,0),v=f+si(m.lat,0),x=t.bq(o.lng,m.lng),b=t.bq(o.lat,m.lat),y=t.ac(v-g);return h=f!==r,{easeFunc:r=>{if(t.b6(s,n)||Ft({startEulerAngles:s,endEulerAngles:n,tr:e,k:r,useSlerp:s.roll!=n.roll}),c&&e.interpolatePadding(a,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else {const t=v>g?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-r),a=ci(o,x,b,r*i);e.setCenter(a.wrap());}if(h){const i=t.B.number(g,v,r)+si(0,e.center.lat);e.setZoom(i);}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,o=e.center,a=e.zoom,s=e.padding,n=!e.isPaddingEqual(i.padding),l=e.getConstrained(t.Q.convert(i.center||i.locationAtOffset),a).center,c=r?+i.zoom:e.zoom+si(e.center.lat,l.lat),h=e.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new t.P(t.ae(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ae(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(l,u);const d=h.center;Et(e,d);const _=function(e,i,r){const o=ii(i),a=ii(r),s=t.aV(o,a),n=Math.acos(s),l=ei(e);return n/(2*Math.PI)*l}(e,o,d),p=a+si(o.lat,0),m=c+si(d.lat,0),f=t.ac(m-p);let g;if("number"==typeof i.minZoom){const r=+i.minZoom+si(d.lat,0),o=Math.min(r,p,m)+si(0,d.lat),a=e.getConstrained(d,o).zoom+si(d.lat,0);g=t.ac(a-p);}const v=t.bq(o.lng,d.lng),x=t.bq(o.lat,d.lat);return {easeFunc:(r,a,l,h)=>{const u=ci(o,v,x,l);n&&e.interpolatePadding(s,i.padding,r);const _=1===r?d:u;e.setCenter(_.wrap());const m=p+t.ah(a);e.setZoom(1===r?c:m+si(0,_.lat));},scaleOfZoom:f,targetCenter:d,scaleOfMinZoom:g,pixelPathLength:_}}static solveVectorScale(e,t,i,r,o){const a="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],n=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],h=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+o*l===n+o*h||s[3]*(n-c)+a[3]*(h-l)+n*h==c*l?null:(c+a[3]-o*h-o*s[3])/(c-n-o*h+o*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.x(e,i&&i.filter((e=>"source.canvas"!==e.identifier))),xi=t.bw();class bi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload();}},this.map=e,this.dispatcher=new B(F(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler("GI",((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this),this.glyphManager=new P(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new R(256,512),this.crossTileSymbolIndex=new vt,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bx,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",t.by()),oe().on(te,this._rtlPluginLoaded),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t);}}));}loadURL(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const o=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const a=this._loadStyleRequest;t.j(o,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,i,r);})).catch((e=>{this._loadStyleRequest=null,e&&!a.signal.aborted&&this.fire(new t.k(e));}));}loadJSON(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r);})).catch((()=>{}));}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(xi,{validate:!1});}_load(e,i,r){var o,a;const s=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!vi(this,t.y(s))){this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new I(this.stylesheet.light),this._setProjectionInternal((null===(o=this.stylesheet.projection)||void 0===o?void 0:o.type)||"mercator"),this.sky=new S(this.stylesheet.sky),this.map.setTerrain(null!==(a=this.stylesheet.terrain)&&void 0!==a?a:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"));}}_createLayers(){const e=t.bz(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.bA(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e;}}_loadSprite(e,i=!1,r=void 0){let o;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,r,o){return t._(this,void 0,void 0,(function*(){const a=f(e),n=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of a){const a=i.transformRequest(g(r,n,".json"),"SpriteJSON");l[e]=t.j(a,o);const s=i.transformRequest(g(r,n,".png"),"SpriteImage");c[e]=p.getImage(s,o);}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,(function*(){const t={};for(const r in e){t[r]={};const o=s.getImageCanvasContext((yield i[r]).data),a=(yield e[r]).data;for(const e in a){const{width:i,height:s,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m}=a[e];t[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:s,x:n,y:l,context:o}};}}return t}))}(l,c)}))}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[t]){const o="default"===t?r:`${t}:${r}`;this._spritesImagesIds[t].push(o),o in this.imageManager.images?this.imageManager.updateImage(o,e[t][r],!1):this.imageManager.addImage(o,e[t][r]),i&&(this._changedImages[o]=!0);}}})).catch((e=>{this._spriteRequest=null,o=e,this.fire(new t.k(o));})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),r&&r(o);}));}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const o=i.getSource();("geojson"===o.type||o.vectorLayerIds&&-1===o.vectorLayerIds.indexOf(r))&&this.fire(new t.k(new Error(`Source layer "${r}" does not exist on source "${o.id}" as specified by style layer "${e.id}".`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._updatedSources).length)return !1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return !1;return !!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bB(r):r);const o=[];for(const a of e)if(r[a]){const e=i?t.bB(r[a]):r[a];o.push(e);}return o}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize());}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return !0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return !0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return !0;for(const e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else {if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e);}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates();}const r={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0);}for(const e in r){const i=this.sourceCaches[e];!!r[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}));}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={};}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1;}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t});}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1;}setState(e,i={}){var r;this._checkLoaded();const o=this.serialize();if(e=i.transformStyle?i.transformStyle(o,e):e,(null===(r=i.validate)||void 0===r||r)&&vi(this,t.y(e)))return !1;(e=t.bB(e)).layers=t.bz(e.layers);const a=t.bC(o,e),s=this._getOperationsToPerform(a);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return !1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case "setCenter":case "setZoom":case "setBearing":case "setPitch":case "setRoll":continue;case "addLayer":t.push((()=>this.addLayer.apply(this,r.args)));break;case "removeLayer":t.push((()=>this.removeLayer.apply(this,r.args)));break;case "setPaintProperty":t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case "setLayoutProperty":t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case "setFilter":t.push((()=>this.setFilter.apply(this,r.args)));break;case "addSource":t.push((()=>this.addSource.apply(this,r.args)));break;case "removeSource":t.push((()=>this.removeSource.apply(this,r.args)));break;case "setLayerZoomRange":t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case "setLight":t.push((()=>this.setLight.apply(this,r.args)));break;case "setGeoJSONSourceData":t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case "setGlyphs":t.push((()=>this.setGlyphs.apply(this,r.args)));break;case "setSprite":t.push((()=>this.setSprite.apply(this,r.args)));break;case "setTerrain":t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case "setSky":t.push((()=>this.setSky.apply(this,r.args)));break;case "setProjection":this.setProjection.apply(this,r.args);break;case "setTransition":t.push((()=>{}));break;default:i.push(r.command);}return {operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e);}updateImage(e,t){this.imageManager.updateImage(e,t);}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e);}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.y.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=this.sourceCaches[e]=new be(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,(()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e}))),o.onAdd(this.map),this._changed=!0;}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0;}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0;}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.k(new Error(`Layer "${o}" already exists on this map.`)));let a;if("custom"===e.type){if(vi(this,t.bD(e)))return;a=t.bA(e);}else {if("source"in e&&"object"==typeof e.source&&(this.addSource(o,e.source),e=t.bB(e),e=t.e(e,{source:o})),this._validate(t.y.layer,`layers.${o}`,e,{arrayIndex:-1},r))return;a=t.bA(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:o}});}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));else {if(this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=a,this._removedLayers[o]&&a.source&&"custom"!==a.type){const e=this._removedLayers[o];delete this._removedLayers[o],e.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause());}this._updateLayer(a),a.onAdd&&a.onAdd(this.map);}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0);}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map);}getLayer(e){return this._layers[e]}getLayersOrder(){return [...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)));}setFilter(e,i,r={}){this._checkLoaded();const o=this.getLayer(e);if(o){if(!t.bE(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.y.filter,`layers.${o.id}.filter`,i,null,r)||(o.filter=t.bB(i),this._updateLayer(o)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)));}getFilter(e){return t.bB(this.getLayer(e).filter)}setLayoutProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bE(a.getLayoutProperty(i),r)||(a.setLayoutProperty(i,r,o),this._updateLayer(a)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)));}setPaintProperty(e,i,r,o={}){this._checkLoaded();const a=this.getLayer(e);a?t.bE(a.getPaintProperty(i),r)||(a.setPaintProperty(i,r,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)));}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,a=this.sourceCaches[r];if(void 0===a)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=a.getSource().type;"geojson"===s&&o?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||o?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),a.setFeatureState(o,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.sourceCaches[r];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.getSource().type,s="vector"===a?e.sourceLayer:void 0;"vector"!==a||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):o.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.sourceCaches[i];if(void 0!==o)return "vector"!==o.getSource().type||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.getFeatureState(r,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)));}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bF(this.sourceCaches,(e=>e.serialize())),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,o=this.stylesheet;return t.bG({version:o.version,name:o.name,metadata:o.metadata,light:o.light,sky:o.sky,center:o.center,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,sprite:o.sprite,glyphs:o.glyphs,transition:o.transition,projection:o.projection,sources:e,layers:i,terrain:r},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0;}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a)){i[a]=o;for(const t of e){const e=t[a];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let a=this._order.length-1;a>=0;a--){const s=this._order[a];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&a.push(function(e,t,i,r,o,a,s){const n={},l=a.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(N);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,o.filter,o.layers,o.availableImages,e);for(const e in r){const t=n[e]=n[e]||[],o=r[e];o.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of o)t.push(e);}}return function(e,t,i){for(const r in e)for(const o of e[r])U(o,i[t[r].source]);return e}(n,e,i)}(this._layers,s,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.y.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],o={};for(let e=0;ee.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);a=a||r;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((o=o||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),e.zoom))&&(this.pauseablePlacement=new _t(e,this.map.terrain,this._order,o,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.now()),n=!0),a&&this.pauseablePlacement.placement.setStale()),n||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles();}getImages(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e}))}getGlyphs(e,i){return t._(this,void 0,void 0,(function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.y.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e));}addSprite(e,i,r={},o){this._checkLoaded();const a=[{id:e,url:i}],s=[...f(this.stylesheet.sprite),...a];this._validate(t.y.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(a,!0,o));}removeSprite(e){this._checkLoaded();const i=f(this.stylesheet.sprite);if(i.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}));}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)));}getSprite(){return f(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.y.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)));}}var yi=t.aG([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class wi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null;}bind(e,t,i,r,o,a,s,n,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.b7.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(o):0,u_horizon_color:r?r.properties.get("horizon-color"):t.b7.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:a?1:0}),Pi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Ci(e){const t=[];for(let i=0;i({u_depth:new t.bH(e,i.u_depth),u_terrain:new t.bH(e,i.u_terrain),u_terrain_dim:new t.b8(e,i.u_terrain_dim),u_terrain_matrix:new t.bJ(e,i.u_terrain_matrix),u_terrain_unpack:new t.bK(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.b8(e,i.u_terrain_exaggeration)}))(e,C),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bJ(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bK(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bK(e,i.u_projection_clipping_plane),u_projection_transition:new t.b8(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bJ(e,i.u_projection_fallback_matrix)}))(e,C),this.binderUniforms=r?r.getUniforms(e,C):[];}draw(e,t,i,r,o,a,s,n,l,c,h,u,d,_,p,m,f,g,v){const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(o),e.setCullFace(a),n){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,n.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,n.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(n[e]);}if(l)for(const e in l)this.projectionUniforms[Pi[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,_,{zoom:p});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1;}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new wi)).bind(e,this,h,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,f,g,v),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2);}}}function Ii(e,i,r){const o=1/t.az(r,1,i.transform.tileZoom),a=Math.pow(2,r.tileID.overscaledZ),s=r.tileSize*Math.pow(2,i.transform.tileZoom)/a,n=s*(r.tileID.canonical.x+r.tileID.wrap*a),l=s*r.tileID.canonical.y;return {u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[o,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}const Ei=(e,i,r,o)=>{const a=e.style.light,s=a.properties.get("position"),n=[s.x,s.y,s.z],l=t.bN();"viewport"===a.properties.get("anchor")&&t.bO(l,e.transform.bearingInRadians),t.bP(n,n,l);const c=e.transform.transformLightDirection(n),h=a.properties.get("color");return {u_lightpos:n,u_lightpos_globe:c,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:o}},Si=(e,i,r,o,a,s,n)=>t.e(Ei(e,i,r,o),Ii(s,e,n),{u_height_factor:-Math.pow(2,a.overscaledZ)/n.tileSize/8}),Ri=(e,i,r,o)=>t.e(Ii(i,e,r),{u_fill_translate:o}),zi=(e,t)=>({u_world:e,u_fill_translate:t}),Di=(e,i,r,o,a)=>t.e(Ri(e,i,r,a),{u_world:o}),Ai=(e,i,r,o,a)=>{const s=e.transform;let n,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.az(i,1,s.zoom);n=!0,l=[e,e],c=e/(t.Z*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*a;}else n=!1,l=s.pixelsToGLUnits;return {u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:o}},Li=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),ki=e=>({u_viewport_size:[e.width,e.height]}),Fi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Bi=(e,i,r,o)=>{const a=t.az(e,1,i)/(t.Z*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*o;return {u_extrude_scale:t.az(e,1,i),u_intensity:r,u_globe_extrude_scale:a}},Oi=(e,i,r,o)=>{const a=t.K();t.bQ(a,0,e.width,e.height,0,0,1);const s=e.context.gl;return {u_matrix:a,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:r,u_color_ramp:o,u_opacity:i.paint.get("heatmap-opacity")}},ji=(e,t,i)=>{const r=i.paint.get("hillshade-accent-color");let o;switch(i.paint.get("hillshade-method")){case "basic":o=4;break;case "combined":o=1;break;case "igor":o=2;break;case "multidirectional":o=3;break;default:o=0;}const a=i.getIlluminationProperties();for(let t=0;t{const r=i.stride,o=t.K();return t.bQ(o,0,t.Z,-8192,0,0,1),t.L(o,o,[0,-8192,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Ni(e,i){const r=Math.pow(2,i.canonical.z),o=i.canonical.y;return [new t.$(0,o/r).toLngLat().lat,new t.$(0,(o+1)/r).toLngLat().lat]}const Ui=(e,i,r,o)=>{const a=e.transform;return {u_translation:Hi(e,i,r),u_ratio:o/t.az(i,1,a.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Gi=(e,i,r,o,a)=>t.e(Ui(e,i,r,o),{u_image:0,u_image_height:a}),Vi=(e,i,r,o,a)=>{const s=e.transform,n=Wi(i,s);return {u_translation:Hi(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:o/t.az(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[n,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},qi=(e,i,r,o,a,s)=>{const n=e.lineAtlas,l=Wi(i,e.transform),c="round"===r.layout.get("line-cap"),h=n.getDash(a.from,c),u=n.getDash(a.to,c),d=h.width*s.fromScale,_=u.width*s.toScale;return t.e(Ui(e,i,r,o),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/_,-u.height/2],u_sdfgamma:n.width/(256*Math.min(d,_)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:s.t})};function Wi(e,i){return 1/t.az(e,1,i.tileZoom)}function Hi(e,i,r){return t.aA(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const $i=(e,t,i,r,o)=>{return {u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=r.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Xi(r.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]};var a,s;};function Xi(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Ki=(e,t,i,r,o,a,s,n,l,c,h,u,d)=>{const _=s.transform;return {u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_pitch:_.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:_.width/_.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:o,u_is_variable_anchor:a,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},Qi=(e,i,r,o,a,s,n,l,c,h,u,d,_,p)=>{const m=n.transform;return t.e(Ki(e,i,r,o,a,s,n,l,c,h,u,d,p),{u_gamma_scale:o?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:n.pixelRatio,u_is_halo:1})},Yi=(e,i,r,o,a,s,n,l,c,h,u,d,_)=>t.e(Qi(e,i,r,o,a,s,n,l,c,h,!0,u,0,_),{u_texsize_icon:d,u_texture_icon:1}),Ji=(e,t)=>({u_opacity:e,u_color:t}),er=(e,i,r,o,a)=>t.e(function(e,i,r,o){const a=r.imageManager.getPattern(e.from.toString()),s=r.imageManager.getPattern(e.to.toString()),{width:n,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,o.tileID.overscaledZ),h=o.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(o.tileID.canonical.x+o.tileID.wrap*c),d=h*o.tileID.canonical.y;return {u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.az(o,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,a,i,o),{u_opacity:e}),tr=(e,t)=>{},ir={fillExtrusion:(e,i)=>({u_lightpos:new t.bL(e,i.u_lightpos),u_lightpos_globe:new t.bL(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bL(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bL(e,i.u_lightpos),u_lightpos_globe:new t.bL(e,i.u_lightpos_globe),u_lightintensity:new t.b8(e,i.u_lightintensity),u_lightcolor:new t.bL(e,i.u_lightcolor),u_vertical_gradient:new t.b8(e,i.u_vertical_gradient),u_height_factor:new t.b8(e,i.u_height_factor),u_opacity:new t.b8(e,i.u_opacity),u_fill_translate:new t.bM(e,i.u_fill_translate),u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bM(e,i.u_world),u_fill_translate:new t.bM(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bM(e,i.u_world),u_image:new t.bH(e,i.u_image),u_texsize:new t.bM(e,i.u_texsize),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade),u_fill_translate:new t.bM(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bH(e,i.u_scale_with_map),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_extrude_scale:new t.bM(e,i.u_extrude_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale),u_translate:new t.bM(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bM(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bM(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bI(e,i.u_color),u_overlay:new t.bH(e,i.u_overlay),u_overlay_scale:new t.b8(e,i.u_overlay_scale)}),depth:tr,clippingMask:tr,heatmap:(e,i)=>({u_extrude_scale:new t.b8(e,i.u_extrude_scale),u_intensity:new t.b8(e,i.u_intensity),u_globe_extrude_scale:new t.b8(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bJ(e,i.u_matrix),u_world:new t.bM(e,i.u_world),u_image:new t.bH(e,i.u_image),u_color_ramp:new t.bH(e,i.u_color_ramp),u_opacity:new t.b8(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bH(e,i.u_image),u_latrange:new t.bM(e,i.u_latrange),u_exaggeration:new t.b8(e,i.u_exaggeration),u_altitudes:new t.bS(e,i.u_altitudes),u_azimuths:new t.bS(e,i.u_azimuths),u_accent:new t.bI(e,i.u_accent),u_method:new t.bH(e,i.u_method),u_shadows:new t.bR(e,i.u_shadows),u_highlights:new t.bR(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bJ(e,i.u_matrix),u_image:new t.bH(e,i.u_image),u_dimension:new t.bM(e,i.u_dimension),u_zoom:new t.b8(e,i.u_zoom),u_unpack:new t.bK(e,i.u_unpack)}),line:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_image:new t.bH(e,i.u_image),u_image_height:new t.b8(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_texsize:new t.bM(e,i.u_texsize),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_image:new t.bH(e,i.u_image),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_scale:new t.bL(e,i.u_scale),u_fade:new t.b8(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bM(e,i.u_translation),u_ratio:new t.b8(e,i.u_ratio),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bM(e,i.u_units_to_pixels),u_patternscale_a:new t.bM(e,i.u_patternscale_a),u_patternscale_b:new t.bM(e,i.u_patternscale_b),u_sdfgamma:new t.b8(e,i.u_sdfgamma),u_image:new t.bH(e,i.u_image),u_tex_y_a:new t.b8(e,i.u_tex_y_a),u_tex_y_b:new t.b8(e,i.u_tex_y_b),u_mix:new t.b8(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bM(e,i.u_tl_parent),u_scale_parent:new t.b8(e,i.u_scale_parent),u_buffer_scale:new t.b8(e,i.u_buffer_scale),u_fade_t:new t.b8(e,i.u_fade_t),u_opacity:new t.b8(e,i.u_opacity),u_image0:new t.bH(e,i.u_image0),u_image1:new t.bH(e,i.u_image1),u_brightness_low:new t.b8(e,i.u_brightness_low),u_brightness_high:new t.b8(e,i.u_brightness_high),u_saturation_factor:new t.b8(e,i.u_saturation_factor),u_contrast_factor:new t.b8(e,i.u_contrast_factor),u_spin_weights:new t.bL(e,i.u_spin_weights),u_coords_top:new t.bK(e,i.u_coords_top),u_coords_bottom:new t.bK(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texture:new t.bH(e,i.u_texture),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texture:new t.bH(e,i.u_texture),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bH(e,i.u_is_halo),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bH(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bH(e,i.u_is_size_feature_constant),u_size_t:new t.b8(e,i.u_size_t),u_size:new t.b8(e,i.u_size),u_camera_to_center_distance:new t.b8(e,i.u_camera_to_center_distance),u_pitch:new t.b8(e,i.u_pitch),u_rotate_symbol:new t.bH(e,i.u_rotate_symbol),u_aspect_ratio:new t.b8(e,i.u_aspect_ratio),u_fade_change:new t.b8(e,i.u_fade_change),u_label_plane_matrix:new t.bJ(e,i.u_label_plane_matrix),u_coord_matrix:new t.bJ(e,i.u_coord_matrix),u_is_text:new t.bH(e,i.u_is_text),u_pitch_with_map:new t.bH(e,i.u_pitch_with_map),u_is_along_line:new t.bH(e,i.u_is_along_line),u_is_variable_anchor:new t.bH(e,i.u_is_variable_anchor),u_texsize:new t.bM(e,i.u_texsize),u_texsize_icon:new t.bM(e,i.u_texsize_icon),u_texture:new t.bH(e,i.u_texture),u_texture_icon:new t.bH(e,i.u_texture_icon),u_gamma_scale:new t.b8(e,i.u_gamma_scale),u_device_pixel_ratio:new t.b8(e,i.u_device_pixel_ratio),u_is_halo:new t.bH(e,i.u_is_halo),u_translation:new t.bM(e,i.u_translation),u_pitched_scale:new t.b8(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_color:new t.bI(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.b8(e,i.u_opacity),u_image:new t.bH(e,i.u_image),u_pattern_tl_a:new t.bM(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bM(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bM(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bM(e,i.u_pattern_br_b),u_texsize:new t.bM(e,i.u_texsize),u_mix:new t.b8(e,i.u_mix),u_pattern_size_a:new t.bM(e,i.u_pattern_size_a),u_pattern_size_b:new t.bM(e,i.u_pattern_size_b),u_scale_a:new t.b8(e,i.u_scale_a),u_scale_b:new t.b8(e,i.u_scale_b),u_pixel_coord_upper:new t.bM(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bM(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.b8(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bH(e,i.u_texture),u_ele_delta:new t.b8(e,i.u_ele_delta),u_fog_matrix:new t.bJ(e,i.u_fog_matrix),u_fog_color:new t.bI(e,i.u_fog_color),u_fog_ground_blend:new t.b8(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.b8(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bI(e,i.u_horizon_color),u_horizon_fog_blend:new t.b8(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.b8(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.b8(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bH(e,i.u_texture),u_terrain_coords_id:new t.b8(e,i.u_terrain_coords_id),u_ele_delta:new t.b8(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.b8(e,i.u_input),u_output_expected:new t.b8(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bL(e,i.u_sun_pos),u_atmosphere_blend:new t.b8(e,i.u_atmosphere_blend),u_globe_position:new t.bL(e,i.u_globe_position),u_globe_radius:new t.b8(e,i.u_globe_radius),u_inv_proj_matrix:new t.bJ(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bI(e,i.u_sky_color),u_horizon_color:new t.bI(e,i.u_horizon_color),u_horizon:new t.bM(e,i.u_horizon),u_horizon_normal:new t.bM(e,i.u_horizon_normal),u_sky_horizon_blend:new t.b8(e,i.u_sky_horizon_blend),u_sky_blend:new t.b8(e,i.u_sky_blend)})};class rr{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}const or={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ar{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const o=e.gl;this.buffer=o.createBuffer(),e.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer;}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i0&&(h.push({circleArray:f,circleOffset:d,coord:_}),u+=f.length/4,d=u),m&&c.draw(s,l.LINES,Ut.disabled,Vt.disabled,e.colorModeForRenderPass(),Nt.disabled,Li(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(_),n.getProjectionData({overscaledTileID:_,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer);}if(!a||!h.length)return;const _=e.useProgram("collisionCircle"),p=new t.bT;p.resize(4*u),p._trim();let m=0;for(const e of h)for(let t=0;t=0&&(f[g.associatedIconIndex]={shiftedAnchor:E,angle:S});}else qe(g.numGlyphs,p);}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");De(c,e,a,O,j,v,h,i,l.toUnwrapped(),f.width,f.height,N,t);}const q=a&&P||V,W=x||q?Hr:v?O:e.transform.clipSpaceToPixelsMatrix,H=p&&0!==r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let $;$=p?c.iconsInText?Yi(T.kind,S,b,v,x,q,e,W,Z,N,z,k,M):Qi(T.kind,S,b,v,x,q,e,W,Z,N,a,z,0,M):Ki(T.kind,S,b,v,x,q,e,W,Z,N,a,z,M);const X={program:E,buffers:u,uniformValues:$,projectionData:U,atlasTexture:D,atlasTextureIcon:F,atlasInterpolation:A,atlasInterpolationIcon:L,isSDF:p,hasHalo:H};if(y&&c.canOverlap){w=!0;const e=u.segments.get();for(const i of e)C.push({segments:new t.aJ([i]),sortKey:i.sortKey,state:X,terrainData:R});}else C.push({segments:u.segments,sortKey:0,state:X,terrainData:R});}w&&C.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of C){const i=t.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,Jr(i.buffers,t.segments,r,e,i.program,T,u,d,o,i.projectionData,t.terrainData)),o.u_is_halo=0;}Jr(i.buffers,t.segments,r,e,i.program,T,u,d,i.uniformValues,i.projectionData,t.terrainData);}}function Jr(e,t,i,r,o,a,s,n,l,c,h){const u=r.context;o.draw(u,u.gl.TRIANGLES,a,s,n,Nt.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer);}function eo(e,i,r,o,a){const s=e.context,n=s.gl,l=Vt.disabled,c=new jt([n.ONE,n.ONE],t.b7.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=o.key;let d=r.heatmapFbos.get(u);d||(d=io(s,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.b7.transparent});const _=h.programConfigurations.get(r.id),p=e.useProgram("heatmap",_,!a),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),f=e.style.map.terrain.getTerrainData(o);p.draw(s,n.TRIANGLES,Ut.disabled,l,c,Nt.disabled,Bi(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),f,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,_);}function to(e,t,i,r,o){const a=e.context,s=a.gl,n=e.transform;a.setColorMode(e.colorModeForRenderPass());const l=ro(a,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),a.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const u=n.getProjectionData({overscaledTileID:i,applyTerrainMatrix:o,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(a,s.TRIANGLES,Ut.disabled,Vt.disabled,e.colorModeForRenderPass(),Nt.disabled,Oi(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,n.zoom),h.destroy(),t.heatmapFbos.delete(c);}function io(e,t,i){var r,o;const a=e.gl,s=a.createTexture();a.bindTexture(a.TEXTURE_2D,s),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);const n=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:a.UNSIGNED_BYTE,l=null!==(o=e.RGBA16F)&&void 0!==o?o:a.RGBA;a.texImage2D(a.TEXTURE_2D,0,l,t,i,0,a.RGBA,n,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function ro(e,t){return t.colorRampTexture||(t.colorRampTexture=new v(e,t.colorRamp,e.gl.RGBA)),t.colorRampTexture}function oo(e,t,i,r,o){if(!i||!r||!r.imageAtlas)return;const a=r.imageAtlas.patternPositions;let s=a[i.to.toString()],n=a[i.from.toString()];if(!s&&n&&(s=n),!n&&s&&(n=s),!s||!n){const e=o.getPaintProperty(t);s=a[e],n=a[e];}s&&n&&e.setConstantPatternPositions(s,n);}function ao(e,i,r,o,a,s,n,l){const c=e.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),_=r.getCrossfadeParameters();let p,m,f,g,v;const x=e.transform,b=r.paint.get("fill-translate"),y=r.paint.get("fill-translate-anchor");n?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=c.LINES):(m=d?"fillPattern":"fill",p=c.TRIANGLES);const w=u.constantOr(null);for(const u of o){const o=i.getTile(u);if(d&&!o.patternsLoaded())continue;const T=o.getBucket(r);if(!T)continue;const P=T.programConfigurations.get(r.id),C=e.useProgram(m,P),M=e.style.map.terrain&&e.style.map.terrain.getTerrainData(u);d&&(e.context.activeTexture.set(c.TEXTURE0),o.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),P.updatePaintBuffers(_)),oo(P,h,w,o,r);const I=x.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),E=t.aA(x,o,b,y);if(n){g=T.indexBuffer2,v=T.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];f="fillOutlinePattern"===m&&d?Di(e,_,o,t,E):zi(t,E);}else g=T.indexBuffer,v=T.segments,f=d?Ri(e,_,o,E):{u_fill_translate:E};const S=e.stencilModeForClipping(u);C.draw(e.context,p,a,S,s,Nt.backCCW,f,M,I,r.id,T.layoutVertexBuffer,g,v,r.paint,e.transform.zoom,P);}}function so(e,i,r,o,a,s,n,l){const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),_=d.constantOr(1),p=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),f=d.constantOr(null),g=e.transform;for(const d of o){const o=i.getTile(d),v=o.getBucket(r);if(!v)continue;const x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),b=v.programConfigurations.get(r.id),y=e.useProgram(_?"fillExtrusionPattern":"fillExtrusion",b);_&&(e.context.activeTexture.set(h.TEXTURE0),o.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers(p));const w=g.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});oo(b,u,f,o,r);const T=t.aA(g,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),P=r.paint.get("fill-extrusion-vertical-gradient"),C=_?Si(e,P,m,T,d,p,o):Ei(e,P,m,T);y.draw(c,c.gl.TRIANGLES,a,s,n,Nt.backCCW,C,x,w,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer);}}function no(e,t,i,r,o,a,s,n,l){var c;const h=e.style.projection,u=e.context,d=e.transform,_=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,p),f=!e.options.moving;for(const p of r){const r=t.getTile(p),g=r.fbo;if(!g)continue;const v=h.getMeshFromTileID(u,p.canonical,n,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(p);u.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,g.colorAttachment.get());const b=d.getProjectionData({overscaledTileID:p,aligned:f,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(u,_.TRIANGLES,a,o[p.overscaledZ],s,Nt.backCCW,ji(e,r,i),x,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments);}}const lo=[new t.P(0,0),new t.P(t.Z,0),new t.P(t.Z,t.Z),new t.P(0,t.Z)];function co(e,t,i,r,o,a,s,n,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=e.context,d=u.gl,_=e.useProgram("raster"),p=e.transform,m=e.style.projection,f=e.colorModeForRenderPass(),g=!e.options.moving;for(const v of r){const r=e.getDepthModeForSublayer(v.overscaledZ-h,1===i.paint.get("raster-opacity")?Ut.ReadWrite:Ut.ReadOnly,d.LESS),x=t.getTile(v);x.registerFadeDuration(i.paint.get("raster-fade-duration"));const b=t.findLoadedParent(v,0),y=t.findLoadedSibling(v),w=ho(x,b||y||null,t,i,e.transform,e.style.map.terrain);let T,P;const C="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;u.activeTexture.set(d.TEXTURE0),x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1),b?(b.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T=Math.pow(2,b.tileID.overscaledZ-x.tileID.overscaledZ),P=[x.tileID.canonical.x*T%1,x.tileID.canonical.y*T%1]):x.texture.bind(C,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&u.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const M=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),I=p.getProjectionData({overscaledTileID:v,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),E=$i(P||[0,0],T||1,w,i,n),S=m.getMeshFromTileID(u,v.canonical,a,s,"raster");_.draw(u,d.TRIANGLES,r,o?o[v.overscaledZ]:Vt.disabled,f,l?Nt.frontCCW:Nt.backCCW,E,M,I,i.id,S.vertexBuffer,S.indexBuffer,S.segments);}}function ho(e,i,r,o,a,n){const l=o.paint.get("raster-fade-duration");if(!n&&l>0){const o=s.now(),n=(o-e.timeAdded)/l,c=i?(o-i.timeAdded)/l:-1,h=r.getSource(),u=ve(a,{tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),_=d&&e.refreshedUponExpiration?1:t.ae(d?n:1-c,0,1);return e.refreshedUponExpiration&&n>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-_}:{opacity:_,mix:0}}return {opacity:1,mix:0}}const uo=new t.b7(1,0,0,1),_o=new t.b7(0,1,0,1),po=new t.b7(0,0,1,1),mo=new t.b7(1,0,1,1),fo=new t.b7(0,1,1,1);function go(e,t,i,r){xo(e,0,t+i/2,e.transform.width,i,r);}function vo(e,t,i,r){xo(e,t-i/2,0,i,e.transform.height,r);}function xo(e,t,i,r,o,a){const s=e.context,n=s.gl;n.enable(n.SCISSOR_TEST),n.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,o*e.pixelRatio),s.clear({color:a}),n.disable(n.SCISSOR_TEST);}function bo(e,i,r){const o=e.context,a=o.gl,s=e.useProgram("debug"),n=Ut.disabled,l=Vt.disabled,c=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);o.activeTexture.set(a.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,_=Math.floor((d&&d.byteLength||0)/1024),p=i.getTile(r).tileSize,m=512/Math.min(p,512)*(r.overscaledZ/e.transform.zoom)*.5;let f=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(f+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,o=e.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(t,5,5),o.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,`${f} ${_}kB`);const g=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(o,a.TRIANGLES,n,l,jt.alphaBlended,Nt.disabled,Fi(t.b7.transparent,m),null,g,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(o,a.LINE_STRIP,n,l,c,Nt.disabled,Fi(t.b7.red),u,g,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments);}function yo(e,t,i,r){const{isRenderingGlobe:o}=r,a=e.context,s=a.gl,n=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),u=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.texture);const _=t.getMeshFrameDelta(n.zoom),p=n.calculateFogMatrix(r.tileID.toUnwrapped()),m=Ti(_,p,e.style.sky,n.pitch,o),f=n.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(a,s.TRIANGLES,c,Vt.disabled,l,Nt.backCCW,m,d,f,"terrain",i.vertexBuffer,i.indexBuffer,i.segments);}}function wo(e,i){if(!i.mesh){const r=new t.aI;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const o=new t.aK;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),i.mesh=new wt(e.createVertexBuffer(r,Tt.members),e.createIndexBuffer(o),t.aJ.simpleSegment(0,0,r.length,o.length));}return i.mesh}class To{constructor(e,i){this.context=new Vr(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ad(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=be.maxUnderzooming+be.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new vt;}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize();}setup(){const e=this.context,i=new t.aI;i.emplaceBack(0,0),i.emplaceBack(t.Z,0),i.emplaceBack(0,t.Z),i.emplaceBack(t.Z,t.Z),this.tileExtentBuffer=e.createVertexBuffer(i,Tt.members),this.tileExtentSegments=t.aJ.simpleSegment(0,0,4,2);const r=new t.aI;r.emplaceBack(0,0),r.emplaceBack(t.Z,0),r.emplaceBack(0,t.Z),r.emplaceBack(t.Z,t.Z),this.debugBuffer=e.createVertexBuffer(r,Tt.members),this.debugSegments=t.aJ.simpleSegment(0,0,4,5);const o=new t.b_;o.emplaceBack(0,0,0,0),o.emplaceBack(t.Z,0,t.Z,0),o.emplaceBack(0,t.Z,0,t.Z),o.emplaceBack(t.Z,t.Z,t.Z,t.Z),this.rasterBoundsBuffer=e.createVertexBuffer(o,yi.members),this.rasterBoundsSegments=t.aJ.simpleSegment(0,0,4,2);const a=new t.aI;a.emplaceBack(0,0),a.emplaceBack(t.Z,0),a.emplaceBack(0,t.Z),a.emplaceBack(t.Z,t.Z),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,Tt.members),this.rasterBoundsSegmentsPosOnly=t.aJ.simpleSegment(0,0,4,5);const s=new t.aI;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Tt.members),this.viewportSegments=t.aJ.simpleSegment(0,0,4,2);const n=new t.b$;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(n);const l=new t.aK;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Vt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new wt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.K();t.bQ(r,0,this.width,this.height,0,0,1),t.M(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const o={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,Ut.disabled,this.stencilClearMode,jt.disabled,Nt.disabled,null,null,o,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(jt.disabled),r.setDepthMode(Ut.disabled);const o={};for(const e of t)o[e.key]=this.nextStencilID++;this._renderTileMasks(o,t,i,!0),this._renderTileMasks(o,t,i,!1),this._tileClippingMaskIDs=o;}_renderTileMasks(e,t,i,r){const o=this.context,a=o.gl,s=this.style.projection,n=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=s.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=n.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(o,a.TRIANGLES,Ut.disabled,new Vt({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),jt.disabled,i?Nt.disabled:Nt.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments);}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,o=this.useProgram("depth"),a=this.getDepthModeFor3D(),s=xe(r,{tileSize:r.tileSize});for(const n of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(n),l=i.getMeshFromTileID(this.context,n.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(e,t.TRIANGLES,a,Vt.disabled,jt.disabled,Nt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Vt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Vt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,o=i[0].overscaledZ-r+1;if(this.clearStencil(),o>1){const e={},a={};for(let i=0;i0};for(const e in n){const t=n[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse();}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.b7.black:t.b7.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,o=((e,t,i)=>{const r=Math.cos(t.rollInRadians),o=Math.sin(t.rollInRadians),a=ue(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return {u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-a*o)*i,(t.height/2+a*r)*i],u_horizon_normal:[-o,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),a=new Ut(r.LEQUAL,Ut.ReadWrite,[0,1]),s=Vt.disabled,n=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=wo(i,t);l.draw(i,r.TRIANGLES,a,s,n,Nt.disabled,o,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments);}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[a[this.currentLayer]],t=n[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,u);}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:o}))(c,u,[p[0],p[1],p[2]],d,_),f=wo(o,i);s.draw(o,a.TRIANGLES,n,Vt.disabled,jt.alphaBlended,Nt.disabled,m,null,null,"atmosphere",f.vertexBuffer,f.indexBuffer,f.segments);}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap((i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[])),o=r.filter((e=>"vector"===e.getSource().type)),a=r.filter((e=>"vector"!==e.getSource().type)),s=e=>{(!i||i.getSource().maxzooms(e))),i||a.forEach((e=>s(e))),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;ru.getElevation(a,e,t):null;Kr(s,d,_,c,h,f,i,p,g,t.aA(h,e,n,l),a.toUnwrapped(),r);}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),a),0!==r.paint.get("icon-opacity").constantOr(1)&&Yr(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,n),0!==r.paint.get("text-opacity").constantOr(1)&&Yr(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,n),i.map.showCollisionBoxes&&(Wr(e,i,r,o,!0),Wr(e,i,r,o,!1));}(e,i,r,o,this.style.placement.variableOffsets,a):t.c4(r)?function(e,i,r,o,a){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=a,n=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===n.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,_=e.transform,p=e.getDepthModeForSublayer(0,Ut.ReadOnly),m=Vt.disabled,f=e.colorModeForRenderPass(),g=[],v=_.getCircleRadiusCorrection();for(let a=0;ae.sortKey-t.sortKey));for(const t of g){const{programConfiguration:i,program:o,layoutVertexBuffer:a,indexBuffer:s,uniformValues:n,terrainData:l,projectionData:c}=t.state;o.draw(u,d.TRIANGLES,p,m,f,Nt.backCCW,n,l,c,r.id,a,s,t.segments,r.paint,e.transform.zoom,i);}}(e,i,r,o,a):t.c5(r)?function(e,i,r,o,a){if(0===r.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:n,isRenderingGlobe:l}=a;if(e.style.map.terrain){for(const t of o){const o=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?eo(e,o,r,t,l):"translucent"===e.renderPass&&to(e,r,t,n,l));}s.viewport.set([0,0,e.width,e.height]);}else "offscreen"===e.renderPass?function(e,i,r,o){const a=e.context,s=a.gl,n=e.transform,l=Vt.disabled,c=new jt([s.ONE,s.ONE],t.b7.transparent,[!0,!0,!0,!0]);((function(e,i,r){const o=e.gl;e.activeTexture.set(o.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let a=r.heatmapFbos.get(t.bW);a?(o.bindTexture(o.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=io(e,i.width/4,i.height/4),r.heatmapFbos.set(t.bW,a));}))(a,e,r),a.clear({color:t.b7.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return !1;if(!e.from||!e.to)return !0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return !t||!i}useProgram(e,t,i=!1,r=[]){this.cache=this.cache||{};const o=!!this.style.map.terrain,a=this.style.projection,s=i?bt.projectionMercator:a.shaderPreludeCode,n=i?Pt:a.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Ct:a.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(o?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||(this.cache[l]=new Mi(this.context,bt[e],t,ir[e],this._showOverdrawInspector,o,s,n,r)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new v(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy();}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Po(e,t){let i,r=!1,o=null,a=null;const s=()=>{o=null,r&&(e.apply(a,i),o=setTimeout(s,t),r=!1);};return (...e)=>(r=!0,a=this,i=e,o||s(),o)}class Co{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return !1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e);},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let o=window.location.href.replace(/(#.+)?$/,r);o=o.replace("&&","&"),window.history.replaceState(window.history.state,null,o);},this._updateHash=Po(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e);}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),a=Math.round(t.lng*o)/o,s=Math.round(t.lat*o)/o,n=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${a}/${s}/${i}`:`${i}/${s}/${a}`,(n||l)&&(c+="/"+Math.round(10*n)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i})).filter((e=>e));return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return `#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return !1;try{new t.Q(+e[2],+e[1]);}catch(e){return !1}const i=+e[0],r=+(e[3]||0),o=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&o>=this._map.getMinPitch()&&o<=this._map.getMaxPitch()}}const Mo={linearity:.3,easing:t.cd(0,0,.3,1)},Io=t.e({deceleration:2500,maxSpeed:1400},Mo),Eo=t.e({deceleration:20,maxSpeed:1400},Mo),So=t.e({deceleration:1e3,maxSpeed:360},Mo),Ro=t.e({deceleration:1e3,maxSpeed:90},Mo),zo=t.e({deceleration:1e3,maxSpeed:360},Mo);class Do{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=s.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const a=Lo(i.pan.mag(),r,t.e({},Io,e||{})),s=i.pan.mult(a.amount/i.pan.mag()),n=this._map.cameraHelper.handlePanInertia(s,this._map.transform);o.center=n.easingCenter,o.offset=n.easingOffset,Ao(o,a);}if(i.zoom){const e=Lo(i.zoom,r,Eo);o.zoom=this._map.transform.zoom+e.amount,Ao(o,e);}if(i.bearing){const e=Lo(i.bearing,r,So);o.bearing=this._map.transform.bearing+t.ae(e.amount,-179,179),Ao(o,e);}if(i.pitch){const e=Lo(i.pitch,r,Ro);o.pitch=this._map.transform.pitch+e.amount,Ao(o,e);}if(i.roll){const e=Lo(i.roll,r,zo);o.roll=this._map.transform.roll+t.ae(e.amount,-179,179),Ao(o,e);}if(o.zoom||o.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;o.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),t.e(o,{noMoveStart:!0})}}function Ao(e,t){(!e.duration||e.durationi.unproject(e))),l=a.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1;}}class Bo extends t.l{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class Oo{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){delete this._mousedownPos;}wheel(e){return this._firePreventable(new Bo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ko(e.type,this._map,e))}mouseup(e){this._map.fire(new ko(e.type,this._map,e));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ko(e.type,this._map,e));}dblclick(e){return this._firePreventable(new ko(e.type,this._map,e))}mouseover(e){this._map.fire(new ko(e.type,this._map,e));}mouseout(e){this._map.fire(new ko(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Fo(e.type,this._map,e))}touchmove(e){this._map.fire(new Fo(e.type,this._map,e));}touchend(e){this._map.fire(new Fo(e.type,this._map,e));}touchcancel(e){this._map.fire(new Fo(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class jo{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent;}mousemove(e){this._map.fire(new ko(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ko("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ko(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Zo{constructor(e){this._map=e;}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return {lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class No{constructor(e,t){this._map=e,this._tr=new Zo(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(n.disableDrag(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(r,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e);}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(n.remove(this._box),this._box=null),n.enableDrag(),delete this._startPos,delete this._lastPos;}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function Uo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=Uo(r,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=Uo(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Vo{constructor(e){this.singleTap=new Go(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class qo{constructor(e){this._tr=new Zo(e),this._zoomIn=new Vo({numTouches:1,numTaps:2}),this._zoomOut=new Vo({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),o=this._zoomOut.touchend(e,t,i),a=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(r)},{originalEvent:e})}):o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(o)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Wo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset();}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e);}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0));}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return !this._moved&&r.dist(i)!0}),t=new Xo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t;}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)));}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)));}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}const Qo=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault();};};class Yo{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset();}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0);}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e);}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const o=Uo(r,i),a=new t.P(0,0),s=new t.P(0,0);let n=0;for(const e in o){const t=o[e],i=this._touches[e];i&&(a._add(t),s._add(t.sub(i)),n++,o[e]=t);}if(this._touches=o,this._shouldBePrevented(n)||!s.mag())return;const l=s.div(n);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class sa extends Jo{constructor(e){super(),this._currentTouchCount=0,this._map=e;}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints;}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length;}_start(e){this._lastPoints=e,aa(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),o=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,o,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+o.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,o=t.mag()>=2;if(!r&&!o)return;if(!r||!o)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const a=e.y>0==t.y>0;return aa(e)&&aa(t)&&a}}const na={panStep:100,bearingStep:15,pitchStep:10};class la{constructor(e){this._tr=new Zo(e);const t=na;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1;}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,o=0,a=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),o=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),o=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const n=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:ca,zoom:t?Math.round(n.zoom)+t*(e.shiftKey?2:1):n.zoom,bearing:n.bearing+i*this._bearingStep,pitch:n.pitch+r*this._pitchStep,offset:[-o*this._panStep,-a*this._panStep],center:n.center},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function ca(e){return e*(2-e)}const ha=4.000244140625;class ua{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);},this._map=e,this._tr=new Zo(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222;}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return !!this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around);}disable(){this.isEnabled()&&(this._enabled=!1);}_shouldBePrevented(e){return !!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=s.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%ha==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault();}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=n.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.Q.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t);}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>ha?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const o="number"!=typeof this._targetZoom?e.scale:t.ac(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),t.ah(o*r)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0;}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,o=this._easing;let a,n=!1;if("wheel"===this._type&&r&&o){const e=s.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=o(l);a=t.B.number(r,i,c),l<1?this._frameId||(this._frameId=!0):n=!0;}else a=i,n=!0;return this._active=!0,n&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout;}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!n,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cf;if(this._prevEase){const e=this._prevEase,r=(s.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(o*o+1e-4)*.01,n=Math.sqrt(.0729-a*a);i=t.cd(a,n,.25,1);}return this._prevEase={start:s.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);}}class da{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class _a{constructor(e){this._tr=new Zo(e),this.reset();}reset(){this._active=!1;}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class pa{constructor(){this._tap=new Vo({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset();}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],o=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;o&&a?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset();}else this._tap.touchstart(e,t,i);}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else {const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r);}}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ma{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class fa{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class ga{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}class va{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1;}isActive(){return !1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=n.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const o=document.createElement("div");o.className="maplibregl-mobile-message",o.textContent=i,this._container.appendChild(o),this._container.setAttribute("aria-hidden","true");}_destroyUI(){this._container&&(n.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container;}enable(){this._setupUI(),this._enabled=!0;}disable(){this._enabled=!1,this._destroyUI();}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show");}),100));}}const xa=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class ba extends t.l{}function ya(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class wa{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`);},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===e.type?void 0:e,o={needsRenderFrame:!1},a={},s={};for(const{handlerName:l,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;if(this._blockedByActive(s,h,l))c.reset();else if(c[i||e.type]){if(t.cg(e,i||e.type)){const t=n.mousePos(this._map.getCanvas(),e);u=c[i||e.type](e,t);}else if(t.ch(e,i||e.type)){const t=this._getMapTouches(e.touches),r=n.touchPos(this._map.getCanvas(),t);u=c[i||e.type](e,r,t);}else t.ci(i||e.type)||(u=c[i||e.type](e));this.mergeHandlerResult(o,a,u,l,r),u&&u.needsRenderFrame&&this._triggerRenderFrame();}(u||c.isActive())&&(s[l]=c);}const l={};for(const e in this._previousActiveHandlers)s[e]||(l[e]=r);this._previousActiveHandlers=s,(Object.keys(l).length||ya(o))&&(this._changes.push([o,a,l]),this._triggerRenderFrame()),(Object.keys(s).length||ya(o))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=o;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map));},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Do(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)n.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}destroy(){for(const[e,t,i]of this._listeners)n.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i);}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new Oo(i,e));const o=i.boxZoom=new No(i,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const a=i.cooperativeGestures=new va(i,e.cooperativeGestures);this._add("cooperativeGestures",a),e.cooperativeGestures&&a.enable();const s=new qo(i),l=new _a(i);i.doubleClickZoom=new da(l,s),this._add("tapZoom",s),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new pa;this._add("tapDragZoom",c);const h=i.touchPitch=new sa(i);this._add("touchPitch",h),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const u=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:o=100,rotateDegreesPerPixelMoved:a=.8},s){const l=new $o({checkCorrectEvent:e=>0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)&&!e.ctrlKey});return new Wo({clickTolerance:i,move:(e,i)=>{const n=s();if(r&&Math.abs(n.y-e.y)>o)return {bearingDelta:t.ce(new t.P(e.x,i.y),i,n)};let l=(i.x-e.x)*a;return r&&i.y0===n.mouseButton(e)&&e.ctrlKey||2===n.mouseButton(e)});return new Wo({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:Qo})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const o=new $o({checkCorrectEvent:e=>2===n.mouseButton(e)&&e.ctrlKey});return new Wo({clickTolerance:t,move:(e,t)=>{const o=r();let a=(t.x-e.x)*i;return t.y0===n.mouseButton(e)&&!e.ctrlKey});return new Wo({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Qo})}(e),f=new Yo(e,i);i.dragPan=new ma(r,m,f),this._add("mousePan",m),this._add("touchPan",f,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new oa,v=new ia;i.touchZoomRotate=new ga(r,v,g,c),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",v,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const x=i.scrollZoom=new ua(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",x,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const b=i.keyboard=new la(i);this._add("keyboard",b),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new jo(i));}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[];}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return Boolean(xa(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,o,a){if(!r)return;t.e(e,r);const s={handlerName:o,originalEvent:r.originalEvent||a};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s);}_applyChanges(){const e={},i={},r={};for(const[o,a,s]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.rollDelta&&(e.rollDelta=(e.rollDelta||0)+o.rollDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.e(i,a),t.e(r,s);this._updateMapTransform(e,i,r),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,o=r._getTransformForUpdate(),a=r.terrain;if(!(ya(e)||a&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:n,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u=u||r.transform.centerPoint,a&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const _={panDelta:s,zoomDelta:n,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!o.isPointOnMapSurface(u)&&(u=o.centerPoint);const p=u.distSqr(o.centerPoint)<.01?o.center:o.screenPointToLocation(s?u.sub(s):u);a?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?o.setCenter(o.screenPointToLocation(o.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(_,o,p):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(_,o,p))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(_,o),this._map.cameraHelper.handleMapControlsPan(_,o,p)),r._applyUpdatedTransform(o),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,i,r){const o=xa(this._eventsInProgress),a=xa(e),n={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(n[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!o&&a&&this._fireEvent("movestart",a.originalEvent);for(const e in n)this._fireEvent(e,n[e]);a&&this._fireEvent("move",a.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||r,l[`${e}end`]=c);}for(const e in l)this._fireEvent(e,l[e]);const h=xa(this._eventsInProgress),u=(o||a)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e);}if(r&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ba("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}class Ta extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",(()=>{delete this._requestedCameraState;}));}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t;}getCenter(){return new t.Q(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e;}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){f.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t);}),e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.l("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.l("rollstart",e));}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0;}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i;}this.transform.setElevation(t.B.number(this._elevationStart,this._elevationTarget,e));}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain);}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return {};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:o,roll:a,pitch:s,bearing:n,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==o&&t.setZoom(o),void 0!==a&&t.setRoll(a),void 0!==s&&t.setPitch(s),void 0!==n&&t.setBearing(n),i.apply(t);}this.transform.apply(i);}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e));}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,o=this._rotating,a=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l("zoomend",e)),o&&this.fire(new t.l("rotateend",e)),a&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e));}flyTo(e,i){if(!e.essential&&s.prefersReducedMotion){const r=t.O(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cf},e);const r=this._getTransformForUpdate(),o=r.bearing,a=r.pitch,n=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,h="pitch"in e?+e.pitch:a,u="roll"in e?this._normalizeBearing(e.roll,n):n,d="padding"in e?e.padding:r.padding,_=t.P.convert(e.offset);let p=r.centerPoint.add(_);const m=r.screenPointToLocation(p),f=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:_,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let g=e.curve;const v=Math.max(r.width,r.height),x=v/f.scaleOfZoom,b=f.pixelPathLength;"number"==typeof f.scaleOfMinZoom&&(g=Math.sqrt(v/f.scaleOfMinZoom/b*2));const y=g*g;function w(e){const t=(x*x-v*v+(e?-1:1)*y*y*b*b)/(2*(e?x:v)*y*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return (Math.exp(e)-Math.exp(-e))/2}function P(e){return (Math.exp(e)+Math.exp(-e))/2}const C=w(!1);let M=function(e){return P(C)/P(C+g*e)},I=function(e){return v*((P(C)*(T(t=C+g*e)/P(t))-T(C))/y)/b;var t;},E=(w(!0)-C)/g;if(Math.abs(b)<2e-6||!isFinite(E)){if(Math.abs(v-x)<1e-6)return this.easeTo(e,i);const t=x0,M=e=>Math.exp(t*g*e);}return e.duration="duration"in e?+e.duration:1e3*E/("screenSpeed"in e?+e.screenSpeed/g:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=h!==a,this._rolling=u!==n,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease((s=>{const m=s*E,g=1/M(m),v=I(m);this._rotating&&r.setBearing(t.B.number(o,c,s)),this._pitching&&r.setPitch(t.B.number(a,h,s)),this._rolling&&r.setRoll(t.B.number(n,u,s)),this._padding&&(r.interpolatePadding(l,d,s),p=r.centerPoint.add(_)),f.easeFunc(s,g,v,p),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(r),this._fireMoveEvents(i);}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i);}),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t);}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_normalizeBearing(e,i){e=t.aL(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class Ca{constructor(e=Pa){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")));},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions();},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"));},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show");},this.options=e;}getDefaultPosition(){return "bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=n.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=n.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i);}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>"string"!=typeof e?"":e))):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style.sourceCaches;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return !1;return !0}));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=n.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null);}}class Ma{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact");}},this.options=e;}getDefaultPosition(){return "bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=n.create("div","maplibregl-ctrl");const t=n.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){n.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0;}}class Ia{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}var Ea=t.aG([{name:"a_pos3d",type:"Int16",components:3}]);class Sa extends t.E{constructor(e){super(),this._lastTilesetChange=s.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize;}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const r={};for(const o of xe(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float64Array(16),t.bQ(o.terrainRttPosMatrix32f,0,t.Z,t.Z,0,0,1),this._tiles[o.key]=new ae(o,this.tileSize),this._lastTilesetChange=s.now());for(const e in this._tiles)r[e]||delete this._tiles[e];}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[]);}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID,a=e.clone(),s=t.b2();if(o.canonical.equals(e.canonical))t.bQ(s,0,t.Z,t.Z,0,0,1);else if(o.canonical.isChildOf(e.canonical)){const i=o.canonical.z-e.canonical.z,r=o.canonical.x-(o.canonical.x>>i<>i<>i;t.bQ(s,0,n,n,0,0,1),t.L(s,s,[-r*n,-a*n,0]);}else {if(!e.canonical.isChildOf(o.canonical))continue;{const i=e.canonical.z-o.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bQ(s,0,t.Z,t.Z,0,0,1),t.L(s,s,[r*n,a*n,0]),t.M(s,s,[1/2**i,1/2**i,0]);}}a.terrainRttPosMatrix32f=new Float32Array(s),i[r]=a;}return i}_getTerrainCoordsForTileRanges(e,i){const r={};for(const o of this._renderableTilesKeys){const a=this._tiles[o].tileID;if(!this._isWithinTileRanges(a,i))continue;const s=e.clone(),n=t.b2();if(a.canonical.z===e.canonical.z){const i=e.canonical.x-a.canonical.x,r=e.canonical.y-a.canonical.y;t.bQ(n,0,t.Z,t.Z,0,0,1),t.L(n,n,[i*t.Z,r*t.Z,0]);}else if(a.canonical.z>e.canonical.z){const i=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>i<>i<>i),l=e.canonical.y-(a.canonical.y>>i),c=t.Z>>i;t.bQ(n,0,c,c,0,0,1),t.L(n,n,[-r*c+s*t.Z,-o*c+l*t.Z,0]);}else {const i=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i)-a.canonical.x,l=(e.canonical.y>>i)-a.canonical.y,c=t.Z<i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!o||!o.dem);)o=this.sourceCache.getTileByID(e.scaledTo(r--).key);return o}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Ra{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Sa(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024;}getDEMElevation(e,i,r,o=t.Z){var a;if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?o=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=e.canonical.x-(e.canonical.x>>o<>o<>8<<4|e>>8,i[t+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),o=new v(e,r,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,o=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),n=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(a,n-s-1,1,1,o.RGBA,o.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,_=(1<0,o=r&&0===e.canonical.y,a=r&&e.canonical.y===(1<e.id!==t)),this._recentlyUsed.push(e.id);}stampObject(e){e.stamp=++this._stamp;}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1;}freeAllObjects(){for(const e of this._objects)this.freeObject(e);}isFull(){return !(this._objects.length!e.inUse))}}const Da={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Aa{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new za(e.context,30,t.sourceCache.tileSize*t.qualityFactor);}destruct(){this.pool.destruct();}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((i=>!e._layers[i].isHidden(t))),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates(),r=e.sourceCaches[t].getSource(),o=r instanceof K?r.terrainTileRanges:null;for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e,o);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e]);}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],r=i.source;if(Da[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join();}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[]);}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return !1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),o=e.type,a=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Da[o]&&(this._prevType&&Da[this._prevType]||this._stacks.push([]),this._prevType=o,this._stacks[this._stacks.length-1].push(e.id),!s))return !0;if(Da[this._prevType]||Da[o]&&s){this._prevType=o;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const o of this._renderableTiles){if(this.pool.isFull()&&(yo(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(o),o.rtt[e]){const t=this.pool.getObjectForId(o.rtt[e].id);if(t.stamp===o.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),o.rtt[e]={id:s.id,stamp:s.stamp},a.context.bindFramebuffer.set(s.fbo.framebuffer),a.context.clear({color:t.b7.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,n.mousePos(this.element,e)),n.addEventListener(window,"mousemove",this.mousemove),n.addEventListener(window,"mouseup",this.mouseup);},this.mousemove=e=>{this.move(e,n.mousePos(this.element,e));},this.mouseup=e=>{this._rotatePitchHanlder.dragEnd(e),this.offTemp();},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),n.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.addEventListener(window,"touchend",this.touchend));},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=n.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos));},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHanlder.reset(),delete this._startPos,delete this._lastPos,this.offTemp();},this._clickTolerance=10,this.element=i;const o=new Ko;this._rotatePitchHanlder=new Wo({clickTolerance:3,move:(e,o)=>{const a=i.getBoundingClientRect(),s=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return {bearingDelta:t.ce(new t.P(e.x,o.y),o,s),pitchDelta:r?-.5*(o.y-e.y):void 0}},moveStateManager:o,enable:!0,assignEvents:()=>{}}),this.map=e,n.addEventListener(i,"mousedown",this.mousedown),n.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),n.addEventListener(i,"touchcancel",this.reset);}startMove(e,t){this._rotatePitchHanlder.dragStart(e,t),n.disableDrag();}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:o}=this._rotatePitchHanlder.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),o&&i.setPitch(i.getPitch()+o);}off(){const e=this.element;n.removeEventListener(e,"mousedown",this.mousedown),n.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend),n.removeEventListener(e,"touchcancel",this.reset),this.offTemp();}offTemp(){n.enableDrag(),n.removeEventListener(window,"mousemove",this.mousemove),n.removeEventListener(window,"mouseup",this.mouseup),n.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),n.removeEventListener(window,"touchend",this.touchend);}}let ja;function Za(e,i,r,o=!1){if(o||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const a=new t.Q(e.lng,e.lat);if(e=new t.Q(e.lng,e.lat),i){const o=new t.Q(e.lng-360,e.lat),a=new t.Q(e.lng+360,e.lat),s=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(o).distSqr(i)180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360;}return e.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:a}const Na={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Ua(e,t,i){const r=e.classList;for(const e in Na)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`);}class Ga extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=Za(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),n.setTransform(this._element,`${Na[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`),s.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&"moveend"===e.type);})).catch((()=>{}));},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t;}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")));},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive";},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp));},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=n.create("div");const i=n.createNS("http://www.w3.org/2000/svg","svg"),r=41,o=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${o}px`),i.setAttributeNS(null,"viewBox",`0 0 ${o} ${r}`);const a=n.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"stroke","none"),a.setAttributeNS(null,"stroke-width","1"),a.setAttributeNS(null,"fill","none"),a.setAttributeNS(null,"fill-rule","evenodd");const s=n.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=n.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=n.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t);}const h=n.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=n.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=n.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const _=n.createNS("http://www.w3.org/2000/svg","path");_.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(_);const p=n.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=n.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const f=n.createNS("http://www.w3.org/2000/svg","circle");f.setAttributeNS(null,"fill","#000000"),f.setAttributeNS(null,"opacity","0.25"),f.setAttributeNS(null,"cx","5.5"),f.setAttributeNS(null,"cy","5.5"),f.setAttributeNS(null,"r","5.4999962");const g=n.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(f),m.appendChild(g),s.appendChild(l),s.appendChild(h),s.appendChild(d),s.appendChild(p),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14]);}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();})),Ua(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null;}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),n.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-13.5,-1*(t-i)]}:this._offset;}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress);}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;const o=null===(i=this._map)||void 0===i?void 0:i.terrain,a=this._map.transform.isLocationOccluded(this._lngLat);if(!o||a){const e=a?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else {if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null;}),100);}const s=this._map,n=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-n<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,h=Math.sin(s.getPitch()*Math.PI/180)*c,u=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+h)-u>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity;}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e);}removeClassName(e){this._element.classList.remove(e);}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return (void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Va={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let qa=0,Wa=!1;const Ha={maxWidth:100,unit:"metric"};function $a(e,t,i){const r=i&&i.maxWidth||100,o=e._container.clientHeight/2,a=e._container.clientWidth/2,s=e.unproject([a-r/2,o]),n=e.unproject([a+r/2,o]),l=Math.round(e.project(n).x-e.project(s).x),c=Math.min(r,l,e._container.clientWidth),h=s.distanceTo(n);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?Xa(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Xa(t,c,i,e._getUIString("ScaleControl.Feet"));}else i&&"nautical"===i.unit?Xa(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?Xa(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):Xa(t,c,h,e._getUIString("ScaleControl.Meters"));}function Xa(e,t,i,r){const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(o/i)+"px",e.innerHTML=`${o} ${r}`;}const Ka={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Qa=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ya(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return {center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return {center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return {center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Ya(new t.P(0,0))}const Ja=i;e.AJAXError=t.cq,e.Event=t.l,e.Evented=t.E,e.LngLat=t.Q,e.MercatorCoordinate=t.$,e.Point=t.P,e.addProtocol=t.cr,e.config=t.a,e.removeProtocol=t.cs,e.AttributionControl=Ca,e.BoxZoomHandler=No,e.CanvasSource=Y,e.CooperativeGesturesHandler=va,e.DoubleClickZoomHandler=da,e.DragPanHandler=ma,e.DragRotateHandler=fa,e.EdgeInsets=It,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange();},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen();},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){n.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange);}_setupUI(){const e=this._fullscreenButton=n.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);n.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e;}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable());}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen();}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen();}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize();}},e.GeoJSONSource=X,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "BACKGROUND":case "BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish();}},this._updateCamera=e=>{const i=new t.Q(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),a=t.e({bearing:o},this.options.fitBoundsOptions),s=V.fromLngLat(i,r);this._map.fitBounds(s,a,{geolocateSource:!0});},this._updateMarker=e=>{if(e){const i=new t.Q(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&Wa)return;this.options.trackUserLocation&&this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish();}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=n.create("button","maplibregl-ctrl-geolocate",this._container),n.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0);},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ga({element:this._dotElement}),this._circleElement=n.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ga({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")));}));}},this.options=t.e({},Va,e);}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if(void 0!==ja&&!e)return ja;if(void 0===window.navigator.permissions)return ja=!!window.navigator.geolocation,ja;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ja="denied"!==e.state;}catch(e){ja=!!window.navigator.geolocation;}return ja}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),n.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,qa=0,Wa=!1;}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case "ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case "ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),r=t.distanceTo(i),o=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.l("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":qa--,Wa=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case "BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case "WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case "OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),qa++,qa>1?(e={maximumAge:6e5,timeout:0},Wa=!0):(e=this.options.positionOptions,Wa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e);}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon();},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"));};}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=n.create("button","maplibregl-ctrl-globe",this._container),n.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){n.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0;}},e.Hash=Co,e.ImageSource=K,e.KeyboardHandler=la,e.LngLatBounds=V,e.LogoControl=Ma,e.Map=class extends Ta{constructor(e){var i,r;t.cn.mark(t.co.create);const o=Object.assign(Object.assign(Object.assign({},Fa),e),{canvasContextAttributes:Object.assign(Object.assign({},Fa.canvasContextAttributes),e.canvasContextAttributes)});if(null!=o.minZoom&&null!=o.maxZoom&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=o.minPitch&&null!=o.maxPitch&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=o.minPitch&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=o.maxPitch&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const a=new Lt,s=new Ot;if(void 0!==o.minZoom&&a.setMinZoom(o.minZoom),void 0!==o.maxZoom&&a.setMaxZoom(o.maxZoom),void 0!==o.minPitch&&a.setMinPitch(o.minPitch),void 0!==o.maxPitch&&a.setMaxPitch(o.maxPitch),void 0!==o.renderWorldCopies&&a.setRenderWorldCopies(o.renderWorldCopies),super(a,s,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ia,this._controls=[],this._mapId=t.a4(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.l("webglcontextlost",{originalEvent:e}));},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}));},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update();},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=!0===o.trackResize,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=!0===o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=!0===o.crossSourceCollisions,this._collectResourceTiming=!0===o.collectResourceTiming,this._locale=Object.assign(Object.assign({},La),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this.transformCameraUpdate=o.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===o.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=p.addThrottleControl((()=>this.isMoving())),this._requestManager=new m(o.transformRequest),"string"==typeof o.container){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else {if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container;}if(o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0);})),this.once("idle",(()=>{this._idleTriggered=!0;})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Po((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw());}),50);this._resizeObserver=new ResizeObserver((i=>{e?t(i):e=!0;})),this._resizeObserver.observe(this._container);}this.handlers=new wa(this,o),this._hash=o.hash&&new Co("string"==typeof o.hash&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,t.e({},o.fitBoundsOptions,{duration:0}))));const n="string"==typeof o.style||!("globe"===(null===(r=null===(i=o.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,n),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new Ca("boolean"==typeof o.attributionControl?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new Ma,o.logoPosition),this.on("style.load",(()=>{if(n||this._resizeTransform(),this.transform.unmodified){const e=t.O(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e);}})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new t.l(`${e.dataType}dataloading`,e));})),this.on("dataabort",(e=>{this.fire(new t.l("sourcedataabort",e));}));}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return -1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){const[r,o]=this._containerDimensions(),a=this._getClampedPixelRatio(r,o);if(this._resizeCanvas(r,o,a),this.painter.resize(r,o,a),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(r,o);this._resizeCanvas(r,o,t),this.painter.resize(r,o,t);}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e);}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,o=this.getPixelRatio(),a=e*o,s=t*o;return Math.min(a>i?i/a:1,s>r?r/s:1)*o}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize();}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(V.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.Q.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e))),s=0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[];s.length?r||(r=!0,i.call(this,new ko(e,this,o.originalEvent,{features:s}))):r=!1;};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=o=>{const a=t.filter((e=>this.getLayer(e)));(0!==a.length?this.queryRenderedFeatures(o.point,{layers:a}):[]).length?r=!0:r&&(r=!1,i.call(this,new ko(e,this,o.originalEvent)));},a=t=>{r&&(r=!1,i.call(this,new ko(e,this,t.originalEvent)));};return {layers:t,listener:i,delegates:{mousemove:o,mouseout:a}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),o=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];o.length&&(e.features=o,i.call(this,e),delete e.features);};return {layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t);}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let e=0;et.includes(e)))){for(const e in o.delegates)this.off(e,o.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,o);for(const e in o.delegates)this.on(e,o.delegates[e]);return {unsubscribe:()=>{this._removeDelegatedListener(e,r,i);}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,o=this._createDelegatedListener(e,r,i);for(const t in o.delegates){const a=o.delegates[t];o.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),a(...t);};}this._saveDelegatedListener(e,o);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return [];let r;const o=e instanceof t.P||Array.isArray(e),a=o?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(o?{}:e)||{},a instanceof t.P||"number"==typeof a[0])r=[t.P.convert(a)];else {const e=t.P.convert(a[0]),i=t.P.convert(a[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e];}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return !1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(e,t)));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new bi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new bi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,"Style");t.j(r,new AbortController).then((e=>{this._updateDiff(e.data,i);})).catch((e=>{e&&this.fire(new t.k(e));}));}else "object"==typeof e&&this._updateDiff(e,i);}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0);}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no source with ID '${e}'`)));}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.");}this.terrain=new Ra(this.painter,i,e),this.painter.renderToTexture=new Aa(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.tile.tileID));},this.style.on("data",this._terrainDataCallback);}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=fe(Math.max(1,e),Math.max(1,t));}else for(const i in this.style.sourceCaches)this.style.sourceCaches[i].getSource().calculateTileZoom=fe(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const r=this.style.sourceCaches[e];if(!r)throw new Error(`There is no source cache with ID "${e}", cannot refresh tile`);void 0===i?r.reload():r.refreshTiles(i.map((e=>new t.a1(e.z,e.x,e.y))));}addImage(e,i,r={}){const{pixelRatio:o=1,sdf:a=!1,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:s,data:d}=i,_=i;return this.style.addImage(e,{data:new t.R({width:r,height:s},new Uint8Array(d)),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0,userImage:_}),_.onAdd&&_.onAdd(this,e),this}}{const{width:r,height:d,data:_}=s.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},_),pixelRatio:o,stretchX:n,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0});}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||t.b(i)?s.getImageData(i):i,{width:a,height:n,data:l}=o;if(void 0===a||void 0===n)return this.fire(new t.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(a!==r.data.width||n!==r.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e){return p.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,(e=>{e||this._update(!0);})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0);})),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=n.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=n.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const o=this._controlContainer=n.create("div","maplibregl-control-container",e),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{a[e]=n.create("div",`maplibregl-ctrl-${e} `,o);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type);}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new To(i,this.transform),l.testSupport(i);}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}));}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_render(e){var i,r,o,a,n;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=s.now();this.style.zoomHistory.update(e,i);const r=new t.C(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=r.crossFadingFactor();1===o&&o===this._crossFadingFactor||(h=!0,this._crossFadingFactor=o),this.style.update(r);}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==c;null===(o=this.style.projection)||void 0===o||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(a=this.style.projection)||void 0===a?void 0:a.transitionState,null===(n=this.style.projection)||void 0===n?void 0:n.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cn.mark(t.co.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cn.mark(t.co.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),p.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),n.remove(this._canvasContainer),n.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cn.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"));}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,(e=>{t.cn.frame(e),this._frameRequest=null;try{this._render(e);}catch(e){if(!t.cp(e)&&!function(e){return e.message===Ur}(e))throw e}}),(()=>{})));}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get version(){return ka}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=ko,e.MapTouchEvent=Fo,e.MapWheelEvent=Bo,e.Marker=Ga,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString());},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`;},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i);},this.options=t.e({},Ba,e),this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(e=>this._map.zoomIn({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(e=>this._map.zoomOut({},{originalEvent:e}))),n.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e});})),this._compassIcon=n.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Oa(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){n.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map;}_createButton(e,t){const i=n.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:void 0);},this.remove=()=>(this._content&&n.remove(this._content),this._container&&(n.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point);},this._onMouseMove=e=>{this._update(e.point);},this._onDrag=e=>{this._update(e.point);},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=n.create("div","maplibregl-popup",this._map.getContainer()),this._tip=n.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer");}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Za(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const r=Ya(this.options.offset);if(!i){const e=this._container.offsetWidth,o=this._container.offsetHeight;let a;a=t.y+r.bottom.ythis._map.transform.height-o?["bottom"]:[],t.xthis._map.transform.width-e/2&&a.push("right"),i=0===a.length?"bottom":a.join("-");}let o=t.add(r[i]);this.options.subpixelPositioning||(o=o.round()),n.setTransform(this._container,`${Na[i]} translate(${o.x}px,${o.y}px)`),Ua(this._container,i,"popup"),this._updateOpacity();},this._onClose=()=>{this.remove();},this.options=t.e(Object.create(Ka),e);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return !!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.Q.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=n.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e;}_createCloseButton(){this.options.closeButton&&(this._closeButton=n.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose));}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Qa);e&&e.focus();}},e.RasterDEMTileSource=$,e.RasterTileSource=H,e.ScaleControl=class{constructor(e){this._onMove=()=>{$a(this._map,this._container,this.options);},this.setUnit=e=>{this.options.unit=e,$a(this._map,this._container,this.options);},this.options=Object.assign(Object.assign({},Ha),e);}getDefaultPosition(){return "bottom-left"}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){n.remove(this._container),this._map.off("move",this._onMove),this._map=void 0;}},e.ScrollZoomHandler=ua,e.Style=bi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon();},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"));},this.options=e;}onAdd(e){return this._map=e,this._container=n.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=n.create("button","maplibregl-ctrl-terrain",this._container),n.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){n.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0;}},e.TwoFingersTouchPitchHandler=sa,e.TwoFingersTouchRotateHandler=oa,e.TwoFingersTouchZoomHandler=ia,e.TwoFingersTouchZoomRotateHandler=ga,e.VectorTileSource=W,e.VideoSource=Q,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,(function*(){if(ee(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{J[e]=t;})(e,i);})),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(z),L=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},e.createTileMesh=Xt,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return oe().getRTLTextPluginStatus()},e.getVersion=function(){return Ja},e.getWorkerCount=function(){return D.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return O().broadcast("IS",e)},e.prewarm=function(){F().acquire(z);},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e;},e.setRTLTextPlugin=function(e,t){return oe().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){D.workerCount=e;},e.setWorkerUrl=function(e){t.a.WORKER_URL=e;};})); // // Our custom intro provides a specialized "define()" function, called by the diff --git a/inst/htmlwidgets/lib/pmtiles/pmtiles.js b/inst/htmlwidgets/lib/pmtiles/pmtiles.js new file mode 100644 index 00000000..d3d188da --- /dev/null +++ b/inst/htmlwidgets/lib/pmtiles/pmtiles.js @@ -0,0 +1,1738 @@ +"use strict"; +var pmtiles = (() => { + var __defProp = Object.defineProperty; + var __getOwnPropDesc = Object.getOwnPropertyDescriptor; + var __getOwnPropNames = Object.getOwnPropertyNames; + var __hasOwnProp = Object.prototype.hasOwnProperty; + var __pow = Math.pow; + var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); + }; + var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; + }; + var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + var __async = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); + }; + + // index.ts + var js_exports = {}; + __export(js_exports, { + Compression: () => Compression, + EtagMismatch: () => EtagMismatch, + FetchSource: () => FetchSource, + FileSource: () => FileSource, + PMTiles: () => PMTiles, + Protocol: () => Protocol, + ResolvedValueCache: () => ResolvedValueCache, + SharedPromiseCache: () => SharedPromiseCache, + TileType: () => TileType, + bytesToHeader: () => bytesToHeader, + findTile: () => findTile, + getUint64: () => getUint64, + leafletRasterLayer: () => leafletRasterLayer, + readVarint: () => readVarint, + tileIdToZxy: () => tileIdToZxy, + tileTypeExt: () => tileTypeExt, + zxyToTileId: () => zxyToTileId + }); + + // node_modules/fflate/esm/browser.js + var u8 = Uint8Array; + var u16 = Uint16Array; + var i32 = Int32Array; + var fleb = new u8([ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 3, + 3, + 3, + 3, + 4, + 4, + 4, + 4, + 5, + 5, + 5, + 5, + 0, + /* unused */ + 0, + 0, + /* impossible */ + 0 + ]); + var fdeb = new u8([ + 0, + 0, + 0, + 0, + 1, + 1, + 2, + 2, + 3, + 3, + 4, + 4, + 5, + 5, + 6, + 6, + 7, + 7, + 8, + 8, + 9, + 9, + 10, + 10, + 11, + 11, + 12, + 12, + 13, + 13, + /* unused */ + 0, + 0 + ]); + var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); + var freb = function(eb, start) { + var b = new u16(31); + for (var i = 0; i < 31; ++i) { + b[i] = start += 1 << eb[i - 1]; + } + var r = new i32(b[30]); + for (var i = 1; i < 30; ++i) { + for (var j = b[i]; j < b[i + 1]; ++j) { + r[j] = j - b[i] << 5 | i; + } + } + return { b, r }; + }; + var _a = freb(fleb, 2); + var fl = _a.b; + var revfl = _a.r; + fl[28] = 258, revfl[258] = 28; + var _b = freb(fdeb, 0); + var fd = _b.b; + var revfd = _b.r; + var rev = new u16(32768); + for (i = 0; i < 32768; ++i) { + x = (i & 43690) >> 1 | (i & 21845) << 1; + x = (x & 52428) >> 2 | (x & 13107) << 2; + x = (x & 61680) >> 4 | (x & 3855) << 4; + rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1; + } + var x; + var i; + var hMap = function(cd, mb, r) { + var s = cd.length; + var i = 0; + var l = new u16(mb); + for (; i < s; ++i) { + if (cd[i]) + ++l[cd[i] - 1]; + } + var le = new u16(mb); + for (i = 1; i < mb; ++i) { + le[i] = le[i - 1] + l[i - 1] << 1; + } + var co; + if (r) { + co = new u16(1 << mb); + var rvb = 15 - mb; + for (i = 0; i < s; ++i) { + if (cd[i]) { + var sv = i << 4 | cd[i]; + var r_1 = mb - cd[i]; + var v = le[cd[i] - 1]++ << r_1; + for (var m = v | (1 << r_1) - 1; v <= m; ++v) { + co[rev[v] >> rvb] = sv; + } + } + } + } else { + co = new u16(s); + for (i = 0; i < s; ++i) { + if (cd[i]) { + co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i]; + } + } + } + return co; + }; + var flt = new u8(288); + for (i = 0; i < 144; ++i) + flt[i] = 8; + var i; + for (i = 144; i < 256; ++i) + flt[i] = 9; + var i; + for (i = 256; i < 280; ++i) + flt[i] = 7; + var i; + for (i = 280; i < 288; ++i) + flt[i] = 8; + var i; + var fdt = new u8(32); + for (i = 0; i < 32; ++i) + fdt[i] = 5; + var i; + var flrm = /* @__PURE__ */ hMap(flt, 9, 1); + var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1); + var max = function(a) { + var m = a[0]; + for (var i = 1; i < a.length; ++i) { + if (a[i] > m) + m = a[i]; + } + return m; + }; + var bits = function(d, p, m) { + var o = p / 8 | 0; + return (d[o] | d[o + 1] << 8) >> (p & 7) & m; + }; + var bits16 = function(d, p) { + var o = p / 8 | 0; + return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7); + }; + var shft = function(p) { + return (p + 7) / 8 | 0; + }; + var slc = function(v, s, e) { + if (s == null || s < 0) + s = 0; + if (e == null || e > v.length) + e = v.length; + var n = new u8(e - s); + n.set(v.subarray(s, e)); + return n; + }; + var ec = [ + "unexpected EOF", + "invalid block type", + "invalid length/literal", + "invalid distance", + "stream finished", + "no stream handler", + , + "no callback", + "invalid UTF-8 data", + "extra field too long", + "date not in range 1980-2099", + "filename too long", + "stream finishing", + "invalid zip data" + // determined by unknown compression method + ]; + var err = function(ind, msg, nt) { + var e = new Error(msg || ec[ind]); + e.code = ind; + if (Error.captureStackTrace) + Error.captureStackTrace(e, err); + if (!nt) + throw e; + return e; + }; + var inflt = function(dat, st, buf, dict) { + var sl = dat.length, dl = dict ? dict.length : 0; + if (!sl || st.f && !st.l) + return buf || new u8(0); + var noBuf = !buf || st.i != 2; + var noSt = st.i; + if (!buf) + buf = new u8(sl * 3); + var cbuf = function(l2) { + var bl = buf.length; + if (l2 > bl) { + var nbuf = new u8(Math.max(bl * 2, l2)); + nbuf.set(buf); + buf = nbuf; + } + }; + var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n; + var tbts = sl * 8; + do { + if (!lm) { + final = bits(dat, pos, 1); + var type = bits(dat, pos + 1, 3); + pos += 3; + if (!type) { + var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l; + if (t > sl) { + if (noSt) + err(0); + break; + } + if (noBuf) + cbuf(bt + l); + buf.set(dat.subarray(s, t), bt); + st.b = bt += l, st.p = pos = t * 8, st.f = final; + continue; + } else if (type == 1) + lm = flrm, dm = fdrm, lbt = 9, dbt = 5; + else if (type == 2) { + var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4; + var tl = hLit + bits(dat, pos + 5, 31) + 1; + pos += 14; + var ldt = new u8(tl); + var clt = new u8(19); + for (var i = 0; i < hcLen; ++i) { + clt[clim[i]] = bits(dat, pos + i * 3, 7); + } + pos += hcLen * 3; + var clb = max(clt), clbmsk = (1 << clb) - 1; + var clm = hMap(clt, clb, 1); + for (var i = 0; i < tl; ) { + var r = clm[bits(dat, pos, clbmsk)]; + pos += r & 15; + var s = r >> 4; + if (s < 16) { + ldt[i++] = s; + } else { + var c = 0, n = 0; + if (s == 16) + n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1]; + else if (s == 17) + n = 3 + bits(dat, pos, 7), pos += 3; + else if (s == 18) + n = 11 + bits(dat, pos, 127), pos += 7; + while (n--) + ldt[i++] = c; + } + } + var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit); + lbt = max(lt); + dbt = max(dt); + lm = hMap(lt, lbt, 1); + dm = hMap(dt, dbt, 1); + } else + err(1); + if (pos > tbts) { + if (noSt) + err(0); + break; + } + } + if (noBuf) + cbuf(bt + 131072); + var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1; + var lpos = pos; + for (; ; lpos = pos) { + var c = lm[bits16(dat, pos) & lms], sym = c >> 4; + pos += c & 15; + if (pos > tbts) { + if (noSt) + err(0); + break; + } + if (!c) + err(2); + if (sym < 256) + buf[bt++] = sym; + else if (sym == 256) { + lpos = pos, lm = null; + break; + } else { + var add = sym - 254; + if (sym > 264) { + var i = sym - 257, b = fleb[i]; + add = bits(dat, pos, (1 << b) - 1) + fl[i]; + pos += b; + } + var d = dm[bits16(dat, pos) & dms], dsym = d >> 4; + if (!d) + err(3); + pos += d & 15; + var dt = fd[dsym]; + if (dsym > 3) { + var b = fdeb[dsym]; + dt += bits16(dat, pos) & (1 << b) - 1, pos += b; + } + if (pos > tbts) { + if (noSt) + err(0); + break; + } + if (noBuf) + cbuf(bt + 131072); + var end = bt + add; + if (bt < dt) { + var shift2 = dl - dt, dend = Math.min(dt, end); + if (shift2 + bt < 0) + err(3); + for (; bt < dend; ++bt) + buf[bt] = dict[shift2 + bt]; + } + for (; bt < end; bt += 4) { + buf[bt] = buf[bt - dt]; + buf[bt + 1] = buf[bt + 1 - dt]; + buf[bt + 2] = buf[bt + 2 - dt]; + buf[bt + 3] = buf[bt + 3 - dt]; + } + bt = end; + } + } + st.l = lm, st.p = lpos, st.b = bt, st.f = final; + if (lm) + final = 1, st.m = lbt, st.d = dm, st.n = dbt; + } while (!final); + return bt == buf.length ? buf : slc(buf, 0, bt); + }; + var et = /* @__PURE__ */ new u8(0); + var gzs = function(d) { + if (d[0] != 31 || d[1] != 139 || d[2] != 8) + err(6, "invalid gzip data"); + var flg = d[3]; + var st = 10; + if (flg & 4) + st += (d[10] | d[11] << 8) + 2; + for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]) + ; + return st + (flg & 2); + }; + var gzl = function(d) { + var l = d.length; + return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0; + }; + var zls = function(d, dict) { + if ((d[0] & 15) != 8 || d[0] >> 4 > 7 || (d[0] << 8 | d[1]) % 31) + err(6, "invalid zlib data"); + if ((d[1] >> 5 & 1) == +!dict) + err(6, "invalid zlib data: " + (d[1] & 32 ? "need" : "unexpected") + " dictionary"); + return (d[1] >> 3 & 4) + 2; + }; + function inflateSync(data, opts) { + return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary); + } + function gunzipSync(data, opts) { + var st = gzs(data); + if (st + 8 > data.length) + err(6, "invalid gzip data"); + return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary); + } + function unzlibSync(data, opts) { + return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary); + } + function decompressSync(data, opts) { + return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzipSync(data, opts) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflateSync(data, opts) : unzlibSync(data, opts); + } + var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder(); + var tds = 0; + try { + td.decode(et, { stream: true }); + tds = 1; + } catch (e) { + } + + // v2.ts + var shift = (n, shift2) => { + return n * __pow(2, shift2); + }; + var unshift = (n, shift2) => { + return Math.floor(n / __pow(2, shift2)); + }; + var getUint24 = (view, pos) => { + return shift(view.getUint16(pos + 1, true), 8) + view.getUint8(pos); + }; + var getUint48 = (view, pos) => { + return shift(view.getUint32(pos + 2, true), 16) + view.getUint16(pos, true); + }; + var compare = (tz, tx, ty, view, i) => { + if (tz !== view.getUint8(i)) + return tz - view.getUint8(i); + const x = getUint24(view, i + 1); + if (tx !== x) + return tx - x; + const y = getUint24(view, i + 4); + if (ty !== y) + return ty - y; + return 0; + }; + var queryLeafdir = (view, z, x, y) => { + const offsetLen = queryView(view, z | 128, x, y); + if (offsetLen) { + return { + z, + x, + y, + offset: offsetLen[0], + length: offsetLen[1], + isDir: true + }; + } + return null; + }; + var queryTile = (view, z, x, y) => { + const offsetLen = queryView(view, z, x, y); + if (offsetLen) { + return { + z, + x, + y, + offset: offsetLen[0], + length: offsetLen[1], + isDir: false + }; + } + return null; + }; + var queryView = (view, z, x, y) => { + let m = 0; + let n = view.byteLength / 17 - 1; + while (m <= n) { + const k = n + m >> 1; + const cmp = compare(z, x, y, view, k * 17); + if (cmp > 0) { + m = k + 1; + } else if (cmp < 0) { + n = k - 1; + } else { + return [getUint48(view, k * 17 + 7), view.getUint32(k * 17 + 13, true)]; + } + } + return null; + }; + var entrySort = (a, b) => { + if (a.isDir && !b.isDir) { + return 1; + } + if (!a.isDir && b.isDir) { + return -1; + } + if (a.z !== b.z) { + return a.z - b.z; + } + if (a.x !== b.x) { + return a.x - b.x; + } + return a.y - b.y; + }; + var parseEntry = (dataview, i) => { + const zRaw = dataview.getUint8(i * 17); + const z = zRaw & 127; + return { + z, + x: getUint24(dataview, i * 17 + 1), + y: getUint24(dataview, i * 17 + 4), + offset: getUint48(dataview, i * 17 + 7), + length: dataview.getUint32(i * 17 + 13, true), + isDir: zRaw >> 7 === 1 + }; + }; + var sortDir = (a) => { + const entries = []; + const view = new DataView(a); + for (let i = 0; i < view.byteLength / 17; i++) { + entries.push(parseEntry(view, i)); + } + return createDirectory(entries); + }; + var createDirectory = (entries) => { + entries.sort(entrySort); + const buffer = new ArrayBuffer(17 * entries.length); + const arr = new Uint8Array(buffer); + for (let i = 0; i < entries.length; i++) { + const entry = entries[i]; + let z = entry.z; + if (entry.isDir) + z = z | 128; + arr[i * 17] = z; + arr[i * 17 + 1] = entry.x & 255; + arr[i * 17 + 2] = entry.x >> 8 & 255; + arr[i * 17 + 3] = entry.x >> 16 & 255; + arr[i * 17 + 4] = entry.y & 255; + arr[i * 17 + 5] = entry.y >> 8 & 255; + arr[i * 17 + 6] = entry.y >> 16 & 255; + arr[i * 17 + 7] = entry.offset & 255; + arr[i * 17 + 8] = unshift(entry.offset, 8) & 255; + arr[i * 17 + 9] = unshift(entry.offset, 16) & 255; + arr[i * 17 + 10] = unshift(entry.offset, 24) & 255; + arr[i * 17 + 11] = unshift(entry.offset, 32) & 255; + arr[i * 17 + 12] = unshift(entry.offset, 48) & 255; + arr[i * 17 + 13] = entry.length & 255; + arr[i * 17 + 14] = entry.length >> 8 & 255; + arr[i * 17 + 15] = entry.length >> 16 & 255; + arr[i * 17 + 16] = entry.length >> 24 & 255; + } + return buffer; + }; + var deriveLeaf = (view, tile) => { + if (view.byteLength < 17) + return null; + const numEntries = view.byteLength / 17; + const entry = parseEntry(view, numEntries - 1); + if (entry.isDir) { + const leafLevel = entry.z; + const levelDiff = tile.z - leafLevel; + const leafX = Math.trunc(tile.x / (1 << levelDiff)); + const leafY = Math.trunc(tile.y / (1 << levelDiff)); + return { z: leafLevel, x: leafX, y: leafY }; + } + return null; + }; + function getHeader(source) { + return __async(this, null, function* () { + const resp = yield source.getBytes(0, 512e3); + const dataview = new DataView(resp.data); + const jsonSize = dataview.getUint32(4, true); + const rootEntries = dataview.getUint16(8, true); + const dec = new TextDecoder("utf-8"); + const jsonMetadata = JSON.parse( + dec.decode(new DataView(resp.data, 10, jsonSize)) + ); + let tileCompression = 0 /* Unknown */; + if (jsonMetadata.compression === "gzip") { + tileCompression = 2 /* Gzip */; + } + let minzoom = 0; + if ("minzoom" in jsonMetadata) { + minzoom = +jsonMetadata.minzoom; + } + let maxzoom = 0; + if ("maxzoom" in jsonMetadata) { + maxzoom = +jsonMetadata.maxzoom; + } + let centerLon = 0; + let centerLat = 0; + let centerZoom = 0; + let minLon = -180; + let minLat = -85; + let maxLon = 180; + let maxLat = 85; + if (jsonMetadata.bounds) { + const split = jsonMetadata.bounds.split(","); + minLon = +split[0]; + minLat = +split[1]; + maxLon = +split[2]; + maxLat = +split[3]; + } + if (jsonMetadata.center) { + const split = jsonMetadata.center.split(","); + centerLon = +split[0]; + centerLat = +split[1]; + centerZoom = +split[2]; + } + const header = { + specVersion: dataview.getUint16(2, true), + rootDirectoryOffset: 10 + jsonSize, + rootDirectoryLength: rootEntries * 17, + jsonMetadataOffset: 10, + jsonMetadataLength: jsonSize, + leafDirectoryOffset: 0, + leafDirectoryLength: void 0, + tileDataOffset: 0, + tileDataLength: void 0, + numAddressedTiles: 0, + numTileEntries: 0, + numTileContents: 0, + clustered: false, + internalCompression: 1 /* None */, + tileCompression, + tileType: 1 /* Mvt */, + minZoom: minzoom, + maxZoom: maxzoom, + minLon, + minLat, + maxLon, + maxLat, + centerZoom, + centerLon, + centerLat, + etag: resp.etag + }; + return header; + }); + } + function getZxy(header, source, cache, z, x, y, signal) { + return __async(this, null, function* () { + let rootDir = yield cache.getArrayBuffer( + source, + header.rootDirectoryOffset, + header.rootDirectoryLength, + header + ); + if (header.specVersion === 1) { + rootDir = sortDir(rootDir); + } + const entry = queryTile(new DataView(rootDir), z, x, y); + if (entry) { + const resp = yield source.getBytes(entry.offset, entry.length, signal); + let tileData = resp.data; + const view = new DataView(tileData); + if (view.getUint8(0) === 31 && view.getUint8(1) === 139) { + tileData = decompressSync(new Uint8Array(tileData)); + } + return { + data: tileData + }; + } + const leafcoords = deriveLeaf(new DataView(rootDir), { z, x, y }); + if (leafcoords) { + const leafdirEntry = queryLeafdir( + new DataView(rootDir), + leafcoords.z, + leafcoords.x, + leafcoords.y + ); + if (leafdirEntry) { + let leafDir = yield cache.getArrayBuffer( + source, + leafdirEntry.offset, + leafdirEntry.length, + header + ); + if (header.specVersion === 1) { + leafDir = sortDir(leafDir); + } + const tileEntry = queryTile(new DataView(leafDir), z, x, y); + if (tileEntry) { + const resp = yield source.getBytes( + tileEntry.offset, + tileEntry.length, + signal + ); + let tileData = resp.data; + const view = new DataView(tileData); + if (view.getUint8(0) === 31 && view.getUint8(1) === 139) { + tileData = decompressSync(new Uint8Array(tileData)); + } + return { + data: tileData + }; + } + } + } + return void 0; + }); + } + var v2_default = { + getHeader, + getZxy + }; + + // adapters.ts + var leafletRasterLayer = (source, options) => { + let loaded = false; + let mimeType = ""; + const cls = L.GridLayer.extend({ + createTile: (coord, done) => { + const el = document.createElement("img"); + const controller = new AbortController(); + const signal = controller.signal; + el.cancel = () => { + controller.abort(); + }; + if (!loaded) { + source.getHeader().then((header) => { + if (header.tileType === 1 /* Mvt */) { + console.error( + "Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details." + ); + } else if (header.tileType === 2) { + mimeType = "image/png"; + } else if (header.tileType === 3) { + mimeType = "image/jpeg"; + } else if (header.tileType === 4) { + mimeType = "image/webp"; + } else if (header.tileType === 5) { + mimeType = "image/avif"; + } + }); + loaded = true; + } + source.getZxy(coord.z, coord.x, coord.y, signal).then((arr) => { + if (arr) { + const blob = new Blob([arr.data], { type: mimeType }); + const imageUrl = window.URL.createObjectURL(blob); + el.src = imageUrl; + el.cancel = void 0; + done(void 0, el); + } + }).catch((e) => { + if (e.name !== "AbortError") { + throw e; + } + }); + return el; + }, + _removeTile: function(key) { + const tile = this._tiles[key]; + if (!tile) { + return; + } + if (tile.el.cancel) + tile.el.cancel(); + tile.el.width = 0; + tile.el.height = 0; + tile.el.deleted = true; + L.DomUtil.remove(tile.el); + delete this._tiles[key]; + this.fire("tileunload", { + tile: tile.el, + coords: this._keyToTileCoords(key) + }); + } + }); + return new cls(options); + }; + var v3compat = (v4) => (requestParameters, arg2) => { + if (arg2 instanceof AbortController) { + return v4(requestParameters, arg2); + } + const abortController = new AbortController(); + v4(requestParameters, abortController).then( + (result) => { + return arg2( + void 0, + result.data, + result.cacheControl || "", + result.expires || "" + ); + }, + (err2) => { + return arg2(err2); + } + ).catch((e) => { + return arg2(e); + }); + return { cancel: () => abortController.abort() }; + }; + var Protocol = class { + /** + * Initialize the MapLibre PMTiles protocol. + * + * * metadata: also load the metadata section of the PMTiles. required for some "inspect" functionality + * and to automatically populate the map attribution. Requires an extra HTTP request. + */ + constructor(options) { + /** @hidden */ + this.tilev4 = (params, abortController) => __async(this, null, function* () { + if (params.type === "json") { + const pmtilesUrl2 = params.url.substr(10); + let instance2 = this.tiles.get(pmtilesUrl2); + if (!instance2) { + instance2 = new PMTiles(pmtilesUrl2); + this.tiles.set(pmtilesUrl2, instance2); + } + if (this.metadata) { + return { + data: yield instance2.getTileJson(params.url) + }; + } + const h = yield instance2.getHeader(); + return { + data: { + tiles: [`${params.url}/{z}/{x}/{y}`], + minzoom: h.minZoom, + maxzoom: h.maxZoom, + bounds: [h.minLon, h.minLat, h.maxLon, h.maxLat] + } + }; + } + const re = new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/); + const result = params.url.match(re); + if (!result) { + throw new Error("Invalid PMTiles protocol URL"); + } + const pmtilesUrl = result[1]; + let instance = this.tiles.get(pmtilesUrl); + if (!instance) { + instance = new PMTiles(pmtilesUrl); + this.tiles.set(pmtilesUrl, instance); + } + const z = result[2]; + const x = result[3]; + const y = result[4]; + const header = yield instance.getHeader(); + const resp = yield instance == null ? void 0 : instance.getZxy(+z, +x, +y, abortController.signal); + if (resp) { + return { + data: new Uint8Array(resp.data), + cacheControl: resp.cacheControl, + expires: resp.expires + }; + } + if (header.tileType === 1 /* Mvt */) { + return { data: new Uint8Array() }; + } + return { data: null }; + }); + this.tile = v3compat(this.tilev4); + this.tiles = /* @__PURE__ */ new Map(); + this.metadata = (options == null ? void 0 : options.metadata) || false; + } + /** + * Add a {@link PMTiles} instance to the global protocol instance. + * + * For remote fetch sources, references in MapLibre styles like pmtiles://http://... + * will resolve to the same instance if the URLs match. + */ + add(p) { + this.tiles.set(p.source.getKey(), p); + } + /** + * Fetch a {@link PMTiles} instance by URL, for remote PMTiles instances. + */ + get(url) { + return this.tiles.get(url); + } + }; + + // index.ts + function toNum(low, high) { + return (high >>> 0) * 4294967296 + (low >>> 0); + } + function readVarintRemainder(l, p) { + const buf = p.buf; + let b = buf[p.pos++]; + let h = (b & 112) >> 4; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 3; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 10; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 17; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 127) << 24; + if (b < 128) + return toNum(l, h); + b = buf[p.pos++]; + h |= (b & 1) << 31; + if (b < 128) + return toNum(l, h); + throw new Error("Expected varint not more than 10 bytes"); + } + function readVarint(p) { + const buf = p.buf; + let b = buf[p.pos++]; + let val = b & 127; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 7; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 14; + if (b < 128) + return val; + b = buf[p.pos++]; + val |= (b & 127) << 21; + if (b < 128) + return val; + b = buf[p.pos]; + val |= (b & 15) << 28; + return readVarintRemainder(val, p); + } + function rotate(n, xy, rx, ry) { + if (ry === 0) { + if (rx === 1) { + xy[0] = n - 1 - xy[0]; + xy[1] = n - 1 - xy[1]; + } + const t = xy[0]; + xy[0] = xy[1]; + xy[1] = t; + } + } + function idOnLevel(z, pos) { + const n = __pow(2, z); + let rx = pos; + let ry = pos; + let t = pos; + const xy = [0, 0]; + let s = 1; + while (s < n) { + rx = 1 & t / 2; + ry = 1 & (t ^ rx); + rotate(s, xy, rx, ry); + xy[0] += s * rx; + xy[1] += s * ry; + t = t / 4; + s *= 2; + } + return [z, xy[0], xy[1]]; + } + var tzValues = [ + 0, + 1, + 5, + 21, + 85, + 341, + 1365, + 5461, + 21845, + 87381, + 349525, + 1398101, + 5592405, + 22369621, + 89478485, + 357913941, + 1431655765, + 5726623061, + 22906492245, + 91625968981, + 366503875925, + 1466015503701, + 5864062014805, + 23456248059221, + 93824992236885, + 375299968947541, + 1501199875790165 + ]; + function zxyToTileId(z, x, y) { + if (z > 26) { + throw Error("Tile zoom level exceeds max safe number limit (26)"); + } + if (x > __pow(2, z) - 1 || y > __pow(2, z) - 1) { + throw Error("tile x/y outside zoom level bounds"); + } + const acc = tzValues[z]; + const n = __pow(2, z); + let rx = 0; + let ry = 0; + let d = 0; + const xy = [x, y]; + let s = n / 2; + while (s > 0) { + rx = (xy[0] & s) > 0 ? 1 : 0; + ry = (xy[1] & s) > 0 ? 1 : 0; + d += s * s * (3 * rx ^ ry); + rotate(s, xy, rx, ry); + s = s / 2; + } + return acc + d; + } + function tileIdToZxy(i) { + let acc = 0; + const z = 0; + for (let z2 = 0; z2 < 27; z2++) { + const numTiles = (1 << z2) * (1 << z2); + if (acc + numTiles > i) { + return idOnLevel(z2, i - acc); + } + acc += numTiles; + } + throw Error("Tile zoom level exceeds max safe number limit (26)"); + } + var Compression = /* @__PURE__ */ ((Compression2) => { + Compression2[Compression2["Unknown"] = 0] = "Unknown"; + Compression2[Compression2["None"] = 1] = "None"; + Compression2[Compression2["Gzip"] = 2] = "Gzip"; + Compression2[Compression2["Brotli"] = 3] = "Brotli"; + Compression2[Compression2["Zstd"] = 4] = "Zstd"; + return Compression2; + })(Compression || {}); + function defaultDecompress(buf, compression) { + return __async(this, null, function* () { + if (compression === 1 /* None */ || compression === 0 /* Unknown */) { + return buf; + } + if (compression === 2 /* Gzip */) { + if (typeof globalThis.DecompressionStream === "undefined") { + return decompressSync(new Uint8Array(buf)); + } + const stream = new Response(buf).body; + if (!stream) { + throw Error("Failed to read response stream"); + } + const result = stream.pipeThrough( + // biome-ignore lint: needed to detect DecompressionStream in browser+node+cloudflare workers + new globalThis.DecompressionStream("gzip") + ); + return new Response(result).arrayBuffer(); + } + throw Error("Compression method not supported"); + }); + } + var TileType = /* @__PURE__ */ ((TileType2) => { + TileType2[TileType2["Unknown"] = 0] = "Unknown"; + TileType2[TileType2["Mvt"] = 1] = "Mvt"; + TileType2[TileType2["Png"] = 2] = "Png"; + TileType2[TileType2["Jpeg"] = 3] = "Jpeg"; + TileType2[TileType2["Webp"] = 4] = "Webp"; + TileType2[TileType2["Avif"] = 5] = "Avif"; + return TileType2; + })(TileType || {}); + function tileTypeExt(t) { + if (t === 1 /* Mvt */) + return ".mvt"; + if (t === 2 /* Png */) + return ".png"; + if (t === 3 /* Jpeg */) + return ".jpg"; + if (t === 4 /* Webp */) + return ".webp"; + if (t === 5 /* Avif */) + return ".avif"; + return ""; + } + var HEADER_SIZE_BYTES = 127; + function findTile(entries, tileId) { + let m = 0; + let n = entries.length - 1; + while (m <= n) { + const k = n + m >> 1; + const cmp = tileId - entries[k].tileId; + if (cmp > 0) { + m = k + 1; + } else if (cmp < 0) { + n = k - 1; + } else { + return entries[k]; + } + } + if (n >= 0) { + if (entries[n].runLength === 0) { + return entries[n]; + } + if (tileId - entries[n].tileId < entries[n].runLength) { + return entries[n]; + } + } + return null; + } + var FileSource = class { + constructor(file) { + this.file = file; + } + getKey() { + return this.file.name; + } + getBytes(offset, length) { + return __async(this, null, function* () { + const blob = this.file.slice(offset, offset + length); + const a = yield blob.arrayBuffer(); + return { data: a }; + }); + } + }; + var FetchSource = class { + constructor(url, customHeaders = new Headers()) { + this.url = url; + this.customHeaders = customHeaders; + this.mustReload = false; + let userAgent = ""; + if ("navigator" in globalThis) { + userAgent = globalThis.navigator.userAgent || ""; + } + const isWindows = userAgent.indexOf("Windows") > -1; + const isChromiumBased = /Chrome|Chromium|Edg|OPR|Brave/.test(userAgent); + this.chromeWindowsNoCache = false; + if (isWindows && isChromiumBased) { + this.chromeWindowsNoCache = true; + } + } + getKey() { + return this.url; + } + /** + * Mutate the custom [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) set for all requests to the remote archive. + */ + setHeaders(customHeaders) { + this.customHeaders = customHeaders; + } + getBytes(offset, length, passedSignal, etag) { + return __async(this, null, function* () { + let controller; + let signal; + if (passedSignal) { + signal = passedSignal; + } else { + controller = new AbortController(); + signal = controller.signal; + } + const requestHeaders = new Headers(this.customHeaders); + requestHeaders.set("range", `bytes=${offset}-${offset + length - 1}`); + let cache; + if (this.mustReload) { + cache = "reload"; + } else if (this.chromeWindowsNoCache) { + cache = "no-store"; + } + let resp = yield fetch(this.url, { + signal, + cache, + headers: requestHeaders + //biome-ignore lint: "cache" is incompatible between cloudflare workers and browser + }); + if (offset === 0 && resp.status === 416) { + const contentRange = resp.headers.get("Content-Range"); + if (!contentRange || !contentRange.startsWith("bytes */")) { + throw Error("Missing content-length on 416 response"); + } + const actualLength = +contentRange.substr(8); + resp = yield fetch(this.url, { + signal, + cache: "reload", + headers: { range: `bytes=0-${actualLength - 1}` } + //biome-ignore lint: "cache" is incompatible between cloudflare workers and browser + }); + } + let newEtag = resp.headers.get("Etag"); + if (newEtag == null ? void 0 : newEtag.startsWith("W/")) { + newEtag = null; + } + if (resp.status === 416 || etag && newEtag && newEtag !== etag) { + this.mustReload = true; + throw new EtagMismatch( + `Server returned non-matching ETag ${etag} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.` + ); + } + if (resp.status >= 300) { + throw Error(`Bad response code: ${resp.status}`); + } + const contentLength = resp.headers.get("Content-Length"); + if (resp.status === 200 && (!contentLength || +contentLength > length)) { + if (controller) + controller.abort(); + throw Error( + "Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving." + ); + } + const a = yield resp.arrayBuffer(); + return { + data: a, + etag: newEtag || void 0, + cacheControl: resp.headers.get("Cache-Control") || void 0, + expires: resp.headers.get("Expires") || void 0 + }; + }); + } + }; + function getUint64(v, offset) { + const wh = v.getUint32(offset + 4, true); + const wl = v.getUint32(offset + 0, true); + return wh * __pow(2, 32) + wl; + } + function bytesToHeader(bytes, etag) { + const v = new DataView(bytes); + const specVersion = v.getUint8(7); + if (specVersion > 3) { + throw Error( + `Archive is spec version ${specVersion} but this library supports up to spec version 3` + ); + } + return { + specVersion, + rootDirectoryOffset: getUint64(v, 8), + rootDirectoryLength: getUint64(v, 16), + jsonMetadataOffset: getUint64(v, 24), + jsonMetadataLength: getUint64(v, 32), + leafDirectoryOffset: getUint64(v, 40), + leafDirectoryLength: getUint64(v, 48), + tileDataOffset: getUint64(v, 56), + tileDataLength: getUint64(v, 64), + numAddressedTiles: getUint64(v, 72), + numTileEntries: getUint64(v, 80), + numTileContents: getUint64(v, 88), + clustered: v.getUint8(96) === 1, + internalCompression: v.getUint8(97), + tileCompression: v.getUint8(98), + tileType: v.getUint8(99), + minZoom: v.getUint8(100), + maxZoom: v.getUint8(101), + minLon: v.getInt32(102, true) / 1e7, + minLat: v.getInt32(106, true) / 1e7, + maxLon: v.getInt32(110, true) / 1e7, + maxLat: v.getInt32(114, true) / 1e7, + centerZoom: v.getUint8(118), + centerLon: v.getInt32(119, true) / 1e7, + centerLat: v.getInt32(123, true) / 1e7, + etag + }; + } + function deserializeIndex(buffer) { + const p = { buf: new Uint8Array(buffer), pos: 0 }; + const numEntries = readVarint(p); + const entries = []; + let lastId = 0; + for (let i = 0; i < numEntries; i++) { + const v = readVarint(p); + entries.push({ tileId: lastId + v, offset: 0, length: 0, runLength: 1 }); + lastId += v; + } + for (let i = 0; i < numEntries; i++) { + entries[i].runLength = readVarint(p); + } + for (let i = 0; i < numEntries; i++) { + entries[i].length = readVarint(p); + } + for (let i = 0; i < numEntries; i++) { + const v = readVarint(p); + if (v === 0 && i > 0) { + entries[i].offset = entries[i - 1].offset + entries[i - 1].length; + } else { + entries[i].offset = v - 1; + } + } + return entries; + } + function detectVersion(a) { + const v = new DataView(a); + if (v.getUint16(2, true) === 2) { + console.warn( + "PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade" + ); + return 2; + } + if (v.getUint16(2, true) === 1) { + console.warn( + "PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade" + ); + return 1; + } + return 3; + } + var EtagMismatch = class extends Error { + }; + function getHeaderAndRoot(source, decompress) { + return __async(this, null, function* () { + const resp = yield source.getBytes(0, 16384); + const v = new DataView(resp.data); + if (v.getUint16(0, true) !== 19792) { + throw new Error("Wrong magic number for PMTiles archive"); + } + if (detectVersion(resp.data) < 3) { + return [yield v2_default.getHeader(source)]; + } + const headerData = resp.data.slice(0, HEADER_SIZE_BYTES); + const header = bytesToHeader(headerData, resp.etag); + const rootDirData = resp.data.slice( + header.rootDirectoryOffset, + header.rootDirectoryOffset + header.rootDirectoryLength + ); + const dirKey = `${source.getKey()}|${header.etag || ""}|${header.rootDirectoryOffset}|${header.rootDirectoryLength}`; + const rootDir = deserializeIndex( + yield decompress(rootDirData, header.internalCompression) + ); + return [header, [dirKey, rootDir.length, rootDir]]; + }); + } + function getDirectory(source, decompress, offset, length, header) { + return __async(this, null, function* () { + const resp = yield source.getBytes(offset, length, void 0, header.etag); + const data = yield decompress(resp.data, header.internalCompression); + const directory = deserializeIndex(data); + if (directory.length === 0) { + throw new Error("Empty directory is invalid"); + } + return directory; + }); + } + var ResolvedValueCache = class { + constructor(maxCacheEntries = 100, prefetch = true, decompress = defaultDecompress) { + this.cache = /* @__PURE__ */ new Map(); + this.maxCacheEntries = maxCacheEntries; + this.counter = 1; + this.decompress = decompress; + } + getHeader(source) { + return __async(this, null, function* () { + const cacheKey = source.getKey(); + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = cacheValue.data; + return data; + } + const res = yield getHeaderAndRoot(source, this.decompress); + if (res[1]) { + this.cache.set(res[1][0], { + lastUsed: this.counter++, + data: res[1][2] + }); + } + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: res[0] + }); + this.prune(); + return res[0]; + }); + } + getDirectory(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = cacheValue.data; + return data; + } + const directory = yield getDirectory( + source, + this.decompress, + offset, + length, + header + ); + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: directory + }); + this.prune(); + return directory; + }); + } + // for v2 backwards compatibility + getArrayBuffer(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const resp = yield source.getBytes(offset, length, void 0, header.etag); + this.cache.set(cacheKey, { + lastUsed: this.counter++, + data: resp.data + }); + this.prune(); + return resp.data; + }); + } + prune() { + if (this.cache.size > this.maxCacheEntries) { + let minUsed = Infinity; + let minKey = void 0; + this.cache.forEach((cacheValue, key) => { + if (cacheValue.lastUsed < minUsed) { + minUsed = cacheValue.lastUsed; + minKey = key; + } + }); + if (minKey) { + this.cache.delete(minKey); + } + } + } + invalidate(source) { + return __async(this, null, function* () { + this.cache.delete(source.getKey()); + }); + } + }; + var SharedPromiseCache = class { + constructor(maxCacheEntries = 100, prefetch = true, decompress = defaultDecompress) { + this.cache = /* @__PURE__ */ new Map(); + this.invalidations = /* @__PURE__ */ new Map(); + this.maxCacheEntries = maxCacheEntries; + this.counter = 1; + this.decompress = decompress; + } + getHeader(source) { + return __async(this, null, function* () { + const cacheKey = source.getKey(); + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + getHeaderAndRoot(source, this.decompress).then((res) => { + if (res[1]) { + this.cache.set(res[1][0], { + lastUsed: this.counter++, + data: Promise.resolve(res[1][2]) + }); + } + resolve(res[0]); + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + getDirectory(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + getDirectory(source, this.decompress, offset, length, header).then((directory) => { + resolve(directory); + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + // for v2 backwards compatibility + getArrayBuffer(source, offset, length, header) { + return __async(this, null, function* () { + const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`; + const cacheValue = this.cache.get(cacheKey); + if (cacheValue) { + cacheValue.lastUsed = this.counter++; + const data = yield cacheValue.data; + return data; + } + const p = new Promise((resolve, reject) => { + source.getBytes(offset, length, void 0, header.etag).then((resp) => { + resolve(resp.data); + if (this.cache.has(cacheKey)) { + } + this.prune(); + }).catch((e) => { + reject(e); + }); + }); + this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); + return p; + }); + } + prune() { + if (this.cache.size >= this.maxCacheEntries) { + let minUsed = Infinity; + let minKey = void 0; + this.cache.forEach((cacheValue, key) => { + if (cacheValue.lastUsed < minUsed) { + minUsed = cacheValue.lastUsed; + minKey = key; + } + }); + if (minKey) { + this.cache.delete(minKey); + } + } + } + invalidate(source) { + return __async(this, null, function* () { + const key = source.getKey(); + if (this.invalidations.get(key)) { + return yield this.invalidations.get(key); + } + this.cache.delete(source.getKey()); + const p = new Promise((resolve, reject) => { + this.getHeader(source).then((h) => { + resolve(); + this.invalidations.delete(key); + }).catch((e) => { + reject(e); + }); + }); + this.invalidations.set(key, p); + }); + } + }; + var PMTiles = class { + constructor(source, cache, decompress) { + if (typeof source === "string") { + this.source = new FetchSource(source); + } else { + this.source = source; + } + if (decompress) { + this.decompress = decompress; + } else { + this.decompress = defaultDecompress; + } + if (cache) { + this.cache = cache; + } else { + this.cache = new SharedPromiseCache(); + } + } + /** + * Return the header of the archive, + * including information such as tile type, min/max zoom, bounds, and summary statistics. + */ + getHeader() { + return __async(this, null, function* () { + return yield this.cache.getHeader(this.source); + }); + } + /** @hidden */ + getZxyAttempt(z, x, y, signal) { + return __async(this, null, function* () { + const tileId = zxyToTileId(z, x, y); + const header = yield this.cache.getHeader(this.source); + if (header.specVersion < 3) { + return v2_default.getZxy(header, this.source, this.cache, z, x, y, signal); + } + if (z < header.minZoom || z > header.maxZoom) { + return void 0; + } + let dO = header.rootDirectoryOffset; + let dL = header.rootDirectoryLength; + for (let depth = 0; depth <= 3; depth++) { + const directory = yield this.cache.getDirectory( + this.source, + dO, + dL, + header + ); + const entry = findTile(directory, tileId); + if (entry) { + if (entry.runLength > 0) { + const resp = yield this.source.getBytes( + header.tileDataOffset + entry.offset, + entry.length, + signal, + header.etag + ); + return { + data: yield this.decompress(resp.data, header.tileCompression), + cacheControl: resp.cacheControl, + expires: resp.expires + }; + } + dO = header.leafDirectoryOffset + entry.offset; + dL = entry.length; + } else { + return void 0; + } + } + throw Error("Maximum directory depth exceeded"); + }); + } + /** + * Primary method to get a single tile's bytes from an archive. + * + * Returns undefined if the tile does not exist in the archive. + */ + getZxy(z, x, y, signal) { + return __async(this, null, function* () { + try { + return yield this.getZxyAttempt(z, x, y, signal); + } catch (e) { + if (e instanceof EtagMismatch) { + this.cache.invalidate(this.source); + return yield this.getZxyAttempt(z, x, y, signal); + } + throw e; + } + }); + } + /** @hidden */ + getMetadataAttempt() { + return __async(this, null, function* () { + const header = yield this.cache.getHeader(this.source); + const resp = yield this.source.getBytes( + header.jsonMetadataOffset, + header.jsonMetadataLength, + void 0, + header.etag + ); + const decompressed = yield this.decompress( + resp.data, + header.internalCompression + ); + const dec = new TextDecoder("utf-8"); + return JSON.parse(dec.decode(decompressed)); + }); + } + /** + * Return the arbitrary JSON metadata of the archive. + */ + getMetadata() { + return __async(this, null, function* () { + try { + return yield this.getMetadataAttempt(); + } catch (e) { + if (e instanceof EtagMismatch) { + this.cache.invalidate(this.source); + return yield this.getMetadataAttempt(); + } + throw e; + } + }); + } + /** + * Construct a [TileJSON](https://github.com/mapbox/tilejson-spec) object. + * + * baseTilesUrl is the desired tiles URL, excluding the suffix `/{z}/{x}/{y}.{ext}`. + * For example, if the desired URL is `http://example.com/tileset/{z}/{x}/{y}.mvt`, + * the baseTilesUrl should be `https://example.com/tileset`. + */ + getTileJson(baseTilesUrl) { + return __async(this, null, function* () { + const header = yield this.getHeader(); + const metadata = yield this.getMetadata(); + const ext = tileTypeExt(header.tileType); + return { + tilejson: "3.0.0", + scheme: "xyz", + tiles: [`${baseTilesUrl}/{z}/{x}/{y}${ext}`], + // biome-ignore lint: TileJSON spec + vector_layers: metadata.vector_layers, + attribution: metadata.attribution, + description: metadata.description, + name: metadata.name, + version: metadata.version, + bounds: [header.minLon, header.minLat, header.maxLon, header.maxLat], + center: [header.centerLon, header.centerLat, header.centerZoom], + minzoom: header.minZoom, + maxzoom: header.maxZoom + }; + }); + } + }; + return __toCommonJS(js_exports); +})(); diff --git a/inst/htmlwidgets/mapboxgl.js b/inst/htmlwidgets/mapboxgl.js index 1ded351d..29e56ff9 100644 --- a/inst/htmlwidgets/mapboxgl.js +++ b/inst/htmlwidgets/mapboxgl.js @@ -1,7 +1,87 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case "get": + return properties[expression[1]]; + case "concat": + return expression + .slice(1) + .map((item) => evaluateExpression(item, properties)) + .join(""); + case "to-string": + return String(evaluateExpression(expression[1], properties)); + case "to-number": + return Number(evaluateExpression(expression[1], properties)); + case "number-format": + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || "en-US"; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty("min-fraction-digits")) { + formatOptions.minimumFractionDigits = options["min-fraction-digits"]; + } + if (options.hasOwnProperty("max-fraction-digits")) { + formatOptions.maximumFractionDigits = options["max-fraction-digits"]; + } + if (options.hasOwnProperty("min-integer-digits")) { + formatOptions.minimumIntegerDigits = options["min-integer-digits"]; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) + formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty("useGrouping")) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { map.getCanvas().style.cursor = "pointer"; if (e.features.length > 0) { - const description = e.features[0].properties[tooltipProperty]; + // Clear any existing active tooltip first to prevent stacking + if (window._activeTooltip && window._activeTooltip !== tooltipPopup) { + window._activeTooltip.remove(); + } + + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression( + tooltipProperty, + e.features[0].properties, + ); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); // Store reference to currently active tooltip @@ -23,1812 +103,2787 @@ function onMouseLeaveTooltip(map, tooltipPopup) { } } +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + window._mapboxPopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on("close", function () { + if (window._mapboxPopups[layerId] === popup) { + delete window._mapboxPopups[layerId]; + } + }); +} + +// Helper function to generate draw styles based on parameters +function generateDrawStyles(styling) { + if (!styling) return null; + + return [ + // Point styles + { + id: "gl-draw-point-active", + type: "circle", + filter: [ + "all", + ["==", "$type", "Point"], + ["==", "meta", "feature"], + ["==", "active", "true"], + ], + paint: { + "circle-radius": styling.vertex_radius + 2, + "circle-color": styling.active_color, + }, + }, + { + id: "gl-draw-point", + type: "circle", + filter: [ + "all", + ["==", "$type", "Point"], + ["==", "meta", "feature"], + ["==", "active", "false"], + ], + paint: { + "circle-radius": styling.vertex_radius, + "circle-color": styling.point_color, + }, + }, + // Line styles + { + id: "gl-draw-line", + type: "line", + filter: ["all", ["==", "$type", "LineString"]], + layout: { + "line-cap": "round", + "line-join": "round", + }, + paint: { + "line-color": [ + "case", + ["==", ["get", "active"], "true"], + styling.active_color, + styling.line_color, + ], + "line-width": styling.line_width, + }, + }, + // Polygon fill + { + id: "gl-draw-polygon-fill", + type: "fill", + filter: ["all", ["==", "$type", "Polygon"]], + paint: { + "fill-color": [ + "case", + ["==", ["get", "active"], "true"], + styling.active_color, + styling.fill_color, + ], + "fill-outline-color": [ + "case", + ["==", ["get", "active"], "true"], + styling.active_color, + styling.fill_color, + ], + "fill-opacity": styling.fill_opacity, + }, + }, + // Polygon outline + { + id: "gl-draw-polygon-stroke", + type: "line", + filter: ["all", ["==", "$type", "Polygon"]], + layout: { + "line-cap": "round", + "line-join": "round", + }, + paint: { + "line-color": [ + "case", + ["==", ["get", "active"], "true"], + styling.active_color, + styling.line_color, + ], + "line-width": styling.line_width, + }, + }, + // Midpoints + { + id: "gl-draw-polygon-midpoint", + type: "circle", + filter: ["all", ["==", "$type", "Point"], ["==", "meta", "midpoint"]], + paint: { + "circle-radius": 3, + "circle-color": styling.active_color, + }, + }, + // Vertex point halos + { + id: "gl-draw-vertex-halo-active", + type: "circle", + filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"]], + paint: { + "circle-radius": [ + "case", + ["==", ["get", "active"], "true"], + styling.vertex_radius + 4, + styling.vertex_radius + 2, + ], + "circle-color": "#FFF", + }, + }, + // Vertex points + { + id: "gl-draw-vertex-active", + type: "circle", + filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"]], + paint: { + "circle-radius": [ + "case", + ["==", ["get", "active"], "true"], + styling.vertex_radius + 2, + styling.vertex_radius, + ], + "circle-color": styling.active_color, + }, + }, + ]; +} + HTMLWidgets.widget({ - name: "mapboxgl", + name: "mapboxgl", + + type: "output", + + factory: function (el, width, height) { + let map; + let draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + + mapboxgl.accessToken = x.access_token; + + map = new mapboxgl.Map({ + container: el.id, + style: x.style, + center: x.center, + zoom: x.zoom, + bearing: x.bearing, + pitch: x.pitch, + projection: x.projection, + parallels: x.parallels, + ...x.additional_params, + }); + + map.controls = []; + + map.on("style.load", function () { + map.resize(); + + if (HTMLWidgets.shinyMode) { + map.on("load", function () { + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.setInputValue(el.id + "_zoom", zoom); + Shiny.setInputValue(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.setInputValue(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + + map.on("moveend", function (e) { + var map = e.target; + var bounds = map.getBounds(); + var center = map.getCenter(); + var zoom = map.getZoom(); + + Shiny.onInputChange(el.id + "_zoom", zoom); + Shiny.onInputChange(el.id + "_center", { + lng: center.lng, + lat: center.lat, + }); + Shiny.onInputChange(el.id + "_bbox", { + xmin: bounds.getWest(), + ymin: bounds.getSouth(), + xmax: bounds.getEast(), + ymax: bounds.getNorth(), + }); + }); + } + + // Set config properties if provided + if (x.config_properties) { + x.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + if (x.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + x.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML(marker.popup), + ); + } - type: "output", + if (HTMLWidgets.shinyMode) { + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(el.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(el.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + }); + } + } - factory: function (el, width, height) { - let map; - let draw; + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (x.sources) { + x.sources.forEach(function (source) { + if (source.type === "vector") { + const sourceOptions = { + type: "vector", + url: source.url, + }; + // Add promoteId if provided + if (source.promoteId) { + sourceOptions.promoteId = source.promoteId; + } + // Add any other additional options + for (const [key, value] of Object.entries(source)) { + if (!["id", "type", "url"].includes(key)) { + sourceOptions[key] = value; + } + } + map.addSource(source.id, sourceOptions); + } else if (source.type === "geojson") { + const geojsonData = source.data; + const sourceOptions = { + type: "geojson", + data: geojsonData, + generateId: source.generateId, + }; - return { - renderValue: function (x) { - if (typeof mapboxgl === "undefined") { - console.error("Mapbox GL JS is not loaded."); - return; + // Add additional options + for (const [key, value] of Object.entries(source)) { + if (!["id", "type", "data", "generateId"].includes(key)) { + sourceOptions[key] = value; + } } - mapboxgl.accessToken = x.access_token; - - map = new mapboxgl.Map({ - container: el.id, - style: x.style, - center: x.center, - zoom: x.zoom, - bearing: x.bearing, - pitch: x.pitch, - projection: x.projection, - parallels: x.parallels, - ...x.additional_params, + map.addSource(source.id, sourceOptions); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (x.layers) { + x.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; - map.controls = []; - - map.on("style.load", function () { - map.resize(); - - if (HTMLWidgets.shinyMode) { - map.on("load", function () { - var bounds = map.getBounds(); - var center = map.getCenter(); - var zoom = map.getZoom(); - - Shiny.setInputValue(el.id + "_zoom", zoom); - Shiny.setInputValue(el.id + "_center", { - lng: center.lng, - lat: center.lat, - }); - Shiny.setInputValue(el.id + "_bbox", { - xmin: bounds.getWest(), - ymin: bounds.getSouth(), - xmax: bounds.getEast(), - ymax: bounds.getNorth(), - }); - }); - - map.on("moveend", function (e) { - var map = e.target; - var bounds = map.getBounds(); - var center = map.getCenter(); - var zoom = map.getZoom(); - - Shiny.onInputChange(el.id + "_zoom", zoom); - Shiny.onInputChange(el.id + "_center", { - lng: center.lng, - lat: center.lat, - }); - Shiny.onInputChange(el.id + "_bbox", { - xmin: bounds.getWest(), - ymin: bounds.getSouth(), - xmax: bounds.getEast(), - ymax: bounds.getNorth(), - }); - }); - } + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } - // Set config properties if provided - if (x.config_properties) { - x.config_properties.forEach(function (config) { - map.setConfigProperty( - config.importId, - config.configName, - config.value, - ); - }); - } + if (layer.source_layer) { + layerConfig["source-layer"] = layer.source_layer; + } - if (x.markers) { - if (!window.mapboxglMarkers) { - window.mapboxglMarkers = []; - } - x.markers.forEach(function (marker) { - const markerOptions = { - color: marker.color, - rotation: marker.rotation, - draggable: marker.options.draggable || false, - ...marker.options, - }; - const mapMarker = new mapboxgl.Marker(markerOptions) - .setLngLat([marker.lng, marker.lat]) - .addTo(map); - - if (marker.popup) { - mapMarker.setPopup( - new mapboxgl.Popup({ offset: 25 }).setHTML( - marker.popup, - ), - ); - } - - if (HTMLWidgets.shinyMode) { - const markerId = marker.id; - if (markerId) { - const lngLat = mapMarker.getLngLat(); - Shiny.setInputValue( - el.id + "_marker_" + markerId, - { - id: markerId, - lng: lngLat.lng, - lat: lngLat.lat, - }, - ); - - mapMarker.on("dragend", function () { - const lngLat = mapMarker.getLngLat(); - Shiny.setInputValue( - el.id + "_marker_" + markerId, - { - id: markerId, - lng: lngLat.lng, - lat: lngLat.lat, - }, - ); - }); - } - } - - window.mapboxglMarkers.push(mapMarker); - }); - } + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } - // Add sources if provided - if (x.sources) { - x.sources.forEach(function (source) { - if (source.type === "vector") { - map.addSource(source.id, { - type: "vector", - url: source.url, - }); - } else if (source.type === "geojson") { - const geojsonData = source.data; - const sourceOptions = { - type: "geojson", - data: geojsonData, - generateId: source.generateId, - }; - - // Add additional options - for (const [key, value] of Object.entries( - source, - )) { - if ( - ![ - "id", - "type", - "data", - "generateId", - ].includes(key) - ) { - sourceOptions[key] = value; - } - } - - map.addSource(source.id, sourceOptions); - } else if (source.type === "raster") { - if (source.url) { - map.addSource(source.id, { - type: "raster", - url: source.url, - tileSize: source.tileSize, - maxzoom: source.maxzoom, - }); - } else if (source.tiles) { - map.addSource(source.id, { - type: "raster", - tiles: source.tiles, - tileSize: source.tileSize, - maxzoom: source.maxzoom, - }); - } - } else if (source.type === "raster-dem") { - map.addSource(source.id, { - type: "raster-dem", - url: source.url, - tileSize: source.tileSize, - maxzoom: source.maxzoom, - }); - } else if (source.type === "image") { - map.addSource(source.id, { - type: "image", - url: source.url, - coordinates: source.coordinates, - }); - } else if (source.type === "video") { - map.addSource(source.id, { - type: "video", - urls: source.urls, - coordinates: source.coordinates, - }); - } - }); - } + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } - // Add layers if provided - if (x.layers) { - x.layers.forEach(function (layer) { - try { - const layerConfig = { - id: layer.id, - type: layer.type, - source: layer.source, - layout: layer.layout || {}, - paint: layer.paint || {}, - }; - - // Check if source is an object and set generateId if source type is 'geojson' - if ( - typeof layer.source === "object" && - layer.source.type === "geojson" - ) { - layerConfig.source.generateId = true; - } else if (typeof layer.source === "string") { - // Handle string source if needed - layerConfig.source = layer.source; - } - - if (layer.source_layer) { - layerConfig["source-layer"] = - layer.source_layer; - } - - if (layer.slot) { - layerConfig["slot"] = layer.slot; - } - - if (layer.minzoom) { - layerConfig["minzoom"] = layer.minzoom; - } - if (layer.maxzoom) { - layerConfig["maxzoom"] = layer.maxzoom; - } - - if (layer.filter) { - layerConfig["filter"] = layer.filter; - } - - if (layer.before_id) { - map.addLayer(layerConfig, layer.before_id); - } else { - map.addLayer(layerConfig); - } - - // Add popups or tooltips if provided - if (layer.popup) { - map.on("click", layer.id, function (e) { - const description = - e.features[0].properties[ - layer.popup - ]; - - new mapboxgl.Popup() - .setLngLat(e.lngLat) - .setHTML(description) - .addTo(map); - }); - - // Change cursor to pointer when hovering over the layer - map.on("mouseenter", layer.id, function () { - map.getCanvas().style.cursor = - "pointer"; - }); - - // Change cursor back to default when leaving the layer - map.on("mouseleave", layer.id, function () { - map.getCanvas().style.cursor = ""; - }); - } - - if (layer.tooltip) { - const tooltip = new mapboxgl.Popup({ - closeButton: false, - closeOnClick: false, - }); - - // Create a reference to the mousemove handler function. - // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. - const mouseMoveHandler = function(e) { - onMouseMoveTooltip(e, map, tooltip, layer.tooltip); - }; - - // Create a reference to the mouseleave handler function. - // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. - const mouseLeaveHandler = function() { - onMouseLeaveTooltip(map, tooltip); - }; - - // Attach the named handler references, not anonymous functions. - map.on("mousemove", layer.id, mouseMoveHandler); - map.on("mouseleave", layer.id, mouseLeaveHandler); - - // Store these handler references so you can remove them later if needed - if (!window._mapboxHandlers) { - window._mapboxHandlers = {}; - } - window._mapboxHandlers[layer.id] = { - mousemove: mouseMoveHandler, - mouseleave: mouseLeaveHandler - }; - } - - // Add hover effect if provided - if (layer.hover_options) { - const jsHoverOptions = {}; - for (const [key, value] of Object.entries( - layer.hover_options, - )) { - const jsKey = key.replace(/_/g, "-"); - jsHoverOptions[jsKey] = value; - } - - let hoveredFeatureId = null; - - map.on("mousemove", layer.id, function (e) { - if (e.features.length > 0) { - if (hoveredFeatureId !== null) { - const featureState = { - source: - typeof layer.source === - "string" - ? layer.source - : layer.id, - id: hoveredFeatureId, - }; - if (layer.source_layer) { - featureState.sourceLayer = - layer.source_layer; - } - map.setFeatureState( - featureState, - { hover: false }, - ); - } - hoveredFeatureId = e.features[0].id; - const featureState = { - source: - typeof layer.source === - "string" - ? layer.source - : layer.id, - id: hoveredFeatureId, - }; - if (layer.source_layer) { - featureState.sourceLayer = - layer.source_layer; - } - map.setFeatureState(featureState, { - hover: true, - }); - } - }); - - map.on("mouseleave", layer.id, function () { - if (hoveredFeatureId !== null) { - const featureState = { - source: - typeof layer.source === - "string" - ? layer.source - : layer.id, - id: hoveredFeatureId, - }; - if (layer.source_layer) { - featureState.sourceLayer = - layer.source_layer; - } - map.setFeatureState(featureState, { - hover: false, - }); - } - hoveredFeatureId = null; - }); - - Object.keys(jsHoverOptions).forEach( - function (key) { - const originalPaint = - map.getPaintProperty( - layer.id, - key, - ) || layer.paint[key]; - map.setPaintProperty( - layer.id, - key, - [ - "case", - [ - "boolean", - [ - "feature-state", - "hover", - ], - false, - ], - jsHoverOptions[key], - originalPaint, - ], - ); - }, - ); - } - } catch (e) { - console.error( - "Failed to add layer: ", - layer, - e, - ); - } - }); - } + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } - // Apply setFilter if provided - if (x.setFilter) { - x.setFilter.forEach(function (filter) { - map.setFilter(filter.layer, filter.filter); - }); - } + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } - // Set terrain if provided - if (x.terrain) { - map.setTerrain({ - source: x.terrain.source, - exaggeration: x.terrain.exaggeration, - }); - } + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } - // Set fog - if (x.fog) { - map.setFog(x.fog); - } + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, layer.popup, layer.id); + }; - if (x.fitBounds) { - map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); - } - if (x.flyTo) { - map.flyTo(x.flyTo); - } - if (x.easeTo) { - map.easeTo(x.easeTo); - } - if (x.setCenter) { - map.setCenter(x.setCenter); - } - if (x.setZoom) { - map.setZoom(x.setZoom); - } - if (x.jumpTo) { - map.jumpTo(x.jumpTo); - } + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layer.id] = clickHandler; - // Add scale control if enabled - if (x.scale_control) { - const scaleControl = new mapboxgl.ScaleControl({ - maxWidth: x.scale_control.maxWidth, - unit: x.scale_control.unit, - }); - map.addControl(scaleControl, x.scale_control.position); - map.controls.push(scaleControl); - } + // Add the click handler + map.on("click", layer.id, clickHandler); - // Add globe minimap if enabled - if (x.globe_minimap && x.globe_minimap.enabled) { - const globeMinimapOptions = { - globeSize: x.globe_minimap.globe_size, - landColor: x.globe_minimap.land_color, - waterColor: x.globe_minimap.water_color, - markerColor: x.globe_minimap.marker_color, - markerSize: x.globe_minimap.marker_size, - }; - const globeMinimap = new GlobeMinimap( - globeMinimapOptions, - ); - map.addControl(globeMinimap, x.globe_minimap.position); - map.controls.push(globeMinimap); - } + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); - // Add geocoder control if enabled - if (x.geocoder_control) { - const geocoderOptions = { - accessToken: mapboxgl.accessToken, - mapboxgl: mapboxgl, - ...x.geocoder_control, - }; + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } - // Set default values if not provided - if (!geocoderOptions.placeholder) - geocoderOptions.placeholder = "Search"; - if (typeof geocoderOptions.collapsed === "undefined") - geocoderOptions.collapsed = false; - - const geocoder = new MapboxGeocoder(geocoderOptions); - - map.addControl( - geocoder, - x.geocoder_control.position || "top-right", - ); - map.controls.push(geocoder); - - // Handle geocoder results in Shiny mode - if (HTMLWidgets.shinyMode) { - geocoder.on("result", function (e) { - Shiny.setInputValue(el.id + "_geocoder", { - result: e.result, - time: new Date(), - }); - }); - } - } + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, layer.tooltip); + }; + + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } - if (x.draw_control && x.draw_control.enabled) { - let drawOptions = x.draw_control.options || {}; - - if (x.draw_control.freehand) { - drawOptions = Object.assign({}, drawOptions, { - modes: Object.assign({}, MapboxDraw.modes, { - draw_polygon: Object.assign( - {}, - MapboxDraw.modes.draw_freehand, - { - // Store the simplify_freehand option on the map object - onSetup: function (opts) { - const state = - MapboxDraw.modes.draw_freehand.onSetup.call( - this, - opts, - ); - this.map.simplify_freehand = - x.draw_control.simplify_freehand; - return state; - }, - }, - ), - }), - // defaultMode: 'draw_polygon' # Don't set the default yet - }); - } + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } - draw = new MapboxDraw(drawOptions); - map.addControl(draw, x.draw_control.position); - map.controls.push(draw); - - // Add event listeners - map.on("draw.create", updateDrawnFeatures); - map.on("draw.delete", updateDrawnFeatures); - map.on("draw.update", updateDrawnFeatures); - - // Apply orientation styling - if (x.draw_control.orientation === "horizontal") { - const drawBar = map - .getContainer() - .querySelector(".mapboxgl-ctrl-group"); - if (drawBar) { - drawBar.style.display = "flex"; - drawBar.style.flexDirection = "row"; - } + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = layer.source_layer; } + map.setFeatureState(featureState, { hover: false }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof layer.source === "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); } - - function updateDrawnFeatures() { - if (draw) { - var drawnFeatures = draw.getAll(); - if (HTMLWidgets.shinyMode) { - Shiny.setInputValue( - el.id + "_drawn_features", - JSON.stringify(drawnFeatures), - ); - } - // Store drawn features in the widget's data - if (el.querySelector) { - var widget = HTMLWidgets.find("#" + el.id); - if (widget) { - widget.drawFeatures = drawnFeatures; - } - } - } + }); + + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(layer.id, key) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + }); + } + + // Apply setFilter if provided + if (x.setFilter) { + x.setFilter.forEach(function (filter) { + map.setFilter(filter.layer, filter.filter); + }); + } + + // Set terrain if provided + if (x.terrain) { + map.setTerrain({ + source: x.terrain.source, + exaggeration: x.terrain.exaggeration, + }); + } + + // Set fog + if (x.fog) { + map.setFog(x.fog); + } + + // Set rain effect if provided + if (x.rain) { + map.setRain(x.rain); + } + + // Set snow effect if provided + if (x.snow) { + map.setSnow(x.snow); + } + + if (x.fitBounds) { + map.fitBounds(x.fitBounds.bounds, x.fitBounds.options); + } + if (x.flyTo) { + map.flyTo(x.flyTo); + } + if (x.easeTo) { + map.easeTo(x.easeTo); + } + if (x.setCenter) { + map.setCenter(x.setCenter); + } + if (x.setZoom) { + map.setZoom(x.setZoom); + } + if (x.jumpTo) { + map.jumpTo(x.jumpTo); + } + + // Add scale control if enabled + if (x.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: x.scale_control.maxWidth, + unit: x.scale_control.unit, + }); + map.addControl(scaleControl, x.scale_control.position); + map.controls.push(scaleControl); + } + + // Add globe minimap if enabled + if (x.globe_minimap && x.globe_minimap.enabled) { + const globeMinimapOptions = { + globeSize: x.globe_minimap.globe_size, + landColor: x.globe_minimap.land_color, + waterColor: x.globe_minimap.water_color, + markerColor: x.globe_minimap.marker_color, + markerSize: x.globe_minimap.marker_size, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, x.globe_minimap.position); + map.controls.push(globeMinimap); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function (key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + } - if (!x.add) { - const existingLegends = - el.querySelectorAll(".mapboxgl-legend"); - existingLegends.forEach((legend) => legend.remove()); - } + customControlContainer.innerHTML = controlOptions.html; - if (x.legend_html && x.legend_css) { - const legendCss = document.createElement("style"); - legendCss.innerHTML = x.legend_css; - document.head.appendChild(legendCss); + const customControl = { + onAdd: function () { + return customControlContainer; + }, + onRemove: function () { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild( + customControlContainer, + ); + } + }, + }; + + map.addControl( + customControl, + controlOptions.position || "top-right", + ); + map.controls.push(customControl); + }); + } + + // Add geocoder control if enabled + if (x.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...x.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + x.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("result", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + } + + if (x.draw_control && x.draw_control.enabled) { + let drawOptions = x.draw_control.options || {}; + + // Generate styles if styling parameters provided + if (x.draw_control.styling) { + const generatedStyles = generateDrawStyles( + x.draw_control.styling, + ); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } - const legend = document.createElement("div"); - legend.innerHTML = x.legend_html; - legend.classList.add("mapboxgl-legend"); - el.appendChild(legend); - } + if (x.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + x.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } - // Add fullscreen control if enabled - if (x.fullscreen_control && x.fullscreen_control.enabled) { - const position = - x.fullscreen_control.position || "top-right"; - const fullscreen = new mapboxgl.FullscreenControl(); - map.addControl(fullscreen, position); - map.controls.push(fullscreen); - } + draw = new MapboxDraw(drawOptions); + map.addControl(draw, x.draw_control.position); + map.controls.push(draw); - // Add geolocate control if enabled - if (x.geolocate_control) { - const geolocate = new mapboxgl.GeolocateControl({ - positionOptions: - x.geolocate_control.positionOptions, - trackUserLocation: - x.geolocate_control.trackUserLocation, - showAccuracyCircle: - x.geolocate_control.showAccuracyCircle, - showUserLocation: - x.geolocate_control.showUserLocation, - showUserHeading: - x.geolocate_control.showUserHeading, - fitBoundsOptions: - x.geolocate_control.fitBoundsOptions, - }); - map.addControl(geolocate, x.geolocate_control.position); - map.controls.push(geolocate); - - if (HTMLWidgets.shinyMode) { - geolocate.on("geolocate", function (event) { - console.log("Geolocate event triggered"); - console.log("Element ID:", el.id); - console.log("Event coords:", event.coords); - - Shiny.setInputValue(el.id + "_geolocate", { - coords: event.coords, - time: new Date(), - }); - }); - - geolocate.on("trackuserlocationstart", function () { - Shiny.setInputValue( - el.id + "_geolocate_tracking", - { - status: "start", - time: new Date(), - }, - ); - }); - - geolocate.on("trackuserlocationend", function () { - Shiny.setInputValue( - el.id + "_geolocate_tracking", - { - status: "end", - time: new Date(), - }, - ); - }); - - geolocate.on("error", function (error) { - if (error.error.code === 1) { - Shiny.setInputValue( - el.id + "_geolocate_error", - { - message: - "Location permission denied", - time: new Date(), - }, - ); - } - }); - } - } + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); - // Add navigation control if enabled - if (x.navigation_control) { - const nav = new mapboxgl.NavigationControl({ - showCompass: x.navigation_control.show_compass, - showZoom: x.navigation_control.show_zoom, - visualizePitch: - x.navigation_control.visualize_pitch, - }); - map.addControl(nav, x.navigation_control.position); - map.controls.push(nav); - - if (x.navigation_control.orientation === "horizontal") { - const navBar = map - .getContainer() - .querySelector( - ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", - ); - if (navBar) { - navBar.style.display = "flex"; - navBar.style.flexDirection = "row"; - } - } - } + // Add initial features if provided + if (x.draw_control.source) { + addSourceFeaturesToDraw(draw, x.draw_control.source, map); + } - // Add reset control if enabled - if (x.reset_control) { - const resetControl = document.createElement("button"); - resetControl.className = - "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; - resetControl.type = "button"; - resetControl.setAttribute("aria-label", "Reset"); - resetControl.innerHTML = "⟲"; - resetControl.style.fontSize = "30px"; - resetControl.style.fontWeight = "bold"; - resetControl.style.backgroundColor = "white"; - resetControl.style.border = "none"; - resetControl.style.cursor = "pointer"; - resetControl.style.padding = "0"; - resetControl.style.width = "30px"; - resetControl.style.height = "30px"; - resetControl.style.display = "flex"; - resetControl.style.justifyContent = "center"; - resetControl.style.alignItems = "center"; - resetControl.style.transition = "background-color 0.2s"; - resetControl.addEventListener("mouseover", function () { - this.style.backgroundColor = "#f0f0f0"; - }); - resetControl.addEventListener("mouseout", function () { - this.style.backgroundColor = "white"; - }); - - const resetContainer = document.createElement("div"); - resetContainer.className = - "mapboxgl-ctrl mapboxgl-ctrl-group"; - resetContainer.appendChild(resetControl); - - const initialView = { - center: x.center, - zoom: x.zoom, - pitch: x.pitch, - bearing: x.bearing, - animate: x.reset_control.animate, - }; + // Process any queued features + if (x.draw_features_queue) { + x.draw_features_queue.forEach(function (data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } - if (x.reset_control.duration) { - initialView.duration = x.reset_control.duration; - } + // Apply orientation styling + if (x.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn("Source not found or has no data:", sourceId); + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + } + + if (!x.add) { + const existingLegends = el.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + } + + if (x.legend_html && x.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = x.legend_css; + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = x.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if (x.fullscreen_control && x.fullscreen_control.enabled) { + const position = x.fullscreen_control.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } + + // Add geolocate control if enabled + if (x.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: x.geolocate_control.positionOptions, + trackUserLocation: x.geolocate_control.trackUserLocation, + showAccuracyCircle: x.geolocate_control.showAccuracyCircle, + showUserLocation: x.geolocate_control.showUserLocation, + showUserHeading: x.geolocate_control.showUserHeading, + fitBoundsOptions: x.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, x.geolocate_control.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + console.log("Geolocate event triggered"); + console.log("Element ID:", el.id); + console.log("Event coords:", event.coords); + + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); - resetControl.onclick = function () { - map.easeTo(initialView); - }; + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); - map.addControl( - { - onAdd: function () { - return resetContainer; - }, - onRemove: function () { - resetContainer.parentNode.removeChild( - resetContainer, - ); - }, - }, - x.reset_control.position, - ); - - map.controls.push({ - onAdd: function () { - return resetContainer; - }, - onRemove: function () { - resetContainer.parentNode.removeChild( - resetContainer, - ); - }, - }); - } + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } + + // Add navigation control if enabled + if (x.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: x.navigation_control.show_compass, + showZoom: x.navigation_control.show_zoom, + visualizePitch: x.navigation_control.visualize_pitch, + }); + map.addControl(nav, x.navigation_control.position); + map.controls.push(nav); + + if (x.navigation_control.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } + + // Add reset control if enabled + if (x.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + // Initialize with empty object, will be populated after map loads + let initialView = {}; + + // Capture the initial view after the map has loaded and all view operations are complete + map.once("load", function () { + initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: x.reset_control.animate, + }; + + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + }); - if (x.images && Array.isArray(x.images)) { - x.images.forEach(function (imageInfo) { - map.loadImage( - imageInfo.url, - function (error, image) { - if (error) { - console.error( - "Error loading image:", - error, - ); - return; - } - if (!map.hasImage(imageInfo.id)) { - map.addImage( - imageInfo.id, - image, - imageInfo.options, - ); - } - }, - ); - }); - } else if (x.images) { - console.error("x.images is not an array:", x.images); - } + resetControl.onclick = function () { + // Only reset if we have captured the initial view + if (initialView.center) { + map.easeTo(initialView); + } + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }, + x.reset_control.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } + + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + map.setProjection(projectionConfig.projection); + } + }); + } + + if (x.images && Array.isArray(x.images)) { + x.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; + } + if (!map.hasImage(imageInfo.id)) { + map.addImage(imageInfo.id, image, imageInfo.options); + } + }); + }); + } else if (x.images) { + console.error("x.images is not an array:", x.images); + } + + // Add the layers control if provided + if (x.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = x.layers_control.control_id; + layersControl.className = x.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } - // Add the layers control if provided - if (x.layers_control) { - const layersControl = document.createElement("div"); - layersControl.id = x.layers_control.control_id; - layersControl.className = x.layers_control.collapsible - ? "layers-control collapsible" - : "layers-control"; - layersControl.style.position = "absolute"; - layersControl.style[ - x.layers_control.position || "top-right" - ] = "10px"; - el.appendChild(layersControl); - - const layersList = document.createElement("div"); - layersList.className = "layers-list"; - layersControl.appendChild(layersList); - - // Fetch layers to be included in the control - let layers = - x.layers_control.layers || - map.getStyle().layers.map((layer) => layer.id); - - // Ensure layers is always an array - if (!Array.isArray(layers)) { - layers = [layers]; - } + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; - layers.forEach((layerId, index) => { - const link = document.createElement("a"); - link.id = layerId; - link.href = "#"; - link.textContent = layerId; - link.className = "active"; - - // Show or hide layer when the toggle is clicked - link.onclick = function (e) { - const clickedLayer = this.textContent; - e.preventDefault(); - e.stopPropagation(); - - const visibility = map.getLayoutProperty( - clickedLayer, - "visibility", - ); - - // Toggle layer visibility by changing the layout object's visibility property - if (visibility === "visible") { - map.setLayoutProperty( - clickedLayer, - "visibility", - "none", - ); - this.className = ""; - } else { - this.className = "active"; - map.setLayoutProperty( - clickedLayer, - "visibility", - "visible", - ); - } - }; - - layersList.appendChild(link); - }); - - // Handle collapsible behavior - if (x.layers_control.collapsible) { - const toggleButton = document.createElement("div"); - toggleButton.className = "toggle-button"; - toggleButton.textContent = "Layers"; - toggleButton.onclick = function () { - layersControl.classList.toggle("open"); - }; - layersControl.insertBefore( - toggleButton, - layersList, - ); - } - } + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; - // If clusters are present, add event handling - map.getStyle().layers.forEach((layer) => { - if (layer.id.includes("-clusters")) { - map.on("click", layer.id, (e) => { - const features = map.queryRenderedFeatures( - e.point, - { - layers: [layer.id], - }, - ); - const clusterId = - features[0].properties.cluster_id; - map.getSource( - layer.source, - ).getClusterExpansionZoom( - clusterId, - (err, zoom) => { - if (err) return; - - map.easeTo({ - center: features[0].geometry - .coordinates, - zoom: zoom, - }); - }, - ); - }); - - map.on("mouseenter", layer.id, () => { - map.getCanvas().style.cursor = "pointer"; - }); - map.on("mouseleave", layer.id, () => { - map.getCanvas().style.cursor = ""; - }); - } - }); + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } - // Add click event listener in shinyMode - if (HTMLWidgets.shinyMode) { - map.on("click", function (e) { - const features = map.queryRenderedFeatures(e.point); - - if (features.length > 0) { - const feature = features[0]; - Shiny.onInputChange(el.id + "_feature_click", { - id: feature.id, - properties: feature.properties, - layer: feature.layer.id, - lng: e.lngLat.lng, - lat: e.lngLat.lat, - time: new Date(), - }); - } else { - Shiny.onInputChange( - el.id + "_feature_click", - null, - ); - } - - // Event listener for the map - Shiny.onInputChange(el.id + "_click", { - lng: e.lngLat.lng, - lat: e.lngLat.lat, - time: new Date(), - }); - }); - } + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } - el.map = map; - }); + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } - el.map = map; - }, + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } - getMap: function () { - return map; // Return the map instance - }, + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } - getDrawnFeatures: function () { - return ( - this.drawFeatures || { - type: "FeatureCollection", - features: [], - } + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + x.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", ); - }, - resize: function (width, height) { - if (map) { - map.resize(); + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty(clickedLayer, "visibility", "none"); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty(clickedLayer, "visibility", "visible"); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); } - }, - }; - }, + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (x.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + } + + // If clusters are present, add event handling + map.getStyle().layers.forEach((layer) => { + if (layer.id.includes("-clusters")) { + map.on("click", layer.id, (e) => { + const features = map.queryRenderedFeatures(e.point, { + layers: [layer.id], + }); + const clusterId = features[0].properties.cluster_id; + map + .getSource(layer.source) + .getClusterExpansionZoom(clusterId, (err, zoom) => { + if (err) return; + + map.easeTo({ + center: features[0].geometry.coordinates, + zoom: zoom, + }); + }); + }); + + map.on("mouseenter", layer.id, () => { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layer.id, () => { + map.getCanvas().style.cursor = ""; + }); + } + }); + + // Add click event listener in shinyMode + if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if (features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_click", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange(el.id + "_feature_click", null); + } + + // Event listener for the map + Shiny.onInputChange(el.id + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + }); + } + + el.map = map; + }); + + el.map = map; + }, + + getMap: function () { + return map; // Return the map instance + }, + + getDraw: function () { + return draw; // Return the draw instance + }, + + getDrawnFeatures: function () { + return ( + this.drawFeatures || { + type: "FeatureCollection", + features: [], + } + ); + }, + + resize: function (width, height) { + if (map) { + map.resize(); + } + }, + }; + }, }); if (HTMLWidgets.shinyMode) { - Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { - var widget = HTMLWidgets.find("#" + data.id); - if (!widget) return; - var map = widget.getMap(); - if (map) { - var message = data.message; - if (message.type === "set_filter") { - map.setFilter(message.layer, message.filter); - } else if (message.type === "add_source") { - if (message.source.type === "vector") { - map.addSource(message.source.id, { - type: "vector", - url: message.source.url, - }); - } else if (message.source.type === "geojson") { - map.addSource(message.source.id, { - type: "geojson", - data: message.source.data, - generateId: message.source.generateId, - }); - } else if (message.source.type === "raster") { - if (message.source.url) { - map.addSource(message.source.id, { - type: "raster", - url: message.source.url, - tileSize: message.source.tileSize, - maxzoom: message.source.maxzoom, - }); - } else if (message.source.tiles) { - map.addSource(message.source.id, { - type: "raster", - tiles: message.source.tiles, - tileSize: message.source.tileSize, - maxzoom: message.source.maxzoom, - }); - } - } else if (message.source.type === "raster-dem") { - map.addSource(message.source.id, { - type: "raster-dem", - url: message.source.url, - tileSize: message.source.tileSize, - maxzoom: message.source.maxzoom, - }); - } else if (message.source.type === "image") { - map.addSource(message.source.id, { - type: "image", - url: message.source.url, - coordinates: message.source.coordinates, - }); - } else if (message.source.type === "video") { - map.addSource(message.source.id, { - type: "video", - urls: message.source.urls, - coordinates: message.source.coordinates, - }); - } - } else if (message.type === "add_layer") { - try { - if (message.layer.before_id) { - map.addLayer(message.layer, message.layer.before_id); - } else { - map.addLayer(message.layer); - } + Shiny.addCustomMessageHandler("mapboxgl-proxy", function (data) { + var widget = HTMLWidgets.find("#" + data.id); + if (!widget) return; + var map = widget.getMap(); + if (map) { + var message = data.message; + + // Initialize layer state tracking if not already present + if (!window._mapglLayerState) { + window._mapglLayerState = {}; + } + const mapId = map.getContainer().id; + if (!window._mapglLayerState[mapId]) { + window._mapglLayerState[mapId] = { + filters: {}, // layerId -> filter expression + paintProperties: {}, // layerId -> {propertyName -> value} + layoutProperties: {}, // layerId -> {propertyName -> value} + tooltips: {}, // layerId -> tooltip property + popups: {}, // layerId -> popup property + legends: {}, // legendId -> {html: string, css: string} + }; + } + const layerState = window._mapglLayerState[mapId]; + + // Helper function to update drawn features + function updateDrawnFeatures() { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + var drawnFeatures = drawControl.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + // Track filter state for layer restoration + layerState.filters[message.layer] = message.filter; + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + const sourceConfig = { + type: "vector", + url: message.source.url, + }; + // Add promoteId if provided + if (message.source.promoteId) { + sourceConfig.promoteId = message.source.promoteId; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "url" && + key !== "promoteId" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "geojson") { + const sourceConfig = { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "data" && + key !== "generateId" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "raster") { + const sourceConfig = { + type: "raster", + tileSize: message.source.tileSize, + }; + if (message.source.url) { + sourceConfig.url = message.source.url; + } else if (message.source.tiles) { + sourceConfig.tiles = message.source.tiles; + } + if (message.source.maxzoom) { + sourceConfig.maxzoom = message.source.maxzoom; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "url" && + key !== "tiles" && + key !== "tileSize" && + key !== "maxzoom" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "raster-dem") { + const sourceConfig = { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + }; + if (message.source.maxzoom) { + sourceConfig.maxzoom = message.source.maxzoom; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "url" && + key !== "tileSize" && + key !== "maxzoom" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "image") { + const sourceConfig = { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "url" && + key !== "coordinates" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "video") { + const sourceConfig = { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "urls" && + key !== "coordinates" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } - // Add popups or tooltips if provided - if (message.layer.popup) { - map.on("click", message.layer.id, function (e) { - const description = - e.features[0].properties[message.layer.popup]; - new mapboxgl.Popup() - .setLngLat(e.lngLat) - .setHTML(description) - .addTo(map); - }); - - // Change cursor to pointer when hovering over the layer - map.on("mouseenter", message.layer.id, function () { - map.getCanvas().style.cursor = "pointer"; - }); - - // Change cursor back to default when leaving the layer - map.on("mouseleave", message.layer.id, function () { - map.getCanvas().style.cursor = ""; - }); - } + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, message.layer.popup, message.layer.id); + }; - if (message.layer.tooltip) { - const tooltip = new mapboxgl.Popup({ - closeButton: false, - closeOnClick: false, - }); + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, message.layer.tooltip); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on("mouseleave", message.layer.id, mouseLeaveHandler); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } - // Define named handler functions: - const mouseMoveHandler = function(e) { - onMouseMoveTooltip(e, map, tooltip, message.layer.tooltip); - }; + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, + }); + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error("Failed to add layer via proxy: ", message.layer, e); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } - const mouseLeaveHandler = function() { - onMouseLeaveTooltip(map, tooltip); - }; + // If there's an active popup for this layer, remove it + if (window._mapboxPopups && window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } - // Attach handlers by reference: - map.on("mousemove", message.layer.id, mouseMoveHandler); - map.on("mouseleave", message.layer.id, mouseLeaveHandler); + if (map.getLayer(message.layer)) { + // Remove tooltip handlers + if (window._mapboxHandlers && window._mapboxHandlers[message.layer]) { + const handlers = window._mapboxHandlers[message.layer]; + if (handlers.mousemove) { + map.off("mousemove", message.layer, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", message.layer, handlers.mouseleave); + } + // Clean up the reference + delete window._mapboxHandlers[message.layer]; + } + + // Remove click handlers for popups + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer] + ) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer], + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Remove the layer + map.removeLayer(message.layer); + } + if (map.getSource(message.layer)) { + map.removeSource(message.layer); + } - // Store these handler references for later removal: - if (!window._mapboxHandlers) { - window._mapboxHandlers = {}; - } - window._mapboxHandlers[message.layer.id] = { - mousemove: mouseMoveHandler, - mouseleave: mouseLeaveHandler - }; - } + // Clean up tracked layer state + const mapId = map.getContainer().id; + if (window._mapglLayerState && window._mapglLayerState[mapId]) { + const layerState = window._mapglLayerState[mapId]; + delete layerState.filters[message.layer]; + delete layerState.paintProperties[message.layer]; + delete layerState.layoutProperties[message.layer]; + delete layerState.tooltips[message.layer]; + delete layerState.popups[message.layer]; + // Note: legends are not tied to specific layers, so we don't clear them here + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty(message.layer, message.name, message.value); + // Track layout property state for layer restoration + if (!layerState.layoutProperties[message.layer]) { + layerState.layoutProperties[message.layer] = {}; + } + layerState.layoutProperties[message.layer][message.name] = + message.value; + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty(layerId, propertyName, newPaintProperty); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + // Track paint property state for layer restoration + if (!layerState.paintProperties[layerId]) { + layerState.paintProperties[layerId] = {}; + } + layerState.paintProperties[layerId][propertyName] = newValue; + } else if (message.type === "add_legend") { + // Extract legend ID from HTML to track it + const legendIdMatch = message.html.match(/id="([^"]+)"/); + const legendId = legendIdMatch ? legendIdMatch[1] : null; + + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll( + "style[data-mapgl-legend-css]", + ); + legendStyles.forEach((style) => style.remove()); + + // Clear legend state when replacing all legends + layerState.legends = {}; + } - // Add hover effect if provided - if (message.layer.hover_options) { - const jsHoverOptions = {}; - for (const [key, value] of Object.entries( - message.layer.hover_options, - )) { - const jsKey = key.replace(/_/g, "-"); - jsHoverOptions[jsKey] = value; - } + // Track legend state + if (legendId) { + layerState.legends[legendId] = { + html: message.html, + css: message.legend_css, + }; + } - let hoveredFeatureId = null; - - map.on("mousemove", message.layer.id, function (e) { - if (e.features.length > 0) { - if (hoveredFeatureId !== null) { - const featureState = { - source: - typeof message.layer.source === - "string" - ? message.layer.source - : message.layer.id, - id: hoveredFeatureId, - }; - if (message.layer.source_layer) { - featureState.sourceLayer = - message.layer.source_layer; - } - map.setFeatureState(featureState, { - hover: false, - }); - } - hoveredFeatureId = e.features[0].id; - const featureState = { - source: - typeof message.layer.source === "string" - ? message.layer.source - : message.layer.id, - id: hoveredFeatureId, - }; - if (message.layer.source_layer) { - featureState.sourceLayer = - message.layer.source_layer; - } - map.setFeatureState(featureState, { - hover: true, - }); - } - }); - - map.on("mouseleave", message.layer.id, function () { - if (hoveredFeatureId !== null) { - const featureState = { - source: - typeof message.layer.source === "string" - ? message.layer.source - : message.layer.id, - id: hoveredFeatureId, - }; - if (message.layer.source_layer) { - featureState.sourceLayer = - message.layer.source_layer; - } - map.setFeatureState(featureState, { - hover: false, - }); - } - hoveredFeatureId = null; - }); - - Object.keys(jsHoverOptions).forEach(function (key) { - const originalPaint = - map.getPaintProperty(message.layer.id, key) || - message.layer.paint[key]; - map.setPaintProperty(message.layer.id, key, [ - "case", - ["boolean", ["feature-state", "hover"], false], - jsHoverOptions[key], - originalPaint, - ]); - }); - } - } catch (e) { - console.error( - "Failed to add layer via proxy: ", - message.layer, - e, - ); + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute("data-mapgl-legend-css", data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + // Identify user-added sources (those not in the original style) + // We'll assume any source that's not "composite", "mapbox", or starts with "mapbox-" is user-added + for (const sourceId in currentStyle.sources) { + if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") + ) { + userSourceIds.push(sourceId); + const source = currentStyle.sources[sourceId]; + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find( + (l) => l.id === layerId, + ); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } } - } else if (message.type === "remove_layer") { - // If there's an active tooltip, remove it first - if (window._activeTooltip) { - window._activeTooltip.remove(); - delete window._activeTooltip; + } + } + } + + // Identify layers using user-added sources + currentStyle.layers.forEach(function (layer) { + if (userSourceIds.includes(layer.source)) { + userLayers.push(layer); + } + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function () { + // Re-add user sources + userSourceIds.forEach(function (sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function (layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + map.on("mouseleave", layer.id, handlers.mouseleave); + } } - if (map.getLayer(message.layer)) { - // Check if we have stored handlers for this layer - if (window._mapboxHandlers && window._mapboxHandlers[message.layer]) { - const handlers = window._mapboxHandlers[message.layer]; - if (handlers.mousemove) { - map.off("mousemove", message.layer, handlers.mousemove); - } - if (handlers.mouseleave) { - map.off("mouseleave", message.layer, handlers.mouseleave); - } - // Clean up the reference - delete window._mapboxHandlers[message.layer]; + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if ( + Array.isArray(value) && + value[0] === "case" && + Array.isArray(value[1]) && + value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && + value[1][1][1] === "hover" + ) { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); } - map.removeLayer(message.layer); + } } - if (map.getSource(message.layer)) { - map.removeSource(message.layer); + } + }); + + // Clear any active tooltips before restoration to prevent stacking + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Restore tracked layer modifications + const mapId = map.getContainer().id; + const savedLayerState = + window._mapglLayerState && window._mapglLayerState[mapId]; + if (savedLayerState) { + // Restore filters + for (const layerId in savedLayerState.filters) { + if (map.getLayer(layerId)) { + map.setFilter(layerId, savedLayerState.filters[layerId]); } - } else if (message.type === "fit_bounds") { - map.fitBounds(message.bounds, message.options); - } else if (message.type === "fly_to") { - map.flyTo(message.options); - } else if (message.type === "ease_to") { - map.easeTo(message.options); - } else if (message.type === "set_center") { - map.setCenter(message.center); - } else if (message.type === "set_zoom") { - map.setZoom(message.zoom); - } else if (message.type === "jump_to") { - map.jumpTo(message.options); - } else if (message.type === "set_layout_property") { - map.setLayoutProperty( - message.layer, - message.name, - message.value, - ); - } else if (message.type === "set_paint_property") { - const layerId = message.layer; - const propertyName = message.name; - const newValue = message.value; - - // Check if the layer has hover options - const layerStyle = map - .getStyle() - .layers.find((layer) => layer.id === layerId); - const currentPaintProperty = map.getPaintProperty( - layerId, - propertyName, - ); + } - if ( - currentPaintProperty && - Array.isArray(currentPaintProperty) && - currentPaintProperty[0] === "case" - ) { - // This property has hover options, so we need to preserve them - const hoverValue = currentPaintProperty[2]; - const newPaintProperty = [ + // Restore paint properties + for (const layerId in savedLayerState.paintProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.paintProperties[layerId]; + for (const propertyName in properties) { + const savedValue = properties[propertyName]; + + // Check if layer has hover effects that need to be preserved + const currentValue = map.getPaintProperty( + layerId, + propertyName, + ); + if ( + currentValue && + Array.isArray(currentValue) && + currentValue[0] === "case" + ) { + // Preserve hover effects while updating base value + const hoverValue = currentValue[2]; + const newPaintProperty = [ "case", ["boolean", ["feature-state", "hover"], false], hoverValue, - newValue, - ]; - map.setPaintProperty( + savedValue, + ]; + map.setPaintProperty( layerId, propertyName, newPaintProperty, - ); - } else { - // No hover options, just set the new value directly - map.setPaintProperty(layerId, propertyName, newValue); + ); + } else { + map.setPaintProperty(layerId, propertyName, savedValue); + } + } } - } else if (message.type === "add_legend") { - if (!message.add) { - const existingLegends = document.querySelectorAll( - `#${data.id} .mapboxgl-legend`, + } + + // Restore layout properties + for (const layerId in savedLayerState.layoutProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.layoutProperties[layerId]; + for (const propertyName in properties) { + map.setLayoutProperty( + layerId, + propertyName, + properties[propertyName], ); - existingLegends.forEach((legend) => legend.remove()); + } } + } - const legendCss = document.createElement("style"); - legendCss.innerHTML = message.legend_css; - document.head.appendChild(legendCss); - - const legend = document.createElement("div"); - legend.innerHTML = message.html; - legend.classList.add("mapboxgl-legend"); - document.getElementById(data.id).appendChild(legend); - } else if (message.type === "set_config_property") { - map.setConfigProperty( - message.importId, - message.configName, - message.value, - ); - } else if (message.type === "set_style") { - map.setStyle(message.style, { diff: message.diff }); - - if (message.config) { - Object.keys(message.config).forEach(function (key) { - map.setConfigProperty( - "basemap", - key, - message.config[key], - ); - }); - } - } else if (message.type === "add_navigation_control") { - const nav = new mapboxgl.NavigationControl({ - showCompass: message.options.show_compass, - showZoom: message.options.show_zoom, - visualizePitch: message.options.visualize_pitch, - }); - map.addControl(nav, message.position); - map.controls.push(nav); - - if (message.orientation === "horizontal") { - const navBar = map - .getContainer() - .querySelector( - ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", - ); - if (navBar) { - navBar.style.display = "flex"; - navBar.style.flexDirection = "row"; + // Restore tooltips + for (const layerId in savedLayerState.tooltips) { + if (map.getLayer(layerId)) { + const tooltipProperty = savedLayerState.tooltips[layerId]; + + // Remove existing tooltip handlers first + if ( + window._mapboxHandlers && + window._mapboxHandlers[layerId] + ) { + if (window._mapboxHandlers[layerId].mousemove) { + map.off( + "mousemove", + layerId, + window._mapboxHandlers[layerId].mousemove, + ); } - } - } else if (message.type === "add_reset_control") { - const resetControl = document.createElement("button"); - resetControl.className = - "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; - resetControl.type = "button"; - resetControl.setAttribute("aria-label", "Reset"); - resetControl.innerHTML = "⟲"; - resetControl.style.fontSize = "30px"; - resetControl.style.fontWeight = "bold"; - resetControl.style.backgroundColor = "white"; - resetControl.style.border = "none"; - resetControl.style.cursor = "pointer"; - resetControl.style.padding = "0"; - resetControl.style.width = "30px"; - resetControl.style.height = "30px"; - resetControl.style.display = "flex"; - resetControl.style.justifyContent = "center"; - resetControl.style.alignItems = "center"; - resetControl.style.transition = "background-color 0.2s"; - resetControl.addEventListener("mouseover", function () { - this.style.backgroundColor = "#f0f0f0"; - }); - resetControl.addEventListener("mouseout", function () { - this.style.backgroundColor = "white"; - }); + if (window._mapboxHandlers[layerId].mouseleave) { + map.off( + "mouseleave", + layerId, + window._mapboxHandlers[layerId].mouseleave, + ); + } + } - const resetContainer = document.createElement("div"); - resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; - resetContainer.appendChild(resetControl); + // Create new tooltip + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); - const initialView = { - center: map.getCenter(), - zoom: map.getZoom(), - pitch: map.getPitch(), - bearing: map.getBearing(), - animate: message.animate, - }; + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, tooltipProperty); + }; - if (message.duration) { - initialView.duration = message.duration; - } + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; - resetControl.onclick = function () { - map.easeTo(initialView); - }; + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); - map.addControl( - { - onAdd: function () { - return resetContainer; - }, - onRemove: function () { - resetContainer.parentNode.removeChild( - resetContainer, - ); - }, - }, - message.position, - ); - - map.controls.push({ - onAdd: function () { - return resetContainer; - }, - onRemove: function () { - resetContainer.parentNode.removeChild(resetContainer); - }, - }); - } else if (message.type === "add_draw_control") { - let drawOptions = message.options || {}; - if (message.freehand) { - drawOptions = Object.assign({}, drawOptions, { - modes: Object.assign({}, MapboxDraw.modes, { - draw_polygon: MapboxDraw.modes.draw_freehand, - }), - // defaultMode: 'draw_polygon' # Don't set the default yet - }); + // Store handler references + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; } + } - draw = new MapboxDraw(drawOptions); - map.addControl(draw, message.position); - map.controls.push(draw); - - // Add event listeners - map.on("draw.create", updateDrawnFeatures); - map.on("draw.delete", updateDrawnFeatures); - map.on("draw.update", updateDrawnFeatures); - - if (message.orientation === "horizontal") { - const drawBar = map - .getContainer() - .querySelector(".mapboxgl-ctrl-group"); - if (drawBar) { - drawBar.style.display = "flex"; - drawBar.style.flexDirection = "row"; - } - } - } else if (message.type === "get_drawn_features") { - if ( - map.controls && - map.controls.some( - (control) => control instanceof MapboxDraw, - ) - ) { - const drawControl = map.controls.find( - (control) => control instanceof MapboxDraw, - ); - const features = drawControl ? drawControl.getAll() : null; - Shiny.setInputValue( - data.id + "_drawn_features", - JSON.stringify(features), - ); - } else { - Shiny.setInputValue( - data.id + "_drawn_features", - JSON.stringify(null), + // Restore popups + for (const layerId in savedLayerState.popups) { + if (map.getLayer(layerId)) { + const popupProperty = savedLayerState.popups[layerId]; + + // Remove existing popup handlers first + if ( + window._mapboxHandlers && + window._mapboxHandlers[layerId] && + window._mapboxHandlers[layerId].click + ) { + map.off( + "click", + layerId, + window._mapboxHandlers[layerId].click, ); + } + + // Create new popup handler + const clickHandler = function (e) { + onClickPopup(e, map, popupProperty, layerId); + }; + + map.on("click", layerId, clickHandler); + + // Store handler reference + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + if (!window._mapboxHandlers[layerId]) { + window._mapboxHandlers[layerId] = {}; + } + window._mapboxHandlers[layerId].click = clickHandler; } - } else if (message.type === "clear_drawn_features") { - if (draw) { - draw.deleteAll(); - // Update the drawn features - updateDrawnFeatures(); - } - } else if (message.type === "add_markers") { - if (!window.mapboxglMarkers) { - window.mapboxglMarkers = []; - } - message.markers.forEach(function (marker) { - const markerOptions = { - color: marker.color, - rotation: marker.rotation, - draggable: marker.options.draggable || false, - ...marker.options, - }; - const mapMarker = new mapboxgl.Marker(markerOptions) - .setLngLat([marker.lng, marker.lat]) - .addTo(map); - - if (marker.popup) { - mapMarker.setPopup( - new mapboxgl.Popup({ offset: 25 }).setHTML( - marker.popup, - ), - ); - } + } - const markerId = marker.id; - if (markerId) { - const lngLat = mapMarker.getLngLat(); - Shiny.setInputValue(data.id + "_marker_" + markerId, { - id: markerId, - lng: lngLat.lng, - lat: lngLat.lat, - }); - - mapMarker.on("dragend", function () { - const lngLat = mapMarker.getLngLat(); - Shiny.setInputValue( - data.id + "_marker_" + markerId, - { - id: markerId, - lng: lngLat.lng, - lat: lngLat.lat, - }, - ); - }); - } + // Restore legends + if (Object.keys(savedLayerState.legends).length > 0) { + // Clear any existing legends first to prevent stacking + const existingLegends = document.querySelectorAll( + `#${mapId} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); - window.mapboxglMarkers.push(mapMarker); - }); - } else if (message.type === "clear_markers") { - if (window.mapboxglMarkers) { - window.mapboxglMarkers.forEach(function (marker) { - marker.remove(); - }); - window.mapboxglMarkers = []; + // Clear existing legend styles + const legendStyles = document.querySelectorAll( + `style[data-mapgl-legend-css="${mapId}"]`, + ); + legendStyles.forEach((style) => style.remove()); + + // Restore each legend + for (const legendId in savedLayerState.legends) { + const legendData = savedLayerState.legends[legendId]; + + // Add legend CSS + const legendCss = document.createElement("style"); + legendCss.innerHTML = legendData.css; + legendCss.setAttribute("data-mapgl-legend-css", mapId); + document.head.appendChild(legendCss); + + // Add legend HTML + const legend = document.createElement("div"); + legend.innerHTML = legendData.html; + legend.classList.add("mapboxgl-legend"); + const mapContainer = document.getElementById(mapId); + if (mapContainer) { + mapContainer.appendChild(legend); + } } - } else if (message.type === "add_fullscreen_control") { - const position = message.position || "top-right"; - const fullscreen = new mapboxgl.FullscreenControl(); - map.addControl(fullscreen, position); - map.controls.push(fullscreen); - } else if (message.type === "add_scale_control") { - const scaleControl = new mapboxgl.ScaleControl({ - maxWidth: message.options.maxWidth, - unit: message.options.unit, - }); - map.addControl(scaleControl, message.options.position); - map.controls.push(scaleControl); - } else if (message.type === "add_geolocate_control") { - const geolocate = new mapboxgl.GeolocateControl({ - positionOptions: message.options.positionOptions, - trackUserLocation: message.options.trackUserLocation, - showAccuracyCircle: message.options.showAccuracyCircle, - showUserLocation: message.options.showUserLocation, - showUserHeading: message.options.showUserHeading, - fitBoundsOptions: message.options.fitBoundsOptions, - }); - map.addControl(geolocate, message.options.position); - map.controls.push(geolocate); - - if (HTMLWidgets.shinyMode) { - geolocate.on("geolocate", function (event) { - Shiny.setInputValue(el.id + "_geolocate", { - coords: event.coords, - time: new Date(), - }); - }); + } + } - geolocate.on("trackuserlocationstart", function () { - Shiny.setInputValue(el.id + "_geolocate_tracking", { - status: "start", - time: new Date(), - }); - }); + // Remove this listener to avoid adding the same layers multiple times + map.off("style.load", onStyleLoad); + }; - geolocate.on("trackuserlocationend", function () { - Shiny.setInputValue(el.id + "_geolocate_tracking", { - status: "end", - time: new Date(), - }); - }); + map.on("style.load", onStyleLoad); + } - geolocate.on("error", function (error) { - if (error.error.code === 1) { - Shiny.setInputValue(el.id + "_geolocate_error", { - message: "Location permission denied", - time: new Date(), - }); - } - }); - } - } else if (message.type === "add_geocoder_control") { - const geocoderOptions = { - accessToken: mapboxgl.accessToken, - mapboxgl: mapboxgl, - ...message.options, - }; + // Change the style + map.setStyle(message.style, { + config: message.config, + diff: message.diff, + }); + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + map.controls.push(nav); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; - // Set default values if not provided - if (!geocoderOptions.placeholder) - geocoderOptions.placeholder = "Search"; - if (typeof geocoderOptions.collapsed === "undefined") - geocoderOptions.collapsed = false; + if (message.duration) { + initialView.duration = message.duration; + } - const geocoder = new MapboxGeocoder(geocoderOptions); + resetControl.onclick = function () { + map.easeTo(initialView); + }; - map.addControl(geocoder, message.position || "top-right"); - map.controls.push(geocoder); + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }, + message.position, + ); + + map.controls.push({ + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } - // Handle geocoder results in Shiny mode - geocoder.on("result", function (e) { - Shiny.setInputValue(data.id + "_geocoder", { - result: e.result, - time: new Date(), - }); - }); - } else if (message.type === "add_layers_control") { - const layersControl = document.createElement("div"); - layersControl.id = message.control_id; - layersControl.className = message.collapsible - ? "layers-control collapsible" - : "layers-control"; - layersControl.style.position = "absolute"; - layersControl.style[message.position || "top-right"] = "10px"; - - const layersList = document.createElement("div"); - layersList.className = "layers-list"; - layersControl.appendChild(layersList); - - let layers = message.layers || []; - - // Ensure layers is always an array - if (!Array.isArray(layers)) { - layers = [layers]; - } + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } - layers.forEach((layerId, index) => { - const link = document.createElement("a"); - link.id = layerId; - link.href = "#"; - link.textContent = layerId; - link.className = "active"; - - link.onclick = function (e) { - const clickedLayer = this.textContent; - e.preventDefault(); - e.stopPropagation(); - - const visibility = map.getLayoutProperty( - clickedLayer, - "visibility", - ); - - if (visibility === "visible") { - map.setLayoutProperty( - clickedLayer, - "visibility", - "none", - ); - this.className = ""; - } else { - this.className = "active"; - map.setLayoutProperty( - clickedLayer, - "visibility", - "visible", - ); - } - }; + // Create the draw control + var drawControl = new MapboxDraw(drawOptions); + map.addControl(drawControl, message.position); + map.controls.push(drawControl); - layersList.appendChild(link); - }); + // Store the draw control on the widget for later access + widget.drawControl = drawControl; - if (message.collapsible) { - const toggleButton = document.createElement("div"); - toggleButton.className = "toggle-button"; - toggleButton.textContent = "Layers"; - toggleButton.onclick = function () { - layersControl.classList.toggle("open"); - }; - layersControl.insertBefore(toggleButton, layersList); - } + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); - const mapContainer = document.getElementById(data.id); - if (mapContainer) { - mapContainer.appendChild(layersControl); - } else { - console.error( - `Cannot find map container with ID ${data.id}`, - ); - } - } else if (message.type === "clear_legend") { - if (message.ids && Array.isArray(message.ids)) { - message.ids.forEach((id) => { - const legend = document.querySelector( - `#${data.id} div[id="${id}"]`, - ); - if (legend) { - legend.remove(); - } - }); - } else if (message.ids) { - const legend = document.querySelector( - `#${data.id} div[id="${message.ids}"]`, - ); - if (legend) { - legend.remove(); - } - } else { - const existingLegends = document.querySelectorAll( - `#${data.id} .mapboxgl-legend`, - ); - existingLegends.forEach((legend) => { - legend.remove(); - }); - } - } else if (message.type === "clear_controls") { - map.controls.forEach((control) => { - map.removeControl(control); - }); - map.controls = []; + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(drawControl, message.source, map); + } - const layersControl = document.querySelector( - `#${data.id} .layers-control`, - ); - if (layersControl) { - layersControl.remove(); - } - } else if (message.type === "move_layer") { - if (map.getLayer(message.layer)) { - if (message.before) { - map.moveLayer(message.layer, message.before); - } else { - map.moveLayer(message.layer); - } - } else { - console.error("Layer not found:", message.layer); - } - } else if (message.type === "add_image") { - if (Array.isArray(message.images)) { - message.images.forEach(function (imageInfo) { - map.loadImage(imageInfo.url, function (error, image) { - if (error) { - console.error("Error loading image:", error); - return; - } - if (!map.hasImage(imageInfo.id)) { - map.addImage( - imageInfo.id, - image, - imageInfo.options, - ); - } - }); - }); - } else if (message.url) { - map.loadImage(message.url, function (error, image) { - if (error) { - console.error("Error loading image:", error); - return; - } - if (!map.hasImage(message.imageId)) { - map.addImage( - message.imageId, - image, - message.options, - ); - } - }); - } else { - console.error("Invalid image data:", message); - } - } else if (message.type === "set_tooltip") { - const layerId = message.layer; - const newTooltipProperty = message.tooltip; - - // If there's an active tooltip open, remove it first - if (window._activeTooltip) { - window._activeTooltip.remove(); - delete window._activeTooltip; - } + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + const features = drawControl.getAll(); + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + drawControl.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_features_to_draw") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + if (message.data.clear_existing) { + drawControl.deleteAll(); + } + addSourceFeaturesToDraw(drawControl, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn("Draw control not initialized"); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setHTML(marker.popup), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + map.controls.push(scaleControl); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; - // Remove old handlers if any - if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { - const handlers = window._mapboxHandlers[layerId]; - if (handlers.mousemove) { - map.off("mousemove", layerId, handlers.mousemove); - } - if (handlers.mouseleave) { - map.off("mouseleave", layerId, handlers.mouseleave); - } - delete window._mapboxHandlers[layerId]; - } + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } - // Create a new tooltip popup - const tooltip = new mapboxgl.Popup({ - closeButton: false, - closeOnClick: false, - }); + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; - // Define new handlers referencing the updated tooltip property - const mouseMoveHandler = function(e) { - onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); - }; - const mouseLeaveHandler = function() { - onMouseLeaveTooltip(map, tooltip); - }; + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; - // Add the new event handlers - map.on("mousemove", layerId, mouseMoveHandler); - map.on("mouseleave", layerId, mouseLeaveHandler); + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } - // Store these handlers so we can remove/update them in the future - if (!window._mapboxHandlers) { - window._mapboxHandlers = {}; - } - window._mapboxHandlers[layerId] = { - mousemove: mouseMoveHandler, - mouseleave: mouseLeaveHandler - }; - } else if (message.type === "set_source") { - const layerId = message.layer; - const newData = message.source; - const layerObject = map.getLayer(layerId); + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } - if (!layerObject) { - console.error("Layer not found: ", layerId); - return; - } + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } - const sourceId = layerObject.source; - const sourceObject = map.getSource(sourceId); + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } - if (!sourceObject) { - console.error("Source not found: ", sourceId); + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + let layers = message.layers || []; + + // Ensure layers is always an array + if (!Array.isArray(layers)) { + layers = [layers]; + } + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } + + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + if (visibility === "visible") { + map.setLayoutProperty(clickedLayer, "visibility", "none"); + this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } else { + this.className = "active"; + map.setLayoutProperty(clickedLayer, "visibility", "visible"); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); + } + }; + + layersList.appendChild(link); + }); + + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + + const mapContainer = document.getElementById(data.id); + if (mapContainer) { + mapContainer.appendChild(layersControl); + } else { + console.error(`Cannot find map container with ID ${data.id}`); + } + } else if (message.type === "clear_legend") { + if (message.ids && Array.isArray(message.ids)) { + message.ids.forEach((id) => { + const legend = document.querySelector( + `#${data.id} div[id="${id}"]`, + ); + if (legend) { + legend.remove(); + } + // Remove from legend state + delete layerState.legends[id]; + }); + } else if (message.ids) { + const legend = document.querySelector( + `#${data.id} div[id="${message.ids}"]`, + ); + if (legend) { + legend.remove(); + } + // Remove from legend state + delete layerState.legends[message.ids]; + } else { + // Remove all legend elements + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => { + legend.remove(); + }); + + // Clean up any legend styles associated with this map + const legendStyles = document.querySelectorAll( + `style[data-mapgl-legend-css="${data.id}"]`, + ); + legendStyles.forEach((style) => { + style.remove(); + }); + + // Clear all legend state + layerState.legends = {}; + } + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = + "mapboxgl-ctrl mapboxgl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function () { + return customControlContainer; + }, + onRemove: function () { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild( + customControlContainer, + ); + } + }, + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + } else if (message.type === "clear_controls") { + map.controls.forEach((control) => { + map.removeControl(control); + }); + map.controls = []; + + const layersControl = document.querySelector( + `#${data.id} .layers-control`, + ); + if (layersControl) { + layersControl.remove(); + } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } else { + console.error("Layer not found:", message.layer); + } + } else if (message.type === "add_image") { + if (Array.isArray(message.images)) { + message.images.forEach(function (imageInfo) { + map.loadImage(imageInfo.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); return; } - - // Update the geojson data - sourceObject.setData(newData); + if (!map.hasImage(imageInfo.id)) { + map.addImage(imageInfo.id, image, imageInfo.options); + } + }); + }); + } else if (message.url) { + map.loadImage(message.url, function (error, image) { + if (error) { + console.error("Error loading image:", error); + return; } + if (!map.hasImage(message.imageId)) { + map.addImage(message.imageId, image, message.options); + } + }); + } else { + console.error("Invalid image data:", message); + } + } else if (message.type === "set_tooltip") { + const layerId = message.layer; + const newTooltipProperty = message.tooltip; + + // Track tooltip state + layerState.tooltips[layerId] = newTooltipProperty; + + // If there's an active tooltip open, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Remove old handlers if any + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; + } + + // Create a new tooltip popup + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define new handlers referencing the updated tooltip property + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + }; + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Add the new event handlers + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers so we can remove/update them in the future + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } else if (message.type === "set_popup") { + const layerId = message.layer; + const newPopupProperty = message.popup; + + // Track popup state + layerState.popups[layerId] = newPopupProperty; + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + delete window._mapboxPopups[layerId]; + } + + // Remove old click handler if any + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[layerId] + ) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + delete window._mapboxClickHandlers[layerId]; } - }); + + // Remove old hover handlers for cursor change + map.off("mouseenter", layerId); + map.off("mouseleave", layerId); + + // Create new click handler + const clickHandler = function (e) { + onClickPopup(e, map, newPopupProperty, layerId); + }; + + // Add the new event handler + map.on("click", layerId, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_rain") { + if (message.rain) { + map.setRain(message.rain); + } else { + map.setRain(null); + } + } else if (message.type === "set_snow") { + if (message.snow) { + map.setSnow(message.snow); + } else { + map.setSnow(null); + } + } else if (message.type === "set_projection") { + const projection = message.projection; + map.setProjection(projection); + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } + }); } diff --git a/inst/htmlwidgets/mapboxgl.yaml b/inst/htmlwidgets/mapboxgl.yaml index dec41442..f2f3c87a 100644 --- a/inst/htmlwidgets/mapboxgl.yaml +++ b/inst/htmlwidgets/mapboxgl.yaml @@ -1,35 +1,35 @@ dependencies: - - name: mapbox-gl-js - version: "3.7.0" - src: - href: "https://api.mapbox.com/mapbox-gl-js/v3.7.0/" - script: - - "mapbox-gl.js" - stylesheet: - - "mapbox-gl.css" - - name: mapbox-gl-draw - version: "1.4.3" - src: - href: "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/" - script: - - "mapbox-gl-draw.js" - stylesheet: - - "mapbox-gl-draw.css" - - name: freehand-mode - version: 1.0.0 - src: "htmlwidgets/lib/freehand-mode" - script: - - "freehand-mode.js" - - name: mapbox-gl-geocoder - version: 5.0.0 - src: - href: "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/" - script: - - "mapbox-gl-geocoder.min.js" - stylesheet: - - "mapbox-gl-geocoder.css" - - name: mapbox-gl-globe-minimap - version: 1.2.1 - src: "htmlwidgets/lib/mapbox-gl-globe-minimap" - script: - - "bundle.js" + - name: mapbox-gl-js + version: "3.12.0" + src: + href: "https://api.mapbox.com/mapbox-gl-js/v3.12.0/" + script: + - "mapbox-gl.js" + stylesheet: + - "mapbox-gl.css" + - name: mapbox-gl-draw + version: "1.5.0" + src: + href: "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.5.0/" + script: + - "mapbox-gl-draw.js" + stylesheet: + - "mapbox-gl-draw.css" + - name: freehand-mode + version: 1.0.0 + src: "htmlwidgets/lib/freehand-mode" + script: + - "freehand-mode.js" + - name: mapbox-gl-geocoder + version: 5.0.0 + src: + href: "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/" + script: + - "mapbox-gl-geocoder.min.js" + stylesheet: + - "mapbox-gl-geocoder.css" + - name: mapbox-gl-globe-minimap + version: 1.2.1 + src: "htmlwidgets/lib/mapbox-gl-globe-minimap" + script: + - "bundle.js" diff --git a/inst/htmlwidgets/mapboxgl_compare.js b/inst/htmlwidgets/mapboxgl_compare.js index 71d34fe3..59d89c9b 100644 --- a/inst/htmlwidgets/mapboxgl_compare.js +++ b/inst/htmlwidgets/mapboxgl_compare.js @@ -1,530 +1,2538 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case "get": + return properties[expression[1]]; + case "concat": + return expression + .slice(1) + .map((item) => evaluateExpression(item, properties)) + .join(""); + case "to-string": + return String(evaluateExpression(expression[1], properties)); + case "to-number": + return Number(evaluateExpression(expression[1], properties)); + case "number-format": + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || "en-US"; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty("min-fraction-digits")) { + formatOptions.minimumFractionDigits = options["min-fraction-digits"]; + } + if (options.hasOwnProperty("max-fraction-digits")) { + formatOptions.maximumFractionDigits = options["max-fraction-digits"]; + } + if (options.hasOwnProperty("min-integer-digits")) { + formatOptions.minimumIntegerDigits = options["min-integer-digits"]; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) + formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty("useGrouping")) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + // Clear any existing active tooltip first to prevent stacking + if (window._activeTooltip && window._activeTooltip !== tooltipPopup) { + window._activeTooltip.remove(); + } + + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression( + tooltipProperty, + e.features[0].properties, + ); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + } + + // Create and show the popup + const popup = new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + window._mapboxPopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on("close", function () { + if (window._mapboxPopups[layerId] === popup) { + delete window._mapboxPopups[layerId]; + } + }); +} + HTMLWidgets.widget({ - name: "mapboxgl_compare", - - type: "output", - - factory: function (el, width, height) { - return { - renderValue: function (x) { - if (typeof mapboxgl === "undefined") { - console.error("Mapbox GL JS is not loaded."); - return; - } - if (typeof mapboxgl.Compare === "undefined") { - console.error("Mapbox GL Compare plugin is not loaded."); - return; - } - - el.innerHTML = ` -

    -
    - `; - - var beforeMap = new mapboxgl.Map({ - container: `${x.elementId}-before`, - style: x.map1.style, - center: x.map1.center, - zoom: x.map1.zoom, - bearing: x.map1.bearing, - pitch: x.map1.pitch, - projection: x.map1.projection, - accessToken: x.map1.access_token, - ...x.map1.additional_params, - }); + name: "mapboxgl_compare", - var afterMap = new mapboxgl.Map({ - container: `${x.elementId}-after`, - style: x.map2.style, - center: x.map2.center, - zoom: x.map2.zoom, - bearing: x.map2.bearing, - pitch: x.map2.pitch, - projection: x.map2.projection, - accessToken: x.map2.access_token, - ...x.map2.additional_params, - }); + type: "output", - new mapboxgl.Compare(beforeMap, afterMap, `#${x.elementId}`, { - mousemove: x.mousemove, - orientation: x.orientation, - }); + factory: function (el, width, height) { + // Store maps and compare object to allow access during Shiny updates + let beforeMap, afterMap, compareControl, draw; + + return { + renderValue: function (x) { + if (typeof mapboxgl === "undefined") { + console.error("Mapbox GL JS is not loaded."); + return; + } + if (typeof mapboxgl.Compare === "undefined") { + console.error("Mapbox GL Compare plugin is not loaded."); + return; + } + + // Create container divs for the maps + const beforeContainerId = `${el.id}-before`; + const afterContainerId = `${el.id}-after`; + + // Different HTML structure based on mode + if (x.mode === "sync") { + // Side-by-side sync mode + const containerStyle = + x.orientation === "horizontal" + ? `display: flex; flex-direction: column; width: 100%; height: 100%;` + : `display: flex; flex-direction: row; width: 100%; height: 100%;`; + + const mapStyle = + x.orientation === "horizontal" + ? `width: 100%; height: 50%; position: relative;` + : `width: 50%; height: 100%; position: relative;`; + + el.innerHTML = ` +
    +
    +
    +
    + `; + } else { + // Default swipe mode + el.innerHTML = ` +
    +
    + `; + } + + beforeMap = new mapboxgl.Map({ + container: beforeContainerId, + style: x.map1.style, + center: x.map1.center, + zoom: x.map1.zoom, + bearing: x.map1.bearing, + pitch: x.map1.pitch, + projection: x.map1.projection, + accessToken: x.map1.access_token, + ...x.map1.additional_params, + }); + + afterMap = new mapboxgl.Map({ + container: afterContainerId, + style: x.map2.style, + center: x.map2.center, + zoom: x.map2.zoom, + bearing: x.map2.bearing, + pitch: x.map2.pitch, + projection: x.map2.projection, + accessToken: x.map2.access_token, + ...x.map2.additional_params, + }); + + // Set the global access token + mapboxgl.accessToken = x.map1.access_token; + + if (x.mode === "swipe") { + // Only create the swiper in swipe mode + compareControl = new mapboxgl.Compare( + beforeMap, + afterMap, + `#${el.id}`, + { + mousemove: x.mousemove, + orientation: x.orientation, + }, + ); - // Ensure both maps resize correctly - beforeMap.on("load", function () { - beforeMap.resize(); - applyMapModifications(beforeMap, x.map1); + // Apply custom swiper color if provided + if (x.swiper_color) { + const swiperSelector = + x.orientation === "vertical" + ? ".mapboxgl-compare .compare-swiper-vertical" + : ".mapboxgl-compare .compare-swiper-horizontal"; + + const styleEl = document.createElement("style"); + styleEl.innerHTML = `${swiperSelector} { background-color: ${x.swiper_color}; }`; + document.head.appendChild(styleEl); + } + } else { + // For sync mode, we directly leverage the sync-move module's approach + + // Function to synchronize maps as seen in the mapbox-gl-sync-move module + const syncMaps = () => { + // Array of maps to sync + const maps = [beforeMap, afterMap]; + // Array of move event handlers + const moveHandlers = []; + + // Setup the sync between maps + maps.forEach((map, index) => { + // Create a handler for each map that syncs all other maps + moveHandlers[index] = (e) => { + // Disable all move events temporarily + maps.forEach((m, i) => { + m.off("move", moveHandlers[i]); }); - afterMap.on("load", function () { - afterMap.resize(); - applyMapModifications(afterMap, x.map2); + // Get the state from the map that triggered the event + const center = map.getCenter(); + const zoom = map.getZoom(); + const bearing = map.getBearing(); + const pitch = map.getPitch(); + + // Apply this state to all other maps + maps + .filter((m, i) => i !== index) + .forEach((m) => { + m.jumpTo({ + center: center, + zoom: zoom, + bearing: bearing, + pitch: pitch, + }); + }); + + // Re-enable move events + maps.forEach((m, i) => { + m.on("move", moveHandlers[i]); }); + }; - function applyMapModifications(map, mapData) { - if (mapData.config_properties) { - mapData.config_properties.forEach(function (config) { - map.setConfigProperty( - config.importId, - config.configName, - config.value, - ); - }); + // Add the move handler to each map + map.on("move", moveHandlers[index]); + }); + }; + + // Initialize the sync + syncMaps(); + } + + // Ensure both maps resize correctly + beforeMap.on("load", function () { + beforeMap.resize(); + applyMapModifications(beforeMap, x.map1); + + // Setup Shiny event handlers for the before map + if (HTMLWidgets.shinyMode) { + setupShinyEvents(beforeMap, el.id, "before"); + } + }); + + afterMap.on("load", function () { + afterMap.resize(); + applyMapModifications(afterMap, x.map2); + + // Setup Shiny event handlers for the after map + if (HTMLWidgets.shinyMode) { + setupShinyEvents(afterMap, el.id, "after"); + } + }); + + // Handle Shiny messages + if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler( + "mapboxgl-compare-proxy", + function (data) { + if (data.id !== el.id) return; + + // Get the message and determine which map to target + var message = data.message; + var map = message.map === "before" ? beforeMap : afterMap; + + if (!map) return; + + // Initialize layer state tracking if not already present + if (!window._mapglLayerState) { + window._mapglLayerState = {}; + } + const mapId = map.getContainer().id; + if (!window._mapglLayerState[mapId]) { + window._mapglLayerState[mapId] = { + filters: {}, // layerId -> filter expression + paintProperties: {}, // layerId -> {propertyName -> value} + layoutProperties: {}, // layerId -> {propertyName -> value} + tooltips: {}, // layerId -> tooltip property + popups: {}, // layerId -> popup property + legends: {}, // legendId -> {html: string, css: string} + }; + } + const layerState = window._mapglLayerState[mapId]; + + // Process the message based on type + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + // Track filter state for layer restoration + layerState.filters[message.layer] = message.filter; + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + const sourceConfig = { + type: "vector", + url: message.source.url, + }; + // Add promoteId if provided + if (message.source.promoteId) { + sourceConfig.promoteId = message.source.promoteId; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "url" && + key !== "promoteId" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "geojson") { + const sourceConfig = { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "data" && + key !== "generateId" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "raster") { + const sourceConfig = { + type: "raster", + tileSize: message.source.tileSize, + }; + if (message.source.url) { + sourceConfig.url = message.source.url; + } else if (message.source.tiles) { + sourceConfig.tiles = message.source.tiles; + } + if (message.source.maxzoom) { + sourceConfig.maxzoom = message.source.maxzoom; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "url" && + key !== "tiles" && + key !== "tileSize" && + key !== "maxzoom" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "raster-dem") { + const sourceConfig = { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + }; + if (message.source.maxzoom) { + sourceConfig.maxzoom = message.source.maxzoom; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "url" && + key !== "tileSize" && + key !== "maxzoom" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "image") { + const sourceConfig = { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "url" && + key !== "coordinates" + ) { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "video") { + const sourceConfig = { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function (key) { + if ( + key !== "id" && + key !== "type" && + key !== "urls" && + key !== "coordinates" + ) { + sourceConfig[key] = message.source[key]; } + }); + map.addSource(message.source.id, sourceConfig); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer(message.layer, message.layer.before_id); + } else { + map.addLayer(message.layer); + } - if (mapData.markers) { - if (!window.mapboxglMarkers) { - window.mapboxglMarkers = []; - } - mapData.markers.forEach(function (marker) { - const markerOptions = { - color: marker.color, - rotation: marker.rotation, - draggable: marker.options.draggable || false, - ...marker.options, - }; - const mapMarker = new mapboxgl.Marker(markerOptions) - .setLngLat([marker.lng, marker.lat]) - .addTo(map); - - if (marker.popup) { - mapMarker.setPopup( - new mapboxgl.Popup({ offset: 25 }).setText( - marker.popup, - ), - ); - } + // Add popups or tooltips if provided + if (message.layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } - const markerId = marker.id; - if (markerId) { - const lngLat = mapMarker.getLngLat(); - Shiny.setInputValue( - el.id + "_marker_" + markerId, - { - id: markerId, - lng: lngLat.lng, - lat: lngLat.lat, - }, - ); - - mapMarker.on("dragend", function () { - const lngLat = mapMarker.getLngLat(); - Shiny.setInputValue( - el.id + "_marker_" + markerId, - { - id: markerId, - lng: lngLat.lng, - lat: lngLat.lat, - }, - ); - }); - } + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup( + e, + map, + message.layer.popup, + message.layer.id, + ); + }; - window.mapboxglMarkers.push(mapMarker); - }); + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; } + window._mapboxClickHandlers[message.layer.id] = + clickHandler; - // Add sources if provided - if (mapData.sources) { - mapData.sources.forEach(function (source) { - if (source.type === "vector") { - map.addSource(source.id, { - type: "vector", - url: source.url, - }); - } else if (source.type === "geojson") { - const geojsonData = source.data; - map.addSource(source.id, { - type: "geojson", - data: geojsonData, - generateId: true, - }); - } else if (source.type === "raster") { - if (source.url) { - map.addSource(source.id, { - type: "raster", - url: source.url, - tileSize: source.tileSize, - maxzoom: source.maxzoom, - }); - } else if (source.tiles) { - map.addSource(source.id, { - type: "raster", - tiles: source.tiles, - tileSize: source.tileSize, - maxzoom: source.maxzoom, - }); - } - } else if (source.type === "raster-dem") { - map.addSource(source.id, { - type: "raster-dem", - url: source.url, - tileSize: source.tileSize, - maxzoom: source.maxzoom, - }); - } else if (source.type === "image") { - map.addSource(source.id, { - type: "image", - url: source.url, - coordinates: source.coordinates, - }); - } else if (source.type === "video") { - map.addSource(source.id, { - type: "video", - urls: source.urls, - coordinates: source.coordinates, - }); - } - }); + // Add the click handler + map.on("click", message.layer.id, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (message.layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on("mousemove", message.layer.id, mouseMoveHandler); + map.on("mouseleave", message.layer.id, mouseLeaveHandler); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; } + window._mapboxHandlers[message.layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } - // Add layers if provided - if (mapData.layers) { - mapData.layers.forEach(function (layer) { - try { - const layerConfig = { - id: layer.id, - type: layer.type, - source: layer.source, - layout: layer.layout || {}, - paint: layer.paint || {}, - }; - - // Check if source is an object and set generateId if source type is 'geojson' - if ( - typeof layer.source === "object" && - layer.source.type === "geojson" - ) { - layerConfig.source.generateId = true; - } else if (typeof layer.source === "string") { - // Handle string source if needed - layerConfig.source = layer.source; - } - - if (layer.source_layer) { - layerConfig["source-layer"] = - layer.source_layer; - } - - if (layer.slot) { - layerConfig["slot"] = layer.slot; - } - - if (layer.minzoom) { - layerConfig["minzoom"] = layer.minzoom; - } - if (layer.maxzoom) { - layerConfig["maxzoom"] = layer.maxzoom; - } - - if (layer.before_id) { - map.addLayer(layerConfig, layer.before_id); - } else { - map.addLayer(layerConfig); - } - - // Add popups or tooltips if provided - if (layer.popup) { - map.on("click", layer.id, function (e) { - const description = - e.features[0].properties[ - layer.popup - ]; - - new mapboxgl.Popup() - .setLngLat(e.lngLat) - .setHTML(description) - .addTo(map); - }); - } - - if (layer.tooltip) { - const tooltip = new mapboxgl.Popup({ - closeButton: false, - closeOnClick: false, - }); - - map.on("mousemove", layer.id, function (e) { - map.getCanvas().style.cursor = - "pointer"; - - if (e.features.length > 0) { - const description = - e.features[0].properties[ - layer.tooltip - ]; - tooltip - .setLngLat(e.lngLat) - .setHTML(description) - .addTo(map); - } else { - tooltip.remove(); - } - }); - - map.on("mouseleave", layer.id, function () { - map.getCanvas().style.cursor = ""; - tooltip.remove(); - }); - } - - // Add hover effect if provided - if (layer.hover_options) { - const jsHoverOptions = {}; - for (const [key, value] of Object.entries( - layer.hover_options, - )) { - const jsKey = key.replace(/_/g, "-"); - jsHoverOptions[jsKey] = value; - } - - let hoveredFeatureId = null; - - map.on("mousemove", layer.id, function (e) { - if (e.features.length > 0) { - if (hoveredFeatureId !== null) { - map.setFeatureState( - { - source: - typeof layer.source === - "string" - ? layer.source - : layer.id, - id: hoveredFeatureId, - }, - { hover: false }, - ); - } - hoveredFeatureId = e.features[0].id; - map.setFeatureState( - { - source: - typeof layer.source === - "string" - ? layer.source - : layer.id, - id: hoveredFeatureId, - }, - { hover: true }, - ); - } - }); - - map.on("mouseleave", layer.id, function () { - if (hoveredFeatureId !== null) { - map.setFeatureState( - { - source: - typeof layer.source === - "string" - ? layer.source - : layer.id, - id: hoveredFeatureId, - }, - { hover: false }, - ); - } - hoveredFeatureId = null; - }); - - Object.keys(jsHoverOptions).forEach( - function (key) { - const originalPaint = - map.getPaintProperty( - layer.id, - key, - ) || layer.paint[key]; - map.setPaintProperty( - layer.id, - key, - [ - "case", - [ - "boolean", - [ - "feature-state", - "hover", - ], - false, - ], - jsHoverOptions[key], - originalPaint, - ], - ); - }, - ); - } - } catch (e) { - console.error( - "Failed to add layer: ", - layer, - e, - ); - } - }); + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; } - // Set terrain if provided - if (mapData.terrain) { - map.setTerrain({ - source: mapData.terrain.source, - exaggeration: mapData.terrain.exaggeration, + let hoveredFeatureId = null; + + map.on("mousemove", message.layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = e.features[0].id; + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: true, }); - } + } + }); + + map.on("mouseleave", message.layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = message.layer.source_layer; + } + map.setFeatureState(featureState, { + hover: false, + }); + } + hoveredFeatureId = null; + }); + + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(message.layer.id, key) || + message.layer.paint[key]; + map.setPaintProperty(message.layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + if ( + window._mapboxPopups && + window._mapboxPopups[message.layer_id] + ) { + window._mapboxPopups[message.layer_id].remove(); + delete window._mapboxPopups[message.layer_id]; + } - // Set fog - if (mapData.fog) { - map.setFog(mapData.fog); + if (map.getLayer(message.layer_id)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer_id] + ) { + const handlers = window._mapboxHandlers[message.layer_id]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer_id, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer_id, + handlers.mouseleave, + ); } + // Clean up the reference + delete window._mapboxHandlers[message.layer_id]; + } - if (mapData.fitBounds) { - map.fitBounds( - mapData.fitBounds.bounds, - mapData.fitBounds.options, - ); + // Remove click handlers for popups + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer_id] + ) { + map.off( + "click", + message.layer_id, + window._mapboxClickHandlers[message.layer_id], + ); + delete window._mapboxClickHandlers[message.layer_id]; + } + + // Remove the layer + map.removeLayer(message.layer_id); + } + if (map.getSource(message.layer_id)) { + map.removeSource(message.layer_id); + } + + // Clean up tracked layer state + const mapId = map.getContainer().id; + if (window._mapglLayerState && window._mapglLayerState[mapId]) { + const layerState = window._mapglLayerState[mapId]; + delete layerState.filters[message.layer_id]; + delete layerState.paintProperties[message.layer_id]; + delete layerState.layoutProperties[message.layer_id]; + delete layerState.tooltips[message.layer_id]; + delete layerState.popups[message.layer_id]; + // Note: legends are not tied to specific layers, so we don't clear them here + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + // Track layout property state for layer restoration + if (!layerState.layoutProperties[message.layer]) { + layerState.layoutProperties[message.layer] = {}; + } + layerState.layoutProperties[message.layer][message.name] = + message.value; + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find((layer) => layer.id === layerId); + const currentPaintProperty = map.getPaintProperty( + layerId, + propertyName, + ); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + newValue, + ]; + map.setPaintProperty(layerId, propertyName, newPaintProperty); + } else { + // No hover options, just set the new value directly + map.setPaintProperty(layerId, propertyName, newValue); + } + // Track paint property state for layer restoration + if (!layerState.paintProperties[layerId]) { + layerState.paintProperties[layerId] = {}; + } + layerState.paintProperties[layerId][propertyName] = newValue; + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = document.querySelectorAll( + `#${data.id} .mapboxgl-legend`, + ); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll( + `style[data-mapgl-legend-css="${data.id}"]`, + ); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute("data-mapgl-legend-css", data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("mapboxgl-legend"); + document.getElementById(data.id).appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Save the current view state + const center = map.getCenter(); + const zoom = map.getZoom(); + const bearing = map.getBearing(); + const pitch = map.getPitch(); + + // Apply the new style + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + // Identify user-added sources (those not in the original style) + // We'll assume any source that's not "composite", "mapbox", or starts with "mapbox-" is user-added + for (const sourceId in currentStyle.sources) { + if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") + ) { + userSourceIds.push(sourceId); + const source = currentStyle.sources[sourceId]; + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find( + (l) => l.id === layerId, + ); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } } - if (mapData.flyTo) { - map.flyTo(mapData.flyTo); + } + + // Identify layers using user-added sources + currentStyle.layers.forEach(function (layer) { + if (userSourceIds.includes(layer.source)) { + userLayers.push(layer); } - if (mapData.easeTo) { - map.easeTo(mapData.easeTo); + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function () { + // Re-add user sources + userSourceIds.forEach(function (sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function (layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if ( + Array.isArray(value) && + value[0] === "case" && + Array.isArray(value[1]) && + value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && + value[1][1][1] === "hover" + ) { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + }); + + // Clear any active tooltips before restoration to prevent stacking + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; } - if (mapData.setCenter) { - map.setCenter(mapData.setCenter); + + // Restore tracked layer modifications + const mapId = map.getContainer().id; + const savedLayerState = + window._mapglLayerState && window._mapglLayerState[mapId]; + if (savedLayerState) { + // Restore filters + for (const layerId in savedLayerState.filters) { + if (map.getLayer(layerId)) { + map.setFilter( + layerId, + savedLayerState.filters[layerId], + ); + } + } + + // Restore paint properties + for (const layerId in savedLayerState.paintProperties) { + if (map.getLayer(layerId)) { + const properties = + savedLayerState.paintProperties[layerId]; + for (const propertyName in properties) { + const savedValue = properties[propertyName]; + + // Check if layer has hover effects that need to be preserved + const currentValue = map.getPaintProperty( + layerId, + propertyName, + ); + if ( + currentValue && + Array.isArray(currentValue) && + currentValue[0] === "case" + ) { + // Preserve hover effects while updating base value + const hoverValue = currentValue[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + savedValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + map.setPaintProperty( + layerId, + propertyName, + savedValue, + ); + } + } + } + } + + // Restore layout properties + for (const layerId in savedLayerState.layoutProperties) { + if (map.getLayer(layerId)) { + const properties = + savedLayerState.layoutProperties[layerId]; + for (const propertyName in properties) { + map.setLayoutProperty( + layerId, + propertyName, + properties[propertyName], + ); + } + } + } + + // Restore tooltips + for (const layerId in savedLayerState.tooltips) { + if (map.getLayer(layerId)) { + const tooltipProperty = + savedLayerState.tooltips[layerId]; + + // Remove existing tooltip handlers first + map.off("mousemove", layerId); + map.off("mouseleave", layerId); + + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + map.on("mousemove", layerId, function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + tooltipProperty, + ); + }); + + map.on("mouseleave", layerId, function () { + onMouseLeaveTooltip(map, tooltip); + }); + } + } + + // Restore popups + for (const layerId in savedLayerState.popups) { + if (map.getLayer(layerId)) { + const popupProperty = savedLayerState.popups[layerId]; + + // Remove existing popup handlers first + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[layerId] + ) { + map.off( + "click", + layerId, + window._mapboxClickHandlers[layerId], + ); + delete window._mapboxClickHandlers[layerId]; + } + + const clickHandler = function (e) { + onClickPopup(e, map, popupProperty, layerId); + }; + + map.on("click", layerId, clickHandler); + + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } + } } - if (mapData.setZoom) { - map.setZoom(mapData.setZoom); + + // Remove this listener to avoid adding the same layers multiple times + map.off("style.load", onStyleLoad); + }; + + map.on("style.load", onStyleLoad); + } + + // Change the style + map.setStyle(message.style, { + config: message.config, + diff: message.diff, + }); + + // Restore the view state after the style has loaded + map.once("style.load", function () { + map.jumpTo({ + center: center, + zoom: zoom, + bearing: bearing, + pitch: pitch, + }); + + // Re-apply map modifications + if (map === beforeMap) { + applyMapModifications(map, x.map1); + } else { + applyMapModifications(map, x.map2); + } + }); + } else if (message.type === "add_navigation_control") { + const nav = new mapboxgl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".mapboxgl-ctrl.mapboxgl-ctrl-group:not(.mapbox-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = document.createElement("button"); + resetControl.className = + "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }, + message.position, + ); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (message.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: MapboxDraw.modes.draw_freehand, + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(draw, message.source, map); + } + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if (draw) { + const features = draw ? draw.getAll() : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if (message.type === "clear_drawn_features") { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_features_to_draw") { + if (draw) { + if (message.data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn("Draw control not initialized"); + } + } else if (message.type === "add_markers") { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue(data.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.mapboxglMarkers) { + window.mapboxglMarkers.forEach(function (marker) { + marker.remove(); + }); + window.mapboxglMarkers = []; + } + } else if (message.type === "add_fullscreen_control") { + const position = message.position || "top-right"; + const fullscreen = new mapboxgl.FullscreenControl(); + map.addControl(fullscreen, position); + } else if (message.type === "add_scale_control") { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl(scaleControl, message.options.position); + } else if (message.type === "add_geolocate_control") { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: message.options.positionOptions, + trackUserLocation: message.options.trackUserLocation, + showAccuracyCircle: message.options.showAccuracyCircle, + showUserLocation: message.options.showUserLocation, + showUserHeading: message.options.showUserHeading, + fitBoundsOptions: message.options.fitBoundsOptions, + }); + map.addControl(geolocate, message.options.position); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(data.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(data.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(data.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(data.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); } - if (mapData.jumpTo) { - map.jumpTo(mapData.jumpTo); + }); + } + } else if (message.type === "add_geocoder_control") { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl(geocoder, message.position || "top-right"); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = document.createElement("div"); + layersControl.id = message.control_id; + + // Handle use_icon parameter + let className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + + if (message.use_icon) { + className += " icon-only"; + } + + layersControl.className = className; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `.layers-control { background-color: ${colors.background} !important; }`; + } + if (colors.text) { + css += `.layers-control a { color: ${colors.text} !important; }`; + } + if (colors.activeBackground) { + css += `.layers-control a.active { background-color: ${colors.activeBackground} !important; }`; + } + if (colors.activeText) { + css += `.layers-control a.active { color: ${colors.activeText} !important; }`; + } + if (colors.hoverBackground) { + css += `.layers-control a:hover { background-color: ${colors.hoverBackground} !important; }`; + } + if (colors.hoverText) { + css += `.layers-control a:hover { color: ${colors.hoverText} !important; }`; + } + if (colors.toggleButtonBackground) { + css += `.layers-control .toggle-button { background-color: ${colors.toggleButtonBackground} + !important; }`; + } + if (colors.toggleButtonText) { + css += `.layers-control .toggle-button { color: ${colors.toggleButtonText} !important; }`; + } + + styleEl.innerHTML = css; + document.head.appendChild(styleEl); + } + + document.getElementById(data.id).appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + message.layers || + map.getStyle().layers.map((layer) => layer.id); + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty(clickedLayer, "visibility", "none"); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); } + }; + + layersList.appendChild(link); + }); - const existingLegend = - document.getElementById("mapboxgl-legend"); - if (existingLegend) { - existingLegend.remove(); + // Handle collapsible behavior + if (message.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + } else if (message.type === "add_globe_minimap") { + // Add the globe minimap control + const minimap = new MapboxGlobeMinimap({ + center: map.getCenter(), + zoom: map.getZoom(), + bearing: map.getBearing(), + pitch: map.getPitch(), + globeSize: message.globe_size, + landColor: message.land_color, + waterColor: message.water_color, + markerColor: message.marker_color, + markerSize: message.marker_size, + }); + + map.addControl(minimap, message.position); + } else if (message.type === "set_rain") { + if (message.rain) { + map.setRain(message.rain); + } else { + map.setRain(null); + } + } else if (message.type === "set_snow") { + if (message.snow) { + map.setSnow(message.snow); + } else { + map.setSnow(null); + } + } else if (message.type === "set_projection") { + map.setProjection(message.projection); + } else if (message.type === "set_source") { + if (map.getLayer(message.layer)) { + const sourceId = map.getLayer(message.layer).source; + map.getSource(sourceId).setData(JSON.parse(message.source)); + } + } else if (message.type === "set_tooltip") { + // Track tooltip state + layerState.tooltips[message.layer] = message.tooltip; + + if (map.getLayer(message.layer)) { + // Remove any existing tooltip handlers + map.off("mousemove", message.layer); + map.off("mouseleave", message.layer); + + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + map.on("mousemove", message.layer, function (e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = + e.features[0].properties[message.tooltip]; + tooltip + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); } + }); + + map.on("mouseleave", message.layer, function () { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }); + } + } else if (message.type === "set_popup") { + // Track popup state + layerState.popups[message.layer] = message.popup; + + if (map.getLayer(message.layer)) { + // Remove any existing popup click handlers for this layer + if ( + window._mapboxClickHandlers && + window._mapboxClickHandlers[message.layer] + ) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer], + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Remove any existing popup for this layer + if ( + window._mapboxPopups && + window._mapboxPopups[message.layer] + ) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + // Create new click handler for popup + const clickHandler = function (e) { + onClickPopup(e, map, message.popup, message.layer); + }; - if (mapData.legend_html && mapData.legend_css) { - const legendCss = document.createElement("style"); - legendCss.innerHTML = mapData.legend_css; - document.head.appendChild(legendCss); + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer] = clickHandler; - const legend = document.createElement("div"); - legend.innerHTML = mapData.legend_html; - // legend.classList.add("mapboxgl-legend"); - el.appendChild(legend); + // Add click handler + map.on("click", message.layer, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer, function () { + map.getCanvas().style.cursor = ""; + }); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer(message.layer, message.before); + } else { + map.moveLayer(message.layer); + } + } + } else if (message.type === "set_opacity") { + // Set opacity for all fill layers + const style = map.getStyle(); + if (style && style.layers) { + style.layers.forEach(function (layer) { + if (layer.type === "fill" && map.getLayer(layer.id)) { + map.setPaintProperty( + layer.id, + "fill-opacity", + message.opacity, + ); } + }); + } + } + }, + ); + } - // Add fullscreen control if enabled - if ( - mapData.fullscreen_control && - mapData.fullscreen_control.enabled - ) { - const position = - mapData.fullscreen_control.position || "top-right"; - map.addControl( - new mapboxgl.FullscreenControl(), - position, + function setupShinyEvents(map, parentId, mapType) { + // Set view state on move end + map.on("moveend", function () { + const center = map.getCenter(); + const zoom = map.getZoom(); + const bearing = map.getBearing(); + const pitch = map.getPitch(); + + if (window.Shiny) { + Shiny.setInputValue(parentId + "_" + mapType + "_view", { + center: [center.lng, center.lat], + zoom: zoom, + bearing: bearing, + pitch: pitch, + }); + } + }); + + // Send clicked point coordinates to Shiny + map.on("click", function (e) { + if (window.Shiny) { + Shiny.setInputValue(parentId + "_" + mapType + "_click", { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: Date.now(), + }); + } + }); + } + + function applyMapModifications(map, mapData) { + // Initialize controls array if it doesn't exist + if (!map.controls) { + map.controls = []; + } + // Note: tooltip handlers are already defined at the top of the file + + // Set config properties if provided + if (mapData.config_properties) { + mapData.config_properties.forEach(function (config) { + map.setConfigProperty( + config.importId, + config.configName, + config.value, + ); + }); + } + + // Process H3J sources if provided + if (mapData.h3j_sources) { + mapData.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + }); + } + + if (mapData.markers) { + if (!window.mapboxglMarkers) { + window.mapboxglMarkers = []; + } + mapData.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new mapboxgl.Marker(markerOptions) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new mapboxgl.Popup({ offset: 25 }).setText(marker.popup), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue(el.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + } + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue(el.id + "_marker_" + markerId, { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }); + } + }); + } + + window.mapboxglMarkers.push(mapMarker); + }); + } + + // Add sources if provided + if (mapData.sources) { + mapData.sources.forEach(function (source) { + if (source.type === "vector") { + const sourceConfig = { + type: "vector", + url: source.url, + }; + if (source.promoteId) { + sourceConfig.promoteId = source.promoteId; + } + map.addSource(source.id, sourceConfig); + } else if (source.type === "geojson") { + const geojsonData = source.data; + map.addSource(source.id, { + type: "geojson", + data: geojsonData, + generateId: true, + }); + } else if (source.type === "raster") { + if (source.url) { + map.addSource(source.id, { + type: "raster", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.tiles) { + map.addSource(source.id, { + type: "raster", + tiles: source.tiles, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } + } else if (source.type === "raster-dem") { + map.addSource(source.id, { + type: "raster-dem", + url: source.url, + tileSize: source.tileSize, + maxzoom: source.maxzoom, + }); + } else if (source.type === "image") { + map.addSource(source.id, { + type: "image", + url: source.url, + coordinates: source.coordinates, + }); + } else if (source.type === "video") { + map.addSource(source.id, { + type: "video", + urls: source.urls, + coordinates: source.coordinates, + }); + } + }); + } + + // Add layers if provided + if (mapData.layers) { + mapData.layers.forEach(function (layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; + + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } + + if (layer.source_layer) { + layerConfig["source-layer"] = layer.source_layer; + } + + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } + + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } + + // Add popups or tooltips if provided + if (layer.popup) { + map.on("click", layer.id, function (e) { + const description = e.features[0].properties[layer.popup]; + + new mapboxgl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + }); + } + + if (layer.tooltip) { + const tooltip = new mapboxgl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, layer.tooltip); + }; + + // Create a reference to the mouseleave handler function + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handler references + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, ); + } + hoveredFeatureId = e.features[0].id; + map.setFeatureState( + { + source: + typeof layer.source === "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: true }, + ); } + }); - // Add navigation control if enabled - if (mapData.navigation_control) { - const nav = new mapboxgl.NavigationControl({ - showCompass: - mapData.navigation_control.show_compass, - showZoom: mapData.navigation_control.show_zoom, - visualizePitch: - mapData.navigation_control.visualize_pitch, - }); - map.addControl( - nav, - mapData.navigation_control.position, - ); + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + map.setFeatureState( + { + source: + typeof layer.source === "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }, + { hover: false }, + ); } + hoveredFeatureId = null; + }); - // Add the layers control if provided - if (mapData.layers_control) { - const layersControl = document.createElement("div"); - layersControl.id = mapData.layers_control.control_id; - layersControl.className = mapData.layers_control - .collapsible - ? "layers-control collapsible" - : "layers-control"; - layersControl.style.position = "absolute"; - layersControl.style[ - mapData.layers_control.position || "top-right" - ] = "10px"; - el.appendChild(layersControl); - - const layersList = document.createElement("div"); - layersList.className = "layers-list"; - layersControl.appendChild(layersList); - - // Fetch layers to be included in the control - let layers = - mapData.layers_control.layers || - map.getStyle().layers.map((layer) => layer.id); - - layers.forEach((layerId, index) => { - const link = document.createElement("a"); - link.id = layerId; - link.href = "#"; - link.textContent = layerId; - link.className = "active"; - - // Show or hide layer when the toggle is clicked - link.onclick = function (e) { - const clickedLayer = this.textContent; - e.preventDefault(); - e.stopPropagation(); - - const visibility = map.getLayoutProperty( - clickedLayer, - "visibility", - ); - - // Toggle layer visibility by changing the layout object's visibility property - if (visibility === "visible") { - map.setLayoutProperty( - clickedLayer, - "visibility", - "none", - ); - this.className = ""; - } else { - this.className = "active"; - map.setLayoutProperty( - clickedLayer, - "visibility", - "visible", - ); - } - }; - - layersList.appendChild(link); - }); + Object.keys(jsHoverOptions).forEach(function (key) { + const originalPaint = + map.getPaintProperty(layer.id, key) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + ["boolean", ["feature-state", "hover"], false], + jsHoverOptions[key], + originalPaint, + ]); + }); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + }); + } + + // Set terrain if provided + if (mapData.terrain) { + map.setTerrain({ + source: mapData.terrain.source, + exaggeration: mapData.terrain.exaggeration, + }); + } + + // Set fog + if (mapData.fog) { + map.setFog(mapData.fog); + } + + // Set rain effect if provided + if (mapData.rain) { + map.setRain(mapData.rain); + } + + // Set snow effect if provided + if (mapData.snow) { + map.setSnow(mapData.snow); + } + + if (mapData.fitBounds) { + map.fitBounds(mapData.fitBounds.bounds, mapData.fitBounds.options); + } + if (mapData.flyTo) { + map.flyTo(mapData.flyTo); + } + if (mapData.easeTo) { + map.easeTo(mapData.easeTo); + } + if (mapData.setCenter) { + map.setCenter(mapData.setCenter); + } + if (mapData.setZoom) { + map.setZoom(mapData.setZoom); + } + if (mapData.jumpTo) { + map.jumpTo(mapData.jumpTo); + } + + // Add custom images if provided + if (mapData.images && Array.isArray(mapData.images)) { + mapData.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage(imageInfo.url); + if (!map.hasImage(imageInfo.id)) { + map.addImage(imageInfo.id, image.data, imageInfo.options); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (mapData.images) { + console.error("mapData.images is not an array:", mapData.images); + } + + // Remove existing legends + const existingLegends = document.querySelectorAll(".mapboxgl-legend"); + existingLegends.forEach((legend) => legend.remove()); + + // Clean up any legend styles that might have been added + const legendStyles = document.querySelectorAll( + "style[data-mapgl-legend-css]", + ); + legendStyles.forEach((style) => style.remove()); + + if (mapData.legend_html && mapData.legend_css) { + const legendCss = document.createElement("style"); + legendCss.innerHTML = mapData.legend_css; + legendCss.setAttribute("data-mapgl-legend-css", el.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = mapData.legend_html; + legend.classList.add("mapboxgl-legend"); + el.appendChild(legend); + } + + // Add fullscreen control if enabled + if ( + mapData.fullscreen_control && + mapData.fullscreen_control.enabled + ) { + const position = mapData.fullscreen_control.position || "top-right"; + map.addControl(new mapboxgl.FullscreenControl(), position); + } + + // Add navigation control if enabled + if (mapData.navigation_control) { + const nav = new mapboxgl.NavigationControl({ + showCompass: mapData.navigation_control.show_compass, + showZoom: mapData.navigation_control.show_zoom, + visualizePitch: mapData.navigation_control.visualize_pitch, + }); + map.addControl(nav, mapData.navigation_control.position); + } + + // Add scale control if enabled + if (mapData.scale_control) { + const scaleControl = new mapboxgl.ScaleControl({ + maxWidth: mapData.scale_control.maxWidth, + unit: mapData.scale_control.unit, + }); + map.addControl(scaleControl, mapData.scale_control.position); + map.controls.push(scaleControl); + } + + // Add geolocate control if enabled + if (mapData.geolocate_control) { + const geolocate = new mapboxgl.GeolocateControl({ + positionOptions: mapData.geolocate_control.positionOptions, + trackUserLocation: mapData.geolocate_control.trackUserLocation, + showAccuracyCircle: mapData.geolocate_control.showAccuracyCircle, + showUserLocation: mapData.geolocate_control.showUserLocation, + showUserHeading: mapData.geolocate_control.showUserHeading, + fitBoundsOptions: mapData.geolocate_control.fitBoundsOptions, + }); + map.addControl(geolocate, mapData.geolocate_control.position); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue(el.id + "_geolocate_error", { + message: "Location permission denied", + time: new Date(), + }); + } + }); + } + } + + // Helper function to generate draw styles based on parameters + function generateDrawStyles(styling) { + if (!styling) return null; - // Handle collapsible behavior - if (mapData.layers_control.collapsible) { - const toggleButton = document.createElement("div"); - toggleButton.className = "toggle-button"; - toggleButton.textContent = "Layers"; - toggleButton.onclick = function () { - layersControl.classList.toggle("open"); - }; - layersControl.insertBefore( - toggleButton, - layersList, + return [ + // Point styles + { + id: "gl-draw-point-active", + type: "circle", + filter: [ + "all", + ["==", "$type", "Point"], + ["==", "meta", "feature"], + ["==", "active", "true"], + ], + paint: { + "circle-radius": styling.vertex_radius + 2, + "circle-color": styling.active_color, + }, + }, + { + id: "gl-draw-point", + type: "circle", + filter: [ + "all", + ["==", "$type", "Point"], + ["==", "meta", "feature"], + ["==", "active", "false"], + ], + paint: { + "circle-radius": styling.vertex_radius, + "circle-color": styling.point_color, + }, + }, + // Line styles + { + id: "gl-draw-line", + type: "line", + filter: ["all", ["==", "$type", "LineString"]], + layout: { + "line-cap": "round", + "line-join": "round", + }, + paint: { + "line-color": [ + "case", + ["==", ["get", "active"], "true"], + styling.active_color, + styling.line_color, + ], + "line-width": styling.line_width, + }, + }, + // Polygon fill + { + id: "gl-draw-polygon-fill", + type: "fill", + filter: ["all", ["==", "$type", "Polygon"]], + paint: { + "fill-color": [ + "case", + ["==", ["get", "active"], "true"], + styling.active_color, + styling.fill_color, + ], + "fill-outline-color": [ + "case", + ["==", ["get", "active"], "true"], + styling.active_color, + styling.fill_color, + ], + "fill-opacity": styling.fill_opacity, + }, + }, + // Polygon outline + { + id: "gl-draw-polygon-stroke", + type: "line", + filter: ["all", ["==", "$type", "Polygon"]], + layout: { + "line-cap": "round", + "line-join": "round", + }, + paint: { + "line-color": [ + "case", + ["==", ["get", "active"], "true"], + styling.active_color, + styling.line_color, + ], + "line-width": styling.line_width, + }, + }, + // Midpoints + { + id: "gl-draw-polygon-midpoint", + type: "circle", + filter: [ + "all", + ["==", "$type", "Point"], + ["==", "meta", "midpoint"], + ], + paint: { + "circle-radius": 3, + "circle-color": styling.active_color, + }, + }, + // Vertex point halos + { + id: "gl-draw-vertex-halo-active", + type: "circle", + filter: [ + "all", + ["==", "meta", "vertex"], + ["==", "$type", "Point"], + ], + paint: { + "circle-radius": [ + "case", + ["==", ["get", "active"], "true"], + styling.vertex_radius + 4, + styling.vertex_radius + 2, + ], + "circle-color": "#FFF", + }, + }, + // Vertex points + { + id: "gl-draw-vertex-active", + type: "circle", + filter: [ + "all", + ["==", "meta", "vertex"], + ["==", "$type", "Point"], + ], + paint: { + "circle-radius": [ + "case", + ["==", ["get", "active"], "true"], + styling.vertex_radius + 2, + styling.vertex_radius, + ], + "circle-color": styling.active_color, + }, + }, + ]; + } + + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn("Source not found or has no data:", sourceId); + } + } + + // Add geocoder control if enabled + if (mapData.geocoder_control) { + const geocoderOptions = { + accessToken: mapboxgl.accessToken, + mapboxgl: mapboxgl, + ...mapData.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MapboxGeocoder(geocoderOptions); + + map.addControl( + geocoder, + mapData.geocoder_control.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("result", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e.result, + time: new Date(), + }); + }); + } + + // Add draw control if enabled + if (mapData.draw_control) { + if (mapData.draw_control && mapData.draw_control.enabled) { + let drawOptions = mapData.draw_control.options || {}; + + // Generate styles if styling parameters provided + if (mapData.draw_control.styling) { + const generatedStyles = generateDrawStyles( + mapData.draw_control.styling, + ); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (mapData.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, ); - } - } + this.map.simplify_freehand = + mapData.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, mapData.draw_control.position); + map.controls.push(draw); + + // Add initial features if provided + if (mapData.draw_control.source) { + addSourceFeaturesToDraw(draw, mapData.draw_control.source, map); + } + + // Process any queued features + if (mapData.draw_features_queue) { + mapData.draw_features_queue.forEach(function (data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } + + // Apply orientation styling + if (mapData.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".mapboxgl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; } - }, + } + } - resize: function (width, height) { - // Code to handle resizing if necessary - }, - }; - }, + // Helper function for updating drawn features + function updateDrawnFeatures() { + if (HTMLWidgets.shinyMode && draw) { + const features = draw.getAll(); + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(features), + ); + } + } + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + } + + // Add reset control if enabled + if (mapData.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = "mapboxgl-ctrl-icon mapboxgl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = "mapboxgl-ctrl mapboxgl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: mapData.reset_control.animate, + }; + + if (mapData.reset_control.duration) { + initialView.duration = mapData.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild(resetContainer); + }, + }, + mapData.reset_control.position, + ); + } + + // Add the layers control if provided + if (mapData.layers_control) { + const layersControl = document.createElement("div"); + layersControl.id = mapData.layers_control.control_id; + + // Handle use_icon parameter + let className = mapData.layers_control.collapsible + ? "layers-control collapsible" + : "layers-control"; + + layersControl.className = className; + layersControl.style.position = "absolute"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = mapData.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + el.appendChild(layersControl); + + const layersList = document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + mapData.layers_control.layers || + map.getStyle().layers.map((layer) => layer.id); + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty(clickedLayer, "visibility", "none"); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty(clickedLayer, "visibility", "visible"); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (mapData.layers_control.collapsible) { + const toggleButton = document.createElement("div"); + toggleButton.className = "toggle-button"; + + if (mapData.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore(toggleButton, layersList); + } + } + } + }, + + resize: function (width, height) { + // Code to handle resizing if necessary + }, + }; + }, }); diff --git a/inst/htmlwidgets/mapboxgl_compare.yaml b/inst/htmlwidgets/mapboxgl_compare.yaml index 2e78ed6b..4ecd7f36 100644 --- a/inst/htmlwidgets/mapboxgl_compare.yaml +++ b/inst/htmlwidgets/mapboxgl_compare.yaml @@ -1,11 +1,37 @@ dependencies: - - name: mapbox-gl-js - version: "3.6.0" - src: - href: "https://api.mapbox.com/mapbox-gl-js/" - script: - - "v3.6.0/mapbox-gl.js" - - "plugins/mapbox-gl-compare/v0.4.0/mapbox-gl-compare.js" - stylesheet: - - "v3.6.0/mapbox-gl.css" - - "plugins/mapbox-gl-compare/v0.4.0/mapbox-gl-compare.css" + - name: mapbox-gl-js + version: "3.12.0" + src: + href: "https://api.mapbox.com/mapbox-gl-js/" + script: + - "v3.12.0/mapbox-gl.js" + - "plugins/mapbox-gl-compare/v0.4.0/mapbox-gl-compare.js" + stylesheet: + - "v3.12.0/mapbox-gl.css" + - "plugins/mapbox-gl-compare/v0.4.0/mapbox-gl-compare.css" + - name: mapbox-gl-draw + version: "1.4.3" + src: + href: "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/" + script: + - "mapbox-gl-draw.js" + stylesheet: + - "mapbox-gl-draw.css" + - name: freehand-mode + version: 1.0.0 + src: "htmlwidgets/lib/freehand-mode" + script: + - "freehand-mode.js" + - name: mapbox-gl-geocoder + version: 5.0.0 + src: + href: "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/" + script: + - "mapbox-gl-geocoder.min.js" + stylesheet: + - "mapbox-gl-geocoder.css" + - name: mapbox-gl-globe-minimap + version: 1.2.1 + src: "htmlwidgets/lib/mapbox-gl-globe-minimap" + script: + - "bundle.js" diff --git a/inst/htmlwidgets/maplibregl.js b/inst/htmlwidgets/maplibregl.js index 9ac263da..4c056115 100644 --- a/inst/htmlwidgets/maplibregl.js +++ b/inst/htmlwidgets/maplibregl.js @@ -1,26 +1,262 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case 'get': + return properties[expression[1]]; + case 'concat': + return expression.slice(1).map(item => evaluateExpression(item, properties)).join(''); + case 'to-string': + return String(evaluateExpression(expression[1], properties)); + case 'to-number': + return Number(evaluateExpression(expression[1], properties)); + case 'number-format': + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || 'en-US'; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty('min-fraction-digits')) { + formatOptions.minimumFractionDigits = options['min-fraction-digits']; + } + if (options.hasOwnProperty('max-fraction-digits')) { + formatOptions.maximumFractionDigits = options['max-fraction-digits']; + } + if (options.hasOwnProperty('min-integer-digits')) { + formatOptions.minimumIntegerDigits = options['min-integer-digits']; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty('useGrouping')) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { - map.getCanvas().style.cursor = "pointer"; - if (e.features.length > 0) { - const description = e.features[0].properties[tooltipProperty]; - tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); - - // Store reference to currently active tooltip - window._activeTooltip = tooltipPopup; - } else { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + // Clear any existing active tooltip first to prevent stacking + if (window._activeTooltip && window._activeTooltip !== tooltipPopup) { + window._activeTooltip.remove(); + } + + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(tooltipProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; tooltipPopup.remove(); - // If this was the active tooltip, clear the reference if (window._activeTooltip === tooltipPopup) { - delete window._activeTooltip; + delete window._activeTooltip; } - } } -function onMouseLeaveTooltip(map, tooltipPopup) { - map.getCanvas().style.cursor = ""; - tooltipPopup.remove(); - if (window._activeTooltip === tooltipPopup) { - delete window._activeTooltip; - } +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + window._mapboxPopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._mapboxPopups[layerId] === popup) { + delete window._mapboxPopups[layerId]; + } + }); +} + +// Helper function to generate draw styles based on parameters +function generateDrawStyles(styling) { + if (!styling) return null; + + return [ + // Point styles + { + 'id': 'gl-draw-point-active', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'true']], + 'paint': { + 'circle-radius': styling.vertex_radius + 2, + 'circle-color': styling.active_color + } + }, + { + 'id': 'gl-draw-point', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'false']], + 'paint': { + 'circle-radius': styling.vertex_radius, + 'circle-color': styling.point_color + } + }, + // Line styles + { + 'id': 'gl-draw-line', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'LineString']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Polygon fill + { + 'id': 'gl-draw-polygon-fill', + 'type': 'fill', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'paint': { + 'fill-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-outline-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-opacity': styling.fill_opacity + } + }, + // Polygon outline + { + 'id': 'gl-draw-polygon-stroke', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Midpoints + { + 'id': 'gl-draw-polygon-midpoint', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'midpoint']], + 'paint': { + 'circle-radius': 3, + 'circle-color': styling.active_color + } + }, + // Vertex point halos + { + 'id': 'gl-draw-vertex-halo-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 4, + styling.vertex_radius + 2 + ], + 'circle-color': '#FFF' + } + }, + // Vertex points + { + 'id': 'gl-draw-vertex-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 2, + styling.vertex_radius + ], + 'circle-color': styling.active_color + } + } + ]; } HTMLWidgets.widget({ @@ -30,6 +266,7 @@ HTMLWidgets.widget({ factory: function (el, width, height) { let map; + let draw; return { renderValue: function (x) { @@ -38,6 +275,9 @@ HTMLWidgets.widget({ return; } + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + map = new maplibregl.Map({ container: el.id, style: x.style, @@ -163,10 +403,21 @@ HTMLWidgets.widget({ if (x.sources) { x.sources.forEach(function (source) { if (source.type === "vector") { - map.addSource(source.id, { + const sourceOptions = { type: "vector", url: source.url, - }); + }; + // Add promoteId if provided + if (source.promoteId) { + sourceOptions.promoteId = source.promoteId; + } + // Add any other additional options + for (const [key, value] of Object.entries(source)) { + if (!["id", "type", "url"].includes(key)) { + sourceOptions[key] = value; + } + } + map.addSource(source.id, sourceOptions); } else if (source.type === "geojson") { const geojsonData = source.data; const sourceOptions = { @@ -231,210 +482,251 @@ HTMLWidgets.widget({ }); } - // Add layers if provided - if (x.layers) { - x.layers.forEach(function (layer) { - try { - const layerConfig = { - id: layer.id, - type: layer.type, - source: layer.source, - layout: layer.layout || {}, - paint: layer.paint || {}, - }; + function add_my_layers(layer) { + try { + const layerConfig = { + id: layer.id, + type: layer.type, + source: layer.source, + layout: layer.layout || {}, + paint: layer.paint || {}, + }; - // Check if source is an object and set generateId if source type is 'geojson' - if ( - typeof layer.source === "object" && - layer.source.type === "geojson" - ) { - layerConfig.source.generateId = true; - } else if (typeof layer.source === "string") { - // Handle string source if needed - layerConfig.source = layer.source; - } + // Check if source is an object and set generateId if source type is 'geojson' + if ( + typeof layer.source === "object" && + layer.source.type === "geojson" + ) { + layerConfig.source.generateId = true; + } else if (typeof layer.source === "string") { + // Handle string source if needed + layerConfig.source = layer.source; + } - if (layer.source_layer) { - layerConfig["source-layer"] = - layer.source_layer; - } + if (layer.source_layer) { + layerConfig["source-layer"] = + layer.source_layer; + } - if (layer.slot) { - layerConfig["slot"] = layer.slot; - } + if (layer.slot) { + layerConfig["slot"] = layer.slot; + } - if (layer.minzoom) { - layerConfig["minzoom"] = layer.minzoom; - } + if (layer.minzoom) { + layerConfig["minzoom"] = layer.minzoom; + } - if (layer.maxzoom) { - layerConfig["maxzoom"] = layer.maxzoom; - } + if (layer.maxzoom) { + layerConfig["maxzoom"] = layer.maxzoom; + } + + if (layer.filter) { + layerConfig["filter"] = layer.filter; + } + + if (layer.before_id) { + map.addLayer(layerConfig, layer.before_id); + } else { + map.addLayer(layerConfig); + } - if (layer.filter) { - layerConfig["filter"] = layer.filter; + // Add popups or tooltips if provided + if (layer.popup) { + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; } - if (layer.before_id) { - map.addLayer(layerConfig, layer.before_id); - } else { - map.addLayer(layerConfig); + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, layer.popup, layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; } + window._mapboxClickHandlers[layer.id] = clickHandler; - // Add popups or tooltips if provided - if (layer.popup) { - map.on("click", layer.id, function (e) { - const description = - e.features[0].properties[ - layer.popup - ]; + // Add the click handler + map.on("click", layer.id, clickHandler); - new maplibregl.Popup() - .setLngLat(e.lngLat) - .setHTML(description) - .addTo(map); - }); + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = "pointer"; + }); - // Change cursor to pointer when hovering over the layer - map.on("mouseenter", layer.id, function () { - map.getCanvas().style.cursor = - "pointer"; - }); + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } - // Change cursor back to default when leaving the layer - map.on("mouseleave", layer.id, function () { - map.getCanvas().style.cursor = ""; - }); - } + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); - if (layer.tooltip) { - const tooltip = new maplibregl.Popup({ - closeButton: false, - closeOnClick: false, - }); + // Create a reference to the mousemove handler function. + // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; - // Create a reference to the mousemove handler function. - // We need to pass 'e', 'map', 'tooltip', and 'layer.tooltip' to onMouseMoveTooltip. - const mouseMoveHandler = function(e) { - onMouseMoveTooltip(e, map, tooltip, layer.tooltip); - }; + // Create a reference to the mouseleave handler function. + // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; - // Create a reference to the mouseleave handler function. - // We need to pass 'map' and 'tooltip' to onMouseLeaveTooltip. - const mouseLeaveHandler = function() { - onMouseLeaveTooltip(map, tooltip); - }; + // Attach the named handler references, not anonymous functions. + map.on("mousemove", layer.id, mouseMoveHandler); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); - // Attach the named handler references, not anonymous functions. - map.on("mousemove", layer.id, mouseMoveHandler); - map.on("mouseleave", layer.id, mouseLeaveHandler); + // Store these handler references so you can remove them later if needed + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } - // Store these handler references so you can remove them later if needed - if (!window._mapboxHandlers) { - window._mapboxHandlers = {}; - } - window._mapboxHandlers[layer.id] = { - mousemove: mouseMoveHandler, - mouseleave: mouseLeaveHandler - }; + // Add hover effect if provided + if (layer.hover_options) { + const jsHoverOptions = {}; + for (const [key, value] of Object.entries( + layer.hover_options, + )) { + const jsKey = key.replace(/_/g, "-"); + jsHoverOptions[jsKey] = value; } - // Add hover effect if provided - if (layer.hover_options) { - const jsHoverOptions = {}; - for (const [key, value] of Object.entries( - layer.hover_options, - )) { - const jsKey = key.replace(/_/g, "-"); - jsHoverOptions[jsKey] = value; - } + let hoveredFeatureId = null; - let hoveredFeatureId = null; + map.on("mousemove", layer.id, function (e) { + if (e.features.length > 0) { + // Check if the feature has an id + const featureId = e.features[0].id; - map.on("mousemove", layer.id, function (e) { - if (e.features.length > 0) { + // Only proceed if the feature has an id + if (featureId !== undefined && featureId !== null) { if (hoveredFeatureId !== null) { - map.setFeatureState( - { - source: - typeof layer.source === - "string" - ? layer.source - : layer.id, - id: hoveredFeatureId, - }, - { hover: false }, - ); - } - hoveredFeatureId = e.features[0].id; - map.setFeatureState( - { + const featureState = { source: typeof layer.source === "string" ? layer.source : layer.id, id: hoveredFeatureId, - }, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = featureId; + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; + } + map.setFeatureState( + featureState, { hover: true }, ); } - }); + } + }); - map.on("mouseleave", layer.id, function () { - if (hoveredFeatureId !== null) { - map.setFeatureState( - { - source: - typeof layer.source === - "string" - ? layer.source - : layer.id, - id: hoveredFeatureId, - }, - { hover: false }, - ); + map.on("mouseleave", layer.id, function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof layer.source === + "string" + ? layer.source + : layer.id, + id: hoveredFeatureId, + }; + if (layer.source_layer) { + featureState.sourceLayer = + layer.source_layer; } - hoveredFeatureId = null; - }); + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = null; + }); - Object.keys(jsHoverOptions).forEach( - function (key) { - const originalPaint = - map.getPaintProperty( - layer.id, - key, - ) || layer.paint[key]; - map.setPaintProperty( + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( layer.id, key, - [ - "case", - [ - "boolean", - [ - "feature-state", - "hover", - ], - false, - ], - jsHoverOptions[key], - originalPaint, - ], - ); - }, - ); - } - } catch (e) { - console.error( - "Failed to add layer: ", - layer, - e, + ) || layer.paint[key]; + map.setPaintProperty(layer.id, key, [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + jsHoverOptions[key], + originalPaint, + ]); + }, + ); + } + } catch (e) { + console.error("Failed to add layer: ", layer, e); + } + } + if (x.h3j_sources) { + x.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + + // A bit hacky? + if (x.layers) { + x.layers.forEach((layer) => + add_my_layers(layer), ); } }); } + // Add layers if provided + if (x.layers) { + x.layers.forEach((layer) => add_my_layers(layer)); + } + // Apply setFilter if provided if (x.setFilter) { x.setFilter.forEach(function (filter) { @@ -484,6 +776,43 @@ HTMLWidgets.widget({ map.controls.push(scaleControl); } + // Add globe control if enabled + if (x.globe_control) { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, x.globe_control.position); + map.controls.push(globeControl); + } + + // Add custom controls if any are defined + if (x.custom_controls) { + Object.keys(x.custom_controls).forEach(function(key) { + const controlOptions = x.custom_controls[key]; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; + } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); + }); + } + // Add globe minimap if enabled if (x.globe_minimap && x.globe_minimap.enabled) { const globeMinimapOptions = { @@ -500,6 +829,19 @@ HTMLWidgets.widget({ map.controls.push(globeMinimap); } + if (x.setProjection) { + x.setProjection.forEach(function (projectionConfig) { + if (projectionConfig.projection) { + const projection = + typeof projectionConfig.projection === + "string" + ? { type: projectionConfig.projection } + : projectionConfig.projection; + map.setProjection(projection); + } + }); + } + // Add geocoder control if enabled if (x.geocoder_control) { const geocoderApi = { @@ -581,6 +923,7 @@ HTMLWidgets.widget({ } } + if (x.draw_control && x.draw_control.enabled) { MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; @@ -591,6 +934,14 @@ HTMLWidgets.widget({ let drawOptions = x.draw_control.options || {}; + // Generate styles if styling parameters provided + if (x.draw_control.styling) { + const generatedStyles = generateDrawStyles(x.draw_control.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + if (x.draw_control.freehand) { drawOptions = Object.assign({}, drawOptions, { modes: Object.assign({}, MapboxDraw.modes, { @@ -616,6 +967,19 @@ HTMLWidgets.widget({ }); } + // Fix MapLibre compatibility - ensure we always have custom styles + if (!drawOptions.styles) { + drawOptions.styles = generateDrawStyles({ + vertex_radius: 5, + active_color: '#fbb03b', + point_color: '#3bb2d0', + line_color: '#3bb2d0', + fill_color: '#3bb2d0', + fill_opacity: 0.1, + line_width: 2 + }); + } + draw = new MapboxDraw(drawOptions); map.addControl(draw, x.draw_control.position); map.controls.push(draw); @@ -625,6 +989,21 @@ HTMLWidgets.widget({ map.on("draw.delete", updateDrawnFeatures); map.on("draw.update", updateDrawnFeatures); + // Add initial features if provided + if (x.draw_control.source) { + addSourceFeaturesToDraw(draw, x.draw_control.source, map); + } + + // Process any queued features + if (x.draw_features_queue) { + x.draw_features_queue.forEach(function(data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } + // Apply orientation styling if (x.draw_control.orientation === "horizontal") { const drawBar = map @@ -637,6 +1016,16 @@ HTMLWidgets.widget({ } } + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn('Source not found or has no data:', sourceId); + } + } + function updateDrawnFeatures() { if (draw) { var drawnFeatures = draw.getAll(); @@ -800,20 +1189,29 @@ HTMLWidgets.widget({ "maplibregl-ctrl maplibregl-ctrl-group"; resetContainer.appendChild(resetControl); - const initialView = { - center: x.center, - zoom: x.zoom, - pitch: x.pitch, - bearing: x.bearing, - animate: x.reset_control.animate, - }; + // Initialize with empty object, will be populated after map loads + let initialView = {}; + + // Capture the initial view after the map has loaded and all view operations are complete + map.once('load', function() { + initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: x.reset_control.animate, + }; - if (x.reset_control.duration) { - initialView.duration = x.reset_control.duration; - } + if (x.reset_control.duration) { + initialView.duration = x.reset_control.duration; + } + }); resetControl.onclick = function () { - map.easeTo(initialView); + // Only reset if we have captured the initial view + if (initialView.center) { + map.easeTo(initialView); + } }; map.addControl( @@ -871,9 +1269,59 @@ HTMLWidgets.widget({ ? "layers-control collapsible" : "layers-control"; layersControl.style.position = "absolute"; - layersControl.style[ - x.layers_control.position || "top-right" - ] = "10px"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + x.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (x.layers_control.custom_colors) { + const colors = x.layers_control.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${x.layers_control.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${x.layers_control.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${x.layers_control.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${x.layers_control.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${x.layers_control.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${x.layers_control.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } + el.appendChild(layersControl); const layersList = document.createElement("div"); @@ -895,7 +1343,25 @@ HTMLWidgets.widget({ link.id = layerId; link.href = "#"; link.textContent = layerId; - link.className = "active"; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } // Show or hide layer when the toggle is clicked link.onclick = function (e) { @@ -916,6 +1382,15 @@ HTMLWidgets.widget({ "none", ); this.className = ""; + + // Hide associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); } else { this.className = "active"; map.setLayoutProperty( @@ -923,6 +1398,15 @@ HTMLWidgets.widget({ "visibility", "visible", ); + + // Show associated legends + const associatedLegends = + document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); } }; @@ -933,7 +1417,25 @@ HTMLWidgets.widget({ if (x.layers_control.collapsible) { const toggleButton = document.createElement("div"); toggleButton.className = "toggle-button"; - toggleButton.textContent = "Layers"; + + // Use stacked layers icon instead of text if requested + if (x.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + toggleButton.onclick = function () { layersControl.classList.toggle("open"); }; @@ -976,6 +1478,7 @@ HTMLWidgets.widget({ // Add click event listener in shinyMode if (HTMLWidgets.shinyMode) { + map.on("click", function (e) { const features = map.queryRenderedFeatures(e.point); @@ -1003,11 +1506,38 @@ HTMLWidgets.widget({ time: new Date(), }); }); + + // also add hover listener for shinyMode! + map.on("mousemove", function (e) { + const features = map.queryRenderedFeatures(e.point); + + if(features.length > 0) { + const feature = features[0]; + Shiny.onInputChange(el.id + "_feature_hover", { + id: feature.id, + properties: feature.properties, + layer: feature.layer.id, + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: new Date(), + }); + } else { + Shiny.onInputChange( + el.id + "_feature_hover", + null, + ); + } + + Shiny.onInputChange(el.id + "_hover", { + lng: e.lngLat.lng, + lat: e.lngLat.let, + time: new Date(), + }); + }); } el.map = map; }); - el.map = map; }, @@ -1015,6 +1545,10 @@ HTMLWidgets.widget({ return map; // Return the map instance }, + getDraw: function () { + return draw; // Return the draw instance + }, + getDrawnFeatures: function () { return ( this.drawFeatures || { @@ -1040,11 +1574,48 @@ if (HTMLWidgets.shinyMode) { var map = widget.getMap(); if (map) { var message = data.message; - if (message.type === "set_filter") { - map.setFilter(message.layer, message.filter); - } else if (message.type === "add_source") { - map.addSource(message.source); - } else if (message.type === "add_layer") { + + // Initialize layer state tracking if not already present + if (!window._mapglLayerState) { + window._mapglLayerState = {}; + } + const mapId = map.getContainer().id; + if (!window._mapglLayerState[mapId]) { + window._mapglLayerState[mapId] = { + filters: {}, // layerId -> filter expression + paintProperties: {}, // layerId -> {propertyName -> value} + layoutProperties: {}, // layerId -> {propertyName -> value} + tooltips: {}, // layerId -> tooltip property + popups: {}, // layerId -> popup property + legends: {} // legendId -> {html: string, css: string} + }; + } + const layerState = window._mapglLayerState[mapId]; + + // Helper function to update drawn features + function updateDrawnFeatures() { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + var drawnFeatures = drawControl.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(drawnFeatures) + ); + } + // Store drawn features in the widget's data + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + // Track filter state for layer restoration + layerState.filters[message.layer] = message.filter; + } else if (message.type === "add_source") { + map.addSource(message.source); + } else if (message.type === "add_layer") { try { if (message.layer.before_id) { map.addLayer(message.layer, message.layer.before_id); @@ -1054,14 +1625,24 @@ if (HTMLWidgets.shinyMode) { // Add popups or tooltips if provided if (message.layer.popup) { - map.on("click", message.layer.id, function (e) { - const description = - e.features[0].properties[message.layer.popup]; - new maplibregl.Popup() - .setLngLat(e.lngLat) - .setHTML(description) - .addTo(map); - }); + // Initialize popup tracking if it doesn't exist + if (!window._mapboxPopups) { + window._mapboxPopups = {}; + } + + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, message.layer.popup, message.layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on("click", message.layer.id, clickHandler); // Change cursor to pointer when hovering over the layer map.on("mouseenter", message.layer.id, function () { @@ -1081,17 +1662,26 @@ if (HTMLWidgets.shinyMode) { }); // Define named handler functions: - const mouseMoveHandler = function(e) { - onMouseMoveTooltip(e, map, tooltip, message.layer.tooltip); + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); }; - const mouseLeaveHandler = function() { + const mouseLeaveHandler = function () { onMouseLeaveTooltip(map, tooltip); }; // Attach handlers by reference: map.on("mousemove", message.layer.id, mouseMoveHandler); - map.on("mouseleave", message.layer.id, mouseLeaveHandler); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); // Store these handler references for later removal: if (!window._mapboxHandlers) { @@ -1099,7 +1689,7 @@ if (HTMLWidgets.shinyMode) { } window._mapboxHandlers[message.layer.id] = { mousemove: mouseMoveHandler, - mouseleave: mouseLeaveHandler + mouseleave: mouseLeaveHandler, }; } @@ -1117,45 +1707,66 @@ if (HTMLWidgets.shinyMode) { map.on("mousemove", message.layer.id, function (e) { if (e.features.length > 0) { - if (hoveredFeatureId !== null) { - map.setFeatureState( - { + // Check if the feature has an id + const featureId = e.features[0].id; + + // Only proceed if the feature has an id + if (featureId !== undefined && featureId !== null) { + if (hoveredFeatureId !== null) { + const featureState = { source: typeof message.layer.source === "string" ? message.layer.source : message.layer.id, id: hoveredFeatureId, - }, - { hover: false }, - ); - } - hoveredFeatureId = e.features[0].id; - map.setFeatureState( - { + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: false }, + ); + } + hoveredFeatureId = featureId; + const featureState = { source: typeof message.layer.source === "string" ? message.layer.source : message.layer.id, id: hoveredFeatureId, - }, - { hover: true }, - ); + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { hover: true }, + ); + } } }); map.on("mouseleave", message.layer.id, function () { if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer.source === + "string" + ? message.layer.source + : message.layer.id, + id: hoveredFeatureId, + }; + if (message.layer.source_layer) { + featureState.sourceLayer = + message.layer.source_layer; + } map.setFeatureState( - { - source: - typeof message.layer.source === - "string" - ? message.layer.source - : message.layer.id, - id: hoveredFeatureId, - }, + featureState, { hover: false }, ); } @@ -1182,29 +1793,94 @@ if (HTMLWidgets.shinyMode) { ); } } else if (message.type === "remove_layer") { - // If there's an active tooltip, remove it first + // If there's an active tooltip, remove it first if (window._activeTooltip) { - window._activeTooltip.remove(); - delete window._activeTooltip; + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + // Check both message.layer and message.layer.id as keys due to different message formats + if (window._mapboxPopups) { + // First check if we have a popup stored with message.layer key + if (window._mapboxPopups[message.layer]) { + window._mapboxPopups[message.layer].remove(); + delete window._mapboxPopups[message.layer]; + } + + // Also check if we have a popup stored with message.layer.id key, which happens when added via add_layer + if (message.layer && message.layer.id && window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + delete window._mapboxPopups[message.layer.id]; + } } + if (map.getLayer(message.layer)) { - // Check if we have stored handlers for this layer - if (window._mapboxHandlers && window._mapboxHandlers[message.layer]) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer] + ) { const handlers = window._mapboxHandlers[message.layer]; if (handlers.mousemove) { - map.off("mousemove", message.layer, handlers.mousemove); + map.off( + "mousemove", + message.layer, + handlers.mousemove, + ); } if (handlers.mouseleave) { - map.off("mouseleave", message.layer, handlers.mouseleave); + map.off( + "mouseleave", + message.layer, + handlers.mouseleave, + ); } // Clean up the reference delete window._mapboxHandlers[message.layer]; } + + // Remove click handlers for popups + if (window._mapboxClickHandlers) { + // First check for handlers stored with message.layer key + if (window._mapboxClickHandlers[message.layer]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer] + ); + delete window._mapboxClickHandlers[message.layer]; + } + + // Also check for handlers stored with message.layer.id key from add_layer + if (message.layer && message.layer.id && window._mapboxClickHandlers[message.layer.id]) { + map.off( + "click", + message.layer, + window._mapboxClickHandlers[message.layer.id] + ); + delete window._mapboxClickHandlers[message.layer.id]; + } + } + + // Remove the layer map.removeLayer(message.layer); } if (map.getSource(message.layer)) { map.removeSource(message.layer); } + + // Clean up tracked layer state + const mapId = map.getContainer().id; + if (window._mapglLayerState && window._mapglLayerState[mapId]) { + const layerState = window._mapglLayerState[mapId]; + delete layerState.filters[message.layer]; + delete layerState.paintProperties[message.layer]; + delete layerState.layoutProperties[message.layer]; + delete layerState.tooltips[message.layer]; + delete layerState.popups[message.layer]; + // Note: legends are not tied to specific layers, so we don't clear them here + } } else if (message.type === "fit_bounds") { map.fitBounds(message.bounds, message.options); } else if (message.type === "fly_to") { @@ -1223,6 +1899,11 @@ if (HTMLWidgets.shinyMode) { message.name, message.value, ); + // Track layout property state for layer restoration + if (!layerState.layoutProperties[message.layer]) { + layerState.layoutProperties[message.layer] = {}; + } + layerState.layoutProperties[message.layer][message.name] = message.value; } else if (message.type === "set_paint_property") { const layerId = message.layer; const propertyName = message.name; @@ -1259,6 +1940,11 @@ if (HTMLWidgets.shinyMode) { // No hover options, just set the new value directly map.setPaintProperty(layerId, propertyName, newValue); } + // Track paint property state for layer restoration + if (!layerState.paintProperties[layerId]) { + layerState.paintProperties[layerId] = {}; + } + layerState.paintProperties[layerId][propertyName] = newValue; } else if (message.type === "query_rendered_features") { const features = map.queryRenderedFeatures(message.geometry, { layers: message.layers, @@ -1266,15 +1952,35 @@ if (HTMLWidgets.shinyMode) { }); Shiny.setInputValue(el.id + "_feature_query", features); } else if (message.type === "add_legend") { + // Extract legend ID from HTML to track it + const legendIdMatch = message.html.match(/id="([^"]+)"/); + const legendId = legendIdMatch ? legendIdMatch[1] : null; + if (!message.add) { const existingLegends = document.querySelectorAll( `#${data.id} .mapboxgl-legend`, ); existingLegends.forEach((legend) => legend.remove()); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => style.remove()); + + // Clear legend state when replacing all legends + layerState.legends = {}; + } + + // Track legend state + if (legendId) { + layerState.legends[legendId] = { + html: message.html, + css: message.legend_css + }; } const legendCss = document.createElement("style"); legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup document.head.appendChild(legendCss); const legend = document.createElement("div"); @@ -1288,6 +1994,976 @@ if (HTMLWidgets.shinyMode) { message.value, ); } else if (message.type === "set_style") { + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + console.log("[MapGL Debug] set_style called with preserve_layers:", preserveLayers); + console.log("[MapGL Debug] message.preserve_layers:", message.preserve_layers); + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + console.log("[MapGL Debug] Current style sources:", Object.keys(currentStyle.sources)); + console.log("[MapGL Debug] Current style layers:", currentStyle.layers.map(l => l.id)); + + // Store layer IDs we know were added by the user via R code + // This is the most reliable way to identify user-added layers + const knownUserLayerIds = []; + + // For each layer in the current style, determine if it's a user-added layer + currentStyle.layers.forEach(function(layer) { + const layerId = layer.id; + + // Critical: Check for nc_counties specifically since we know that's used in the test app + if (layerId === "nc_counties") { + console.log("[MapGL Debug] Found explicit test layer:", layerId); + knownUserLayerIds.push(layerId); + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found source from test layer:", layer.source); + userSourceIds.push(layer.source); + } + return; // Skip other checks for this layer + } + + // These are common patterns for user-added layers from R code + if ( + // Specific layer IDs from the R package + layerId.endsWith("_counties") || + layerId.endsWith("_label") || + layerId.endsWith("_layer") || + + // Look for hover handlers - only user-added layers have these + (window._mapboxHandlers && window._mapboxHandlers[layerId]) || + + // If the layer ID contains these strings, it's likely user-added + layerId.includes("user") || + layerId.includes("custom") || + + // If the paint property has a hover case, it's user-added + (layer.paint && Object.values(layer.paint).some(value => + Array.isArray(value) && + value[0] === "case" && + Array.isArray(value[1]) && + value[1][1] && + Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && + value[1][1][1] === "hover")) + ) { + console.log("[MapGL Debug] Found user layer:", layerId); + knownUserLayerIds.push(layerId); + // Only include its source if it's not a base map source + if (layer.source && !userSourceIds.includes(layer.source)) { + const layerSource = currentStyle.sources[layer.source]; + const isBaseMapSource = layerSource && layerSource.type === "vector" && ( + layer.source === "composite" || + layer.source === "mapbox" || + layer.source.startsWith("mapbox-") || + layer.source === "openmaptiles" || + layer.source.startsWith("carto") || + layer.source.startsWith("maptiler") + ); + + if (!isBaseMapSource) { + console.log("[MapGL Debug] Found user source from layer:", layer.source); + userSourceIds.push(layer.source); + } else { + console.log("[MapGL Debug] Not adding base map source from layer:", layer.source); + } + } + } + }); + + // For each source, determine if it's a user-added source + for (const sourceId in currentStyle.sources) { + const source = currentStyle.sources[sourceId]; + + console.log("[MapGL Debug] Examining source:", sourceId, "type:", source.type); + + // Strategy 1: All GeoJSON sources are likely user-added + if (source.type === "geojson") { + console.log("[MapGL Debug] Found user GeoJSON source:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 2: Check for source data URL patterns typical of R-generated data + else if (source.url && typeof source.url === 'string' && + (source.url.includes("data:application/json") || + source.url.includes("blob:"))) { + console.log("[MapGL Debug] Found user source with data URL:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 3: Standard filtering - exclude common base map sources + else if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") && + sourceId !== "openmaptiles" && // Common in MapLibre styles + !(sourceId.startsWith("carto") && sourceId !== "carto-source") && // Filter CARTO base sources but keep user ones + !(sourceId.startsWith("maptiler") && !sourceId.includes("user")) && // Filter MapTiler sources but keep user ones + !sourceId.includes("terrain") && // Common terrain sources + !sourceId.includes("hillshade") && // Common hillshade sources + !(sourceId.includes("basemap") && !sourceId.includes("user")) // Filter basemap sources but keep user ones + ) { + console.log("[MapGL Debug] Found user source via filtering:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } else { + console.log("[MapGL Debug] Filtered out base map source:", sourceId); + } + + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + + // Identify layers using user-added sources or known user layer IDs + // ONLY include layers that use genuinely user-added sources (not base map sources) + currentStyle.layers.forEach(function(layer) { + // Check if this layer uses a genuine user source (not filtered out base map sources) + const usesUserSource = userSourceIds.includes(layer.source); + const isKnownUserLayer = knownUserLayerIds.includes(layer.id); + + // Additional check: exclude layers that use base map sources even if they were temporarily added to userSourceIds + const layerSource = currentStyle.sources[layer.source]; + const isBaseMapSource = layerSource && layerSource.type === "vector" && ( + layer.source === "composite" || + layer.source === "mapbox" || + layer.source.startsWith("mapbox-") || + layer.source === "openmaptiles" || + layer.source.startsWith("carto") || + layer.source.startsWith("maptiler") + ); + + if ((usesUserSource || isKnownUserLayer) && !isBaseMapSource) { + userLayers.push(layer); + console.log("[MapGL Debug] Including user layer:", layer.id, "source:", layer.source); + } else if (isBaseMapSource) { + console.log("[MapGL Debug] Excluding base map layer:", layer.id, "source:", layer.source); + } + }); + + // Log detected user sources and layers + console.log("[MapGL Debug] Detected user sources:", userSourceIds); + console.log("[MapGL Debug] Detected user layers:", userLayers.map(l => l.id)); + console.log("[MapGL Debug] Will preserve", userLayers.length, "user layers"); + + // Store them for potential use outside the onStyleLoad event + // This helps in case the event timing is different in MapLibre + if (!window._mapglPreservedData) { + window._mapglPreservedData = {}; + } + window._mapglPreservedData[map.getContainer().id] = { + sources: userSourceIds.map(id => ({id, source: currentStyle.sources[id]})), + layers: userLayers + }; + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + console.log("[MapGL Debug] style.load event fired"); + + try { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + try { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + console.log("[MapGL Debug] Re-adding source:", sourceId); + map.addSource(sourceId, source); + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding source:", sourceId, err); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Re-adding layer:", layer.id); + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + console.log("[MapGL Debug] Re-adding mousemove handler for:", layer.id); + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + console.log("[MapGL Debug] Re-adding mouseleave handler for:", layer.id); + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Check if we need to restore tooltip handlers + const layerId = layer.id; + if (layerId === "nc_counties" || layer.tooltip) { + console.log("[MapGL Debug] Restoring tooltip for:", layerId); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = layer.tooltip || "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Error re-adding layer:", layer.id, err); + } + }); + } catch (err) { + console.error("[MapGL Debug] Error in style.load handler:", err); + } + + // Clear any active tooltips before restoration to prevent stacking + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Restore tracked layer modifications + const mapId = map.getContainer().id; + const savedLayerState = window._mapglLayerState && window._mapglLayerState[mapId]; + if (savedLayerState) { + console.log("[MapGL Debug] Restoring tracked layer modifications"); + + // Restore filters + for (const layerId in savedLayerState.filters) { + if (map.getLayer(layerId)) { + console.log("[MapGL Debug] Restoring filter for layer:", layerId); + map.setFilter(layerId, savedLayerState.filters[layerId]); + } + } + + // Restore paint properties + for (const layerId in savedLayerState.paintProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.paintProperties[layerId]; + for (const propertyName in properties) { + const savedValue = properties[propertyName]; + + console.log("[MapGL Debug] Restoring paint property:", layerId, propertyName, savedValue); + + // Check if layer has hover effects that need to be preserved + const currentValue = map.getPaintProperty(layerId, propertyName); + if (currentValue && Array.isArray(currentValue) && currentValue[0] === "case") { + // Preserve hover effects while updating base value + const hoverValue = currentValue[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + savedValue, + ]; + map.setPaintProperty(layerId, propertyName, newPaintProperty); + } else { + map.setPaintProperty(layerId, propertyName, savedValue); + } + } + } + } + + // Restore layout properties + for (const layerId in savedLayerState.layoutProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.layoutProperties[layerId]; + for (const propertyName in properties) { + console.log("[MapGL Debug] Restoring layout property:", layerId, propertyName, properties[propertyName]); + map.setLayoutProperty(layerId, propertyName, properties[propertyName]); + } + } + } + + // Restore tooltips + for (const layerId in savedLayerState.tooltips) { + if (map.getLayer(layerId)) { + const tooltipProperty = savedLayerState.tooltips[layerId]; + console.log("[MapGL Debug] Restoring tooltip:", layerId, tooltipProperty); + + // Remove existing tooltip handlers first + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + if (window._mapboxHandlers[layerId].mousemove) { + map.off("mousemove", layerId, window._mapboxHandlers[layerId].mousemove); + } + if (window._mapboxHandlers[layerId].mouseleave) { + map.off("mouseleave", layerId, window._mapboxHandlers[layerId].mouseleave); + } + } + + // Create new tooltip + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, tooltipProperty); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store handler references + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + } + + // Restore popups + for (const layerId in savedLayerState.popups) { + if (map.getLayer(layerId)) { + const popupProperty = savedLayerState.popups[layerId]; + console.log("[MapGL Debug] Restoring popup:", layerId, popupProperty); + + // Remove existing popup handlers first + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + } + + // Create new popup handler + const clickHandler = function(e) { + onClickPopup(e, map, popupProperty, layerId); + }; + + map.on("click", layerId, clickHandler); + + // Add hover effects for cursor + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } + } + + // Restore legends + if (Object.keys(savedLayerState.legends).length > 0) { + // Clear any existing legends first to prevent stacking + const existingLegends = document.querySelectorAll(`#${mapId} .mapboxgl-legend`); + existingLegends.forEach((legend) => legend.remove()); + + // Clear existing legend styles + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${mapId}"]`); + legendStyles.forEach((style) => style.remove()); + + // Restore each legend + for (const legendId in savedLayerState.legends) { + const legendData = savedLayerState.legends[legendId]; + console.log("[MapGL Debug] Restoring legend:", legendId); + + // Add legend CSS + const legendCss = document.createElement("style"); + legendCss.innerHTML = legendData.css; + legendCss.setAttribute('data-mapgl-legend-css', mapId); + document.head.appendChild(legendCss); + + // Add legend HTML + const legend = document.createElement("div"); + legend.innerHTML = legendData.html; + legend.classList.add("mapboxgl-legend"); + const mapContainer = document.getElementById(mapId); + if (mapContainer) { + mapContainer.appendChild(legend); + } + } + } + } + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + + // Add a backup mechanism specific to MapLibre + // Some MapLibre styles or versions may have different event timing + if (userLayers.length > 0) { + // Set a timeout to check if layers were added after a reasonable delay + setTimeout(function() { + try { + console.log("[MapGL Debug] Running backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Backup restoration needed for layers"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding layer", layer.id, err); + } + }); + + // Restore tracked layer modifications in backup + const mapId = map.getContainer().id; + const savedLayerState = window._mapglLayerState && window._mapglLayerState[mapId]; + if (savedLayerState) { + console.log("[MapGL Debug] Backup: restoring tracked layer modifications"); + + // Restore filters + for (const layerId in savedLayerState.filters) { + if (map.getLayer(layerId)) { + console.log("[MapGL Debug] Backup: restoring filter for layer:", layerId); + map.setFilter(layerId, savedLayerState.filters[layerId]); + } + } + + // Restore paint properties + for (const layerId in savedLayerState.paintProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.paintProperties[layerId]; + for (const propertyName in properties) { + const savedValue = properties[propertyName]; + console.log("[MapGL Debug] Backup: restoring paint property:", layerId, propertyName, savedValue); + + // Check if layer has hover effects that need to be preserved + const currentValue = map.getPaintProperty(layerId, propertyName); + if (currentValue && Array.isArray(currentValue) && currentValue[0] === "case") { + // Preserve hover effects while updating base value + const hoverValue = currentValue[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + savedValue, + ]; + map.setPaintProperty(layerId, propertyName, newPaintProperty); + } else { + map.setPaintProperty(layerId, propertyName, savedValue); + } + } + } + } + + // Restore layout properties + for (const layerId in savedLayerState.layoutProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.layoutProperties[layerId]; + for (const propertyName in properties) { + console.log("[MapGL Debug] Backup: restoring layout property:", layerId, propertyName, properties[propertyName]); + map.setLayoutProperty(layerId, propertyName, properties[propertyName]); + } + } + } + + // Restore tooltips + for (const layerId in savedLayerState.tooltips) { + if (map.getLayer(layerId)) { + const tooltipProperty = savedLayerState.tooltips[layerId]; + console.log("[MapGL Debug] Backup: restoring tooltip:", layerId, tooltipProperty); + + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + if (window._mapboxHandlers[layerId].mousemove) { + map.off("mousemove", layerId, window._mapboxHandlers[layerId].mousemove); + } + if (window._mapboxHandlers[layerId].mouseleave) { + map.off("mouseleave", layerId, window._mapboxHandlers[layerId].mouseleave); + } + } + + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, tooltipProperty); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + } + + // Restore popups + for (const layerId in savedLayerState.popups) { + if (map.getLayer(layerId)) { + const popupProperty = savedLayerState.popups[layerId]; + console.log("[MapGL Debug] Backup: restoring popup:", layerId, popupProperty); + + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + } + + const clickHandler = function(e) { + onClickPopup(e, map, popupProperty, layerId); + }; + + map.on("click", layerId, clickHandler); + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } + } + + // Restore legends + if (Object.keys(savedLayerState.legends).length > 0) { + // Clear any existing legends first to prevent stacking + const existingLegends = document.querySelectorAll(`#${mapId} .mapboxgl-legend`); + existingLegends.forEach((legend) => legend.remove()); + + // Clear existing legend styles + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${mapId}"]`); + legendStyles.forEach((style) => style.remove()); + + // Restore each legend + for (const legendId in savedLayerState.legends) { + const legendData = savedLayerState.legends[legendId]; + console.log("[MapGL Debug] Backup: restoring legend:", legendId); + + // Add legend CSS + const legendCss = document.createElement("style"); + legendCss.innerHTML = legendData.css; + legendCss.setAttribute('data-mapgl-legend-css', mapId); + document.head.appendChild(legendCss); + + // Add legend HTML + const legend = document.createElement("div"); + legend.innerHTML = legendData.html; + legend.classList.add("mapboxgl-legend"); + const mapContainer = document.getElementById(mapId); + if (mapContainer) { + mapContainer.appendChild(legend); + } + } + } + } + } else { + console.log("[MapGL Debug] Backup check: layers already restored properly"); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in backup restoration:", err); + } + }, 500); // 500ms delay - faster recovery + + // Add a second backup with a bit more delay in case the first one fails + setTimeout(function() { + try { + console.log("[MapGL Debug] Running second backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Second backup restoration needed"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Second backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Second backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Second backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Second backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Second backup: error adding layer", layer.id, err); + } + }); + + // Restore tracked layer modifications in second backup + const mapId = map.getContainer().id; + const savedLayerState = window._mapglLayerState && window._mapglLayerState[mapId]; + if (savedLayerState) { + console.log("[MapGL Debug] Second backup: restoring tracked layer modifications"); + + // Restore filters + for (const layerId in savedLayerState.filters) { + if (map.getLayer(layerId)) { + console.log("[MapGL Debug] Second backup: restoring filter for layer:", layerId); + map.setFilter(layerId, savedLayerState.filters[layerId]); + } + } + + // Restore paint properties + for (const layerId in savedLayerState.paintProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.paintProperties[layerId]; + for (const propertyName in properties) { + const savedValue = properties[propertyName]; + console.log("[MapGL Debug] Second backup: restoring paint property:", layerId, propertyName, savedValue); + + // Check if layer has hover effects that need to be preserved + const currentValue = map.getPaintProperty(layerId, propertyName); + if (currentValue && Array.isArray(currentValue) && currentValue[0] === "case") { + // Preserve hover effects while updating base value + const hoverValue = currentValue[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + savedValue, + ]; + map.setPaintProperty(layerId, propertyName, newPaintProperty); + } else { + map.setPaintProperty(layerId, propertyName, savedValue); + } + } + } + } + + // Restore layout properties + for (const layerId in savedLayerState.layoutProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.layoutProperties[layerId]; + for (const propertyName in properties) { + console.log("[MapGL Debug] Second backup: restoring layout property:", layerId, propertyName, properties[propertyName]); + map.setLayoutProperty(layerId, propertyName, properties[propertyName]); + } + } + } + + // Restore tooltips + for (const layerId in savedLayerState.tooltips) { + if (map.getLayer(layerId)) { + const tooltipProperty = savedLayerState.tooltips[layerId]; + console.log("[MapGL Debug] Second backup: restoring tooltip:", layerId, tooltipProperty); + + if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { + if (window._mapboxHandlers[layerId].mousemove) { + map.off("mousemove", layerId, window._mapboxHandlers[layerId].mousemove); + } + if (window._mapboxHandlers[layerId].mouseleave) { + map.off("mouseleave", layerId, window._mapboxHandlers[layerId].mouseleave); + } + } + + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, tooltipProperty); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + } + + // Restore popups + for (const layerId in savedLayerState.popups) { + if (map.getLayer(layerId)) { + const popupProperty = savedLayerState.popups[layerId]; + console.log("[MapGL Debug] Second backup: restoring popup:", layerId, popupProperty); + + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + } + + const clickHandler = function(e) { + onClickPopup(e, map, popupProperty, layerId); + }; + + map.on("click", layerId, clickHandler); + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } + } + + // Restore legends + if (Object.keys(savedLayerState.legends).length > 0) { + // Clear any existing legends first to prevent stacking + const existingLegends = document.querySelectorAll(`#${mapId} .mapboxgl-legend`); + existingLegends.forEach((legend) => legend.remove()); + + // Clear existing legend styles + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${mapId}"]`); + legendStyles.forEach((style) => style.remove()); + + // Restore each legend + for (const legendId in savedLayerState.legends) { + const legendData = savedLayerState.legends[legendId]; + console.log("[MapGL Debug] Second backup: restoring legend:", legendId); + + // Add legend CSS + const legendCss = document.createElement("style"); + legendCss.innerHTML = legendData.css; + legendCss.setAttribute('data-mapgl-legend-css', mapId); + document.head.appendChild(legendCss); + + // Add legend HTML + const legend = document.createElement("div"); + legend.innerHTML = legendData.html; + legend.classList.add("mapboxgl-legend"); + const mapContainer = document.getElementById(mapId); + if (mapContainer) { + mapContainer.appendChild(legend); + } + } + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Error in second backup:", err); + } + }, 1000); // 1 second delay for second backup + } + } + + // Change the style + console.log("[MapGL Debug] About to call setStyle with:", message.style); + console.log("[MapGL Debug] setStyle diff option:", message.diff); map.setStyle(message.style, { diff: message.diff }); if (message.config) { @@ -1327,6 +3003,15 @@ if (HTMLWidgets.shinyMode) { "maplibregl-ctrl-group"; let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + if (message.freehand) { drawOptions = Object.assign({}, drawOptions, { modes: Object.assign({}, MapboxDraw.modes, { @@ -1336,15 +3021,24 @@ if (HTMLWidgets.shinyMode) { }); } - draw = new MapboxDraw(drawOptions); - map.addControl(draw, message.position); - map.controls.push(draw); + // Create the draw control + var drawControl = new MapboxDraw(drawOptions); + map.addControl(drawControl, message.position); + map.controls.push(drawControl); + + // Store the draw control on the widget for later access + widget.drawControl = drawControl; // Add event listeners map.on("draw.create", updateDrawnFeatures); map.on("draw.delete", updateDrawnFeatures); map.on("draw.update", updateDrawnFeatures); + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(drawControl, message.source, map); + } + // Apply orientation styling if (message.orientation === "horizontal") { const drawBar = map @@ -1356,16 +3050,9 @@ if (HTMLWidgets.shinyMode) { } } } else if (message.type === "get_drawn_features") { - if ( - map.controls && - map.controls.some( - (control) => control instanceof MapboxDraw, - ) - ) { - const drawControl = map.controls.find( - (control) => control instanceof MapboxDraw, - ); - const features = drawControl ? drawControl.getAll() : null; + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + const features = drawControl.getAll(); Shiny.setInputValue( data.id + "_drawn_features", JSON.stringify(features), @@ -1377,11 +3064,24 @@ if (HTMLWidgets.shinyMode) { ); } } else if (message.type === "clear_drawn_features") { - if (draw) { - draw.deleteAll(); + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + drawControl.deleteAll(); // Update the drawn features updateDrawnFeatures(); } + } else if (message.type === "add_features_to_draw") { + var drawControl = widget.drawControl || widget.getDraw(); + if (drawControl) { + if (message.data.clear_existing) { + drawControl.deleteAll(); + } + addSourceFeaturesToDraw(drawControl, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn('Draw control not initialized'); + } } else if (message.type === "add_markers") { if (!window.maplibreMarkers) { window.maplibreMarkers = []; @@ -1626,7 +3326,57 @@ if (HTMLWidgets.shinyMode) { ? "layers-control collapsible" : "layers-control"; layersControl.style.position = "absolute"; - layersControl.style[message.position || "top-right"] = "10px"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "10px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `#${message.control_id} { background-color: ${colors.background}; }\n`; + } + + if (colors.text) { + css += `#${message.control_id} a { color: ${colors.text}; }\n`; + } + + if (colors.active) { + css += `#${message.control_id} a.active { background-color: ${colors.active}; }\n`; + css += `#${message.control_id} .toggle-button { background-color: ${colors.active}; }\n`; + } + + if (colors.activeText) { + css += `#${message.control_id} a.active { color: ${colors.activeText}; }\n`; + css += `#${message.control_id} .toggle-button { color: ${colors.activeText}; }\n`; + } + + if (colors.hover) { + css += `#${message.control_id} a:hover { background-color: ${colors.hover}; }\n`; + css += `#${message.control_id} .toggle-button:hover { background-color: ${colors.hover}; }\n`; + } + + styleEl.textContent = css; + document.head.appendChild(styleEl); + } const layersList = document.createElement("div"); layersList.className = "layers-list"; @@ -1644,7 +3394,24 @@ if (HTMLWidgets.shinyMode) { link.id = layerId; link.href = "#"; link.textContent = layerId; - link.className = "active"; + + // Check if the layer visibility is set to "none" initially + const initialVisibility = map.getLayoutProperty( + layerId, + "visibility", + ); + link.className = + initialVisibility === "none" ? "" : "active"; + + // Also hide any associated legends if the layer is initially hidden + if (initialVisibility === "none") { + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${layerId}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); + } link.onclick = function (e) { const clickedLayer = this.textContent; @@ -1663,6 +3430,14 @@ if (HTMLWidgets.shinyMode) { "none", ); this.className = ""; + + // Hide associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = "none"; + }); } else { this.className = "active"; map.setLayoutProperty( @@ -1670,6 +3445,14 @@ if (HTMLWidgets.shinyMode) { "visibility", "visible", ); + + // Show associated legends + const associatedLegends = document.querySelectorAll( + `.mapboxgl-legend[data-layer-id="${clickedLayer}"]`, + ); + associatedLegends.forEach((legend) => { + legend.style.display = ""; + }); } }; @@ -1679,7 +3462,25 @@ if (HTMLWidgets.shinyMode) { if (message.collapsible) { const toggleButton = document.createElement("div"); toggleButton.className = "toggle-button"; - toggleButton.textContent = "Layers"; + + // Use stacked layers icon instead of text if requested + if (message.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + toggleButton.onclick = function () { layersControl.classList.toggle("open"); }; @@ -1703,6 +3504,8 @@ if (HTMLWidgets.shinyMode) { if (legend) { legend.remove(); } + // Remove from legend state + delete layerState.legends[id]; }); } else if (message.ids) { const legend = document.querySelector( @@ -1711,6 +3514,8 @@ if (HTMLWidgets.shinyMode) { if (legend) { legend.remove(); } + // Remove from legend state + delete layerState.legends[message.ids]; } else { const existingLegends = document.querySelectorAll( `#${data.id} .mapboxgl-legend`, @@ -1718,6 +3523,9 @@ if (HTMLWidgets.shinyMode) { existingLegends.forEach((legend) => { legend.remove(); }); + + // Clear all legend state + layerState.legends = {}; } } else if (message.type === "clear_controls") { map.controls.forEach((control) => { @@ -1731,6 +3539,14 @@ if (HTMLWidgets.shinyMode) { if (layersControl) { layersControl.remove(); } + + // Remove globe minimap if it exists + const globeMinimap = document.querySelector( + ".mapboxgl-ctrl-globe-minimap", + ); + if (globeMinimap) { + globeMinimap.remove(); + } } else if (message.type === "move_layer") { if (map.getLayer(message.layer)) { if (message.before) { @@ -1779,36 +3595,39 @@ if (HTMLWidgets.shinyMode) { const layerId = message.layer; const newTooltipProperty = message.tooltip; + // Track tooltip state + layerState.tooltips[layerId] = newTooltipProperty; + // If there's an active tooltip open, remove it first if (window._activeTooltip) { - window._activeTooltip.remove(); - delete window._activeTooltip; + window._activeTooltip.remove(); + delete window._activeTooltip; } // Remove old handlers if any if (window._mapboxHandlers && window._mapboxHandlers[layerId]) { - const handlers = window._mapboxHandlers[layerId]; - if (handlers.mousemove) { - map.off("mousemove", layerId, handlers.mousemove); - } - if (handlers.mouseleave) { - map.off("mouseleave", layerId, handlers.mouseleave); - } - delete window._mapboxHandlers[layerId]; + const handlers = window._mapboxHandlers[layerId]; + if (handlers.mousemove) { + map.off("mousemove", layerId, handlers.mousemove); + } + if (handlers.mouseleave) { + map.off("mouseleave", layerId, handlers.mouseleave); + } + delete window._mapboxHandlers[layerId]; } // Create a new tooltip popup const tooltip = new maplibregl.Popup({ - closeButton: false, - closeOnClick: false, + closeButton: false, + closeOnClick: false, }); // Define new handlers referencing the updated tooltip property - const mouseMoveHandler = function(e) { - onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); + const mouseMoveHandler = function (e) { + onMouseMoveTooltip(e, map, tooltip, newTooltipProperty); }; - const mouseLeaveHandler = function() { - onMouseLeaveTooltip(map, tooltip); + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); }; // Add the new event handlers @@ -1817,33 +3636,134 @@ if (HTMLWidgets.shinyMode) { // Store these handlers so we can remove/update them in the future if (!window._mapboxHandlers) { - window._mapboxHandlers = {}; + window._mapboxHandlers = {}; } window._mapboxHandlers[layerId] = { - mousemove: mouseMoveHandler, - mouseleave: mouseLeaveHandler + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, }; - } else if (message.type === "set_source") { - const layerId = message.layer; - const newData = message.source; - const layerObject = map.getLayer(layerId); - - if (!layerObject) { - console.error("Layer not found: ", layerId); - return; - } - - const sourceId = layerObject.source; - const sourceObject = map.getSource(sourceId); - - if (!sourceObject) { - console.error("Source not found: ", sourceId); - return; - } - - // Update the geojson data - sourceObject.setData(newData); + } else if (message.type === "set_popup") { + const layerId = message.layer; + const newPopupProperty = message.popup; + + // Track popup state + layerState.popups[layerId] = newPopupProperty; + + // Remove any existing popup for this layer + if (window._mapboxPopups && window._mapboxPopups[layerId]) { + window._mapboxPopups[layerId].remove(); + delete window._mapboxPopups[layerId]; + } + + // Remove old click handler if any + if (window._mapboxClickHandlers && window._mapboxClickHandlers[layerId]) { + map.off("click", layerId, window._mapboxClickHandlers[layerId]); + delete window._mapboxClickHandlers[layerId]; + } + + // Remove old hover handlers for cursor change + map.off("mouseenter", layerId); + map.off("mouseleave", layerId); + + // Create new click handler + const clickHandler = function (e) { + onClickPopup(e, map, newPopupProperty, layerId); + }; + + // Add the new event handler + map.on("click", layerId, clickHandler); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layerId, function () { + map.getCanvas().style.cursor = "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layerId, function () { + map.getCanvas().style.cursor = ""; + }); + + // Store handler reference + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[layerId] = clickHandler; + } else if (message.type === "set_source") { + const layerId = message.layer; + const newData = message.source; + const layerObject = map.getLayer(layerId); + + if (!layerObject) { + console.error("Layer not found: ", layerId); + return; + } + + const sourceId = layerObject.source; + const sourceObject = map.getSource(sourceId); + + if (!sourceObject) { + console.error("Source not found: ", sourceId); + return; + } + + // Update the geojson data + sourceObject.setData(newData); + } + } else if (message.type === "set_projection") { + if (map.loaded()) { + const projection = + typeof message.projection === "string" + ? { type: message.projection } + : message.projection; + + try { + map.setProjection(projection); + } catch (e) { + console.error("Failed to set projection:", e); + } + } else { + console.error("Map not loaded yet"); + } + } else if (message.type === "add_globe_minimap") { + const globeMinimapOptions = { + globeSize: message.options.globe_size || 100, + landColor: message.options.land_color || "#404040", + waterColor: message.options.water_color || "#090909", + markerColor: message.options.marker_color || "#1da1f2", + markerSize: message.options.marker_size || 2, + }; + const globeMinimap = new GlobeMinimap(globeMinimapOptions); + map.addControl(globeMinimap, message.position || "bottom-left"); + map.controls.push(globeMinimap); + } else if (message.type === "add_globe_control") { + const globeControl = new maplibregl.GlobeControl(); + map.addControl(globeControl, message.position); + map.controls.push(globeControl); + } else if (message.type === "add_custom_control") { + const controlOptions = message.options; + const customControlContainer = document.createElement("div"); + + if (controlOptions.className) { + customControlContainer.className = controlOptions.className; + } else { + customControlContainer.className = "maplibregl-ctrl maplibregl-ctrl-group"; } + + customControlContainer.innerHTML = controlOptions.html; + + const customControl = { + onAdd: function() { + return customControlContainer; + }, + onRemove: function() { + if (customControlContainer.parentNode) { + customControlContainer.parentNode.removeChild(customControlContainer); + } + } + }; + + map.addControl(customControl, controlOptions.position || "top-right"); + map.controls.push(customControl); } }); } diff --git a/inst/htmlwidgets/maplibregl.yaml b/inst/htmlwidgets/maplibregl.yaml index ab6ddf9b..a71cedc5 100644 --- a/inst/htmlwidgets/maplibregl.yaml +++ b/inst/htmlwidgets/maplibregl.yaml @@ -1,32 +1,42 @@ dependencies: - - name: maplibre-gl - version: "4.7.1" - src: "htmlwidgets/lib/maplibre-gl" - script: - - "maplibre-gl.js" - stylesheet: - - "maplibre-gl.css" - - name: mapbox-gl-draw - version: "1.4.3" - src: "htmlwidgets/lib/mapbox-gl-draw" - script: - - "mapbox-gl-draw.js" - stylesheet: - - "mapbox-gl-draw.css" - - name: freehand-mode - version: 1.0.0 - src: "htmlwidgets/lib/freehand-mode" - script: - - "freehand-mode.js" - - name: maplibre-gl-geocoder - version: 1.5.0 - src: "htmlwidgets/lib/maplibre-gl-geocoder" - script: - - "maplibre-gl-geocoder.min.js" - stylesheet: - - "maplibre-gl-geocoder.css" - - name: mapbox-gl-globe-minimap - version: 1.2.1 - src: "htmlwidgets/lib/mapbox-gl-globe-minimap" - script: - - "bundle.js" + - name: maplibre-gl + version: "5.5.0" + src: "htmlwidgets/lib/maplibre-gl" + script: + - "maplibre-gl.js" + stylesheet: + - "maplibre-gl.css" + - name: mapbox-gl-draw + version: "1.5.0" + src: "htmlwidgets/lib/mapbox-gl-draw" + script: + - "mapbox-gl-draw.js" + stylesheet: + - "mapbox-gl-draw.css" + - name: freehand-mode + version: 1.0.0 + src: "htmlwidgets/lib/freehand-mode" + script: + - "freehand-mode.js" + - name: maplibre-gl-geocoder + version: 1.5.0 + src: "htmlwidgets/lib/maplibre-gl-geocoder" + script: + - "maplibre-gl-geocoder.min.js" + stylesheet: + - "maplibre-gl-geocoder.css" + - name: mapbox-gl-globe-minimap + version: 1.2.1 + src: "htmlwidgets/lib/mapbox-gl-globe-minimap" + script: + - "bundle.js" + - name: pmtiles + version: 3.2.0 + src: "htmlwidgets/lib/pmtiles" + script: + - "pmtiles.js" + - name: h3j-h3t + version: 0.9.2 + src: "htmlwidgets/lib/h3j-h3t" + script: + - "h3j_h3t.js" diff --git a/inst/htmlwidgets/maplibregl_compare.js b/inst/htmlwidgets/maplibregl_compare.js index ced54c58..a5e4ff6e 100644 --- a/inst/htmlwidgets/maplibregl_compare.js +++ b/inst/htmlwidgets/maplibregl_compare.js @@ -1,64 +1,2372 @@ +function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case 'get': + return properties[expression[1]]; + case 'concat': + return expression.slice(1).map(item => evaluateExpression(item, properties)).join(''); + case 'to-string': + return String(evaluateExpression(expression[1], properties)); + case 'to-number': + return Number(evaluateExpression(expression[1], properties)); + case 'number-format': + const value = evaluateExpression(expression[1], properties); + const options = expression[2] || {}; + + // Handle locale option + const locale = options.locale || 'en-US'; + + // Build Intl.NumberFormat options + const formatOptions = {}; + + // Style options + if (options.style) formatOptions.style = options.style; // 'decimal', 'currency', 'percent', 'unit' + if (options.currency) formatOptions.currency = options.currency; + if (options.unit) formatOptions.unit = options.unit; + + // Digit options + if (options.hasOwnProperty('min-fraction-digits')) { + formatOptions.minimumFractionDigits = options['min-fraction-digits']; + } + if (options.hasOwnProperty('max-fraction-digits')) { + formatOptions.maximumFractionDigits = options['max-fraction-digits']; + } + if (options.hasOwnProperty('min-integer-digits')) { + formatOptions.minimumIntegerDigits = options['min-integer-digits']; + } + + // Notation options + if (options.notation) formatOptions.notation = options.notation; // 'standard', 'scientific', 'engineering', 'compact' + if (options.compactDisplay) formatOptions.compactDisplay = options.compactDisplay; // 'short', 'long' + + // Grouping + if (options.hasOwnProperty('useGrouping')) { + formatOptions.useGrouping = options.useGrouping; + } + + return new Intl.NumberFormat(locale, formatOptions).format(value); + default: + // For literals and other simple values + return expression; + } +} + +function onMouseMoveTooltip(e, map, tooltipPopup, tooltipProperty) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + // Clear any existing active tooltip first to prevent stacking + if (window._activeTooltip && window._activeTooltip !== tooltipPopup) { + window._activeTooltip.remove(); + } + + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(tooltipProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup.setLngLat(e.lngLat).setHTML(description).addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } +} + +function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } +} + +function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._maplibrePopups && window._maplibrePopups[layerId]) { + window._maplibrePopups[layerId].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._maplibrePopups) { + window._maplibrePopups = {}; + } + window._maplibrePopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._maplibrePopups[layerId] === popup) { + delete window._maplibrePopups[layerId]; + } + }); +} + HTMLWidgets.widget({ name: "maplibregl_compare", - type: "output", + type: "output", + + factory: function (el, width, height) { + // Store maps and compare object to allow access during Shiny updates + let beforeMap, afterMap, compareControl, draw; + + return { + renderValue: function (x) { + if (typeof maplibregl === "undefined") { + console.error("Maplibre GL JS is not loaded."); + return; + } + if (typeof maplibregl.Compare === "undefined") { + console.error("Maplibre GL Compare plugin is not loaded."); + return; + } + + // Add PMTiles support + if (typeof pmtiles !== "undefined") { + let protocol = new pmtiles.Protocol({ metadata: true }); + maplibregl.addProtocol("pmtiles", protocol.tile); + } + + // Create container divs for the maps + const beforeContainerId = `${el.id}-before`; + const afterContainerId = `${el.id}-after`; + + // Different HTML structure based on mode + if (x.mode === "sync") { + // Side-by-side sync mode + const containerStyle = + x.orientation === "horizontal" + ? `display: flex; flex-direction: column; width: 100%; height: 100%;` + : `display: flex; flex-direction: row; width: 100%; height: 100%;`; + + const mapStyle = + x.orientation === "horizontal" + ? `width: 100%; height: 50%; position: relative;` + : `width: 50%; height: 100%; position: relative;`; + + el.innerHTML = ` +
    +
    +
    +
    + `; + } else { + // Default swipe mode + el.innerHTML = ` +
    +
    + `; + } + + beforeMap = new maplibregl.Map({ + container: beforeContainerId, + style: x.map1.style, + center: x.map1.center, + zoom: x.map1.zoom, + bearing: x.map1.bearing, + pitch: x.map1.pitch, + accessToken: x.map1.access_token, + ...x.map1.additional_params, + }); + + // Initialize controls array + beforeMap.controls = []; + + afterMap = new maplibregl.Map({ + container: afterContainerId, + style: x.map2.style, + center: x.map2.center, + zoom: x.map2.zoom, + bearing: x.map2.bearing, + pitch: x.map2.pitch, + accessToken: x.map2.access_token, + ...x.map2.additional_params, + }); + + // Initialize controls array + afterMap.controls = []; + + if (x.mode === "swipe") { + // Only create the swiper in swipe mode + compareControl = new maplibregl.Compare( + beforeMap, + afterMap, + `#${el.id}`, + { + mousemove: x.mousemove, + orientation: x.orientation, + }, + ); + + // Apply custom swiper color if provided + if (x.swiper_color) { + const swiperSelector = x.orientation === "vertical" ? + ".maplibregl-compare .compare-swiper-vertical" : + ".maplibregl-compare .compare-swiper-horizontal"; + + const styleEl = document.createElement('style'); + styleEl.innerHTML = `${swiperSelector} { background-color: ${x.swiper_color}; }`; + document.head.appendChild(styleEl); + } + } else { + // For sync mode, we directly leverage the sync-move module's approach + + // Function to synchronize maps as seen in the mapbox-gl-sync-move module + const syncMaps = () => { + // Array of maps to sync + const maps = [beforeMap, afterMap]; + // Array of move event handlers + const moveHandlers = []; + + // Setup the sync between maps + maps.forEach((map, index) => { + // Create a handler for each map that syncs all other maps + moveHandlers[index] = (e) => { + // Disable all move events temporarily + maps.forEach((m, i) => { + m.off("move", moveHandlers[i]); + }); + + // Get the state from the map that triggered the event + const center = map.getCenter(); + const zoom = map.getZoom(); + const bearing = map.getBearing(); + const pitch = map.getPitch(); + + // Apply this state to all other maps + maps.filter((m, i) => i !== index).forEach( + (m) => { + m.jumpTo({ + center: center, + zoom: zoom, + bearing: bearing, + pitch: pitch, + }); + }, + ); + + // Re-enable move events + maps.forEach((m, i) => { + m.on("move", moveHandlers[i]); + }); + }; + + // Add the move handler to each map + map.on("move", moveHandlers[index]); + }); + }; + + // Initialize the sync + syncMaps(); + } + + // Ensure both maps resize correctly + beforeMap.on("load", function () { + beforeMap.resize(); + applyMapModifications(beforeMap, x.map1); + + // Setup Shiny event handlers for the before map + if (HTMLWidgets.shinyMode) { + setupShinyEvents(beforeMap, el.id, "before"); + } + }); + + afterMap.on("load", function () { + afterMap.resize(); + applyMapModifications(afterMap, x.map2); + + // Setup Shiny event handlers for the after map + if (HTMLWidgets.shinyMode) { + setupShinyEvents(afterMap, el.id, "after"); + } + }); + + // Define updateDrawnFeatures function for the draw tool + window.updateDrawnFeatures = function () { + if (draw) { + const features = draw.getAll(); + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(features), + ); + } + }; + + // Handle Shiny messages + if (HTMLWidgets.shinyMode) { + Shiny.addCustomMessageHandler( + "maplibre-compare-proxy", + function (data) { + if (data.id !== el.id) return; + + // Get the message and determine which map to target + var message = data.message; + var map = + message.map === "before" ? beforeMap : afterMap; + + if (!map) return; + + // Initialize layer state tracking if not already present + if (!window._mapglLayerState) { + window._mapglLayerState = {}; + } + const mapId = map.getContainer().id; + if (!window._mapglLayerState[mapId]) { + window._mapglLayerState[mapId] = { + filters: {}, // layerId -> filter expression + paintProperties: {}, // layerId -> {propertyName -> value} + layoutProperties: {}, // layerId -> {propertyName -> value} + tooltips: {}, // layerId -> tooltip property + popups: {}, // layerId -> popup property + legends: {} // legendId -> {html: string, css: string} + }; + } + const layerState = window._mapglLayerState[mapId]; + + // Process the message based on type + if (message.type === "set_filter") { + map.setFilter(message.layer, message.filter); + // Track filter state for layer restoration + layerState.filters[message.layer] = message.filter; + } else if (message.type === "add_source") { + if (message.source.type === "vector") { + const sourceConfig = { + type: "vector", + url: message.source.url, + }; + // Add promoteId if provided + if (message.source.promoteId) { + sourceConfig.promoteId = message.source.promoteId; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function(key) { + if (key !== "id" && key !== "type" && key !== "url" && key !== "promoteId") { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "geojson") { + const sourceConfig = { + type: "geojson", + data: message.source.data, + generateId: message.source.generateId, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function(key) { + if (key !== "id" && key !== "type" && key !== "data" && key !== "generateId") { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "raster") { + const sourceConfig = { + type: "raster", + tileSize: message.source.tileSize, + }; + if (message.source.url) { + sourceConfig.url = message.source.url; + } else if (message.source.tiles) { + sourceConfig.tiles = message.source.tiles; + } + if (message.source.maxzoom) { + sourceConfig.maxzoom = message.source.maxzoom; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function(key) { + if (key !== "id" && key !== "type" && key !== "url" && key !== "tiles" && key !== "tileSize" && key !== "maxzoom") { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if ( + message.source.type === "raster-dem" + ) { + const sourceConfig = { + type: "raster-dem", + url: message.source.url, + tileSize: message.source.tileSize, + }; + if (message.source.maxzoom) { + sourceConfig.maxzoom = message.source.maxzoom; + } + // Add any other properties from the source object + Object.keys(message.source).forEach(function(key) { + if (key !== "id" && key !== "type" && key !== "url" && key !== "tileSize" && key !== "maxzoom") { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "image") { + const sourceConfig = { + type: "image", + url: message.source.url, + coordinates: message.source.coordinates, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function(key) { + if (key !== "id" && key !== "type" && key !== "url" && key !== "coordinates") { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } else if (message.source.type === "video") { + const sourceConfig = { + type: "video", + urls: message.source.urls, + coordinates: message.source.coordinates, + }; + // Add any other properties from the source object + Object.keys(message.source).forEach(function(key) { + if (key !== "id" && key !== "type" && key !== "urls" && key !== "coordinates") { + sourceConfig[key] = message.source[key]; + } + }); + map.addSource(message.source.id, sourceConfig); + } + } else if (message.type === "add_layer") { + try { + if (message.layer.before_id) { + map.addLayer( + message.layer, + message.layer.before_id, + ); + } else { + map.addLayer(message.layer); + } + + // Add popups or tooltips if provided + if (message.layer.popup) { + // Create click handler for this layer + const clickHandler = function (e) { + onClickPopup(e, map, message.layer.popup, message.layer.id); + }; + + // Store these handler references so we can remove them later if needed + if (!window._mapboxClickHandlers) { + window._mapboxClickHandlers = {}; + } + window._mapboxClickHandlers[message.layer.id] = clickHandler; + + // Add the click handler + map.on( + "click", + message.layer.id, + clickHandler + ); + + // Change cursor to pointer when hovering over the layer + map.on( + "mouseenter", + message.layer.id, + function () { + map.getCanvas().style.cursor = + "pointer"; + }, + ); + + // Change cursor back to default when leaving the layer + map.on( + "mouseleave", + message.layer.id, + function () { + map.getCanvas().style.cursor = + ""; + }, + ); + } + + if (message.layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Define named handler functions: + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + message.layer.tooltip, + ); + }; + + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach handlers by reference: + map.on( + "mousemove", + message.layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + message.layer.id, + mouseLeaveHandler, + ); + + // Store these handler references for later removal: + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[ + message.layer.id + ] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } + + // Add hover effect if provided + if (message.layer.hover_options) { + const jsHoverOptions = {}; + for (const [ + key, + value, + ] of Object.entries( + message.layer.hover_options, + )) { + const jsKey = key.replace( + /_/g, + "-", + ); + jsHoverOptions[jsKey] = value; + } + + let hoveredFeatureId = null; + + map.on( + "mousemove", + message.layer.id, + function (e) { + if (e.features.length > 0) { + if ( + hoveredFeatureId !== + null + ) { + const featureState = { + source: + typeof message + .layer + .source === + "string" + ? message + .layer + .source + : message + .layer + .id, + id: hoveredFeatureId, + }; + if ( + message.layer + .source_layer + ) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { + hover: false, + }, + ); + } + hoveredFeatureId = + e.features[0].id; + const featureState = { + source: + typeof message.layer + .source === + "string" + ? message.layer + .source + : message.layer + .id, + id: hoveredFeatureId, + }; + if ( + message.layer + .source_layer + ) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { + hover: true, + }, + ); + } + }, + ); + + map.on( + "mouseleave", + message.layer.id, + function () { + if (hoveredFeatureId !== null) { + const featureState = { + source: + typeof message.layer + .source === + "string" + ? message.layer + .source + : message.layer + .id, + id: hoveredFeatureId, + }; + if ( + message.layer + .source_layer + ) { + featureState.sourceLayer = + message.layer.source_layer; + } + map.setFeatureState( + featureState, + { + hover: false, + }, + ); + } + hoveredFeatureId = null; + }, + ); + + Object.keys(jsHoverOptions).forEach( + function (key) { + const originalPaint = + map.getPaintProperty( + message.layer.id, + key, + ) || + message.layer.paint[key]; + map.setPaintProperty( + message.layer.id, + key, + [ + "case", + [ + "boolean", + [ + "feature-state", + "hover", + ], + false, + ], + jsHoverOptions[key], + originalPaint, + ], + ); + }, + ); + } + } catch (e) { + console.error( + "Failed to add layer via proxy: ", + message.layer, + e, + ); + } + } else if (message.type === "remove_layer") { + // If there's an active tooltip, remove it first + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // If there's an active popup for this layer, remove it + // Check both message.layer_id and message.layer.id as keys due to different message formats + if (window._mapboxPopups) { + // First check if we have a popup stored with message.layer_id key + if (window._mapboxPopups[message.layer_id]) { + window._mapboxPopups[message.layer_id].remove(); + delete window._mapboxPopups[message.layer_id]; + } + + // Also check if we have a popup stored with message.layer.id key, which happens when added via add_layer + if (message.layer && message.layer.id && window._mapboxPopups[message.layer.id]) { + window._mapboxPopups[message.layer.id].remove(); + delete window._mapboxPopups[message.layer.id]; + } + } + + if (map.getLayer(message.layer_id)) { + // Remove tooltip handlers + if ( + window._mapboxHandlers && + window._mapboxHandlers[message.layer_id] + ) { + const handlers = + window._mapboxHandlers[ + message.layer_id + ]; + if (handlers.mousemove) { + map.off( + "mousemove", + message.layer_id, + handlers.mousemove, + ); + } + if (handlers.mouseleave) { + map.off( + "mouseleave", + message.layer_id, + handlers.mouseleave, + ); + } + // Clean up the reference + delete window._mapboxHandlers[ + message.layer_id + ]; + } + + // Remove click handlers for popups + if (window._mapboxClickHandlers) { + // First check for handlers stored with message.layer_id key + if (window._mapboxClickHandlers[message.layer_id]) { + map.off( + "click", + message.layer_id, + window._mapboxClickHandlers[message.layer_id] + ); + delete window._mapboxClickHandlers[message.layer_id]; + } + + // Also check for handlers stored with message.layer.id key from add_layer + if (message.layer && message.layer.id && window._mapboxClickHandlers[message.layer.id]) { + map.off( + "click", + message.layer_id, + window._mapboxClickHandlers[message.layer.id] + ); + delete window._mapboxClickHandlers[message.layer.id]; + } + } + + // Remove the layer + map.removeLayer(message.layer_id); + } + if (map.getSource(message.layer_id)) { + map.removeSource(message.layer_id); + } + + // Clean up tracked layer state + const mapId = map.getContainer().id; + if (window._mapglLayerState && window._mapglLayerState[mapId]) { + const layerState = window._mapglLayerState[mapId]; + delete layerState.filters[message.layer_id]; + delete layerState.paintProperties[message.layer_id]; + delete layerState.layoutProperties[message.layer_id]; + delete layerState.tooltips[message.layer_id]; + delete layerState.popups[message.layer_id]; + // Note: legends are not tied to specific layers, so we don't clear them here + } + } else if (message.type === "fit_bounds") { + map.fitBounds(message.bounds, message.options); + } else if (message.type === "fly_to") { + map.flyTo(message.options); + } else if (message.type === "ease_to") { + map.easeTo(message.options); + } else if (message.type === "set_center") { + map.setCenter(message.center); + } else if (message.type === "set_zoom") { + map.setZoom(message.zoom); + } else if (message.type === "jump_to") { + map.jumpTo(message.options); + } else if (message.type === "set_layout_property") { + map.setLayoutProperty( + message.layer, + message.name, + message.value, + ); + // Track layout property state for layer restoration + if (!layerState.layoutProperties[message.layer]) { + layerState.layoutProperties[message.layer] = {}; + } + layerState.layoutProperties[message.layer][message.name] = message.value; + } else if (message.type === "set_paint_property") { + const layerId = message.layer; + const propertyName = message.name; + const newValue = message.value; + + // Check if the layer has hover options + const layerStyle = map + .getStyle() + .layers.find( + (layer) => layer.id === layerId, + ); + const currentPaintProperty = + map.getPaintProperty(layerId, propertyName); + + if ( + currentPaintProperty && + Array.isArray(currentPaintProperty) && + currentPaintProperty[0] === "case" + ) { + // This property has hover options, so we need to preserve them + const hoverValue = currentPaintProperty[2]; + const newPaintProperty = [ + "case", + [ + "boolean", + ["feature-state", "hover"], + false, + ], + hoverValue, + newValue, + ]; + map.setPaintProperty( + layerId, + propertyName, + newPaintProperty, + ); + } else { + // No hover options, just set the new value directly + map.setPaintProperty( + layerId, + propertyName, + newValue, + ); + } + // Track paint property state for layer restoration + if (!layerState.paintProperties[layerId]) { + layerState.paintProperties[layerId] = {}; + } + layerState.paintProperties[layerId][propertyName] = newValue; + } else if (message.type === "add_legend") { + if (!message.add) { + const existingLegends = + document.querySelectorAll( + `#${data.id} .maplibregl-legend`, + ); + existingLegends.forEach((legend) => + legend.remove(), + ); + + // Clean up any existing legend styles that might have been added + const legendStyles = document.querySelectorAll(`style[data-mapgl-legend-css="${data.id}"]`); + legendStyles.forEach((style) => style.remove()); + } + + const legendCss = + document.createElement("style"); + legendCss.innerHTML = message.legend_css; + legendCss.setAttribute('data-mapgl-legend-css', data.id); // Mark this style for later cleanup + document.head.appendChild(legendCss); + + const legend = document.createElement("div"); + legend.innerHTML = message.html; + legend.classList.add("maplibregl-legend"); + document + .getElementById(data.id) + .appendChild(legend); + } else if (message.type === "set_config_property") { + map.setConfigProperty( + message.importId, + message.configName, + message.value, + ); + } else if (message.type === "set_style") { + // Save the current view state + const center = map.getCenter(); + const zoom = map.getZoom(); + const bearing = map.getBearing(); + const pitch = map.getPitch(); + + // Default preserve_layers to true if not specified + const preserveLayers = message.preserve_layers !== false; + + // If we should preserve layers and sources + if (preserveLayers) { + // Store the current style before changing it + const currentStyle = map.getStyle(); + const userSourceIds = []; + const userLayers = []; + + console.log("[MapGL Debug] Current style sources:", Object.keys(currentStyle.sources)); + console.log("[MapGL Debug] Current style layers:", currentStyle.layers.map(l => l.id)); + + // Store layer IDs we know were added by the user via R code + // This is the most reliable way to identify user-added layers + const knownUserLayerIds = []; + + // For each layer in the current style, determine if it's a user-added layer + currentStyle.layers.forEach(function(layer) { + const layerId = layer.id; + + // Critical: Check for nc_counties specifically since we know that's used in the test app + if (layerId === "nc_counties") { + console.log("[MapGL Debug] Found explicit test layer:", layerId); + knownUserLayerIds.push(layerId); + if (layer.source && !userSourceIds.includes(layer.source)) { + console.log("[MapGL Debug] Found source from test layer:", layer.source); + userSourceIds.push(layer.source); + } + return; // Skip other checks for this layer + } + + // These are common patterns for user-added layers from R code + if ( + // Specific layer IDs from the R package + layerId.endsWith("_counties") || + layerId.endsWith("_label") || + layerId.endsWith("_layer") || + + // Look for hover handlers - only user-added layers have these + (window._mapboxHandlers && window._mapboxHandlers[layerId]) || + + // If the layer ID contains these strings, it's likely user-added + layerId.includes("user") || + layerId.includes("custom") || + + // If the paint property has a hover case, it's user-added + (layer.paint && Object.values(layer.paint).some(value => + Array.isArray(value) && + value[0] === "case" && + Array.isArray(value[1]) && + value[1][1] && + Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && + value[1][1][1] === "hover")) + ) { + console.log("[MapGL Debug] Found user layer:", layerId); + knownUserLayerIds.push(layerId); + // Only include its source if it's not a base map source + if (layer.source && !userSourceIds.includes(layer.source)) { + const layerSource = currentStyle.sources[layer.source]; + const isBaseMapSource = layerSource && layerSource.type === "vector" && ( + layer.source === "composite" || + layer.source === "mapbox" || + layer.source.startsWith("mapbox-") || + layer.source === "openmaptiles" || + layer.source.startsWith("carto") || + layer.source.startsWith("maptiler") + ); + + if (!isBaseMapSource) { + console.log("[MapGL Debug] Found user source from layer:", layer.source); + userSourceIds.push(layer.source); + } else { + console.log("[MapGL Debug] Not adding base map source from layer:", layer.source); + } + } + } + }); + + // For each source, determine if it's a user-added source + for (const sourceId in currentStyle.sources) { + const source = currentStyle.sources[sourceId]; + + // Strategy 1: All GeoJSON sources are likely user-added + if (source.type === "geojson") { + console.log("[MapGL Debug] Found user GeoJSON source:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 2: Check for source data URL patterns typical of R-generated data + else if (source.url && typeof source.url === 'string' && + (source.url.includes("data:application/json") || + source.url.includes("blob:"))) { + console.log("[MapGL Debug] Found user source with data URL:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + // Strategy 3: Standard filtering - exclude common base map sources + else if ( + sourceId !== "composite" && + sourceId !== "mapbox" && + !sourceId.startsWith("mapbox-") && + sourceId !== "openmaptiles" && // Common in MapLibre styles + !(sourceId.startsWith("carto") && sourceId !== "carto-source") && // Filter CARTO base sources but keep user ones + !(sourceId.startsWith("maptiler") && !sourceId.includes("user")) && // Filter MapTiler sources but keep user ones + !sourceId.includes("terrain") && // Common terrain sources + !sourceId.includes("hillshade") && // Common hillshade sources + !(sourceId.includes("basemap") && !sourceId.includes("user")) // Filter basemap sources but keep user ones + ) { + console.log("[MapGL Debug] Found user source via filtering:", sourceId); + if (!userSourceIds.includes(sourceId)) { + userSourceIds.push(sourceId); + } + } + + // Store layer-specific handler references + if (window._mapboxHandlers) { + const handlers = window._mapboxHandlers; + for (const layerId in handlers) { + // Find layers associated with this source + const layer = currentStyle.layers.find(l => l.id === layerId); + if (layer && layer.source === sourceId) { + layer._handlers = handlers[layerId]; + } + } + } + } + + // Identify layers using user-added sources or known user layer IDs + // ONLY include layers that use genuinely user-added sources (not base map sources) + currentStyle.layers.forEach(function(layer) { + // Check if this layer uses a genuine user source (not filtered out base map sources) + const usesUserSource = userSourceIds.includes(layer.source); + const isKnownUserLayer = knownUserLayerIds.includes(layer.id); + + // Additional check: exclude layers that use base map sources even if they were temporarily added to userSourceIds + const layerSource = currentStyle.sources[layer.source]; + const isBaseMapSource = layerSource && layerSource.type === "vector" && ( + layer.source === "composite" || + layer.source === "mapbox" || + layer.source.startsWith("mapbox-") || + layer.source === "openmaptiles" || + layer.source.startsWith("carto") || + layer.source.startsWith("maptiler") + ); + + if ((usesUserSource || isKnownUserLayer) && !isBaseMapSource) { + userLayers.push(layer); + console.log("[MapGL Debug] Including user layer:", layer.id, "source:", layer.source); + } else if (isBaseMapSource) { + console.log("[MapGL Debug] Excluding base map layer:", layer.id, "source:", layer.source); + } + }); + + // Set up event listener to re-add sources and layers after style loads + const onStyleLoad = function() { + // Re-add user sources + userSourceIds.forEach(function(sourceId) { + if (!map.getSource(sourceId)) { + const source = currentStyle.sources[sourceId]; + map.addSource(sourceId, source); + } + }); + + // Re-add user layers + userLayers.forEach(function(layer) { + if (!map.getLayer(layer.id)) { + map.addLayer(layer); + + // Re-add event handlers for tooltips and hover effects + if (layer._handlers) { + const handlers = layer._handlers; + + if (handlers.mousemove) { + console.log("[MapGL Debug] Re-adding mousemove handler for:", layer.id); + map.on("mousemove", layer.id, handlers.mousemove); + } + + if (handlers.mouseleave) { + console.log("[MapGL Debug] Re-adding mouseleave handler for:", layer.id); + map.on("mouseleave", layer.id, handlers.mouseleave); + } + } + + // Check if we need to restore tooltip handlers + const layerId = layer.id; + if (layerId === "nc_counties" || layer.tooltip) { + console.log("[MapGL Debug] Restoring tooltip for:", layerId); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = layer.tooltip || "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layerId, mouseMoveHandler); + map.on("mouseleave", layerId, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layerId] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Recreate hover states if needed + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + map.setPaintProperty(layer.id, key, value); + } + } + } + } + }); + + // Clear any active tooltips before restoration to prevent stacking + if (window._activeTooltip) { + window._activeTooltip.remove(); + delete window._activeTooltip; + } + + // Restore tracked layer modifications + const mapId = map.getContainer().id; + const savedLayerState = window._mapglLayerState && window._mapglLayerState[mapId]; + if (savedLayerState) { + console.log("[MapGL Debug] Restoring tracked layer modifications"); + + // Restore filters + for (const layerId in savedLayerState.filters) { + if (map.getLayer(layerId)) { + console.log("[MapGL Debug] Restoring filter for layer:", layerId); + map.setFilter(layerId, savedLayerState.filters[layerId]); + } + } + + // Restore paint properties + for (const layerId in savedLayerState.paintProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.paintProperties[layerId]; + for (const propertyName in properties) { + const savedValue = properties[propertyName]; + + console.log("[MapGL Debug] Restoring paint property:", layerId, propertyName, savedValue); + + // Check if layer has hover effects that need to be preserved + const currentValue = map.getPaintProperty(layerId, propertyName); + if (currentValue && Array.isArray(currentValue) && currentValue[0] === "case") { + // Preserve hover effects while updating base value + const hoverValue = currentValue[2]; + const newPaintProperty = [ + "case", + ["boolean", ["feature-state", "hover"], false], + hoverValue, + savedValue, + ]; + map.setPaintProperty(layerId, propertyName, newPaintProperty); + } else { + map.setPaintProperty(layerId, propertyName, savedValue); + } + } + } + } + + // Restore layout properties + for (const layerId in savedLayerState.layoutProperties) { + if (map.getLayer(layerId)) { + const properties = savedLayerState.layoutProperties[layerId]; + for (const propertyName in properties) { + console.log("[MapGL Debug] Restoring layout property:", layerId, propertyName, properties[propertyName]); + map.setLayoutProperty(layerId, propertyName, properties[propertyName]); + } + } + } + + // Restore tooltips + for (const layerId in savedLayerState.tooltips) { + if (map.getLayer(layerId)) { + const tooltipProperty = savedLayerState.tooltips[layerId]; + console.log("[MapGL Debug] Restoring tooltip:", layerId, tooltipProperty); + + // Remove existing tooltip handlers first + map.off("mousemove", layerId); + map.off("mouseleave", layerId); + + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + map.on("mousemove", layerId, function (e) { + onMouseMoveTooltip(e, map, tooltip, tooltipProperty); + }); + + map.on("mouseleave", layerId, function () { + onMouseLeaveTooltip(map, tooltip); + }); + } + } + + // Restore popups + for (const layerId in savedLayerState.popups) { + if (map.getLayer(layerId)) { + const popupProperty = savedLayerState.popups[layerId]; + console.log("[MapGL Debug] Restoring popup:", layerId, popupProperty); + + // Remove existing popup handlers first + if (window._maplibreClickHandlers && window._maplibreClickHandlers[layerId]) { + map.off("click", layerId, window._maplibreClickHandlers[layerId]); + delete window._maplibreClickHandlers[layerId]; + } + + const clickHandler = function(e) { + onClickPopup(e, map, popupProperty, layerId); + }; + + map.on("click", layerId, clickHandler); + + if (!window._maplibreClickHandlers) { + window._maplibreClickHandlers = {}; + } + window._maplibreClickHandlers[layerId] = clickHandler; + } + } + } + + // Remove this listener to avoid adding the same layers multiple times + map.off('style.load', onStyleLoad); + }; + + map.on('style.load', onStyleLoad); + + // Store them for potential use outside the onStyleLoad event + // This helps in case the event timing is different in MapLibre + if (!window._mapglPreservedData) { + window._mapglPreservedData = {}; + } + window._mapglPreservedData[map.getContainer().id] = { + sources: userSourceIds.map(id => ({id, source: currentStyle.sources[id]})), + layers: userLayers + }; + + // Add a backup mechanism specific to MapLibre + // Some MapLibre styles or versions may have different event timing + if (userLayers.length > 0) { + // Set a timeout to check if layers were added after a reasonable delay + setTimeout(function() { + try { + console.log("[MapGL Debug] Running backup layer check"); + const mapId = map.getContainer().id; + const preserved = window._mapglPreservedData && window._mapglPreservedData[mapId]; + + if (preserved) { + // Check if user layers were successfully restored + const firstLayerId = preserved.layers[0]?.id; + if (firstLayerId && !map.getLayer(firstLayerId)) { + console.log("[MapGL Debug] Backup restoration needed for layers"); + + // Re-add sources first + preserved.sources.forEach(function(src) { + try { + if (!map.getSource(src.id)) { + console.log("[MapGL Debug] Backup: adding source", src.id); + map.addSource(src.id, src.source); + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding source", src.id, err); + } + }); + + // Then re-add layers + preserved.layers.forEach(function(layer) { + try { + if (!map.getLayer(layer.id)) { + console.log("[MapGL Debug] Backup: adding layer", layer.id); + map.addLayer(layer); + + // Check for nc_counties layer to restore tooltip + if (layer.id === "nc_counties") { + console.log("[MapGL Debug] Backup: restoring tooltip for", layer.id); + + // Create a new tooltip popup + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false + }); + + // Re-add tooltip handlers + const tooltipProperty = "NAME"; + + const mouseMoveHandler = function(e) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + const description = e.features[0].properties[tooltipProperty]; + tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); + } + }; + + const mouseLeaveHandler = function() { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }; + + map.on("mousemove", layer.id, mouseMoveHandler); + map.on("mouseleave", layer.id, mouseLeaveHandler); + + // Store these handlers + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler + }; + } + + // Restore hover states + if (layer.paint) { + for (const key in layer.paint) { + const value = layer.paint[key]; + if (Array.isArray(value) && value[0] === "case" && + Array.isArray(value[1]) && value[1][0] === "boolean" && + value[1][1] && Array.isArray(value[1][1]) && + value[1][1][0] === "feature-state" && value[1][1][1] === "hover") { + // This is a hover-enabled paint property + console.log("[MapGL Debug] Backup: restoring hover style for", layer.id, key); + map.setPaintProperty(layer.id, key, value); + } + } + } + } + } catch (err) { + console.error("[MapGL Debug] Backup: error adding layer", layer.id, err); + } + }); + } else { + console.log("[MapGL Debug] Backup check: layers already restored properly"); + } + } + } catch (err) { + console.error("[MapGL Debug] Error in backup restoration:", err); + } + }, 500); // 500ms delay - faster recovery + } + } + + // Apply the new style + map.setStyle(message.style, { + diff: message.diff, + }); + + if (message.config) { + Object.keys(message.config).forEach( + function (key) { + map.setConfigProperty( + "basemap", + key, + message.config[key], + ); + }, + ); + } + + // Restore the view state after the style has loaded + map.once("style.load", function () { + map.jumpTo({ + center: center, + zoom: zoom, + bearing: bearing, + pitch: pitch, + }); + + // Re-apply map modifications + if (map === beforeMap) { + applyMapModifications(map, x.map1); + } else { + applyMapModifications(map, x.map2); + } + }); + } else if ( + message.type === "add_navigation_control" + ) { + const nav = new maplibregl.NavigationControl({ + showCompass: message.options.show_compass, + showZoom: message.options.show_zoom, + visualizePitch: + message.options.visualize_pitch, + }); + map.addControl(nav, message.position); + + if (message.orientation === "horizontal") { + const navBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl.maplibregl-ctrl-group:not(.maplibre-gl-draw_ctrl-draw-btn)", + ); + if (navBar) { + navBar.style.display = "flex"; + navBar.style.flexDirection = "row"; + } + } + } else if (message.type === "add_reset_control") { + const resetControl = + document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute( + "aria-label", + "Reset", + ); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = + "background-color 0.2s"; + resetControl.addEventListener( + "mouseover", + function () { + this.style.backgroundColor = "#f0f0f0"; + }, + ); + resetControl.addEventListener( + "mouseout", + function () { + this.style.backgroundColor = "white"; + }, + ); + + const resetContainer = + document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: message.animate, + }; + + if (message.duration) { + initialView.duration = message.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + message.position, + ); + // Add to controls array + map.controls.push(resetControl); + } else if (message.type === "add_draw_control") { + let drawOptions = message.options || {}; + if (message.freehand) { + drawOptions = Object.assign( + {}, + drawOptions, + { + modes: Object.assign( + {}, + MapboxDraw.modes, + { + draw_polygon: + MapboxDraw.modes + .draw_freehand, + }, + ), + }, + ); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add event listeners + map.on( + "draw.create", + window.updateDrawnFeatures, + ); + map.on( + "draw.delete", + window.updateDrawnFeatures, + ); + map.on( + "draw.update", + window.updateDrawnFeatures, + ); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector( + ".maplibregl-ctrl-group", + ); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if (draw) { + const features = draw + ? draw.getAll() + : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if ( + message.type === "clear_drawn_features" + ) { + if (draw) { + draw.deleteAll(); + // Update the drawn features + window.updateDrawnFeatures(); + } + } else if (message.type === "add_markers") { + if (!window.maplibreglMarkers) { + window.maplibreglMarkers = []; + } + message.markers.forEach(function (marker) { + const markerOptions = { + color: marker.color, + rotation: marker.rotation, + draggable: + marker.options.draggable || false, + ...marker.options, + }; + const mapMarker = new maplibregl.Marker( + markerOptions, + ) + .setLngLat([marker.lng, marker.lat]) + .addTo(map); + + if (marker.popup) { + mapMarker.setPopup( + new maplibregl.Popup({ + offset: 25, + }).setHTML(marker.popup), + ); + } + + const markerId = marker.id; + if (markerId) { + const lngLat = mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + + mapMarker.on("dragend", function () { + const lngLat = + mapMarker.getLngLat(); + Shiny.setInputValue( + data.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + }); + } + + window.maplibreglMarkers.push(mapMarker); + }); + } else if (message.type === "clear_markers") { + if (window.maplibreglMarkers) { + window.maplibreglMarkers.forEach( + function (marker) { + marker.remove(); + }, + ); + window.maplibreglMarkers = []; + } + } else if ( + message.type === "add_fullscreen_control" + ) { + const position = + message.position || "top-right"; + const fullscreen = + new maplibregl.FullscreenControl(); + map.addControl(fullscreen, position); + map.controls.push(fullscreen); + } else if (message.type === "add_scale_control") { + const scaleControl = + new maplibregl.ScaleControl({ + maxWidth: message.options.maxWidth, + unit: message.options.unit, + }); + map.addControl( + scaleControl, + message.options.position, + ); + map.controls.push(scaleControl); + } else if ( + message.type === "add_geolocate_control" + ) { + const geolocate = + new maplibregl.GeolocateControl({ + positionOptions: + message.options.positionOptions, + trackUserLocation: + message.options.trackUserLocation, + showAccuracyCircle: + message.options.showAccuracyCircle, + showUserLocation: + message.options.showUserLocation, + showUserHeading: + message.options.showUserHeading, + fitBoundsOptions: + message.options.fitBoundsOptions, + }); + map.addControl( + geolocate, + message.options.position, + ); + map.controls.push(geolocate); + + if (HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue( + data.id + "_geolocate", + { + coords: event.coords, + time: new Date(), + }, + ); + }); + + geolocate.on( + "trackuserlocationstart", + function () { + Shiny.setInputValue( + data.id + "_geolocate_tracking", + { + status: "start", + time: new Date(), + }, + ); + }, + ); + + geolocate.on( + "trackuserlocationend", + function () { + Shiny.setInputValue( + data.id + "_geolocate_tracking", + { + status: "end", + time: new Date(), + }, + ); + }, + ); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + data.id + "_geolocate_error", + { + message: + "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + } else if ( + message.type === "add_geocoder_control" + ) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = + await fetch(request); + const geojson = + await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties + .display_name, + properties: + feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + + const geocoderOptions = { + maplibregl: maplibregl, + ...message.options, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if ( + typeof geocoderOptions.collapsed === + "undefined" + ) + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + message.position || "top-right", + ); + map.controls.push(geocoder); + + // Handle geocoder results in Shiny mode + geocoder.on("results", function (e) { + Shiny.setInputValue(data.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } else if (message.type === "add_layers_control") { + const layersControl = + document.createElement("div"); + layersControl.id = message.control_id; + layersControl.className = message.collapsible + ? "layers-control collapsible" + : "layers-control"; + layersControl.style.position = "absolute"; + + // Set the position correctly + const position = message.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + + // Apply custom colors if provided + if (message.custom_colors) { + const colors = message.custom_colors; + + // Create a style element for custom colors + const styleEl = + document.createElement("style"); + let css = ""; + + if (colors.background) { + css += `.layers-control { background-color: ${colors.background} !important; }`; + } + if (colors.text) { + css += `.layers-control a { color: ${colors.text} !important; }`; + } + if (colors.activeBackground) { + css += `.layers-control a.active { background-color: ${colors.activeBackground} !important; }`; + } + if (colors.activeText) { + css += `.layers-control a.active { color: ${colors.activeText} !important; }`; + } + if (colors.hoverBackground) { + css += `.layers-control a:hover { background-color: ${colors.hoverBackground} !important; }`; + } + if (colors.hoverText) { + css += `.layers-control a:hover { color: ${colors.hoverText} !important; }`; + } + if (colors.toggleButtonBackground) { + css += `.layers-control .toggle-button { background-color: ${colors.toggleButtonBackground} + !important; }`; + } + if (colors.toggleButtonText) { + css += `.layers-control .toggle-button { color: ${colors.toggleButtonText} !important; }`; + } + + styleEl.innerHTML = css; + document.head.appendChild(styleEl); + } + + document + .getElementById(data.id) + .appendChild(layersControl); + + const layersList = + document.createElement("div"); + layersList.className = "layers-list"; + layersControl.appendChild(layersList); + + // Fetch layers to be included in the control + let layers = + message.layers || + map + .getStyle() + .layers.map((layer) => layer.id); + + layers.forEach((layerId, index) => { + const link = document.createElement("a"); + link.id = layerId; + link.href = "#"; + link.textContent = layerId; + link.className = "active"; + + // Show or hide layer when the toggle is clicked + link.onclick = function (e) { + const clickedLayer = this.textContent; + e.preventDefault(); + e.stopPropagation(); + + const visibility = + map.getLayoutProperty( + clickedLayer, + "visibility", + ); + + // Toggle layer visibility by changing the layout object's visibility property + if (visibility === "visible") { + map.setLayoutProperty( + clickedLayer, + "visibility", + "none", + ); + this.className = ""; + } else { + this.className = "active"; + map.setLayoutProperty( + clickedLayer, + "visibility", + "visible", + ); + } + }; + + layersList.appendChild(link); + }); + + // Handle collapsible behavior + if (message.collapsible) { + const toggleButton = + document.createElement("div"); + toggleButton.className = "toggle-button"; + toggleButton.textContent = "Layers"; + toggleButton.onclick = function () { + layersControl.classList.toggle("open"); + }; + layersControl.insertBefore( + toggleButton, + layersList, + ); + } + } else if (message.type === "add_globe_minimap") { + // Add the globe minimap control if supported + if (typeof MapboxGlobeMinimap !== "undefined") { + const minimap = new MapboxGlobeMinimap({ + center: map.getCenter(), + zoom: map.getZoom(), + bearing: map.getBearing(), + pitch: map.getPitch(), + globeSize: message.globe_size, + landColor: message.land_color, + waterColor: message.water_color, + markerColor: message.marker_color, + markerSize: message.marker_size, + }); + + map.addControl(minimap, message.position); + } else { + console.warn( + "MapboxGlobeMinimap is not defined", + ); + } + } else if (message.type === "add_globe_control") { + // Add the globe control + const globeControl = + new maplibregl.GlobeControl(); + map.addControl(globeControl, message.position); + map.controls.push(globeControl); + } else if (message.type === "add_draw_control") { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = "maplibregl-ctrl-group"; + + let drawOptions = message.options || {}; + + // Generate styles if styling parameters provided + if (message.styling) { + const generatedStyles = generateDrawStyles(message.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (message.freehand) { + drawOptions = Object.assign( + {}, + drawOptions, + { + modes: Object.assign( + {}, + MapboxDraw.modes, + { + draw_polygon: + MapboxDraw.modes + .draw_freehand, + }, + ), + // defaultMode: 'draw_polygon' # Don't set the default yet + }, + ); + } + + // Fix MapLibre compatibility - ensure we always have custom styles + if (!drawOptions.styles) { + drawOptions.styles = generateDrawStyles({ + vertex_radius: 5, + active_color: '#fbb03b', + point_color: '#3bb2d0', + line_color: '#3bb2d0', + fill_color: '#3bb2d0', + fill_opacity: 0.1, + line_width: 2 + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, message.position); + map.controls.push(draw); + + // Add initial features if provided + if (message.source) { + addSourceFeaturesToDraw(draw, message.source, map); + } + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + if (message.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } else if (message.type === "get_drawn_features") { + if (draw) { + const features = draw + ? draw.getAll() + : null; + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(features), + ); + } else { + Shiny.setInputValue( + data.id + "_drawn_features", + JSON.stringify(null), + ); + } + } else if ( + message.type === "clear_drawn_features" + ) { + if (draw) { + draw.deleteAll(); + // Update the drawn features + updateDrawnFeatures(); + } + } else if (message.type === "add_features_to_draw") { + if (draw) { + if (message.data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, message.data.source, map); + // Update the drawn features + updateDrawnFeatures(); + } else { + console.warn('Draw control not initialized'); + } + } else if (message.type === "set_projection") { + // Only if maplibre supports projection + if (typeof map.setProjection === "function") { + map.setProjection(message.projection); + } + } else if (message.type === "set_source") { + if (map.getLayer(message.layer)) { + const sourceId = map.getLayer( + message.layer, + ).source; + map.getSource(sourceId).setData( + JSON.parse(message.source), + ); + } + } else if (message.type === "set_tooltip") { + // Track tooltip state + layerState.tooltips[message.layer] = message.tooltip; + + if (map.getLayer(message.layer)) { + // Remove any existing tooltip handlers + map.off("mousemove", message.layer); + map.off("mouseleave", message.layer); + + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + map.on( + "mousemove", + message.layer, + function (e) { + map.getCanvas().style.cursor = + "pointer"; + if (e.features.length > 0) { + const description = + e.features[0].properties[ + message.tooltip + ]; + tooltip + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + } + }, + ); - factory: function (el, width, height) { - return { - renderValue: function (x) { - if (typeof maplibregl === "undefined") { - console.error("Maplibre GL JS is not loaded."); - return; - } - if (typeof maplibregl.Compare === "undefined") { - console.error("Maplibre GL Compare plugin is not loaded."); - return; - } + map.on( + "mouseleave", + message.layer, + function () { + map.getCanvas().style.cursor = ""; + tooltip.remove(); + }, + ); + } + } else if (message.type === "set_popup") { + // Track popup state + layerState.popups[message.layer] = message.popup; + + if (map.getLayer(message.layer)) { + // Remove any existing popup click handlers for this layer + if (window._maplibreClickHandlers && window._maplibreClickHandlers[message.layer]) { + map.off("click", message.layer, window._maplibreClickHandlers[message.layer]); + delete window._maplibreClickHandlers[message.layer]; + } + + // Remove any existing popup for this layer + if (window._maplibrePopups && window._maplibrePopups[message.layer]) { + window._maplibrePopups[message.layer].remove(); + delete window._maplibrePopups[message.layer]; + } - el.innerHTML = ` -
    -
    - `; + // Create new click handler for popup + const clickHandler = function (e) { + onClickPopup(e, map, message.popup, message.layer); + }; + + // Store handler reference + if (!window._maplibreClickHandlers) { + window._maplibreClickHandlers = {}; + } + window._maplibreClickHandlers[message.layer] = clickHandler; + + // Add click handler + map.on("click", message.layer, clickHandler); - var beforeMap = new maplibregl.Map({ - container: `${x.elementId}-before`, - style: x.map1.style, - center: x.map1.center, - zoom: x.map1.zoom, - bearing: x.map1.bearing, - pitch: x.map1.pitch, - accessToken: x.map1.access_token, - ...x.map1.additional_params, - }); + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", message.layer, function () { + map.getCanvas().style.cursor = "pointer"; + }); - var afterMap = new maplibregl.Map({ - container: `${x.elementId}-after`, - style: x.map2.style, - center: x.map2.center, - zoom: x.map2.zoom, - bearing: x.map2.bearing, - pitch: x.map2.pitch, - accessToken: x.map2.access_token, - ...x.map2.additional_params, - }); + // Change cursor back to default when leaving the layer + map.on("mouseleave", message.layer, function () { + map.getCanvas().style.cursor = ""; + }); + } + } else if (message.type === "move_layer") { + if (map.getLayer(message.layer)) { + if (message.before) { + map.moveLayer( + message.layer, + message.before, + ); + } else { + map.moveLayer(message.layer); + } + } + } else if (message.type === "set_opacity") { + // Set opacity for all fill layers + const style = map.getStyle(); + if (style && style.layers) { + style.layers.forEach(function (layer) { + if ( + layer.type === "fill" && + map.getLayer(layer.id) + ) { + map.setPaintProperty( + layer.id, + "fill-opacity", + message.opacity, + ); + } + }); + } + } + }, + ); + } - new maplibregl.Compare(beforeMap, afterMap, `#${x.elementId}`, { - mousemove: x.mousemove, - orientation: x.orientation, - }); + function setupShinyEvents(map, parentId, mapType) { + // Set view state on move end + map.on("moveend", function () { + const center = map.getCenter(); + const zoom = map.getZoom(); + const bearing = map.getBearing(); + const pitch = map.getPitch(); - // Ensure both maps resize correctly - beforeMap.on("load", function () { - beforeMap.resize(); - applyMapModifications(beforeMap, x.map1); - }); + if (window.Shiny) { + Shiny.setInputValue( + parentId + "_" + mapType + "_view", + { + center: [center.lng, center.lat], + zoom: zoom, + bearing: bearing, + pitch: pitch, + }, + ); + } + }); - afterMap.on("load", function () { - afterMap.resize(); - applyMapModifications(afterMap, x.map2); - }); + // Send clicked point coordinates to Shiny + map.on("click", function (e) { + if (window.Shiny) { + Shiny.setInputValue( + parentId + "_" + mapType + "_click", + { + lng: e.lngLat.lng, + lat: e.lngLat.lat, + time: Date.now(), + }, + ); + } + }); + } function applyMapModifications(map, mapData) { + // Initialize controls array if it doesn't exist + if (!map.controls) { + map.controls = []; + } + // Define the tooltip handler functions to match the ones in maplibregl.js + function onMouseMoveTooltip( + e, + map, + tooltipPopup, + tooltipProperty, + ) { + map.getCanvas().style.cursor = "pointer"; + if (e.features.length > 0) { + let description; + + // Check if tooltipProperty is an expression (array) or a simple property name (string) + if (Array.isArray(tooltipProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(tooltipProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[tooltipProperty]; + } + + tooltipPopup + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to currently active tooltip + window._activeTooltip = tooltipPopup; + } else { + tooltipPopup.remove(); + // If this was the active tooltip, clear the reference + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } + } + + function onMouseLeaveTooltip(map, tooltipPopup) { + map.getCanvas().style.cursor = ""; + tooltipPopup.remove(); + if (window._activeTooltip === tooltipPopup) { + delete window._activeTooltip; + } + } + + function evaluateExpression(expression, properties) { + if (!Array.isArray(expression)) { + return expression; + } + + const operator = expression[0]; + + switch (operator) { + case 'get': + return properties[expression[1]]; + case 'concat': + return expression.slice(1).map(item => evaluateExpression(item, properties)).join(''); + case 'to-string': + return String(evaluateExpression(expression[1], properties)); + case 'to-number': + return Number(evaluateExpression(expression[1], properties)); + default: + // For literals and other simple values + return expression; + } + } + + function onClickPopup(e, map, popupProperty, layerId) { + let description; + + // Check if popupProperty is an expression (array) or a simple property name (string) + if (Array.isArray(popupProperty)) { + // It's an expression, evaluate it + description = evaluateExpression(popupProperty, e.features[0].properties); + } else { + // It's a property name, get the value + description = e.features[0].properties[popupProperty]; + } + + // Remove any existing popup for this layer + if (window._maplibrePopups && window._maplibrePopups[layerId]) { + window._maplibrePopups[layerId].remove(); + } + + // Create and show the popup + const popup = new maplibregl.Popup() + .setLngLat(e.lngLat) + .setHTML(description) + .addTo(map); + + // Store reference to this popup + if (!window._maplibrePopups) { + window._maplibrePopups = {}; + } + window._maplibrePopups[layerId] = popup; + + // Remove reference when popup is closed + popup.on('close', function() { + if (window._maplibrePopups[layerId] === popup) { + delete window._maplibrePopups[layerId]; + } + }); + } + // Set config properties if provided if (mapData.config_properties) { mapData.config_properties.forEach(function (config) { @@ -70,6 +2378,15 @@ HTMLWidgets.widget({ }); } + // Process H3J sources if provided + if (mapData.h3j_sources) { + mapData.h3j_sources.forEach(async function (source) { + await map.addH3JSource(source.id, { + data: source.url, + }); + }); + } + if (mapData.markers) { if (!window.maplibreglMarkers) { window.maplibreglMarkers = []; @@ -98,17 +2415,7 @@ HTMLWidgets.widget({ const markerId = marker.id; if (markerId) { const lngLat = mapMarker.getLngLat(); - Shiny.setInputValue( - el.id + "_marker_" + markerId, - { - id: markerId, - lng: lngLat.lng, - lat: lngLat.lat, - }, - ); - - mapMarker.on("dragend", function () { - const lngLat = mapMarker.getLngLat(); + if (HTMLWidgets.shinyMode) { Shiny.setInputValue( el.id + "_marker_" + markerId, { @@ -117,6 +2424,20 @@ HTMLWidgets.widget({ lat: lngLat.lat, }, ); + } + + mapMarker.on("dragend", function () { + const lngLat = mapMarker.getLngLat(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_marker_" + markerId, + { + id: markerId, + lng: lngLat.lng, + lat: lngLat.lat, + }, + ); + } }); } @@ -128,16 +2449,19 @@ HTMLWidgets.widget({ if (mapData.sources) { mapData.sources.forEach(function (source) { if (source.type === "vector") { - map.addSource(source.id, { + const sourceConfig = { type: "vector", url: source.url, - }); + }; + if (source.promoteId) { + sourceConfig.promoteId = source.promoteId; + } + map.addSource(source.id, sourceConfig); } else if (source.type === "geojson") { - const geojsonData = source.geojson; map.addSource(source.id, { type: "geojson", - data: geojsonData, - generateId: true, + data: source.data, + generateId: source.generateId !== false, }); } else if (source.type === "raster") { if (source.url) { @@ -225,40 +2549,65 @@ HTMLWidgets.widget({ } // Add popups or tooltips if provided - // if (layer.popup) { - // map.on('click', layer.id, function(e) { - // const description = e.features[0].properties[layer.popup]; - // - // new maplibregl.Popup() - // .setLngLat(e.lngLat) - // .setHTML(description) - // .addTo(map); - // }); - // } - // - // if (layer.tooltip) { - // const tooltip = new maplibregl.Popup({ - // closeButton: false, - // closeOnClick: false - // }); - // - // map.on('mousemove', layer.id, function(e) { - // map.getCanvas().style.cursor = 'pointer'; - // - // if (e.features.length > 0) { - // const description = e.features[0].properties[layer.tooltip]; - // tooltip.setLngLat(e.lngLat).setHTML(description).addTo(map); - // } else { - // tooltip.remove(); - // } - // }); - // - // map.on('mouseleave', layer.id, function() { - // map.getCanvas().style.cursor = ''; - // tooltip.remove(); - // }); - // - // } + if (layer.popup) { + map.on("click", layer.id, function (e) { + onClickPopup(e, map, layer.popup, layer.id); + }); + + // Change cursor to pointer when hovering over the layer + map.on("mouseenter", layer.id, function () { + map.getCanvas().style.cursor = + "pointer"; + }); + + // Change cursor back to default when leaving the layer + map.on("mouseleave", layer.id, function () { + map.getCanvas().style.cursor = ""; + }); + } + + if (layer.tooltip) { + const tooltip = new maplibregl.Popup({ + closeButton: false, + closeOnClick: false, + }); + + // Create a reference to the mousemove handler function + const mouseMoveHandler = function (e) { + onMouseMoveTooltip( + e, + map, + tooltip, + layer.tooltip, + ); + }; + + // Create a reference to the mouseleave handler function + const mouseLeaveHandler = function () { + onMouseLeaveTooltip(map, tooltip); + }; + + // Attach the named handler references + map.on( + "mousemove", + layer.id, + mouseMoveHandler, + ); + map.on( + "mouseleave", + layer.id, + mouseLeaveHandler, + ); + + // Store these handler references + if (!window._mapboxHandlers) { + window._mapboxHandlers = {}; + } + window._mapboxHandlers[layer.id] = { + mousemove: mouseMoveHandler, + mouseleave: mouseLeaveHandler, + }; + } // Add hover effect if provided if (layer.hover_options) { @@ -391,6 +2740,31 @@ HTMLWidgets.widget({ map.jumpTo(mapData.jumpTo); } + // Add custom images if provided + if (mapData.images && Array.isArray(mapData.images)) { + mapData.images.forEach(async function (imageInfo) { + try { + const image = await map.loadImage( + imageInfo.url, + ); + if (!map.hasImage(imageInfo.id)) { + map.addImage( + imageInfo.id, + image.data, + imageInfo.options, + ); + } + } catch (error) { + console.error("Error loading image:", error); + } + }); + } else if (mapData.images) { + console.error( + "mapData.images is not an array:", + mapData.images, + ); + } + const existingLegend = document.getElementById("mapboxgl-legend"); if (existingLegend) { @@ -421,6 +2795,154 @@ HTMLWidgets.widget({ ); } + // Helper function to generate draw styles based on parameters + function generateDrawStyles(styling) { + if (!styling) return null; + + return [ + // Point styles + { + 'id': 'gl-draw-point-active', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'true']], + 'paint': { + 'circle-radius': styling.vertex_radius + 2, + 'circle-color': styling.active_color + } + }, + { + 'id': 'gl-draw-point', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['==', 'active', 'false']], + 'paint': { + 'circle-radius': styling.vertex_radius, + 'circle-color': styling.point_color + } + }, + // Line styles + { + 'id': 'gl-draw-line', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'LineString']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Polygon fill + { + 'id': 'gl-draw-polygon-fill', + 'type': 'fill', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'paint': { + 'fill-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-outline-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.fill_color + ], + 'fill-opacity': styling.fill_opacity + } + }, + // Polygon outline + { + 'id': 'gl-draw-polygon-stroke', + 'type': 'line', + 'filter': ['all', ['==', '$type', 'Polygon']], + 'layout': { + 'line-cap': 'round', + 'line-join': 'round' + }, + 'paint': { + 'line-color': ['case', + ['==', ['get', 'active'], 'true'], styling.active_color, + styling.line_color + ], + 'line-width': styling.line_width + } + }, + // Midpoints + { + 'id': 'gl-draw-polygon-midpoint', + 'type': 'circle', + 'filter': ['all', + ['==', '$type', 'Point'], + ['==', 'meta', 'midpoint']], + 'paint': { + 'circle-radius': 3, + 'circle-color': styling.active_color + } + }, + // Vertex point halos + { + 'id': 'gl-draw-vertex-halo-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 4, + styling.vertex_radius + 2 + ], + 'circle-color': '#FFF' + } + }, + // Vertex points + { + 'id': 'gl-draw-vertex-active', + 'type': 'circle', + 'filter': ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point']], + 'paint': { + 'circle-radius': ['case', + ['==', ['get', 'active'], 'true'], styling.vertex_radius + 2, + styling.vertex_radius + ], + 'circle-color': styling.active_color + } + } + ]; + } + + // Helper function to add features from a source to draw + function addSourceFeaturesToDraw(draw, sourceId, map) { + const source = map.getSource(sourceId); + if (source && source._data) { + draw.add(source._data); + } else { + console.warn('Source not found or has no data:', sourceId); + } + } + + if (mapData.scale_control) { + const scaleControl = new maplibregl.ScaleControl({ + maxWidth: mapData.scale_control.maxWidth, + unit: mapData.scale_control.unit, + }); + map.addControl( + scaleControl, + mapData.scale_control.position, + ); + map.controls.push(scaleControl); + } + // Add navigation control if enabled if (mapData.navigation_control) { const nav = new maplibregl.NavigationControl({ @@ -434,20 +2956,429 @@ HTMLWidgets.widget({ nav, mapData.navigation_control.position, ); + map.controls.push(nav); + } + + // Add geolocate control if enabled + if (mapData.geolocate_control) { + const geolocate = new maplibregl.GeolocateControl({ + positionOptions: + mapData.geolocate_control.positionOptions, + trackUserLocation: + mapData.geolocate_control.trackUserLocation, + showAccuracyCircle: + mapData.geolocate_control.showAccuracyCircle, + showUserLocation: + mapData.geolocate_control.showUserLocation, + showUserHeading: + mapData.geolocate_control.showUserHeading, + fitBoundsOptions: + mapData.geolocate_control.fitBoundsOptions, + }); + map.addControl( + geolocate, + mapData.geolocate_control.position, + ); + + map.controls.push(geolocate); + } + + // Add globe control if enabled + if (mapData.globe_control) { + const globeControl = new maplibregl.GlobeControl(); + map.addControl( + globeControl, + mapData.globe_control.position, + ); + map.controls.push(globeControl); + } + + // Add draw control if enabled + if (mapData.draw_control && mapData.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = "maplibregl-ctrl-group"; + + let drawOptions = mapData.draw_control.options || {}; + + // Generate styles if styling parameters provided + if (mapData.draw_control.styling) { + const generatedStyles = generateDrawStyles(mapData.draw_control.styling); + if (generatedStyles) { + drawOptions.styles = generatedStyles; + } + } + + if (mapData.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + mapData.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + // Fix MapLibre compatibility - ensure we always have custom styles + if (!drawOptions.styles) { + drawOptions.styles = generateDrawStyles({ + vertex_radius: 5, + active_color: '#fbb03b', + point_color: '#3bb2d0', + line_color: '#3bb2d0', + fill_color: '#3bb2d0', + fill_opacity: 0.1, + line_width: 2 + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, mapData.draw_control.position); + map.controls.push(draw); + + // Add initial features if provided + if (mapData.draw_control.source) { + addSourceFeaturesToDraw(draw, mapData.draw_control.source, map); + } + + // Process any queued features + if (mapData.draw_features_queue) { + mapData.draw_features_queue.forEach(function(data) { + if (data.clear_existing) { + draw.deleteAll(); + } + addSourceFeaturesToDraw(draw, data.source, map); + }); + } + + // Apply orientation styling + if (mapData.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + + // Helper function for updating drawn features + function updateDrawnFeatures() { + if (HTMLWidgets.shinyMode && draw) { + const features = draw.getAll(); + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(features), + ); + } + } + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + } + + if (mapData.geolocate_control && HTMLWidgets.shinyMode) { + geolocate.on("geolocate", function (event) { + Shiny.setInputValue(el.id + "_geolocate", { + coords: event.coords, + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationstart", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "start", + time: new Date(), + }); + }); + + geolocate.on("trackuserlocationend", function () { + Shiny.setInputValue(el.id + "_geolocate_tracking", { + status: "end", + time: new Date(), + }); + }); + + geolocate.on("error", function (error) { + if (error.error.code === 1) { + Shiny.setInputValue( + el.id + "_geolocate_error", + { + message: "Location permission denied", + time: new Date(), + }, + ); + } + }); + } + + // Add geocoder control if enabled + if (mapData.geocoder_control) { + const geocoderApi = { + forwardGeocode: async (config) => { + const features = []; + try { + const request = `https://nominatim.openstreetmap.org/search?q=${ + config.query + }&format=geojson&polygon_geojson=1&addressdetails=1`; + const response = await fetch(request); + const geojson = await response.json(); + for (const feature of geojson.features) { + const center = [ + feature.bbox[0] + + (feature.bbox[2] - + feature.bbox[0]) / + 2, + feature.bbox[1] + + (feature.bbox[3] - + feature.bbox[1]) / + 2, + ]; + const point = { + type: "Feature", + geometry: { + type: "Point", + coordinates: center, + }, + place_name: + feature.properties.display_name, + properties: feature.properties, + text: feature.properties + .display_name, + place_type: ["place"], + center, + }; + features.push(point); + } + } catch (e) { + console.error( + `Failed to forwardGeocode with error: ${e}`, + ); + } + + return { + features, + }; + }, + }; + const geocoderOptions = { + maplibregl: maplibregl, + ...mapData.geocoder_control, + }; + + // Set default values if not provided + if (!geocoderOptions.placeholder) + geocoderOptions.placeholder = "Search"; + if (typeof geocoderOptions.collapsed === "undefined") + geocoderOptions.collapsed = false; + + const geocoder = new MaplibreGeocoder( + geocoderApi, + geocoderOptions, + ); + + map.addControl( + geocoder, + mapData.geocoder_control.position || "top-right", + ); + + // Handle geocoder results in Shiny mode + if (HTMLWidgets.shinyMode) { + geocoder.on("results", function (e) { + Shiny.setInputValue(el.id + "_geocoder", { + result: e, + time: new Date(), + }); + }); + } + } + + // Add reset control if enabled + if (mapData.reset_control) { + const resetControl = document.createElement("button"); + resetControl.className = + "maplibregl-ctrl-icon maplibregl-ctrl-reset"; + resetControl.type = "button"; + resetControl.setAttribute("aria-label", "Reset"); + resetControl.innerHTML = "⟲"; + resetControl.style.fontSize = "30px"; + resetControl.style.fontWeight = "bold"; + resetControl.style.backgroundColor = "white"; + resetControl.style.border = "none"; + resetControl.style.cursor = "pointer"; + resetControl.style.padding = "0"; + resetControl.style.width = "30px"; + resetControl.style.height = "30px"; + resetControl.style.display = "flex"; + resetControl.style.justifyContent = "center"; + resetControl.style.alignItems = "center"; + resetControl.style.transition = "background-color 0.2s"; + resetControl.addEventListener("mouseover", function () { + this.style.backgroundColor = "#f0f0f0"; + }); + resetControl.addEventListener("mouseout", function () { + this.style.backgroundColor = "white"; + }); + + const resetContainer = document.createElement("div"); + resetContainer.className = + "maplibregl-ctrl maplibregl-ctrl-group"; + resetContainer.appendChild(resetControl); + + const initialView = { + center: map.getCenter(), + zoom: map.getZoom(), + pitch: map.getPitch(), + bearing: map.getBearing(), + animate: mapData.reset_control.animate, + }; + + if (mapData.reset_control.duration) { + initialView.duration = + mapData.reset_control.duration; + } + + resetControl.onclick = function () { + map.easeTo(initialView); + }; + + map.addControl( + { + onAdd: function () { + return resetContainer; + }, + onRemove: function () { + resetContainer.parentNode.removeChild( + resetContainer, + ); + }, + }, + mapData.reset_control.position, + ); + } + + if (mapData.draw_control && mapData.draw_control.enabled) { + MapboxDraw.constants.classes.CONTROL_BASE = + "maplibregl-ctrl"; + MapboxDraw.constants.classes.CONTROL_PREFIX = + "maplibregl-ctrl-"; + MapboxDraw.constants.classes.CONTROL_GROUP = + "maplibregl-ctrl-group"; + + let drawOptions = mapData.draw_control.options || {}; + + if (mapData.draw_control.freehand) { + drawOptions = Object.assign({}, drawOptions, { + modes: Object.assign({}, MapboxDraw.modes, { + draw_polygon: Object.assign( + {}, + MapboxDraw.modes.draw_freehand, + { + // Store the simplify_freehand option on the map object + onSetup: function (opts) { + const state = + MapboxDraw.modes.draw_freehand.onSetup.call( + this, + opts, + ); + this.map.simplify_freehand = + mapData.draw_control.simplify_freehand; + return state; + }, + }, + ), + }), + // defaultMode: 'draw_polygon' # Don't set the default yet + }); + } + + draw = new MapboxDraw(drawOptions); + map.addControl(draw, mapData.draw_control.position); + map.controls.push(draw); + + // Add event listeners + map.on("draw.create", updateDrawnFeatures); + map.on("draw.delete", updateDrawnFeatures); + map.on("draw.update", updateDrawnFeatures); + + // Apply orientation styling + if (mapData.draw_control.orientation === "horizontal") { + const drawBar = map + .getContainer() + .querySelector(".maplibregl-ctrl-group"); + if (drawBar) { + drawBar.style.display = "flex"; + drawBar.style.flexDirection = "row"; + } + } + } + + function updateDrawnFeatures() { + if (draw) { + var drawnFeatures = draw.getAll(); + if (HTMLWidgets.shinyMode) { + Shiny.setInputValue( + el.id + "_drawn_features", + JSON.stringify(drawnFeatures), + ); + } + // Store drawn features in the widget's data + if (el.querySelector) { + var widget = HTMLWidgets.find("#" + el.id); + if (widget) { + widget.drawFeatures = drawnFeatures; + } + } + } } // Add the layers control if provided if (mapData.layers_control) { const layersControl = document.createElement("div"); layersControl.id = mapData.layers_control.control_id; - layersControl.className = mapData.layers_control - .collapsible + + // Handle use_icon parameter + let className = mapData.layers_control.collapsible ? "layers-control collapsible" : "layers-control"; + + layersControl.className = className; layersControl.style.position = "absolute"; - layersControl.style[ - mapData.layers_control.position || "top-right" - ] = "10px"; + + // Set the position correctly - fix position bug by using correct CSS positioning + const position = + mapData.layers_control.position || "top-left"; + if (position === "top-left") { + layersControl.style.top = "10px"; + layersControl.style.left = "10px"; + } else if (position === "top-right") { + layersControl.style.top = "10px"; + layersControl.style.right = "10px"; + } else if (position === "bottom-left") { + layersControl.style.bottom = "30px"; + layersControl.style.left = "10px"; + } else if (position === "bottom-right") { + layersControl.style.bottom = "40px"; + layersControl.style.right = "10px"; + } + el.appendChild(layersControl); const layersList = document.createElement("div"); @@ -502,7 +3433,24 @@ HTMLWidgets.widget({ if (mapData.layers_control.collapsible) { const toggleButton = document.createElement("div"); toggleButton.className = "toggle-button"; - toggleButton.textContent = "Layers"; + + if (mapData.layers_control.use_icon) { + // Add icon-only class to the control for compact styling + layersControl.classList.add("icon-only"); + + // More GIS-like layers stack icon + toggleButton.innerHTML = ` + + + + `; + toggleButton.style.display = "flex"; + toggleButton.style.alignItems = "center"; + toggleButton.style.justifyContent = "center"; + } else { + toggleButton.textContent = "Layers"; + } + toggleButton.onclick = function () { layersControl.classList.toggle("open"); }; diff --git a/inst/htmlwidgets/maplibregl_compare.yaml b/inst/htmlwidgets/maplibregl_compare.yaml index 214b8dcd..f93b34d0 100644 --- a/inst/htmlwidgets/maplibregl_compare.yaml +++ b/inst/htmlwidgets/maplibregl_compare.yaml @@ -1,13 +1,47 @@ dependencies: - - name: maplibre-gl - version: 2 - src: - href: "https://unpkg.com/" - script: - - "maplibre-gl/dist/maplibre-gl.js" - - "maplibre-gl-compare@0.4.0/dist/maplibre-gl-compare.js" - - name: maplibre-gl-compare - version: 1 - src: "htmlwidgets/lib/maplibre-gl-compare/" - script: "maplibre-gl-compare.js" - stylesheet: "maplibre-gl-compare.css" + - name: maplibre-gl + version: "5.3.0" + src: "htmlwidgets/lib/maplibre-gl" + script: + - "maplibre-gl.js" + stylesheet: + - "maplibre-gl.css" + - name: maplibre-gl-compare + version: 1 + src: "htmlwidgets/lib/maplibre-gl-compare/" + script: "maplibre-gl-compare.js" + stylesheet: "maplibre-gl-compare.css" + - name: mapbox-gl-draw + version: "1.4.3" + src: "htmlwidgets/lib/mapbox-gl-draw" + script: + - "mapbox-gl-draw.js" + stylesheet: + - "mapbox-gl-draw.css" + - name: freehand-mode + version: 1.0.0 + src: "htmlwidgets/lib/freehand-mode" + script: + - "freehand-mode.js" + - name: maplibre-gl-geocoder + version: 1.5.0 + src: "htmlwidgets/lib/maplibre-gl-geocoder" + script: + - "maplibre-gl-geocoder.min.js" + stylesheet: + - "maplibre-gl-geocoder.css" + - name: mapbox-gl-globe-minimap + version: 1.2.1 + src: "htmlwidgets/lib/mapbox-gl-globe-minimap" + script: + - "bundle.js" + - name: pmtiles + version: 3.2.0 + src: "htmlwidgets/lib/pmtiles" + script: + - "pmtiles.js" + - name: h3j-h3t + version: 0.9.2 + src: "htmlwidgets/lib/h3j-h3t" + script: + - "h3j_h3t.js" diff --git a/inst/htmlwidgets/styles/layers-control.css b/inst/htmlwidgets/styles/layers-control.css index 07ebdcc1..85512288 100644 --- a/inst/htmlwidgets/styles/layers-control.css +++ b/inst/htmlwidgets/styles/layers-control.css @@ -2,11 +2,14 @@ background: #fff; position: absolute; z-index: 1; - border-radius: 3px; + border-radius: 4px; width: 120px; - border: 1px solid rgba(0, 0, 0, 0.4); - font-family: 'Open Sans', sans-serif; - margin: 10px; + border: 1px solid rgba(0, 0, 0, 0.15); + font-family: "Open Sans", sans-serif; + margin: 0px; + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); + overflow: hidden; + transition: all 0.2s ease-in-out; } .layers-control a { @@ -14,11 +17,12 @@ color: #404040; display: block; margin: 0; - padding: 0; padding: 10px; text-decoration: none; - border-bottom: 1px solid rgba(0, 0, 0, 0.25); + border-bottom: 1px solid rgba(0, 0, 0, 0.1); text-align: center; + transition: all 0.15s ease-in-out; + font-weight: normal; } .layers-control a:last-child { @@ -27,32 +31,35 @@ .layers-control a:hover { background-color: #f8f8f8; - color: #404040; + color: #1a1a1a; } .layers-control a.active { - background-color: darkgrey; + background-color: #4a90e2; color: #ffffff; + font-weight: 500; } .layers-control a.active:hover { - background: grey; + background: #3b7ed2; } .layers-control .toggle-button { display: none; - background: darkgrey; + background: #4a90e2; color: #ffffff; text-align: center; cursor: pointer; - padding: 5px 0; - border-radius: 3px 3px 0 0; - + padding: 8px 0; + border-radius: 4px 4px 0 0; + font-weight: 500; + letter-spacing: 0.3px; + box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05) inset; + transition: all 0.15s ease-in-out; } - .layers-control .toggle-button:hover { - background: grey; + background: #3b7ed2; } .layers-control .layers-list { @@ -66,8 +73,51 @@ .layers-control.collapsible .layers-list { display: none; + opacity: 0; + max-height: 0; + transition: + opacity 0.25s ease, + max-height 0.25s ease; } .layers-control.collapsible.open .layers-list { display: block; + opacity: 1; + max-height: 500px; /* Large enough value to accommodate all content */ +} + +/* Compact icon styling */ +.layers-control.collapsible.icon-only { + width: auto; + min-width: 36px; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); + transform: translateZ( + 0 + ); /* Force hardware acceleration for smoother animations */ +} + +.layers-control.collapsible.icon-only .toggle-button { + border-radius: 4px; + padding: 8px; + width: 36px; + height: 36px; + box-sizing: border-box; + margin: 0; + border-bottom: none; + display: flex; + align-items: center; + justify-content: center; + box-shadow: none; +} + +.layers-control.collapsible.icon-only.open { + width: 120px; + box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25); +} + +.layers-control.collapsible.icon-only.open .toggle-button { + border-radius: 4px 4px 0 0; + border-bottom: 1px solid rgba(0, 0, 0, 0.1); + width: 100%; } diff --git a/man/add_categorical_legend.Rd b/man/add_categorical_legend.Rd index 2c687cbd..fc3ea48a 100644 --- a/man/add_categorical_legend.Rd +++ b/man/add_categorical_legend.Rd @@ -14,7 +14,12 @@ add_categorical_legend( unique_id = NULL, sizes = NULL, add = FALSE, - width = NULL + width = NULL, + layer_id = NULL, + margin_top = NULL, + margin_right = NULL, + margin_bottom = NULL, + margin_left = NULL ) } \arguments{ @@ -37,6 +42,16 @@ add_categorical_legend( \item{add}{Logical, whether to add this legend to existing legends (TRUE) or replace existing legends (FALSE). Default is FALSE.} \item{width}{The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default.} + +\item{layer_id}{The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled.} + +\item{margin_top}{Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning).} + +\item{margin_right}{Custom right margin in pixels. Default is NULL.} + +\item{margin_bottom}{Custom bottom margin in pixels. Default is NULL.} + +\item{margin_left}{Custom left margin in pixels. Default is NULL.} } \value{ The updated map object with the legend added. diff --git a/man/add_continuous_legend.Rd b/man/add_continuous_legend.Rd index 2f460131..5d75f7c0 100644 --- a/man/add_continuous_legend.Rd +++ b/man/add_continuous_legend.Rd @@ -12,7 +12,12 @@ add_continuous_legend( position = "top-left", unique_id = NULL, add = FALSE, - width = NULL + width = NULL, + layer_id = NULL, + margin_top = NULL, + margin_right = NULL, + margin_bottom = NULL, + margin_left = NULL ) } \arguments{ @@ -31,6 +36,16 @@ add_continuous_legend( \item{add}{Logical, whether to add this legend to existing legends (TRUE) or replace existing legends (FALSE). Default is FALSE.} \item{width}{The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default.} + +\item{layer_id}{The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled.} + +\item{margin_top}{Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning).} + +\item{margin_right}{Custom right margin in pixels. Default is NULL.} + +\item{margin_bottom}{Custom bottom margin in pixels. Default is NULL.} + +\item{margin_left}{Custom left margin in pixels. Default is NULL.} } \value{ The updated map object with the legend added. diff --git a/man/add_control.Rd b/man/add_control.Rd new file mode 100644 index 00000000..6e3f5ecd --- /dev/null +++ b/man/add_control.Rd @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/controls.R +\name{add_control} +\alias{add_control} +\title{Add a custom control to a map} +\usage{ +add_control(map, html, position = "top-right", className = NULL, ...) +} +\arguments{ +\item{map}{A map object created by the \code{mapboxgl} or \code{maplibre} functions.} + +\item{html}{Character string containing the HTML content for the control.} + +\item{position}{The position of the control. Can be one of "top-left", "top-right", +"bottom-left", or "bottom-right". Default is "top-right".} + +\item{className}{Optional CSS class name for the control container.} + +\item{...}{Additional arguments passed to the JavaScript side.} +} +\value{ +The modified map object with the custom control added. +} +\description{ +This function adds a custom control to a Mapbox GL or MapLibre GL map. +It allows you to create custom HTML element controls and add them to the map. +} +\examples{ +\dontrun{ +library(mapgl) + +maplibre() |> + add_control( + html = "
    +

    Custom HTML

    + image +
    ", + position = "top-left" + ) +} +} diff --git a/man/add_draw_control.Rd b/man/add_draw_control.Rd index f097f238..32d39b70 100644 --- a/man/add_draw_control.Rd +++ b/man/add_draw_control.Rd @@ -10,6 +10,14 @@ add_draw_control( freehand = FALSE, simplify_freehand = FALSE, orientation = "vertical", + source = NULL, + point_color = "#3bb2d0", + line_color = "#3bb2d0", + fill_color = "#3bb2d0", + fill_opacity = 0.1, + active_color = "#fbb03b", + vertex_radius = 5, + line_width = 2, ... ) } @@ -26,6 +34,23 @@ One of "top-right", "top-left", "bottom-right", or "bottom-left".} \item{orientation}{A string specifying the orientation of the draw control. Either "vertical" (default) or "horizontal".} +\item{source}{A character string specifying a source ID to add to the draw control. +Default is NULL.} + +\item{point_color}{Color for point features. Default is "#3bb2d0" (light blue).} + +\item{line_color}{Color for line features. Default is "#3bb2d0" (light blue).} + +\item{fill_color}{Fill color for polygon features. Default is "#3bb2d0" (light blue).} + +\item{fill_opacity}{Fill opacity for polygon features. Default is 0.1.} + +\item{active_color}{Color for active (selected) features. Default is "#fbb03b" (orange).} + +\item{vertex_radius}{Radius of vertex points in pixels. Default is 5.} + +\item{line_width}{Width of lines in pixels. Default is 2.} + \item{...}{Additional named arguments. See \url{https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md#options} for a list of options.} } \value{ @@ -44,5 +69,24 @@ mapboxgl( zoom = 9 ) |> add_draw_control() + +# With initial features from a source +library(tigris) +tx <- counties(state = "TX", cb = TRUE) +mapboxgl(bounds = tx) |> + add_source(id = "tx", data = tx) |> + add_draw_control(source = "tx") + +# With custom styling +mapboxgl() |> + add_draw_control( + point_color = "#ff0000", + line_color = "#00ff00", + fill_color = "#0000ff", + fill_opacity = 0.3, + active_color = "#ff00ff", + vertex_radius = 7, + line_width = 3 + ) } } diff --git a/man/add_features_to_draw.Rd b/man/add_features_to_draw.Rd new file mode 100644 index 00000000..d67a81cd --- /dev/null +++ b/man/add_features_to_draw.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/controls.R +\name{add_features_to_draw} +\alias{add_features_to_draw} +\title{Add features to an existing draw control} +\usage{ +add_features_to_draw(map, source, clear_existing = FALSE) +} +\arguments{ +\item{map}{A map object with a draw control already added} + +\item{source}{Character string specifying a source ID to get features from} + +\item{clear_existing}{Logical, whether to clear existing drawn features before adding new ones. Default is FALSE.} +} +\value{ +The modified map object +} +\description{ +This function adds features from an existing source to a draw control on a map. +} +\examples{ +\dontrun{ +library(mapgl) +library(tigris) + +# Add features from an existing source +tx <- counties(state = "TX", cb = TRUE) +mapboxgl(bounds = tx) |> + add_source(id = "tx", data = tx) |> + add_draw_control() |> + add_features_to_draw(source = "tx") + +# In a Shiny app +observeEvent(input$load_data, { + mapboxgl_proxy("map") |> + add_features_to_draw( + source = "dynamic_data", + clear_existing = TRUE + ) +}) +} +} diff --git a/man/add_globe_control.Rd b/man/add_globe_control.Rd new file mode 100644 index 00000000..423fcc6c --- /dev/null +++ b/man/add_globe_control.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/controls.R +\name{add_globe_control} +\alias{add_globe_control} +\title{Add a globe control to a map} +\usage{ +add_globe_control(map, position = "top-right") +} +\arguments{ +\item{map}{A map object created by the \code{maplibre} function.} + +\item{position}{The position of the control. Can be one of "top-left", "top-right", +"bottom-left", or "bottom-right". Default is "top-right".} +} +\value{ +The modified map object with the globe control added. +} +\description{ +This function adds a globe control to a MapLibre GL map that allows toggling +between "mercator" and "globe" projections with a single click. +} +\examples{ +\dontrun{ +library(mapgl) + +maplibre() |> + add_globe_control(position = "top-right") +} +} diff --git a/man/add_h3j_source.Rd b/man/add_h3j_source.Rd new file mode 100644 index 00000000..0753e39c --- /dev/null +++ b/man/add_h3j_source.Rd @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/h3j-h3t.R +\name{add_h3j_source} +\alias{add_h3j_source} +\title{Add a hexagon source from the H3 geospatial indexing system.} +\usage{ +add_h3j_source(map, id, url) +} +\arguments{ +\item{map}{A map object created by the \code{mapboxgl} or \code{maplibre} function.} + +\item{id}{A unique ID for the source.} + +\item{url}{A URL pointing to the vector tile source.} +} +\description{ +Add a hexagon source from the H3 geospatial indexing system. +} +\examples{ +\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +url = "https://inspide.github.io/h3j-h3t/examples/h3j/sample.h3j" +maplibre(center=c(-3.704, 40.417), zoom=15, pitch=30) |> + add_h3j_source("h3j_testsource", + url = url + ) |> + add_fill_extrusion_layer( + id = "h3j_testlayer", + source = "h3j_testsource", + fill_extrusion_color = interpolate( + column = "value", + values = c(0, 21.864), + stops = c("#430254", "#f83c70") + ), + fill_extrusion_height = list( + "interpolate", + list("linear"), + list("zoom"), + 14, + 0, + 15.05, + list("*", 10, list("get", "value")) + ), + fill_extrusion_opacity = 0.7 + ) +\dontshow{\}) # examplesIf} +} +\references{ +https://h3geo.org, https://github.com/INSPIDE/h3j-h3t +} diff --git a/man/add_layers_control.Rd b/man/add_layers_control.Rd index 417aedb2..3e8f8b8f 100644 --- a/man/add_layers_control.Rd +++ b/man/add_layers_control.Rd @@ -8,7 +8,13 @@ add_layers_control( map, position = "top-left", layers = NULL, - collapsible = FALSE + collapsible = TRUE, + use_icon = TRUE, + background_color = NULL, + active_color = NULL, + hover_color = NULL, + active_text_color = NULL, + inactive_text_color = NULL ) } \arguments{ @@ -19,6 +25,19 @@ add_layers_control( \item{layers}{A vector of layer IDs to be included in the control. If NULL, all layers will be included.} \item{collapsible}{Whether the control should be collapsible.} + +\item{use_icon}{Whether to use a stacked layers icon instead of the "Layers" text when collapsed. Only applies when collapsible = TRUE.} + +\item{background_color}{The background color for the layers control; this will be the +color used for inactive layer items.} + +\item{active_color}{The background color for active layer items.} + +\item{hover_color}{The background color for layer items when hovered.} + +\item{active_text_color}{The text color for active layer items.} + +\item{inactive_text_color}{The text color for inactive layer items.} } \value{ The modified map object with the layers control added. @@ -47,6 +66,10 @@ maplibre() |> source = rds, line_color = "pink" ) |> - add_layers_control(collapsible = TRUE) + add_layers_control( + position = "top-left", + background_color = "#ffffff", + active_color = "#4a90e2" + ) } } diff --git a/man/add_legend.Rd b/man/add_legend.Rd index 2afda275..9d295290 100644 --- a/man/add_legend.Rd +++ b/man/add_legend.Rd @@ -14,7 +14,13 @@ add_legend( position = "top-left", sizes = NULL, add = FALSE, - width = NULL + unique_id = NULL, + width = NULL, + layer_id = NULL, + margin_top = NULL, + margin_right = NULL, + margin_bottom = NULL, + margin_left = NULL ) } \arguments{ @@ -36,7 +42,19 @@ add_legend( \item{add}{Logical, whether to add this legend to existing legends (TRUE) or replace existing legends (FALSE). Default is FALSE.} +\item{unique_id}{Optional. A unique identifier for the legend. If not provided, a random ID will be generated.} + \item{width}{The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default.} + +\item{layer_id}{The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled.} + +\item{margin_top}{Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning).} + +\item{margin_right}{Custom right margin in pixels. Default is NULL.} + +\item{margin_bottom}{Custom bottom margin in pixels. Default is NULL.} + +\item{margin_left}{Custom left margin in pixels. Default is NULL.} } \value{ The updated map object with the legend added. diff --git a/man/add_raster_dem_source.Rd b/man/add_raster_dem_source.Rd index e16f45c8..489999d1 100644 --- a/man/add_raster_dem_source.Rd +++ b/man/add_raster_dem_source.Rd @@ -4,7 +4,7 @@ \alias{add_raster_dem_source} \title{Add a raster DEM source to a Mapbox GL or Maplibre GL map} \usage{ -add_raster_dem_source(map, id, url, tileSize = 512, maxzoom = NULL) +add_raster_dem_source(map, id, url, tileSize = 512, maxzoom = NULL, ...) } \arguments{ \item{map}{A map object created by the \code{mapboxgl} or \code{maplibre} function.} @@ -16,6 +16,8 @@ add_raster_dem_source(map, id, url, tileSize = 512, maxzoom = NULL) \item{tileSize}{The size of the raster tiles.} \item{maxzoom}{The maximum zoom level for the raster tiles.} + +\item{...}{Additional arguments to be passed to the JavaScript addSource method.} } \value{ The modified map object with the new source added. diff --git a/man/add_raster_source.Rd b/man/add_raster_source.Rd index 30e926ee..a4c6e90e 100644 --- a/man/add_raster_source.Rd +++ b/man/add_raster_source.Rd @@ -10,7 +10,8 @@ add_raster_source( url = NULL, tiles = NULL, tileSize = 256, - maxzoom = 22 + maxzoom = 22, + ... ) } \arguments{ @@ -25,6 +26,8 @@ add_raster_source( \item{tileSize}{The size of the raster tiles.} \item{maxzoom}{The maximum zoom level for the raster tiles.} + +\item{...}{Additional arguments to be passed to the JavaScript addSource method.} } \value{ The modified map object with the new source added. diff --git a/man/add_vector_source.Rd b/man/add_vector_source.Rd index 9dea8ee0..112bac0e 100644 --- a/man/add_vector_source.Rd +++ b/man/add_vector_source.Rd @@ -4,7 +4,7 @@ \alias{add_vector_source} \title{Add a vector tile source to a Mapbox GL or Maplibre GL map} \usage{ -add_vector_source(map, id, url) +add_vector_source(map, id, url, promote_id = NULL, ...) } \arguments{ \item{map}{A map object created by the \code{mapboxgl} or \code{maplibre} function.} @@ -12,6 +12,10 @@ add_vector_source(map, id, url) \item{id}{A unique ID for the source.} \item{url}{A URL pointing to the vector tile source.} + +\item{promote_id}{An optional property name to use as the feature ID. This is required for hover effects on vector tiles.} + +\item{...}{Additional arguments to be passed to the JavaScript addSource method.} } \value{ The modified map object with the new source added. diff --git a/man/clear_legend.Rd b/man/clear_legend.Rd index e63182b7..fbc9afc4 100644 --- a/man/clear_legend.Rd +++ b/man/clear_legend.Rd @@ -2,16 +2,18 @@ % Please edit documentation in R/legends.R \name{clear_legend} \alias{clear_legend} -\title{Clear legend from a map in a proxy session} +\title{Clear legend(s) from a map in a proxy session} \usage{ -clear_legend(map) +clear_legend(map, legend_ids = NULL) } \arguments{ \item{map}{A map object created by the \code{mapboxgl_proxy} or \code{maplibre_proxy} function.} + +\item{legend_ids}{Optional. A character vector of legend IDs to clear. If not provided, all legends will be cleared.} } \value{ -The updated map object with the legend cleared. +The updated map object with the specified legend(s) cleared. } \description{ -Clear legend from a map in a proxy session +Clear legend(s) from a map in a proxy session } diff --git a/man/compare.Rd b/man/compare.Rd index b70796aa..c4960466 100644 --- a/man/compare.Rd +++ b/man/compare.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/plugins.R \name{compare} \alias{compare} -\title{Create a Compare slider widget} +\title{Create a Compare widget} \usage{ compare( map1, @@ -11,7 +11,9 @@ compare( height = NULL, elementId = NULL, mousemove = FALSE, - orientation = "vertical" + orientation = "vertical", + mode = "swipe", + swiper_color = NULL ) } \arguments{ @@ -25,26 +27,109 @@ compare( \item{elementId}{An optional string specifying the ID of the container for the comparison. If NULL, a unique ID will be generated.} -\item{mousemove}{A logical value indicating whether to enable swiping during cursor movement (rather than only when clicked).} +\item{mousemove}{A logical value indicating whether to enable swiping during cursor movement (rather than only when clicked). Only applicable when \code{mode="swipe"}.} -\item{orientation}{A string specifying the orientation of the swiper, either "horizontal" or "vertical".} +\item{orientation}{A string specifying the orientation of the swiper or the side-by-side layout, either "horizontal" or "vertical".} + +\item{mode}{A string specifying the comparison mode: "swipe" (default) for a swipeable comparison with a slider, or "sync" for synchronized maps displayed next to each other.} + +\item{swiper_color}{An optional CSS color value (e.g., "#000000", "rgb(0,0,0)", "black") to customize the color of the swiper handle. Only applicable when \code{mode="swipe"}.} } \value{ A comparison widget. } \description{ -This function creates a comparison view between two Mapbox GL or Maplibre GL maps, allowing users to swipe between the two maps to compare different styles or data layers. +This function creates a comparison view between two Mapbox GL or Maplibre GL maps, allowing users to either swipe between the two maps or view them side-by-side with synchronized navigation. +} +\details{ +\subsection{Comparison modes}{ + +The \code{compare()} function supports two modes: +\itemize{ +\item \code{mode="swipe"} (default) - Creates a swipeable interface with a slider to reveal portions of each map +\item \code{mode="sync"} - Places the maps next to each other with synchronized navigation +} + +In both modes, navigation (panning, zooming, rotating, tilting) is synchronized between the maps. +} + +\subsection{Using the compare widget in Shiny}{ + +The compare widget can be used in Shiny applications with the following functions: +\itemize{ +\item \code{mapboxglCompareOutput()} / \code{renderMapboxglCompare()} - For Mapbox GL comparisons +\item \code{maplibreCompareOutput()} / \code{renderMaplibreCompare()} - For Maplibre GL comparisons +\item \code{mapboxgl_compare_proxy()} / \code{maplibre_compare_proxy()} - For updating maps in a compare widget +} + +After creating a compare widget in a Shiny app, you can use the proxy functions to update either the "before" +(left/top) or "after" (right/bottom) map. The proxy objects work with all the regular map update functions like \code{set_style()}, +\code{set_paint_property()}, etc. + +To get a proxy that targets a specific map in the comparison: + +\if{html}{\out{
    }}\preformatted{# Access the left/top map +left_proxy <- maplibre_compare_proxy("compare_id", map_side = "before") + +# Access the right/bottom map +right_proxy <- maplibre_compare_proxy("compare_id", map_side = "after") +}\if{html}{\out{
    }} + +The compare widget also provides Shiny input values for view state and clicks. For a compare widget with ID "mycompare", you'll have: +\itemize{ +\item \code{input$mycompare_before_view} - View state (center, zoom, bearing, pitch) of the left/top map +\item \code{input$mycompare_after_view} - View state of the right/bottom map +\item \code{input$mycompare_before_click} - Click events on the left/top map +\item \code{input$mycompare_after_click} - Click events on the right/bottom map +} +} } \examples{ \dontrun{ library(mapgl) -library(mapgl) - m1 <- mapboxgl(style = mapbox_style("light")) - m2 <- mapboxgl(style = mapbox_style("dark")) +# Default swipe mode compare(m1, m2) + +# Synchronized side-by-side mode +compare(m1, m2, mode = "sync") + +# Custom swiper color +compare(m1, m2, swiper_color = "#FF0000") # Red swiper + +# Shiny example +library(shiny) + +ui <- fluidPage( + maplibreCompareOutput("comparison") +) + +server <- function(input, output, session) { + output$comparison <- renderMaplibreCompare({ + compare( + maplibre(style = carto_style("positron")), + maplibre(style = carto_style("dark-matter")), + mode = "sync" + ) + }) + +# Update the right map + observe({ + right_proxy <- maplibre_compare_proxy("comparison", map_side = "after") + set_style(right_proxy, carto_style("voyager")) + }) + + # Example with custom swiper color + output$comparison2 <- renderMaplibreCompare({ + compare( + maplibre(style = carto_style("positron")), + maplibre(style = carto_style("dark-matter")), + swiper_color = "#3498db" # Blue swiper + ) + }) +} } } diff --git a/man/concat.Rd b/man/concat.Rd new file mode 100644 index 00000000..2669938e --- /dev/null +++ b/man/concat.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/style_helpers.R +\name{concat} +\alias{concat} +\title{Create a concatenation expression} +\usage{ +concat(...) +} +\arguments{ +\item{...}{Values or expressions to concatenate. Can be strings, numbers, or other expressions like \code{get_column()}.} +} +\value{ +A list representing the concatenation expression. +} +\description{ +This function creates a concatenation expression that combines multiple values or expressions into a single string. +Useful for creating dynamic tooltips or labels. +} +\examples{ +# Create a dynamic tooltip +concat("Name: ", get_column("name"), "
    Value: ", get_column("value")) +} diff --git a/man/mapboxgl.Rd b/man/mapboxgl.Rd index 8e94ca91..cc0657c0 100644 --- a/man/mapboxgl.Rd +++ b/man/mapboxgl.Rd @@ -32,7 +32,7 @@ mapboxgl( \item{projection}{The map projection to use (e.g., "mercator", "globe").} -\item{parallels}{A vector of two numbers representing the standard parellels of the projection. Only available when the projection is "albers" or "lambertConformalConic".} +\item{parallels}{A vector of two numbers representing the standard parallels of the projection. Only available when the projection is "albers" or "lambertConformalConic".} \item{access_token}{Your Mapbox access token.} diff --git a/man/mapboxglCompareOutput.Rd b/man/mapboxglCompareOutput.Rd new file mode 100644 index 00000000..59c291c0 --- /dev/null +++ b/man/mapboxglCompareOutput.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plugins.R +\name{mapboxglCompareOutput} +\alias{mapboxglCompareOutput} +\title{Create a Mapbox GL Compare output element for Shiny} +\usage{ +mapboxglCompareOutput(outputId, width = "100\%", height = "400px") +} +\arguments{ +\item{outputId}{The output variable to read from} + +\item{width}{The width of the element} + +\item{height}{The height of the element} +} +\value{ +A Mapbox GL Compare output element for use in a Shiny UI +} +\description{ +Create a Mapbox GL Compare output element for Shiny +} diff --git a/man/mapboxgl_compare_proxy.Rd b/man/mapboxgl_compare_proxy.Rd new file mode 100644 index 00000000..b89797c4 --- /dev/null +++ b/man/mapboxgl_compare_proxy.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plugins.R +\name{mapboxgl_compare_proxy} +\alias{mapboxgl_compare_proxy} +\title{Create a proxy object for a Mapbox GL Compare widget in Shiny} +\usage{ +mapboxgl_compare_proxy( + compareId, + session = shiny::getDefaultReactiveDomain(), + map_side = "before" +) +} +\arguments{ +\item{compareId}{The ID of the compare output element.} + +\item{session}{The Shiny session object.} + +\item{map_side}{Which map side to target in the compare widget, either "before" or "after".} +} +\value{ +A proxy object for the Mapbox GL Compare widget. +} +\description{ +This function allows updates to be sent to an existing Mapbox GL Compare widget in a Shiny application. +} diff --git a/man/mapboxgl_view.Rd b/man/mapboxgl_view.Rd new file mode 100644 index 00000000..130c2d3e --- /dev/null +++ b/man/mapboxgl_view.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/quickview.R +\name{mapboxgl_view} +\alias{mapboxgl_view} +\title{Quick visualization of geometries with Mapbox GL} +\usage{ +mapboxgl_view( + data, + column = NULL, + n = NULL, + style = mapbox_style("light"), + ... +) +} +\arguments{ +\item{data}{An sf object to visualize} + +\item{column}{The name of the column to visualize. If NULL (default), geometries are shown with default styling.} + +\item{n}{Number of quantile breaks for numeric columns. If specified, uses step_expr() instead of interpolate().} + +\item{style}{The Mapbox style to use. Defaults to mapbox_style("light").} + +\item{...}{Additional arguments passed to mapboxgl()} +} +\value{ +A Mapbox GL map object +} +\description{ +This function provides a quick way to visualize sf geometries using Mapbox GL JS. +It automatically detects the geometry type and applies appropriate styling. +} +\examples{ +\dontrun{ +library(sf) +nc <- st_read(system.file("shape/nc.shp", package = "sf")) + +# Basic view +mapboxgl_view(nc) + +# View with column visualization +mapboxgl_view(nc, column = "AREA") + +# View with quantile breaks +mapboxgl_view(nc, column = "AREA", n = 5) +} +} diff --git a/man/mapgl-package.Rd b/man/mapgl-package.Rd index 81bfc91b..2a548c42 100644 --- a/man/mapgl-package.Rd +++ b/man/mapgl-package.Rd @@ -14,6 +14,7 @@ Provides an interface to the 'Mapbox GL JS' (\url{https://docs.mapbox.com/mapbox Useful links: \itemize{ \item \url{https://walker-data.com/mapgl/} + \item Report bugs at \url{https://github.com/walkerke/mapgl/issues} } } diff --git a/man/maplibreCompareOutput.Rd b/man/maplibreCompareOutput.Rd new file mode 100644 index 00000000..31beecf6 --- /dev/null +++ b/man/maplibreCompareOutput.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plugins.R +\name{maplibreCompareOutput} +\alias{maplibreCompareOutput} +\title{Create a Maplibre GL Compare output element for Shiny} +\usage{ +maplibreCompareOutput(outputId, width = "100\%", height = "400px") +} +\arguments{ +\item{outputId}{The output variable to read from} + +\item{width}{The width of the element} + +\item{height}{The height of the element} +} +\value{ +A Maplibre GL Compare output element for use in a Shiny UI +} +\description{ +Create a Maplibre GL Compare output element for Shiny +} diff --git a/man/maplibre_compare_proxy.Rd b/man/maplibre_compare_proxy.Rd new file mode 100644 index 00000000..5ee1eda8 --- /dev/null +++ b/man/maplibre_compare_proxy.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plugins.R +\name{maplibre_compare_proxy} +\alias{maplibre_compare_proxy} +\title{Create a proxy object for a Maplibre GL Compare widget in Shiny} +\usage{ +maplibre_compare_proxy( + compareId, + session = shiny::getDefaultReactiveDomain(), + map_side = "before" +) +} +\arguments{ +\item{compareId}{The ID of the compare output element.} + +\item{session}{The Shiny session object.} + +\item{map_side}{Which map side to target in the compare widget, either "before" or "after".} +} +\value{ +A proxy object for the Maplibre GL Compare widget. +} +\description{ +This function allows updates to be sent to an existing Maplibre GL Compare widget in a Shiny application. +} diff --git a/man/maplibre_view.Rd b/man/maplibre_view.Rd new file mode 100644 index 00000000..1131c86e --- /dev/null +++ b/man/maplibre_view.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/quickview.R +\name{maplibre_view} +\alias{maplibre_view} +\title{Quick visualization of geometries with MapLibre GL} +\usage{ +maplibre_view( + data, + column = NULL, + n = NULL, + style = carto_style("positron"), + ... +) +} +\arguments{ +\item{data}{An sf object to visualize} + +\item{column}{The name of the column to visualize. If NULL (default), geometries are shown with default styling.} + +\item{n}{Number of quantile breaks for numeric columns. If specified, uses step_expr() instead of interpolate().} + +\item{style}{The MapLibre style to use. Defaults to carto_style("positron").} + +\item{...}{Additional arguments passed to maplibre()} +} +\value{ +A MapLibre GL map object +} +\description{ +This function provides a quick way to visualize sf geometries using MapLibre GL JS. +It automatically detects the geometry type and applies appropriate styling. +} +\examples{ +\dontrun{ +library(sf) +nc <- st_read(system.file("shape/nc.shp", package = "sf")) + +# Basic view +maplibre_view(nc) + +# View with column visualization +maplibre_view(nc, column = "AREA") + +# View with quantile breaks +maplibre_view(nc, column = "AREA", n = 5) +} +} diff --git a/man/number_format.Rd b/man/number_format.Rd new file mode 100644 index 00000000..d790b14c --- /dev/null +++ b/man/number_format.Rd @@ -0,0 +1,86 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/style_helpers.R +\name{number_format} +\alias{number_format} +\title{Create a number formatting expression} +\usage{ +number_format( + column, + locale = "en-US", + style = "decimal", + currency = NULL, + unit = NULL, + minimum_fraction_digits = NULL, + maximum_fraction_digits = NULL, + minimum_integer_digits = NULL, + use_grouping = NULL, + notation = NULL, + compact_display = NULL +) +} +\arguments{ +\item{column}{The name of the column containing the numeric value to format. +Can also be an expression that evaluates to a number.} + +\item{locale}{A string specifying the locale to use for formatting (e.g., "en-US", +"de-DE", "fr-FR"). Defaults to "en-US".} + +\item{style}{The formatting style to use. Options include: +\itemize{ +\item "decimal" (default): Plain number formatting +\item "currency": Currency formatting (requires \code{currency} parameter) +\item "percent": Percentage formatting (multiplies by 100 and adds \%) +\item "unit": Unit formatting (requires \code{unit} parameter) +}} + +\item{currency}{For style = "currency", the ISO 4217 currency code (e.g., "USD", "EUR", "GBP").} + +\item{unit}{For style = "unit", the unit to use (e.g., "kilometer", "mile", "liter").} + +\item{minimum_fraction_digits}{The minimum number of fraction digits to display.} + +\item{maximum_fraction_digits}{The maximum number of fraction digits to display.} + +\item{minimum_integer_digits}{The minimum number of integer digits to display.} + +\item{use_grouping}{Whether to use grouping separators (e.g., thousands separators). +Defaults to TRUE.} + +\item{notation}{The formatting notation. Options include: +\itemize{ +\item "standard" (default): Regular notation +\item "scientific": Scientific notation +\item "engineering": Engineering notation +\item "compact": Compact notation (e.g., "1.2K", "3.4M") +}} + +\item{compact_display}{For notation = "compact", whether to use "short" (default) +or "long" form.} +} +\value{ +A list representing the number-format expression. +} +\description{ +This function creates a number formatting expression that formats numeric values +according to locale-specific conventions. It can be used in tooltips, popups, +and text fields for symbol layers. +} +\examples{ +# Basic number formatting with thousands separators +number_format("population") + +# Currency formatting +number_format("income", style = "currency", currency = "USD") + +# Percentage with 1 decimal place +number_format("rate", style = "percent", maximum_fraction_digits = 1) + +# Compact notation for large numbers +number_format("population", notation = "compact") + +# Using within a tooltip +concat("Population: ", number_format("population", notation = "compact")) + +# Using with get_column() +number_format(get_column("value"), style = "currency", currency = "EUR") +} diff --git a/man/on_section.Rd b/man/on_section.Rd new file mode 100644 index 00000000..71be9bc2 --- /dev/null +++ b/man/on_section.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/storymaps.R +\name{on_section} +\alias{on_section} +\title{Observe events on story map section transitions} +\usage{ +on_section(map_id, section_id, handler) +} +\arguments{ +\item{map_id}{The ID of your map output} + +\item{section_id}{The ID of the section to trigger on, defined in \code{story_section()}} + +\item{handler}{Expression to execute when section becomes visible.} +} +\description{ +For a given \code{story_section()}, you may want to trigger an event when the section becomes visible. +This function wraps \code{shiny::observeEvent()} to allow you to modify the state of your map or +invoke other Shiny actions on user scroll. +} diff --git a/man/renderMapboxglCompare.Rd b/man/renderMapboxglCompare.Rd new file mode 100644 index 00000000..506d4e1a --- /dev/null +++ b/man/renderMapboxglCompare.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plugins.R +\name{renderMapboxglCompare} +\alias{renderMapboxglCompare} +\title{Render a Mapbox GL Compare output element in Shiny} +\usage{ +renderMapboxglCompare(expr, env = parent.frame(), quoted = FALSE) +} +\arguments{ +\item{expr}{An expression that generates a Mapbox GL Compare map} + +\item{env}{The environment in which to evaluate \code{expr}} + +\item{quoted}{Is \code{expr} a quoted expression} +} +\value{ +A rendered Mapbox GL Compare map for use in a Shiny server +} +\description{ +Render a Mapbox GL Compare output element in Shiny +} diff --git a/man/renderMaplibreCompare.Rd b/man/renderMaplibreCompare.Rd new file mode 100644 index 00000000..74e9e41e --- /dev/null +++ b/man/renderMaplibreCompare.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plugins.R +\name{renderMaplibreCompare} +\alias{renderMaplibreCompare} +\title{Render a Maplibre GL Compare output element in Shiny} +\usage{ +renderMaplibreCompare(expr, env = parent.frame(), quoted = FALSE) +} +\arguments{ +\item{expr}{An expression that generates a Maplibre GL Compare map} + +\item{env}{The environment in which to evaluate \code{expr}} + +\item{quoted}{Is \code{expr} a quoted expression} +} +\value{ +A rendered Maplibre GL Compare map for use in a Shiny server +} +\description{ +Render a Maplibre GL Compare output element in Shiny +} diff --git a/man/set_popup.Rd b/man/set_popup.Rd new file mode 100644 index 00000000..ea5b0f5b --- /dev/null +++ b/man/set_popup.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/shiny.R +\name{set_popup} +\alias{set_popup} +\title{Set popup on a map layer} +\usage{ +set_popup(map, layer, popup) +} +\arguments{ +\item{map}{A map object created by the \code{mapboxgl} or \code{maplibre} function, or a proxy object.} + +\item{layer}{The ID of the layer to update.} + +\item{popup}{The name of the popup property or an expression to set.} +} +\value{ +The updated map object. +} +\description{ +Set popup on a map layer +} diff --git a/man/set_projection.Rd b/man/set_projection.Rd new file mode 100644 index 00000000..9a40fbbf --- /dev/null +++ b/man/set_projection.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/style_helpers.R +\name{set_projection} +\alias{set_projection} +\title{Set Projection for a Mapbox/Maplibre Map} +\usage{ +set_projection(map, projection) +} +\arguments{ +\item{map}{A map object created by mapboxgl() or maplibre() functions, or their respective proxy objects} + +\item{projection}{A string representing the projection name (e.g., "mercator", "globe", "albers", "equalEarth", etc.)} +} +\value{ +The modified map object +} +\description{ +This function sets the projection dynamically after map initialization. +} diff --git a/man/set_rain.Rd b/man/set_rain.Rd new file mode 100644 index 00000000..e881836e --- /dev/null +++ b/man/set_rain.Rd @@ -0,0 +1,75 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/terrain.R +\name{set_rain} +\alias{set_rain} +\title{Set rain effect on a Mapbox GL map} +\usage{ +set_rain( + map, + density = 0.5, + intensity = 1, + color = "#a8adbc", + opacity = 0.7, + center_thinning = 0.57, + direction = c(0, 80), + droplet_size = c(2.6, 18.2), + distortion_strength = 0.7, + vignette = 1, + vignette_color = "#464646", + remove = FALSE +) +} +\arguments{ +\item{map}{A map object created by the \code{mapboxgl} function or a proxy object.} + +\item{density}{A number between 0 and 1 controlling the rain particles density. Default is 0.5.} + +\item{intensity}{A number between 0 and 1 controlling the rain particles movement speed. Default is 1.} + +\item{color}{A string specifying the color of the rain droplets. Default is "#a8adbc".} + +\item{opacity}{A number between 0 and 1 controlling the rain particles opacity. Default is 0.7.} + +\item{center_thinning}{A number between 0 and 1 controlling the thinning factor of rain particles from center. Default is 0.57.} + +\item{direction}{A numeric vector of length 2 defining the azimuth and polar angles of the rain direction. Default is c(0, 80).} + +\item{droplet_size}{A numeric vector of length 2 controlling the rain droplet size (x - normal to direction, y - along direction). Default is c(2.6, 18.2).} + +\item{distortion_strength}{A number between 0 and 1 controlling the rain particles screen-space distortion strength. Default is 0.7.} + +\item{vignette}{A number between 0 and 1 controlling the screen-space vignette rain tinting effect intensity. Default is 1.0.} + +\item{vignette_color}{A string specifying the rain vignette screen-space corners tint color. Default is "#464646".} + +\item{remove}{A logical value indicating whether to remove the rain effect. Default is FALSE.} +} +\value{ +The updated map object. +} +\description{ +Set rain effect on a Mapbox GL map +} +\examples{ +\dontrun{ +# Add rain effect with default values +mapboxgl(...) |> set_rain() + +# Add rain effect with custom values +mapboxgl( + style = mapbox_style("standard"), + center = c(24.951528, 60.169573), + zoom = 16.8, + pitch = 74, + bearing = 12.8 +) |> + set_rain( + density = 0.5, + opacity = 0.7, + color = "#a8adbc" + ) + +# Remove rain effect (useful in Shiny) +map_proxy |> set_rain(remove = TRUE) +} +} diff --git a/man/set_snow.Rd b/man/set_snow.Rd new file mode 100644 index 00000000..89d830e6 --- /dev/null +++ b/man/set_snow.Rd @@ -0,0 +1,72 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/terrain.R +\name{set_snow} +\alias{set_snow} +\title{Set snow effect on a Mapbox GL map} +\usage{ +set_snow( + map, + density = 0.85, + intensity = 1, + color = "#ffffff", + opacity = 1, + center_thinning = 0.4, + direction = c(0, 50), + flake_size = 0.71, + vignette = 0.3, + vignette_color = "#ffffff", + remove = FALSE +) +} +\arguments{ +\item{map}{A map object created by the \code{mapboxgl} function or a proxy object.} + +\item{density}{A number between 0 and 1 controlling the snow particles density. Default is 0.85.} + +\item{intensity}{A number between 0 and 1 controlling the snow particles movement speed. Default is 1.0.} + +\item{color}{A string specifying the color of the snow particles. Default is "#ffffff".} + +\item{opacity}{A number between 0 and 1 controlling the snow particles opacity. Default is 1.0.} + +\item{center_thinning}{A number between 0 and 1 controlling the thinning factor of snow particles from center. Default is 0.4.} + +\item{direction}{A numeric vector of length 2 defining the azimuth and polar angles of the snow direction. Default is c(0, 50).} + +\item{flake_size}{A number between 0 and 5 controlling the snow flake particle size. Default is 0.71.} + +\item{vignette}{A number between 0 and 1 controlling the snow vignette screen-space effect. Default is 0.3.} + +\item{vignette_color}{A string specifying the snow vignette screen-space corners tint color. Default is "#ffffff".} + +\item{remove}{A logical value indicating whether to remove the snow effect. Default is FALSE.} +} +\value{ +The updated map object. +} +\description{ +Set snow effect on a Mapbox GL map +} +\examples{ +\dontrun{ +# Add snow effect with default values +mapboxgl(...) |> set_snow() + +# Add snow effect with custom values +mapboxgl( + style = mapbox_style("standard"), + center = c(24.951528, 60.169573), + zoom = 16.8, + pitch = 74, + bearing = 12.8 +) |> + set_snow( + density = 0.85, + flake_size = 0.71, + color = "#ffffff" + ) + +# Remove snow effect (useful in Shiny) +map_proxy |> set_snow(remove = TRUE) +} +} diff --git a/man/set_style.Rd b/man/set_style.Rd index c7e03901..7363e9b5 100644 --- a/man/set_style.Rd +++ b/man/set_style.Rd @@ -4,7 +4,7 @@ \alias{set_style} \title{Update the style of a map} \usage{ -set_style(map, style, config = NULL, diff = TRUE) +set_style(map, style, config = NULL, diff = TRUE, preserve_layers = TRUE) } \arguments{ \item{map}{A map object created by the \code{mapboxgl} or \code{maplibre} function, or a proxy object.} @@ -14,6 +14,8 @@ set_style(map, style, config = NULL, diff = TRUE) \item{config}{A named list of options to be passed to the style config.} \item{diff}{A boolean that attempts a diff-based update rather than re-drawing the full style. Not available for all styles.} + +\item{preserve_layers}{A boolean that indicates whether to preserve user-added sources and layers when changing styles. Defaults to TRUE.} } \value{ The modified map object. diff --git a/man/story_leaflet.Rd b/man/story_leaflet.Rd new file mode 100644 index 00000000..2a085ff5 --- /dev/null +++ b/man/story_leaflet.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/storymaps.R +\name{story_leaflet} +\alias{story_leaflet} +\title{Create a scrollytelling story map with Leaflet} +\usage{ +story_leaflet( + map_id, + sections, + root_margin = "-20\% 0px -20\% 0px", + threshold = 0, + styles = NULL, + bg_color = "rgba(255,255,255,0.9)", + text_color = "#34495e", + font_family = NULL +) +} +\arguments{ +\item{map_id}{The ID of your mapboxgl, maplibre, or leaflet output +defined in the server, e.g. \code{"map"}} + +\item{sections}{A named list of story_section objects. +Names will correspond to map events defined within +the server using \code{on_section()}.} + +\item{root_margin}{The margin around the viewport for triggering sections by +the intersection observer. Should be specified as a string, +e.g. \code{"-20\% 0px -20\% 0px"}.} + +\item{threshold}{A number that indicates the visibility ratio for a story +' panel to be used to trigger a section; should be a number between +0 and 1. Defaults to 0, meaning that the section is triggered as soon +as the first pixel is visible.} + +\item{styles}{Optional custom CSS styles. Should be specified as a +character string within \code{shiny::tags$style()}.} + +\item{bg_color}{Default background color for all sections} + +\item{text_color}{Default text color for all sections} + +\item{font_family}{Default font family for all sections} +} +\description{ +Create a scrollytelling story map with Leaflet +} diff --git a/man/story_map.Rd b/man/story_map.Rd new file mode 100644 index 00000000..dbc286cd --- /dev/null +++ b/man/story_map.Rd @@ -0,0 +1,52 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/storymaps.R +\name{story_map} +\alias{story_map} +\title{Create a scrollytelling story map} +\usage{ +story_map( + map_id, + sections, + map_type = c("mapboxgl", "maplibre", "leaflet"), + root_margin = "-20\% 0px -20\% 0px", + threshold = 0, + styles = NULL, + bg_color = "rgba(255,255,255,0.9)", + text_color = "#34495e", + font_family = NULL +) +} +\arguments{ +\item{map_id}{The ID of your mapboxgl, maplibre, or leaflet output +defined in the server, e.g. \code{"map"}} + +\item{sections}{A named list of story_section objects. +Names will correspond to map events defined within +the server using \code{on_section()}.} + +\item{map_type}{One of \code{"mapboxgl"}, \code{"maplibre"}, or \code{"leaflet"}. +This will use either \code{mapboxglOutput()}, \code{maplibreOutput()}, +or \code{leafletOutput()} respectively, and must +correspond to the appropriate \verb{render*()} function used in the server.} + +\item{root_margin}{The margin around the viewport for triggering sections by +the intersection observer. Should be specified as a string, +e.g. \code{"-20\% 0px -20\% 0px"}.} + +\item{threshold}{A number that indicates the visibility ratio for a story +' panel to be used to trigger a section; should be a number between +0 and 1. Defaults to 0, meaning that the section is triggered as soon +as the first pixel is visible.} + +\item{styles}{Optional custom CSS styles. Should be specified as a +character string within \code{shiny::tags$style()}.} + +\item{bg_color}{Default background color for all sections} + +\item{text_color}{Default text color for all sections} + +\item{font_family}{Default font family for all sections} +} +\description{ +Create a scrollytelling story map +} diff --git a/man/story_maplibre.Rd b/man/story_maplibre.Rd new file mode 100644 index 00000000..449aebfd --- /dev/null +++ b/man/story_maplibre.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/storymaps.R +\name{story_maplibre} +\alias{story_maplibre} +\title{Create a scrollytelling story map with MapLibre} +\usage{ +story_maplibre( + map_id, + sections, + root_margin = "-20\% 0px -20\% 0px", + threshold = 0, + styles = NULL, + bg_color = "rgba(255,255,255,0.9)", + text_color = "#34495e", + font_family = NULL +) +} +\arguments{ +\item{map_id}{The ID of your mapboxgl, maplibre, or leaflet output +defined in the server, e.g. \code{"map"}} + +\item{sections}{A named list of story_section objects. +Names will correspond to map events defined within +the server using \code{on_section()}.} + +\item{root_margin}{The margin around the viewport for triggering sections by +the intersection observer. Should be specified as a string, +e.g. \code{"-20\% 0px -20\% 0px"}.} + +\item{threshold}{A number that indicates the visibility ratio for a story +' panel to be used to trigger a section; should be a number between +0 and 1. Defaults to 0, meaning that the section is triggered as soon +as the first pixel is visible.} + +\item{styles}{Optional custom CSS styles. Should be specified as a +character string within \code{shiny::tags$style()}.} + +\item{bg_color}{Default background color for all sections} + +\item{text_color}{Default text color for all sections} + +\item{font_family}{Default font family for all sections} +} +\description{ +Create a scrollytelling story map with MapLibre +} diff --git a/man/story_section.Rd b/man/story_section.Rd new file mode 100644 index 00000000..1f23cfb5 --- /dev/null +++ b/man/story_section.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/storymaps.R +\name{story_section} +\alias{story_section} +\title{Create a story section for story maps} +\usage{ +story_section( + title, + content, + position = c("left", "center", "right"), + width = 400, + bg_color = NULL, + text_color = NULL, + font_family = NULL +) +} +\arguments{ +\item{title}{Section title} + +\item{content}{Section content - can be text, HTML, or Shiny outputs} + +\item{position}{Position of text block ("left", "center", "right")} + +\item{width}{Width of text block in pixels (default: 400)} + +\item{bg_color}{Background color (with alpha) for text block} + +\item{text_color}{Text color} + +\item{font_family}{Font family for the section} +} +\description{ +Create a story section for story maps +} diff --git a/mapgl.Rproj b/mapgl.Rproj index 270314b8..d8e473c9 100644 --- a/mapgl.Rproj +++ b/mapgl.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: 4adf0831-8ad3-403b-86ee-9d8bd1632d74 RestoreWorkspace: Default SaveWorkspace: Default diff --git a/vignettes/getting-started.Rmd b/vignettes/getting-started.Rmd index bc0dd6f8..959e0d85 100644 --- a/vignettes/getting-started.Rmd +++ b/vignettes/getting-started.Rmd @@ -66,7 +66,7 @@ maplibre( ### Comparing map views -**mapgl** includes a function `compare()` that allows users to create synced swipe maps that can compare two styles. This function works for either Mapbox or MapLibre maps. I don't have this working correctly in rendered R Markdown / Quarto docs or Shiny apps yet, but I'm working on it! +**mapgl** includes a function `compare()` that allows users to create synced swipe maps that can compare two styles. This function works for either Mapbox or MapLibre maps. ```{r, eval = FALSE} m1 <- mapboxgl() diff --git a/vignettes/images/story-1a.gif b/vignettes/images/story-1a.gif new file mode 100644 index 00000000..2677753e Binary files /dev/null and b/vignettes/images/story-1a.gif differ diff --git a/vignettes/images/story-1b.gif b/vignettes/images/story-1b.gif new file mode 100644 index 00000000..7187ec3b Binary files /dev/null and b/vignettes/images/story-1b.gif differ diff --git a/vignettes/images/story-1c.gif b/vignettes/images/story-1c.gif new file mode 100644 index 00000000..ebbdd45a Binary files /dev/null and b/vignettes/images/story-1c.gif differ diff --git a/vignettes/images/story-2.gif b/vignettes/images/story-2.gif new file mode 100644 index 00000000..a00dfc4a Binary files /dev/null and b/vignettes/images/story-2.gif differ diff --git a/vignettes/images/story-3.gif b/vignettes/images/story-3.gif new file mode 100644 index 00000000..87518d83 Binary files /dev/null and b/vignettes/images/story-3.gif differ diff --git a/vignettes/shiny.Rmd b/vignettes/shiny.Rmd index d38b13f0..77ebc789 100644 --- a/vignettes/shiny.Rmd +++ b/vignettes/shiny.Rmd @@ -151,3 +151,7 @@ shinyApp(ui, server) ``` ![](images/clipboard-4076622643.png) + +### Comparison maps in Shiny + +Because of the way that side-by-side maps generated with the `compare()` function work in **mapgl**, comparison maps require their own rendering functions. For Mapbox maps, you can use `mapboxglCompareOutput()`, `renderMapboxglCompare()`; and `mapboxgl_compare_proxy()`; for MapLibre, use `maplibreCompareOutput()`; `renderMaplibreCompare()`; and `maplibre_compare_proxy()`. For compare proxies, you can target the side of the map you want to modify with the argument `map_side = "before"` (left or top) or `map_side = "after"` (right or bottom). diff --git a/vignettes/story-maps.Rmd b/vignettes/story-maps.Rmd new file mode 100644 index 00000000..3a963e89 --- /dev/null +++ b/vignettes/story-maps.Rmd @@ -0,0 +1,374 @@ +--- +title: "Building story maps with mapgl" +format: html +editor: visual +--- + +*Story maps* are effective tools for communicating map-based narratives. In a story map, users typically scroll through a web page in which different map views and elements of the "story" are shown as the user scrolls down. The **mapgl** package brings story maps in Shiny to R users, and supports both Mapbox and MapLibre backends as well as Leaflet. + +This tutorial will help you learn how to build a basic story map Shiny app with mapgl. You'll rely on the following three functions when building your story: + +- `story_map()` sets up the user interface component for your story map. You'll wrap this in a Shiny layout function; it is recommended to use `fluidPage()` (or `bslib::page_fluid()`) which will get you a standard full-screen story map template. `story_map()` defaults to Mapbox maps; you can use `story_maplibre()` for MapLibre maps, and `story_leaflet()` for Leaflet. + +- Within `story_map()`, you'll define a named list of sections to be passed to the `sections` parameter. You'll use the `story_section()` function to build each section. In `story_section()`, you'll specify a `title` (set to NULL or `""` to omit it) as well as `content`, which will be a list of UI elements you want to put in your section panel. This can be HTML elements (defined with `tags$p()`, `tags$a()`, `tags$img()`, etc.) as well as Shiny inputs or outputs. + +- Within your `server` function, you'll then use the `on_section()` function to bring your story map to life. `on_section()` allows you to link Shiny events to specific story sections. This means that you can trigger map movements, add data, or even perform analyses on user scroll. + +## Moving the map on scroll + +Let's take a look at how this works with a basic example. We'll build a story map with two sections: an introductory section, and a second section where the map "flies to" a location when the user scrolls. + +To get started, let's build a basic user interface without any map actions. In `ui`, we set up `story_map()` inside a fluid page with two sections. In `server`, we'll create a Mapbox globe with `mapboxgl()` and `renderMapboxgl()`. In most cases you'll want to set the option `scrollZoom = FALSE` when you initialize your map so map scrolling behavior doesn't interfere with story scrolling. + +```{r, eval = FALSE} +library(shiny) +library(mapgl) + +ui <- fluidPage( + story_map( + map_id = "map", + sections = list( + "intro" = story_section( + "Introduction", + "This is a story map." + ), + "location" = story_section( + "Location", + "Check out this interesting location." + ) + ) + ) +) + +server <- function(input, output, session) { + output$map <- renderMapboxgl({ + mapboxgl(scrollZoom = FALSE) + }) +} + +shinyApp(ui, server) +``` + +![](images/story-1a.gif) + +You'll note that scrolling will transition between story sections, and that you can still interact with the map by clicking and panning. However, because we haven't set up any actions in `server`, nothing else happens when you scroll between sections. + +We can change this by using the `on_section()` function. In `on_section()`, you'll specify the map ID (in this case, `"map"`) and the section ID to link to an action; the section ID is the name of the corresponding list element defined in the list passed to `sections` in the UI. You'll then define an expression, much like you would in `observeEvent()` in Shiny, to be executed when a given section appears. + +```{r, eval = FALSE} +library(shiny) +library(mapgl) + +ui <- fluidPage( + story_map( + map_id = "map", + sections = list( + "intro" = story_section( + "Introduction", + "This is a story map." + ), + "location" = story_section( + "Location", + "Check out this interesting location." + ) + ) + ) +) + +server <- function(input, output, session) { + output$map <- renderMapboxgl({ + mapboxgl(scrollZoom = FALSE) + }) + + on_section("map", "location", { + mapboxgl_proxy("map") |> + fly_to(center = c(12.49257, 41.890233), + zoom = 17.5, + pitch = 49, + bearing = 12.8) + }) + +} + +shinyApp(ui, server) +``` + +![](images/story-1b.gif) + +The map zooms into the Colosseum in Rome on user scroll. If you scroll back up to the top, however, you'll notice that the view does not return to the original globe. This can be remedied by tying an `on_section()` event to the introductory section. + +```{r, eval = FALSE} +library(shiny) +library(mapgl) + +ui <- fluidPage( + story_map( + map_id = "map", + sections = list( + "intro" = story_section( + "Introduction", + "This is a story map." + ), + "location" = story_section( + "Location", + "Check out this interesting location." + ) + ) + ) +) + +server <- function(input, output, session) { + output$map <- renderMapboxgl({ + mapboxgl(scrollZoom = FALSE) + }) + + on_section("map", "intro", { + mapboxgl_proxy("map") |> + fly_to(center = c(0, 0), + zoom = 0, + pitch = 0, + bearing = 0) + }) + + on_section("map", "location", { + mapboxgl_proxy("map") |> + fly_to(center = c(12.49257, 41.890233), + zoom = 17.5, + pitch = 49, + bearing = 12.8) + }) + +} + +shinyApp(ui, server) +``` + +![](images/story-1c.gif) + +For map transitions, in addition to `fly_to()`, you might consider using `ease_to()` and `jump_to()` depending on your use case. Map transition functions support [camera options](https://docs.mapbox.com/mapbox-gl-js/api/properties/#cameraoptions) and [animation options](https://docs.mapbox.com/mapbox-gl-js/api/properties/#animationoptions) as keyword arguments when applicable. + +## Adding data and modifying story appearance + +In many cases, you'll want to use story maps to visualize data that you'll add to a Mapbox / MapLibre basemap. Let's build an example of how a real estate firm might use a story map to market a property. + +```{r, eval = FALSE} +library(shiny) +library(mapgl) +library(mapboxapi) + +property <- c(-97.71326, 30.402550) +isochrone <- mb_isochrone(property, profile = "driving", time = 20) + +ui <- fluidPage( + tags$link(href = "https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap", rel="stylesheet"), + story_map( + map_id = "map", + font_family = "Poppins", + sections = list( + "intro" = story_section( + title = "MULTIFAMILY INVESTMENT OPPORTUNITY", + content = list( + p("New Class A Apartments in Austin, Texas"), + img(src = "apartment.png", width = "300px") + ), + position = "center" + ), + "marker" = story_section( + title = "PROPERTY LOCATION", + content = list( + p("The property will be located in the thriving Domain district of north Austin, home to some of the city's best shopping, dining, and entertainment.") + ) + ), + "isochrone" = story_section( + title = "AUSTIN AT YOUR FINGERTIPS", + content = list( + p("The property is within a 20-minute drive of downtown Austin, the University of Texas, and the city's major employers.") + ) + ) + ) + ) +) + +server <- function(input, output, session) { + output$map <- renderMapboxgl({ + mapboxgl(scrollZoom = FALSE, + center = c(-97.7301093, 30.288647), + zoom = 12) + }) + + on_section("map", "intro", { + mapboxgl_proxy("map") |> + clear_markers() |> + fly_to(center = c(-97.7301093, 30.288647), + zoom = 12, + pitch = 0, + bearing = 0) + + }) + + on_section("map", "marker", { + mapboxgl_proxy("map") |> + clear_layer("isochrone") |> + add_markers(data = property, color = "#CC5500") |> + fly_to(center = property, + zoom = 16, + pitch = 45, + bearing = -90) + }) + + on_section("map", "isochrone", { + mapboxgl_proxy("map") |> + add_fill_layer( + id = "isochrone", + source = isochrone, + fill_color = "#CC5500", + fill_opacity = 0.5 + ) |> + fit_bounds( + isochrone, + animate = TRUE, + duration = 8000, + pitch = 75 + ) + }) + +} + +shinyApp(ui, server) +``` + +![](images/story-2.gif) + +Let's break down some key elements of this story map. + +* We're loading a Google font, "Poppins", into our Shiny app with `tags$link()`. This allows us to use Poppins as our font globally in `story_map()` by passing it as an argument to `font_family`. The appearance of panels can also be modified section-by-section if you prefer. + +* In each story section panel, we are passing a list of HTML items to `content`. The introductory section shows how to include a local image (which should be in a `www` folder local to your app); you can also reference remotely-hosted images or include all other HTML elements supported by Shiny. Also note the `position = "center"` argument to position the introductory panel in the center of the screen; `"left"` is the default, and `"right"` is also supported without the need for additional CSS customization. + +* As in the first example, all of our story actions defined in calls to `on_section()` operate on the Mapbox GL proxy object, `"map"`. In this example, we use `add_markers()` to add a marker at a location, and `add_fill_layer()` to add a 20-minute drivetime isochrone created with the Mapbox API. Transitions between the views are handled with `fly_to()` and `fit_bounds()`, and `clear_layer()` and `clear_markers()` calls are used to control which data layers are visible as the user goes forward and backward through the story. + +## Integrating Shiny inputs and outputs + +While the story map feature in __mapgl__ is built in a unique way to accommodate map-based scrollytelling, it is still creating an R Shiny app. This means that all of Shiny's functionality and interactivity is available to you as you build your story maps. The list of items you pass to `content` in any given story section panel can include both Shiny _inputs_ as well as Shiny _outputs_ which can correspond to the content visible on your story maps. + +Let's set up a scenario that adds interactivity to the data displayed in the [Fundamentals of map design with mapgl](https://walker-data.com/mapgl/articles/map-design.html) vignette. We'll make a map of median age in Florida, which will display with the introductory story panel. The user selects a county to display; on scroll, the story will then zoom to the selected county and show a histogram of values for Census tracts in that county. + +```{r, eval = FALSE} +library(shiny) +library(mapgl) +library(tidycensus) +library(tidyverse) +library(sf) + +fl_age <- get_acs( + geography = "tract", + variables = "B01002_001", + state = "FL", + year = 2023, + geometry = TRUE +) |> + separate_wider_delim(NAME, delim = "; ", names = c("tract", "county", "state")) %>% + st_sf() + +ui <- fluidPage( + story_maplibre( + map_id = "map", + sections = list( + "intro" = story_section( + "Median Age in Florida", + content = list( + selectInput( + "county", + "Select a county", + choices = sort(unique(fl_age$county)) + ), + p("Scroll down to view the median age distribution in the selected county.") + ) + ), + "county" = story_section( + title = NULL, + content = list( + uiOutput("county_text"), + plotOutput("county_plot") + ) + ) + ) + ) +) + +server <- function(input, output, session) { + + sel_county <- reactive({ + filter(fl_age, county == input$county) + }) + + output$map <- renderMaplibre({ + maplibre( + carto_style("positron"), + bounds = fl_age, + scrollZoom = FALSE + ) |> + add_fill_layer( + id = "fl_tracts", + source = fl_age, + fill_color = interpolate( + column = "estimate", + values = c(20, 80), + stops = c("lightblue", "darkblue"), + na_color = "lightgrey" + ), + fill_opacity = 0.5 + ) |> + add_legend( + "Median age in Florida", + values = c(20, 80), + colors = c("lightblue", "darkblue"), + position = "bottom-right" + ) + }) + + output$county_text <- renderUI({ + h2(toupper(input$county)) + }) + + output$county_plot <- renderPlot({ + ggplot(sel_county(), aes(x = estimate)) + + geom_histogram(fill = "lightblue", color = "black", bins = 10) + + theme_minimal() + + labs(x = "Median Age", y = "") + }) + + on_section("map", "intro", { + maplibre_proxy("map") |> + set_filter("fl_tracts", NULL) |> + fit_bounds(fl_age, animate = TRUE) + }) + + on_section("map", "county", { + maplibre_proxy("map") |> + set_filter("fl_tracts", filter = list("==", "county", input$county)) |> + fit_bounds(sel_county(), animate = TRUE) + }) + +} + +shinyApp(ui, server) +``` + +![](images/story-3.gif) + +Let's walk through how this works. + +* The UI code will be familiar, though we are now using the MapLibre backend with `story_maplibre()`. The main difference is our inclusion of a Shiny `selectInput()` in the first story panel and two Shiny outputs in the second story panel. As we've set it up, users can select a county at the beginning of the story, and then get a different output when they scroll down. + +* A reactive object `sel_county()` will be used to get county-specific values for the second story panel, and will help us determine the map's extent as we want to zoom to the selected county. + +* That said, we don't use `sel_county()` directly on the map. Instead, we use mapgl's `set_filter()` function, which is more performant than filtering data by clearing a layer and re-adding it. This allows us to invoke the underlying `setFilter()` JavaScript method ([see here for more documentation](https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#setfilter)) and operate directly on the map layer itself. Setting the filter to `NULL` clears the filter and gives us back the entire state of Florida. + +* We note that the content of the second panel is entirely Shiny outputs: an h2 header that corresponds to the selected county, and a histogram of median age values for Census tracts in that county drawn with ggplot2. + +## Sharing your stories / next steps + +As your story map is a Shiny app, you'll need to publish it to a Shiny server to share it. Posit's [ShinyApps.io](https://www.shinyapps.io/) and [Connect Cloud](https://connect.posit.cloud/) products are nice options if you don't want to set up your own Shiny server. + +If you are building story maps with mapgl, please let me know about it! I'm also planning some trainings / workshops on this feature, so please do reach out if you are interested. \ No newline at end of file